Reorder materialStateProperty defaults (#125905)
Fixes #122250. This PR is to make sure all the MaterialStateProperty defaults are able to correctly resolve different states. * When a widget is pressed, it is also hovered, so we need to put the `MaterialState.pressed` check before `MaterialState.hovered`. * When a widget is focused, the widget should still be able to be hovered, so we should check `MaterialState.hovered` before `MaterialState.focused`. * There are also cases like in _InputDecoratorDefaultsM3, the `MaterialState.disabled` should be checked before `MaterialState.error`. the order should be disabled, (error), pressed, hovered, focused.
This commit is contained in:
@@ -78,12 +78,6 @@ class _MediumScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig {
|
||||
TextStyle? get expandedTextStyle =>
|
||||
${textStyle('md.comp.top-app-bar.medium.headline')}?.apply(color: ${color('md.comp.top-app-bar.medium.headline.color')});
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get collapsedTitlePadding => const EdgeInsetsDirectional.only(start: 40);
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get collapsedCenteredTitlePadding => const EdgeInsetsDirectional.only(start: 40);
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 20);
|
||||
}
|
||||
@@ -107,12 +101,6 @@ class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig {
|
||||
TextStyle? get expandedTextStyle =>
|
||||
${textStyle('md.comp.top-app-bar.large.headline')}?.apply(color: ${color('md.comp.top-app-bar.large.headline.color')});
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get collapsedTitlePadding => const EdgeInsetsDirectional.only(start: 40);
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get collapsedCenteredTitlePadding => const EdgeInsetsDirectional.only(start: 40);
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28);
|
||||
}
|
||||
|
||||
@@ -35,15 +35,15 @@ class ButtonTemplate extends TokenTemplate {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${elevation("$tokenGroup.disabled.container")};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${elevation("$tokenGroup.pressed.container")};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${elevation("$tokenGroup.hover.container")};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${elevation("$tokenGroup.focus.container")};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${elevation("$tokenGroup.pressed.container")};
|
||||
}
|
||||
return ${elevation("$tokenGroup.container")};
|
||||
})''';
|
||||
}
|
||||
@@ -92,15 +92,15 @@ class _${blockName}DefaultsM3 extends ButtonStyle {
|
||||
@override
|
||||
MaterialStateProperty<Color?>? get overlayColor =>
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
@@ -106,25 +106,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
|
||||
MaterialStateProperty<Color?>? get dayOverlayColor =>
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'pressed')};
|
||||
}
|
||||
} else {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'pressed')};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -173,25 +173,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
|
||||
MaterialStateProperty<Color?>? get yearOverlayColor =>
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'pressed')};
|
||||
}
|
||||
} else {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'pressed')};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -208,14 +208,14 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
|
||||
@override
|
||||
MaterialStateProperty<Color?>? get rangeSelectionOverlayColor =>
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range.', null, 'hover')};
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range.', null, 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range.', null, 'pressed')};
|
||||
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'focus')};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -95,26 +95,29 @@ class IconButtonTemplate extends TokenTemplate {
|
||||
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.toggle.selected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.toggle.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.toggle.selected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.toggle.selected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
}
|
||||
if (toggleable) { // toggleable but unselected case
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.toggle.unselected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.toggle.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.toggle.unselected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.toggle.unselected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.hover.state-layer')};
|
||||
@@ -122,24 +125,24 @@ class IconButtonTemplate extends TokenTemplate {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
return Colors.transparent;
|
||||
})''';
|
||||
case 'md.comp.outlined-icon-button':
|
||||
return '''
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.selected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.selected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.selected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.unselected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
|
||||
@@ -147,9 +150,6 @@ class IconButtonTemplate extends TokenTemplate {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.unselected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')});
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.unselected.pressed.state-layer')}.withOpacity(${opacity('$tokenGroup.pressed.state-layer.opacity')});
|
||||
}
|
||||
return Colors.transparent;
|
||||
})''';
|
||||
case 'md.comp.icon-button':
|
||||
@@ -157,15 +157,18 @@ class IconButtonTemplate extends TokenTemplate {
|
||||
|
||||
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.selected.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.selected.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.selected.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.selected.pressed.state-layer')};
|
||||
}
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.unselected.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.unselected.hover.state-layer')};
|
||||
@@ -173,9 +176,6 @@ class IconButtonTemplate extends TokenTemplate {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.unselected.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('$tokenGroup.unselected.pressed.state-layer')};
|
||||
}
|
||||
return Colors.transparent;
|
||||
})''';
|
||||
}
|
||||
|
||||
@@ -39,119 +39,119 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
|
||||
|
||||
@override
|
||||
BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${mergedBorder('md.comp.filled-text-field.error.focus.active-indicator','md.comp.filled-text-field.focus.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.filled-text-field.error.hover.active-indicator')};
|
||||
}
|
||||
return ${border('md.comp.filled-text-field.error.active-indicator')};
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${border('md.comp.filled-text-field.disabled.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.filled-text-field.error.hover.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${border('md.comp.filled-text-field.focus.active-indicator')};
|
||||
return ${mergedBorder('md.comp.filled-text-field.error.focus.active-indicator','md.comp.filled-text-field.focus.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.filled-text-field.hover.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${border('md.comp.filled-text-field.disabled.active-indicator')};
|
||||
}
|
||||
return ${border('md.comp.filled-text-field.active-indicator')};
|
||||
return ${border('md.comp.filled-text-field.error.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.filled-text-field.hover.active-indicator')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${border('md.comp.filled-text-field.focus.active-indicator')};
|
||||
}
|
||||
return ${border('md.comp.filled-text-field.active-indicator')};
|
||||
});
|
||||
|
||||
@override
|
||||
BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${mergedBorder('md.comp.outlined-text-field.error.focus.outline','md.comp.outlined-text-field.focus.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.outlined-text-field.error.hover.outline')};
|
||||
}
|
||||
return ${border('md.comp.outlined-text-field.error.outline')};
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${border('md.comp.outlined-text-field.disabled.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.outlined-text-field.error.hover.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${border('md.comp.outlined-text-field.focus.outline')};
|
||||
return ${mergedBorder('md.comp.outlined-text-field.error.focus.outline','md.comp.outlined-text-field.focus.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.outlined-text-field.hover.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${border('md.comp.outlined-text-field.disabled.outline')};
|
||||
}
|
||||
return ${border('md.comp.outlined-text-field.outline')};
|
||||
});
|
||||
return ${border('md.comp.outlined-text-field.error.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${border('md.comp.outlined-text-field.hover.outline')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${border('md.comp.outlined-text-field.focus.outline')};
|
||||
}
|
||||
return ${border('md.comp.outlined-text-field.outline')};
|
||||
});
|
||||
|
||||
@override
|
||||
Color? get iconColor => ${componentColor("md.comp.filled-text-field.leading-icon")};
|
||||
|
||||
@override
|
||||
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {${componentColor('md.comp.filled-text-field.error.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
|
||||
if(states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')};
|
||||
}
|
||||
return ${componentColor('md.comp.filled-text-field.error.leading-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.focus.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.focus.leading-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.hover.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.hover.leading-icon')};
|
||||
}'''}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')};
|
||||
}
|
||||
if(states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')};
|
||||
}
|
||||
return ${componentColor('md.comp.filled-text-field.error.leading-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.hover.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.hover.leading-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.focus.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.focus.leading-icon')};
|
||||
}'''}
|
||||
return ${componentColor('md.comp.filled-text-field.leading-icon')};
|
||||
});
|
||||
|
||||
@override
|
||||
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||
if(states.contains(MaterialState.error)) {${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')};
|
||||
}'''}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')};
|
||||
}
|
||||
return ${componentColor('md.comp.filled-text-field.error.trailing-icon')};
|
||||
}${componentColor('md.comp.filled-text-field.focus.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.focus.trailing-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.hover.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')};
|
||||
}'''}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')};
|
||||
}
|
||||
if(states.contains(MaterialState.error)) {${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')};
|
||||
}'''}
|
||||
return ${componentColor('md.comp.filled-text-field.error.trailing-icon')};
|
||||
}${componentColor('md.comp.filled-text-field.hover.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')};
|
||||
}'''}${componentColor('md.comp.filled-text-field.focus.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.filled-text-field.focus.trailing-icon')};
|
||||
}'''}
|
||||
return ${componentColor('md.comp.filled-text-field.trailing-icon')};
|
||||
});
|
||||
|
||||
@override
|
||||
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
|
||||
}
|
||||
if(states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
|
||||
}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.label-text')});
|
||||
}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.label-text')});
|
||||
});
|
||||
@@ -159,50 +159,50 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
|
||||
@override
|
||||
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
|
||||
}
|
||||
if(states.contains(MaterialState.error)) {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
|
||||
}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')});
|
||||
}
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.label-text')});
|
||||
}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.label-text')});
|
||||
});
|
||||
|
||||
@override
|
||||
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.supporting-text')});
|
||||
}'''}${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.supporting-text')});
|
||||
}'''}
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.supporting-text')});
|
||||
}
|
||||
}${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.supporting-text')});
|
||||
}'''}${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.supporting-text')});
|
||||
}'''}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.supporting-text')});
|
||||
});
|
||||
|
||||
@override
|
||||
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.supporting-text')});
|
||||
}'''}${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
|
||||
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.supporting-text')});
|
||||
}'''}${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.supporting-text')});
|
||||
}'''}
|
||||
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.supporting-text')});
|
||||
});
|
||||
|
||||
@@ -82,25 +82,25 @@ class _${blockName}DefaultsM3 extends SegmentedButtonThemeData {
|
||||
}),
|
||||
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor(tokenGroup, 'selected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor(tokenGroup, 'selected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor(tokenGroup, 'selected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor(tokenGroup, 'selected', 'pressed')};
|
||||
}
|
||||
} else {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor(tokenGroup, 'unselected', 'pressed')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${_stateColor(tokenGroup, 'unselected', 'hover')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${_stateColor(tokenGroup, 'unselected', 'focus')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${_stateColor(tokenGroup, 'unselected', 'pressed')};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
|
||||
@@ -58,15 +58,15 @@ class _${blockName}DefaultsM3 extends SliderThemeData {
|
||||
|
||||
@override
|
||||
Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.dragged)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('$tokenGroup.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('$tokenGroup.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.dragged)) {
|
||||
return ${componentColor('$tokenGroup.pressed.state-layer')};
|
||||
}
|
||||
|
||||
return Colors.transparent;
|
||||
});
|
||||
|
||||
@@ -43,26 +43,26 @@ class _${blockName}PrimaryDefaultsM3 extends TabBarTheme {
|
||||
MaterialStateProperty<Color?> get overlayColor {
|
||||
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.active.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.active.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.active.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.active.pressed.state-layer')};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.inactive.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.inactive.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.inactive.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.primary-navigation-tab.inactive.pressed.state-layer')};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -107,26 +107,26 @@ class _${blockName}SecondaryDefaultsM3 extends TabBarTheme {
|
||||
MaterialStateProperty<Color?> get overlayColor {
|
||||
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.pressed.state-layer')};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.pressed.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.focus.state-layer')};
|
||||
}
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor('md.comp.secondary-navigation-tab.pressed.state-layer')};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,12 +96,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
textColor = ${componentColor("$dayPeriodComponent.selected.pressed.label-text")};
|
||||
} else {
|
||||
// not pressed
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.selected.focus.label-text")};
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.selected.hover.label-text")};
|
||||
} else {
|
||||
// not focused
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.selected.hover.label-text")};
|
||||
// not hovered
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.selected.focus.label-text")};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,12 +111,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
textColor = ${componentColor("$dayPeriodComponent.unselected.pressed.label-text")};
|
||||
} else {
|
||||
// not pressed
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.unselected.focus.label-text")};
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.unselected.hover.label-text")};
|
||||
} else {
|
||||
// not focused
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.unselected.hover.label-text")};
|
||||
// not hovered
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
textColor = ${componentColor("$dayPeriodComponent.unselected.focus.label-text")};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,24 +205,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
Color overlayColor = ${componentColor('$hourMinuteComponent.selected.container')};
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.selected.pressed.state-layer')};
|
||||
} else if (states.contains(MaterialState.focused)) {
|
||||
const double focusOpacity = ${opacity('$hourMinuteComponent.focus.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.selected.focus.state-layer')}.withOpacity(focusOpacity);
|
||||
} else if (states.contains(MaterialState.hovered)) {
|
||||
const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.selected.hover.state-layer')}.withOpacity(hoverOpacity);
|
||||
} else if (states.contains(MaterialState.focused)) {
|
||||
const double focusOpacity = ${opacity('$hourMinuteComponent.focus.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.selected.focus.state-layer')}.withOpacity(focusOpacity);
|
||||
}
|
||||
return Color.alphaBlend(overlayColor, ${componentColor('$hourMinuteComponent.selected.container')});
|
||||
} else {
|
||||
Color overlayColor = ${componentColor('$hourMinuteComponent.unselected.container')};
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.unselected.pressed.state-layer')};
|
||||
} else if (states.contains(MaterialState.focused)) {
|
||||
const double focusOpacity = ${opacity('$hourMinuteComponent.focus.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.unselected.focus.state-layer')}.withOpacity(focusOpacity);
|
||||
} else if (states.contains(MaterialState.hovered)) {
|
||||
const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.unselected.hover.state-layer')}.withOpacity(hoverOpacity);
|
||||
} else if (states.contains(MaterialState.focused)) {
|
||||
const double focusOpacity = ${opacity('$hourMinuteComponent.focus.state-layer.opacity')};
|
||||
overlayColor = ${componentColor('$hourMinuteComponent.unselected.focus.state-layer')}.withOpacity(focusOpacity);
|
||||
}
|
||||
return Color.alphaBlend(overlayColor, ${componentColor('$hourMinuteComponent.unselected.container')});
|
||||
}
|
||||
@@ -271,24 +271,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor("$hourMinuteComponent.selected.pressed.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor("$hourMinuteComponent.selected.focus.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor("$hourMinuteComponent.selected.hover.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor("$hourMinuteComponent.selected.focus.label-text")};
|
||||
}
|
||||
return ${componentColor("$hourMinuteComponent.selected.label-text")};
|
||||
} else {
|
||||
// unselected
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return ${componentColor("$hourMinuteComponent.unselected.pressed.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor("$hourMinuteComponent.unselected.focus.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.hovered)) {
|
||||
return ${componentColor("$hourMinuteComponent.unselected.hover.label-text")};
|
||||
}
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return ${componentColor("$hourMinuteComponent.unselected.focus.label-text")};
|
||||
}
|
||||
return ${componentColor("$hourMinuteComponent.unselected.label-text")};
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user