Updated the defaults to only use function overrides for computed values. (#97677)

This commit is contained in:
Darren Austin
2022-02-02 16:13:56 -08:00
committed by GitHub
parent 0b72d5ca58
commit e82e94b28a
2 changed files with 72 additions and 92 deletions

View File

@@ -13,7 +13,30 @@ class FABTemplate extends TokenTemplate {
class _M3Defaults extends FloatingActionButtonThemeData {
_M3Defaults(this.context, this.type, this.hasChild)
: _colors = Theme.of(context).colorScheme,
_textTheme = Theme.of(context).textTheme;
_textTheme = Theme.of(context).textTheme,
super(
elevation: ${elevation("md.comp.fab.primary.container.elevation")},
focusElevation: ${elevation("md.comp.fab.primary.focus.container.elevation")},
hoverElevation: ${elevation("md.comp.fab.primary.hover.container.elevation")},
highlightElevation: ${elevation("md.comp.fab.primary.pressed.container.elevation")},
enableFeedback: true,
sizeConstraints: const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.container.width"]},
height: ${tokens["md.comp.fab.primary.container.height"]},
),
smallSizeConstraints: const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.small.container.width"]},
height: ${tokens["md.comp.fab.primary.small.container.height"]},
),
largeSizeConstraints: const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.large.container.width"]},
height: ${tokens["md.comp.fab.primary.large.container.height"]},
),
extendedSizeConstraints: const BoxConstraints.tightFor(
height: ${tokens["md.comp.extended-fab.primary.container.height"]},
),
extendedIconLabelSpacing: 8.0,
);
final BuildContext context;
final _FloatingActionButtonType type;
@@ -26,12 +49,8 @@ class _M3Defaults extends FloatingActionButtonThemeData {
@override Color? get foregroundColor => _colors.${color("md.comp.fab.primary.icon")};
@override Color? get backgroundColor => _colors.${color("md.comp.fab.primary.container")};
@override Color? get splashColor => _colors.${color("md.comp.fab.primary.pressed.state-layer")};
@override double get elevation => ${elevation("md.comp.fab.primary.container.elevation")};
@override Color? get focusColor => _colors.${color("md.comp.fab.primary.focus.state-layer")};
@override double get focusElevation => ${elevation("md.comp.fab.primary.focus.container.elevation")};
@override Color? get hoverColor => _colors.${color("md.comp.fab.primary.hover.state-layer")};
@override double get hoverElevation => ${elevation("md.comp.fab.primary.hover.container.elevation")};
@override double get highlightElevation => ${elevation("md.comp.fab.primary.pressed.container.elevation")};
@override
ShapeBorder? get shape {
@@ -47,8 +66,6 @@ class _M3Defaults extends FloatingActionButtonThemeData {
}
}
@override bool? get enableFeedback => true;
@override
double? get iconSize {
switch (type) {
@@ -59,30 +76,6 @@ class _M3Defaults extends FloatingActionButtonThemeData {
}
}
@override
BoxConstraints? get sizeConstraints => const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.container.width"]},
height: ${tokens["md.comp.fab.primary.container.height"]},
);
@override
BoxConstraints? get smallSizeConstraints => const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.small.container.width"]},
height: ${tokens["md.comp.fab.primary.small.container.height"]},
);
@override
BoxConstraints? get largeSizeConstraints => const BoxConstraints.tightFor(
width: ${tokens["md.comp.fab.primary.large.container.width"]},
height: ${tokens["md.comp.fab.primary.large.container.height"]},
);
@override
BoxConstraints? get extendedSizeConstraints => const BoxConstraints.tightFor(
height: ${tokens["md.comp.extended-fab.primary.container.height"]},
);
@override double? get extendedIconLabelSpacing => 8.0;
@override EdgeInsetsGeometry? get extendedPadding => EdgeInsetsDirectional.only(start: hasChild && _isExtended ? 16.0 : 20.0, end: 20.0);
@override TextStyle? get extendedTextStyle => _textTheme.${textStyle("md.comp.extended-fab.primary.label-text")};
}