From 987553e63367fad142b101534b1c97d76a5ac695 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:06:32 -0700 Subject: [PATCH 1/4] Move template and generated code out of temporarily_excluded directory --- .../src/generated/bottom_app_bar_defaults_m3.g.dart} | 0 .../templates/bottom_app_bar_template.dart | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename packages/material_ui/{tool/gen_defaults/temporarily_excluded/generated/bottom_app_bar_defaults.g.dart => lib/src/generated/bottom_app_bar_defaults_m3.g.dart} (100%) rename packages/material_ui/tool/gen_defaults/{temporarily_excluded => }/templates/bottom_app_bar_template.dart (100%) diff --git a/packages/material_ui/tool/gen_defaults/temporarily_excluded/generated/bottom_app_bar_defaults.g.dart b/packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart similarity index 100% rename from packages/material_ui/tool/gen_defaults/temporarily_excluded/generated/bottom_app_bar_defaults.g.dart rename to packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart diff --git a/packages/material_ui/tool/gen_defaults/temporarily_excluded/templates/bottom_app_bar_template.dart b/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart similarity index 100% rename from packages/material_ui/tool/gen_defaults/temporarily_excluded/templates/bottom_app_bar_template.dart rename to packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart From e9a462b18a8b4b4fcee88544184472130e9ae069 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:11:25 -0700 Subject: [PATCH 2/4] WIP --- .../templates/bottom_app_bar_template.dart | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart b/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart index 55e41d24c0d..a26c00e1715 100644 --- a/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart +++ b/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart @@ -4,18 +4,23 @@ import 'template.dart'; -class BottomAppBarTemplate extends TokenTemplate { - const BottomAppBarTemplate( - super.blockName, - super.fileName, - super.tokens, { - super.colorSchemePrefix = '_colors.', +class BottomAppBarTemplate extends TokenTemplateM3 { + const BottomAppBarTemplate( { + this.colorSchemePrefix = '_colors.', }); + final String colorSchemePrefix; + + @override + String get name => 'Bottom App Bar'; + + @override + String get parentFilePath => 'bottom_app_bar.dart'; + @override - String generate() => ''' -class _${blockName}DefaultsM3 extends BottomAppBarThemeData { - _${blockName}DefaultsM3(this.context) + String generateContents(String className) => ''' +class $className extends BottomAppBarThemeData { + $className(this.context) : super( elevation: ${elevation('md.comp.bottom-app-bar.container')}, height: ${getToken('md.comp.bottom-app-bar.container.height')}, From 58e6598ee623beee4bf95b69c0aa2c3b4b6f7d25 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Thu, 16 Jul 2026 14:38:45 -0700 Subject: [PATCH 3/4] Complete migration --- .../material_ui/lib/src/bottom_app_bar.dart | 34 ++----------------- .../bottom_app_bar_defaults_m3.g.dart | 5 +++ .../tool/gen_defaults/bin/gen_defaults.dart | 2 ++ .../templates/bottom_app_bar_template.dart | 19 +++++------ 4 files changed, 17 insertions(+), 43 deletions(-) diff --git a/packages/material_ui/lib/src/bottom_app_bar.dart b/packages/material_ui/lib/src/bottom_app_bar.dart index b3ff0e3c71e..05c0990d5cc 100644 --- a/packages/material_ui/lib/src/bottom_app_bar.dart +++ b/packages/material_ui/lib/src/bottom_app_bar.dart @@ -20,6 +20,8 @@ import 'material.dart'; import 'scaffold.dart'; import 'theme.dart'; +part 'generated/bottom_app_bar_defaults_m3.g.dart'; + // Examples can assume: // late Widget bottomAppBarContents; @@ -303,35 +305,3 @@ class _BottomAppBarDefaultsM2 extends BottomAppBarThemeData { @override Color get shadowColor => const Color(0xFF000000); } - -// BEGIN GENERATED TOKEN PROPERTIES - BottomAppBar - -// 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 _BottomAppBarDefaultsM3 extends BottomAppBarThemeData { - _BottomAppBarDefaultsM3(this.context) - : super( - elevation: 3.0, - height: 80.0, - shape: const AutomaticNotchedShape(RoundedRectangleBorder()), - ); - - final BuildContext context; - late final ColorScheme _colors = Theme.of(context).colorScheme; - - @override - Color? get color => _colors.surfaceContainer; - - @override - Color? get surfaceTintColor => Colors.transparent; - - @override - Color? get shadowColor => Colors.transparent; -} -// dart format on - -// END GENERATED TOKEN PROPERTIES - BottomAppBar diff --git a/packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart b/packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart index 3c4b46e0c11..2f494343173 100644 --- a/packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart +++ b/packages/material_ui/lib/src/generated/bottom_app_bar_defaults_m3.g.dart @@ -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 '../bottom_app_bar.dart'; + class _BottomAppBarDefaultsM3 extends BottomAppBarThemeData { _BottomAppBarDefaultsM3(this.context) : super( diff --git a/packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart b/packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart index bcfe06fba9d..bf86a954f43 100644 --- a/packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart +++ b/packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart @@ -13,6 +13,7 @@ import 'package:args/args.dart'; import '../templates/app_bar_template.dart'; +import '../templates/bottom_app_bar_template.dart'; Future main(List args) async { // Parse arguments @@ -22,4 +23,5 @@ Future main(List args) async { // TODO(elliette): Add token logger when verbose flag is used. final verbose = argResults['verbose'] as bool; const AppBarTemplateM3().generateFile(verbose: verbose); + const BottomAppBarTemplateM3().generateFile(verbose: verbose); } diff --git a/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart b/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart index a26c00e1715..70c174a83aa 100644 --- a/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart +++ b/packages/material_ui/tool/gen_defaults/templates/bottom_app_bar_template.dart @@ -2,14 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import '../data/bottom_app_bar.dart'; import 'template.dart'; -class BottomAppBarTemplate extends TokenTemplateM3 { - const BottomAppBarTemplate( { - this.colorSchemePrefix = '_colors.', - }); - - final String colorSchemePrefix; +class BottomAppBarTemplateM3 extends TokenTemplateM3 { + const BottomAppBarTemplateM3(); @override String get name => 'Bottom App Bar'; @@ -22,19 +19,19 @@ class BottomAppBarTemplate extends TokenTemplateM3 { class $className extends BottomAppBarThemeData { $className(this.context) : super( - elevation: ${elevation('md.comp.bottom-app-bar.container')}, - height: ${getToken('md.comp.bottom-app-bar.container.height')}, - shape: const AutomaticNotchedShape(${shape('md.comp.bottom-app-bar.container', '')}), + elevation: ${number(TokenBottomAppBar.containerElevation)}, + height: ${number(TokenBottomAppBar.containerHeight)}, + shape: const AutomaticNotchedShape(${shape(TokenBottomAppBar.containerShape, '')}), ); final BuildContext context; late final ColorScheme _colors = Theme.of(context).colorScheme; @override - Color? get color => ${componentColor('md.comp.bottom-app-bar.container')}; + Color? get color => ${color(TokenBottomAppBar.containerColor, '_colors')}; @override - Color? get surfaceTintColor => ${colorOrTransparent('md.comp.bottom-app-bar.container.surface-tint-layer')}; + Color? get surfaceTintColor => Colors.transparent; @override Color? get shadowColor => Colors.transparent; From ba670b721839e45149c3efa02257e7eed8f11b49 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:05:14 -0700 Subject: [PATCH 4/4] Add test case --- .../tool/gen_defaults/test/gen_defaults_test.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart b/packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart index 90063d5cdbe..dc0c5759487 100644 --- a/packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart +++ b/packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart @@ -8,6 +8,7 @@ import 'package:test/test.dart'; import '../data/color_role.dart'; import '../data/shape_struct.dart'; import '../templates/app_bar_template.dart'; +import '../templates/bottom_app_bar_template.dart'; import '../templates/template.dart'; import 'test_fixtures/test_templates.dart'; @@ -159,6 +160,19 @@ void main() { expect(contents, contains('static const double expandedHeight = 112.0')); expect(contents, contains('static const double expandedHeight = 152.0')); }); + + test('BottomAppBarTemplateM3 emits M3 BottomAppBar defaults from bottom app bar tokens', () { + final String contents = const BottomAppBarTemplateM3().generateContents( + '_BottomAppBarDefaultsM3', + ); + expect(contents, contains('class _BottomAppBarDefaultsM3 extends BottomAppBarThemeData')); + expect(contents, contains('elevation: 3.0')); + expect(contents, contains('height: 80.0')); + expect(contents, contains('shape: const AutomaticNotchedShape(RoundedRectangleBorder())')); + expect(contents, contains('Color? get color => _colors.surfaceContainer')); + expect(contents, contains('Color? get surfaceTintColor => Colors.transparent')); + }); + test('will run dart format over the generated file', () { final template = UnformattedTemplate(testPath()); template.generateFile();