Cleanup M3 token templates for theme lookups (#122601)
Cleanup M3 token templates for theme lookups
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
import 'template.dart';
|
||||
|
||||
class ActionChipTemplate extends TokenTemplate {
|
||||
|
||||
const ActionChipTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const ActionChipTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
super.textThemePrefix = '_textTheme.'
|
||||
});
|
||||
|
||||
static const String tokenGroup = 'md.comp.assist-chip';
|
||||
static const String variant = '.flat';
|
||||
@@ -14,7 +16,7 @@ class ActionChipTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
const _${blockName}DefaultsM3(this.context, this.isEnabled)
|
||||
_${blockName}DefaultsM3(this.context, this.isEnabled)
|
||||
: super(
|
||||
elevation: ${elevation("$tokenGroup$variant.container")},
|
||||
shape: ${shape("$tokenGroup.container")},
|
||||
@@ -23,6 +25,8 @@ class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
|
||||
final BuildContext context;
|
||||
final bool isEnabled;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
|
||||
@override
|
||||
TextStyle? get labelStyle => ${textStyle("$tokenGroup.label-text")};
|
||||
|
||||
@@ -5,15 +5,20 @@
|
||||
import 'template.dart';
|
||||
|
||||
class BannerTemplate extends TokenTemplate {
|
||||
const BannerTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const BannerTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
super.textThemePrefix = '_textTheme.'
|
||||
});
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends MaterialBannerThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: super(elevation: ${elevation("md.comp.banner.container")});
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.banner.container")};
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
import 'template.dart';
|
||||
|
||||
class BottomAppBarTemplate extends TokenTemplate {
|
||||
const BottomAppBarTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const BottomAppBarTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
});
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends BottomAppBarTheme {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation('md.comp.bottom-app-bar.container')},
|
||||
height: ${tokens['md.comp.bottom-app-bar.container.height']},
|
||||
@@ -18,6 +20,7 @@ class _${blockName}DefaultsM3 extends BottomAppBarTheme {
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
|
||||
@override
|
||||
Color? get color => ${componentColor('md.comp.bottom-app-bar.container')};
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
import 'template.dart';
|
||||
|
||||
class BottomSheetTemplate extends TokenTemplate {
|
||||
const BottomSheetTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const BottomSheetTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
});
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends BottomSheetThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation("md.comp.sheet.bottom.docked.standard.container")},
|
||||
modalElevation: ${elevation("md.comp.sheet.bottom.docked.modal.container")},
|
||||
@@ -18,6 +20,7 @@ class _${blockName}DefaultsM3 extends BottomSheetThemeData {
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.sheet.bottom.docked.container")};
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
import 'template.dart';
|
||||
|
||||
class CardTemplate extends TokenTemplate {
|
||||
const CardTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const CardTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
});
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends CardTheme {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
clipBehavior: Clip.none,
|
||||
elevation: ${elevation("md.comp.elevated-card.container")},
|
||||
@@ -19,6 +21,7 @@ class _${blockName}DefaultsM3 extends CardTheme {
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
|
||||
@override
|
||||
Color? get color => ${componentColor("md.comp.elevated-card.container")};
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
import 'template.dart';
|
||||
|
||||
class FilterChipTemplate extends TokenTemplate {
|
||||
const FilterChipTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const FilterChipTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
super.textThemePrefix = '_textTheme.'
|
||||
});
|
||||
|
||||
static const String tokenGroup = 'md.comp.filter-chip';
|
||||
static const String variant = '.flat';
|
||||
@@ -13,7 +16,7 @@ class FilterChipTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
const _${blockName}DefaultsM3(this.context, this.isEnabled, this.isSelected)
|
||||
_${blockName}DefaultsM3(this.context, this.isEnabled, this.isSelected)
|
||||
: super(
|
||||
elevation: ${elevation("$tokenGroup$variant.container")},
|
||||
shape: ${shape("$tokenGroup.container")},
|
||||
@@ -23,6 +26,8 @@ class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
final BuildContext context;
|
||||
final bool isEnabled;
|
||||
final bool isSelected;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
|
||||
@override
|
||||
TextStyle? get labelStyle => ${textStyle("$tokenGroup.label-text")};
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
import 'template.dart';
|
||||
|
||||
class InputChipTemplate extends TokenTemplate {
|
||||
const InputChipTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const InputChipTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
super.textThemePrefix = '_textTheme.'
|
||||
});
|
||||
|
||||
static const String tokenGroup = 'md.comp.input-chip';
|
||||
static const String variant = '';
|
||||
@@ -13,7 +16,7 @@ class InputChipTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
const _${blockName}DefaultsM3(this.context, this.isEnabled, this.isSelected)
|
||||
_${blockName}DefaultsM3(this.context, this.isEnabled, this.isSelected)
|
||||
: super(
|
||||
elevation: ${elevation("$tokenGroup$variant.container")},
|
||||
shape: ${shape("$tokenGroup.container")},
|
||||
@@ -23,6 +26,8 @@ class _${blockName}DefaultsM3 extends ChipThemeData {
|
||||
final BuildContext context;
|
||||
final bool isEnabled;
|
||||
final bool isSelected;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
|
||||
@override
|
||||
TextStyle? get labelStyle => ${textStyle("$tokenGroup.label-text")};
|
||||
|
||||
@@ -5,20 +5,25 @@
|
||||
import 'template.dart';
|
||||
|
||||
class NavigationDrawerTemplate extends TokenTemplate {
|
||||
const NavigationDrawerTemplate(super.blockName, super.fileName, super.tokens);
|
||||
const NavigationDrawerTemplate(super.blockName, super.fileName, super.tokens, {
|
||||
super.colorSchemePrefix = '_colors.',
|
||||
super.textThemePrefix = '_textTheme.'
|
||||
});
|
||||
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends NavigationDrawerThemeData {
|
||||
const _${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation("md.comp.navigation-drawer.modal.container")},
|
||||
tileHeight: ${tokens["md.comp.navigation-drawer.active-indicator.height"]},
|
||||
indicatorShape: ${shape("md.comp.navigation-drawer.active-indicator")},
|
||||
indicatorSize: const Size(${tokens["md.comp.navigation-drawer.active-indicator.width"]}, ${tokens["md.comp.navigation-drawer.active-indicator.height"]}),
|
||||
);
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: super(
|
||||
elevation: ${elevation("md.comp.navigation-drawer.modal.container")},
|
||||
tileHeight: ${tokens["md.comp.navigation-drawer.active-indicator.height"]},
|
||||
indicatorShape: ${shape("md.comp.navigation-drawer.active-indicator")},
|
||||
indicatorSize: const Size(${tokens["md.comp.navigation-drawer.active-indicator.width"]}, ${tokens["md.comp.navigation-drawer.active-indicator.height"]}),
|
||||
);
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
|
||||
@override
|
||||
Color? get backgroundColor => ${componentColor("md.comp.navigation-drawer.container")};
|
||||
|
||||
@@ -15,11 +15,10 @@ class SliderTemplate extends TokenTemplate {
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends SliderThemeData {
|
||||
_${blockName}DefaultsM3(this.context)
|
||||
: _colors = Theme.of(context).colorScheme,
|
||||
super(trackHeight: ${tokens['$tokenGroup.active.track.height']});
|
||||
: super(trackHeight: ${tokens['$tokenGroup.active.track.height']});
|
||||
|
||||
final BuildContext context;
|
||||
final ColorScheme _colors;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
|
||||
@override
|
||||
Color? get activeTrackColor => ${componentColor('$tokenGroup.active.track')};
|
||||
|
||||
@@ -19,7 +19,6 @@ class _${blockName}DefaultsM3 extends SnackBarThemeData {
|
||||
|
||||
final BuildContext context;
|
||||
late final ThemeData _theme = Theme.of(context);
|
||||
|
||||
late final ColorScheme _colors = _theme.colorScheme;
|
||||
|
||||
@override
|
||||
|
||||
@@ -12,10 +12,10 @@ class SwitchTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends SwitchThemeData {
|
||||
_${blockName}DefaultsM3(BuildContext context)
|
||||
: _colors = Theme.of(context).colorScheme;
|
||||
_${blockName}DefaultsM3(this.context);
|
||||
|
||||
final ColorScheme _colors;
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
|
||||
@override
|
||||
MaterialStateProperty<Color> get thumbColor {
|
||||
|
||||
Reference in New Issue
Block a user