* Revert "Revert "Add Material 3 support for BottomAppBar" (#114421)"
This reverts commit 210a2aa371.
* Regenerated the defaults from tokens and fixed tests.
* Fixed the tests.
* Updated the shape token template to optimize the a common case.
This commit is contained in:
@@ -20,6 +20,7 @@ import 'dart:io';
|
||||
import 'package:gen_defaults/action_chip_template.dart';
|
||||
import 'package:gen_defaults/app_bar_template.dart';
|
||||
import 'package:gen_defaults/banner_template.dart';
|
||||
import 'package:gen_defaults/bottom_app_bar_template.dart';
|
||||
import 'package:gen_defaults/bottom_sheet_template.dart';
|
||||
import 'package:gen_defaults/button_template.dart';
|
||||
import 'package:gen_defaults/card_template.dart';
|
||||
@@ -121,6 +122,7 @@ Future<void> main(List<String> args) async {
|
||||
ActionChipTemplate('ActionChip', '$materialLib/action_chip.dart', tokens).updateFile();
|
||||
AppBarTemplate('AppBar', '$materialLib/app_bar.dart', tokens).updateFile();
|
||||
BannerTemplate('Banner', '$materialLib/banner.dart', tokens).updateFile();
|
||||
BottomAppBarTemplate('BottomAppBar', '$materialLib/bottom_app_bar.dart', tokens).updateFile();
|
||||
BottomSheetTemplate('BottomSheet', '$materialLib/bottom_sheet.dart', tokens).updateFile();
|
||||
ButtonTemplate('md.comp.elevated-button', 'ElevatedButton', '$materialLib/elevated_button.dart', tokens).updateFile();
|
||||
ButtonTemplate('md.comp.filled-button', 'FilledButton', '$materialLib/filled_button.dart', tokens).updateFile();
|
||||
|
||||
30
dev/tools/gen_defaults/lib/bottom_app_bar_template.dart
Normal file
30
dev/tools/gen_defaults/lib/bottom_app_bar_template.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'template.dart';
|
||||
|
||||
class BottomAppBarTemplate extends TokenTemplate {
|
||||
const BottomAppBarTemplate(super.blockName, super.fileName, super.tokens);
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
// Generated version ${tokens["version"]}
|
||||
class _${blockName}DefaultsM3 extends BottomAppBarTheme {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation('md.comp.bottom-app-bar.container')},
|
||||
height: ${tokens['md.comp.bottom-app-bar.container.height']},
|
||||
shape: const AutomaticNotchedShape(${shape('md.comp.bottom-app-bar.container', '')}),
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
|
||||
@override
|
||||
Color? get color => ${componentColor('md.comp.bottom-app-bar.container')};
|
||||
|
||||
@override
|
||||
Color? get surfaceTintColor => ${componentColor('md.comp.bottom-app-bar.container.surface-tint-layer')};
|
||||
}
|
||||
''';
|
||||
}
|
||||
@@ -175,22 +175,25 @@ abstract class TokenTemplate {
|
||||
final double bottomLeft = shape['bottomLeft'] as double;
|
||||
final double bottomRight = shape['bottomRight'] as double;
|
||||
if (topLeft == topRight && topLeft == bottomLeft && topLeft == bottomRight) {
|
||||
if (topLeft == 0) {
|
||||
return '${prefix}RoundedRectangleBorder()';
|
||||
}
|
||||
return '${prefix}RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular($topLeft)))';
|
||||
}
|
||||
if (topLeft == topRight && bottomLeft == bottomRight) {
|
||||
return '${prefix}RoundedRectangleBorder(borderRadius: BorderRadius.vertical('
|
||||
'${topLeft > 0 ? 'top: Radius.circular($topLeft)':''}'
|
||||
'${topLeft > 0 && bottomLeft > 0 ? ',':''}'
|
||||
'${bottomLeft > 0 ? 'bottom: Radius.circular($bottomLeft)':''}'
|
||||
'))';
|
||||
'${topLeft > 0 ? 'top: Radius.circular($topLeft)':''}'
|
||||
'${topLeft > 0 && bottomLeft > 0 ? ',':''}'
|
||||
'${bottomLeft > 0 ? 'bottom: Radius.circular($bottomLeft)':''}'
|
||||
'))';
|
||||
}
|
||||
return '${prefix}RoundedRectangleBorder(borderRadius: '
|
||||
'BorderRadius.only('
|
||||
'topLeft: Radius.circular(${shape['topLeft']}), '
|
||||
'topRight: Radius.circular(${shape['topRight']}), '
|
||||
'bottomLeft: Radius.circular(${shape['bottomLeft']}), '
|
||||
'bottomRight: Radius.circular(${shape['bottomRight']})))';
|
||||
case 'SHAPE_FAMILY_CIRCULAR':
|
||||
'BorderRadius.only('
|
||||
'topLeft: Radius.circular(${shape['topLeft']}), '
|
||||
'topRight: Radius.circular(${shape['topRight']}), '
|
||||
'bottomLeft: Radius.circular(${shape['bottomLeft']}), '
|
||||
'bottomRight: Radius.circular(${shape['bottomRight']})))';
|
||||
case 'SHAPE_FAMILY_CIRCULAR':
|
||||
return '${prefix}StadiumBorder()';
|
||||
}
|
||||
print('Unsupported shape family type: ${shape['family']} for $componentToken');
|
||||
|
||||
Reference in New Issue
Block a user