Support Material 3 in bottom sheet (#112466)
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_sheet_template.dart';
|
||||
import 'package:gen_defaults/button_template.dart';
|
||||
import 'package:gen_defaults/card_template.dart';
|
||||
import 'package:gen_defaults/checkbox_template.dart';
|
||||
@@ -88,6 +89,7 @@ Future<void> main(List<String> args) async {
|
||||
'radio_button.json',
|
||||
'segmented_button_outlined.json',
|
||||
'shape.json',
|
||||
'sheet_bottom.json',
|
||||
'slider.json',
|
||||
'state.json',
|
||||
'switch.json',
|
||||
@@ -115,6 +117,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();
|
||||
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();
|
||||
ButtonTemplate('md.comp.filled-tonal-button', 'FilledTonalButton', '$materialLib/filled_button.dart', tokens).updateFile();
|
||||
|
||||
30
dev/tools/gen_defaults/lib/bottom_sheet_template.dart
Normal file
30
dev/tools/gen_defaults/lib/bottom_sheet_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 BottomSheetTemplate extends TokenTemplate {
|
||||
const BottomSheetTemplate(super.blockName, super.fileName, super.tokens);
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
// Generated version ${tokens["version"]}
|
||||
class _${blockName}DefaultsM3 extends BottomSheetThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation("md.comp.sheet.bottom.docked.standard.container")},
|
||||
modalElevation: ${elevation("md.comp.sheet.bottom.docked.modal.container")},
|
||||
shape: ${shape("md.comp.sheet.bottom.docked.container")},
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.sheet.bottom.docked.container")};
|
||||
|
||||
@override
|
||||
Color? get surfaceTintColor => ${componentColor("md.comp.sheet.bottom.docked.container.surface-tint-layer")};
|
||||
}
|
||||
''';
|
||||
}
|
||||
@@ -177,6 +177,12 @@ abstract class TokenTemplate {
|
||||
if (topLeft == topRight && topLeft == bottomLeft && topLeft == bottomRight) {
|
||||
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),':''}'
|
||||
'${bottomLeft > 0 ? 'bottom: Radius.circular($bottomLeft),':''}'
|
||||
'))';
|
||||
}
|
||||
return '${prefix}RoundedRectangleBorder(borderRadius: '
|
||||
'BorderRadius.only('
|
||||
'topLeft: Radius.circular(${shape['topLeft']}), '
|
||||
|
||||
Reference in New Issue
Block a user