Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions packages/material_ui/lib/src/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import 'scaffold.dart';
import 'text_theme.dart';
import 'theme.dart';

part 'generated/banner_defaults_m3.g.dart';

// Examples can assume:
// late BuildContext context;

Expand Down Expand Up @@ -489,35 +491,3 @@ class _BannerDefaultsM2 extends MaterialBannerThemeData {
@override
TextStyle? get contentTextStyle => _theme.textTheme.bodyMedium;
}

// BEGIN GENERATED TOKEN PROPERTIES - Banner

// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.

// dart format off
class _BannerDefaultsM3 extends MaterialBannerThemeData {
_BannerDefaultsM3(this.context)
: super(elevation: 1.0);

final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
late final TextTheme _textTheme = Theme.of(context).textTheme;

@override
Color? get backgroundColor => _colors.surfaceContainerLow;

@override
Color? get surfaceTintColor => Colors.transparent;

@override
Color? get dividerColor => _colors.outlineVariant;

@override
TextStyle? get contentTextStyle => _textTheme.bodyMedium;
}
// dart format on

// END GENERATED TOKEN PROPERTIES - Banner
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Do not edit by hand. The code is generated from data in the Material
// Design token database by the script:
// packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart.
part of '../banner.dart';

class _BannerDefaultsM3 extends MaterialBannerThemeData {
_BannerDefaultsM3(this.context) : super(elevation: 1.0);

Expand Down
4 changes: 2 additions & 2 deletions packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import 'package:args/args.dart';

import '../templates/action_chip_template.dart';
import '../templates/app_bar_template.dart';
import '../templates/banner_template.dart';
import '../templates/badge_template.dart';
// import '../templates/banner_template.dart';
// import '../templates/bottom_app_bar_template.dart';
import '../templates/bottom_sheet_template.dart';
// import '../templates/button_template.dart';
Expand Down Expand Up @@ -65,8 +65,8 @@ Future<void> main(List<String> args) async {

const ActionChipTemplateM3().generateFile(verbose: verbose);
const AppBarTemplateM3().generateFile(verbose: verbose);
const BannerTemplateM3().generateFile(verbose: verbose);
const BadgeTemplateM3().generateFile(verbose: verbose);
// const BannerTemplateM3().generateFile(verbose: verbose);
// const BottomAppBarTemplateM3().generateFile(verbose: verbose);
const BottomSheetTemplateM3().generateFile(verbose: verbose);
// const ButtonTemplateM3().generateFile(verbose: verbose);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../data/banner.dart';
import '../data/divider.dart';
import 'template.dart';

class BannerTemplateM3 extends TokenTemplateM3 {
const BannerTemplateM3();

@override
String get name => 'Banner';

@override
String get parentFilePath => 'banner.dart';

@override
String generateContents(String className) =>
'''
class $className extends MaterialBannerThemeData {
$className(this.context)
: super(elevation: ${number(TokenBanner.containerElevation)});

final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
late final TextTheme _textTheme = Theme.of(context).textTheme;

@override
Color? get backgroundColor => ${color(TokenBanner.containerColor, '_colors')};

@override
Color? get surfaceTintColor => Colors.transparent;

@override
Color? get dividerColor => ${color(TokenDivider.color, '_colors')};

@override
TextStyle? get contentTextStyle => ${textStyle(TokenBanner.supportingTextType, '_textTheme')};
}
''';
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../data/typescale.dart';
import '../data/typescale_emphasized.dart';
import '../templates/action_chip_template.dart';
import '../templates/app_bar_template.dart';
import '../templates/banner_template.dart';
import '../templates/badge_template.dart';
import '../templates/bottom_sheet_template.dart';
import '../templates/template.dart';
Expand Down Expand Up @@ -220,9 +221,14 @@ void main() {
);
});

test('BannerTemplateM3 emits M3 Banner defaults from tokens', () {
// Intentionally empty, will be implemented during migration. See:
// https://github.com/flutter/flutter/issues/187899
test('BannerTemplateM3 emits M3 Banner defaults from banner tokens', () {
final String contents = _generateContents(const BannerTemplateM3());
expect(contents, contains('class _BannerDefaultsM3 extends MaterialBannerThemeData'));
expect(contents, contains('elevation: 1.0'));
expect(contents, contains('Color? get backgroundColor => _colors.surfaceContainerLow'));
expect(contents, contains('Color? get surfaceTintColor => Colors.transparent'));
expect(contents, contains('Color? get dividerColor => _colors.outlineVariant'));
expect(contents, contains('TextStyle? get contentTextStyle => _textTheme.bodyMedium'));
});

test('BottomAppBarTemplateM3 emits M3 BottomAppBar defaults from tokens', () {
Expand Down