Support Material 3 in bottom sheet (#112466)

This commit is contained in:
hangyu
2022-10-11 17:55:26 +08:00
committed by GitHub
parent f01baefe0f
commit 4fed6aaeff
8 changed files with 210 additions and 6 deletions

View 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")};
}
''';
}

View File

@@ -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']}), '