Skip to content
Open
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/bottom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
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 '../bottom_app_bar.dart';

class _BottomAppBarDefaultsM3 extends BottomAppBarThemeData {
_BottomAppBarDefaultsM3(this.context)
: super(
Expand Down
2 changes: 2 additions & 0 deletions packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import 'package:args/args.dart';

import '../templates/app_bar_template.dart';
import '../templates/bottom_app_bar_template.dart';

Future<void> main(List<String> args) async {
// Parse arguments
Expand All @@ -22,4 +23,5 @@ Future<void> main(List<String> 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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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/bottom_app_bar.dart';
import 'template.dart';

class BottomAppBarTemplateM3 extends TokenTemplateM3 {
const BottomAppBarTemplateM3();

@override
String get name => 'Bottom App Bar';

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

@override
String generateContents(String className) => '''
class $className extends BottomAppBarThemeData {
$className(this.context)
: super(
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 => ${color(TokenBottomAppBar.containerColor, '_colors')};

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

@override
Color? get shadowColor => Colors.transparent;
}
''';
}

This file was deleted.

14 changes: 14 additions & 0 deletions packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand Down