Unverified Commit 4e7e4512 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

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.
parent a48cc240
...@@ -78,12 +78,6 @@ class _MediumScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { ...@@ -78,12 +78,6 @@ class _MediumScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig {
TextStyle? get expandedTextStyle => TextStyle? get expandedTextStyle =>
${textStyle('md.comp.top-app-bar.medium.headline')}?.apply(color: ${color('md.comp.top-app-bar.medium.headline.color')}); ${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 @override
EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 20); EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 20);
} }
...@@ -107,12 +101,6 @@ class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { ...@@ -107,12 +101,6 @@ class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig {
TextStyle? get expandedTextStyle => TextStyle? get expandedTextStyle =>
${textStyle('md.comp.top-app-bar.large.headline')}?.apply(color: ${color('md.comp.top-app-bar.large.headline.color')}); ${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 @override
EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28); EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28);
} }
......
...@@ -35,15 +35,15 @@ class ButtonTemplate extends TokenTemplate { ...@@ -35,15 +35,15 @@ class ButtonTemplate extends TokenTemplate {
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return ${elevation("$tokenGroup.disabled.container")}; return ${elevation("$tokenGroup.disabled.container")};
} }
if (states.contains(MaterialState.pressed)) {
return ${elevation("$tokenGroup.pressed.container")};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${elevation("$tokenGroup.hover.container")}; return ${elevation("$tokenGroup.hover.container")};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${elevation("$tokenGroup.focus.container")}; return ${elevation("$tokenGroup.focus.container")};
} }
if (states.contains(MaterialState.pressed)) {
return ${elevation("$tokenGroup.pressed.container")};
}
return ${elevation("$tokenGroup.container")}; return ${elevation("$tokenGroup.container")};
})'''; })''';
} }
...@@ -92,15 +92,15 @@ class _${blockName}DefaultsM3 extends ButtonStyle { ...@@ -92,15 +92,15 @@ class _${blockName}DefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return ${componentColor('$tokenGroup.pressed.state-layer')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.hover.state-layer')}; return ${componentColor('$tokenGroup.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.focus.state-layer')}; return ${componentColor('$tokenGroup.focus.state-layer')};
} }
if (states.contains(MaterialState.pressed)) {
return ${componentColor('$tokenGroup.pressed.state-layer')};
}
return null; return null;
}); });
......
...@@ -106,25 +106,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { ...@@ -106,25 +106,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get dayOverlayColor => MaterialStateProperty<Color?>? get dayOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'hover')}; return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'focus')}; return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'focus')};
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'pressed')}; return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'pressed')};
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'hover')}; return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'focus')}; 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; return null;
}); });
...@@ -173,25 +173,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { ...@@ -173,25 +173,25 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get yearOverlayColor => MaterialStateProperty<Color?>? get yearOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'hover')}; return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'focus')}; return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'focus')};
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'pressed')}; return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'pressed')};
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'hover')}; return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'focus')}; 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; return null;
}); });
...@@ -208,14 +208,14 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { ...@@ -208,14 +208,14 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData {
@override @override
MaterialStateProperty<Color?>? get rangeSelectionOverlayColor => MaterialStateProperty<Color?>? get rangeSelectionOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { 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)) { 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)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range.', null, 'focus')}; 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 null; return null;
}); });
......
...@@ -95,26 +95,29 @@ class IconButtonTemplate extends TokenTemplate { ...@@ -95,26 +95,29 @@ class IconButtonTemplate extends TokenTemplate {
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.toggle.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')}); return ${componentColor('$tokenGroup.toggle.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.toggle.selected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')}); 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 (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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.toggle.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')}); return ${componentColor('$tokenGroup.toggle.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.toggle.unselected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')}); 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.hover.state-layer')}; return ${componentColor('$tokenGroup.hover.state-layer')};
...@@ -122,24 +125,24 @@ class IconButtonTemplate extends TokenTemplate { ...@@ -122,24 +125,24 @@ class IconButtonTemplate extends TokenTemplate {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.focus.state-layer')}; return ${componentColor('$tokenGroup.focus.state-layer')};
} }
if (states.contains(MaterialState.pressed)) {
return ${componentColor('$tokenGroup.pressed.state-layer')};
}
return Colors.transparent; return Colors.transparent;
})'''; })''';
case 'md.comp.outlined-icon-button': case 'md.comp.outlined-icon-button':
return ''' return '''
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')}); return ${componentColor('$tokenGroup.selected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.selected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')}); 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')}); return ${componentColor('$tokenGroup.unselected.hover.state-layer')}.withOpacity(${opacity('$tokenGroup.hover.state-layer.opacity')});
...@@ -147,9 +150,6 @@ class IconButtonTemplate extends TokenTemplate { ...@@ -147,9 +150,6 @@ class IconButtonTemplate extends TokenTemplate {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.unselected.focus.state-layer')}.withOpacity(${opacity('$tokenGroup.focus.state-layer.opacity')}); 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; return Colors.transparent;
})'''; })''';
case 'md.comp.icon-button': case 'md.comp.icon-button':
...@@ -157,15 +157,18 @@ class IconButtonTemplate extends TokenTemplate { ...@@ -157,15 +157,18 @@ class IconButtonTemplate extends TokenTemplate {
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return ${componentColor('$tokenGroup.selected.pressed.state-layer')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.selected.hover.state-layer')}; return ${componentColor('$tokenGroup.selected.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.selected.focus.state-layer')}; 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.unselected.hover.state-layer')}; return ${componentColor('$tokenGroup.unselected.hover.state-layer')};
...@@ -173,9 +176,6 @@ class IconButtonTemplate extends TokenTemplate { ...@@ -173,9 +176,6 @@ class IconButtonTemplate extends TokenTemplate {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.unselected.focus.state-layer')}; return ${componentColor('$tokenGroup.unselected.focus.state-layer')};
} }
if (states.contains(MaterialState.pressed)) {
return ${componentColor('$tokenGroup.unselected.pressed.state-layer')};
}
return Colors.transparent; return Colors.transparent;
})'''; })''';
} }
......
...@@ -39,119 +39,119 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -39,119 +39,119 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override @override
BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) { BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.disabled)) {
if (states.contains(MaterialState.focused)) { return ${border('md.comp.filled-text-field.disabled.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.error)) {
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.focused)) {
return ${border('md.comp.filled-text-field.focus.active-indicator')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${border('md.comp.filled-text-field.hover.active-indicator')}; return ${border('md.comp.filled-text-field.error.hover.active-indicator')};
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return ${border('md.comp.filled-text-field.disabled.active-indicator')}; return ${mergedBorder('md.comp.filled-text-field.error.focus.active-indicator','md.comp.filled-text-field.focus.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 @override
BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) { BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.disabled)) {
if (states.contains(MaterialState.focused)) { return ${border('md.comp.outlined-text-field.disabled.outline')};
return ${mergedBorder('md.comp.outlined-text-field.error.focus.outline','md.comp.outlined-text-field.focus.outline')}; }
} if (states.contains(MaterialState.error)) {
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.focused)) {
return ${border('md.comp.outlined-text-field.focus.outline')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${border('md.comp.outlined-text-field.hover.outline')}; return ${border('md.comp.outlined-text-field.error.hover.outline')};
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return ${border('md.comp.outlined-text-field.disabled.outline')}; return ${mergedBorder('md.comp.outlined-text-field.error.focus.outline','md.comp.outlined-text-field.focus.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 @override
Color? get iconColor => ${componentColor("md.comp.filled-text-field.leading-icon")}; Color? get iconColor => ${componentColor("md.comp.filled-text-field.leading-icon")};
@override @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') ? '' : ''' 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.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')};
}
if(states.contains(MaterialState.error)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')}; 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')}; 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') ? '' : ''' }'''}${componentColor('md.comp.filled-text-field.hover.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.hover.leading-icon')}; 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')};
}'''} }'''}
if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')};
}
return ${componentColor('md.comp.filled-text-field.leading-icon')}; return ${componentColor('md.comp.filled-text-field.leading-icon')};
}); });
@override @override
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
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.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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')}; 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')}; 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') ? '' : ''' }${componentColor('md.comp.filled-text-field.hover.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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')}; 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')};
}'''} }'''}
if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')};
}
return ${componentColor('md.comp.filled-text-field.trailing-icon')}; return ${componentColor('md.comp.filled-text-field.trailing-icon')};
}); });
@override @override
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle(); 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.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)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')}); 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')}); 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)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')});
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')}); 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')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.label-text')});
}); });
...@@ -159,50 +159,50 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -159,50 +159,50 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle(); 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.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)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')}); 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')}); 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)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.label-text')});
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')}); 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')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.label-text')});
}); });
@override @override
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { 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') ? '' : ''' final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.focus.supporting-text')}); 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') ? '' : ''' }${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.hover.supporting-text')}); 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')});
}'''} }'''}
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.supporting-text')});
}
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.supporting-text')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.supporting-text')});
}); });
@override @override
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { 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') ? '' : ''' 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.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') ? '' : '''
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.supporting-text')}); 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')}); return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.supporting-text')});
}); });
......
...@@ -82,25 +82,25 @@ class _${blockName}DefaultsM3 extends SegmentedButtonThemeData { ...@@ -82,25 +82,25 @@ class _${blockName}DefaultsM3 extends SegmentedButtonThemeData {
}), }),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return ${_stateColor(tokenGroup, 'selected', 'pressed')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor(tokenGroup, 'selected', 'hover')}; return ${_stateColor(tokenGroup, 'selected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor(tokenGroup, 'selected', 'focus')}; return ${_stateColor(tokenGroup, 'selected', 'focus')};
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return ${_stateColor(tokenGroup, 'selected', 'pressed')}; return ${_stateColor(tokenGroup, 'unselected', 'pressed')};
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${_stateColor(tokenGroup, 'unselected', 'hover')}; return ${_stateColor(tokenGroup, 'unselected', 'hover')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${_stateColor(tokenGroup, 'unselected', 'focus')}; return ${_stateColor(tokenGroup, 'unselected', 'focus')};
} }
if (states.contains(MaterialState.pressed)) {
return ${_stateColor(tokenGroup, 'unselected', 'pressed')};
}
} }
return null; return null;
}), }),
......
...@@ -58,15 +58,15 @@ class _${blockName}DefaultsM3 extends SliderThemeData { ...@@ -58,15 +58,15 @@ class _${blockName}DefaultsM3 extends SliderThemeData {
@override @override
Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.dragged)) {
return ${componentColor('$tokenGroup.pressed.state-layer')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('$tokenGroup.hover.state-layer')}; return ${componentColor('$tokenGroup.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('$tokenGroup.focus.state-layer')}; return ${componentColor('$tokenGroup.focus.state-layer')};
} }
if (states.contains(MaterialState.dragged)) {
return ${componentColor('$tokenGroup.pressed.state-layer')};
}
return Colors.transparent; return Colors.transparent;
}); });
......
...@@ -43,26 +43,26 @@ class _${blockName}PrimaryDefaultsM3 extends TabBarTheme { ...@@ -43,26 +43,26 @@ class _${blockName}PrimaryDefaultsM3 extends TabBarTheme {
MaterialStateProperty<Color?> get overlayColor { MaterialStateProperty<Color?> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) { return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.primary-navigation-tab.active.hover.state-layer')}; return ${componentColor('md.comp.primary-navigation-tab.active.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.primary-navigation-tab.active.focus.state-layer')}; 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; return null;
} }
if (states.contains(MaterialState.pressed)) {
return ${componentColor('md.comp.primary-navigation-tab.inactive.pressed.state-layer')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.primary-navigation-tab.inactive.hover.state-layer')}; return ${componentColor('md.comp.primary-navigation-tab.inactive.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.primary-navigation-tab.inactive.focus.state-layer')}; 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; return null;
}); });
} }
...@@ -107,26 +107,26 @@ class _${blockName}SecondaryDefaultsM3 extends TabBarTheme { ...@@ -107,26 +107,26 @@ class _${blockName}SecondaryDefaultsM3 extends TabBarTheme {
MaterialStateProperty<Color?> get overlayColor { MaterialStateProperty<Color?> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) { return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { 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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')}; return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.secondary-navigation-tab.focus.state-layer')}; 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; return null;
} }
if (states.contains(MaterialState.pressed)) {
return ${componentColor('md.comp.secondary-navigation-tab.pressed.state-layer')};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')}; return ${componentColor('md.comp.secondary-navigation-tab.hover.state-layer')};
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.secondary-navigation-tab.focus.state-layer')}; 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; return null;
}); });
} }
......
...@@ -96,12 +96,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults { ...@@ -96,12 +96,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
textColor = ${componentColor("$dayPeriodComponent.selected.pressed.label-text")}; textColor = ${componentColor("$dayPeriodComponent.selected.pressed.label-text")};
} else { } else {
// not pressed // not pressed
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
textColor = ${componentColor("$dayPeriodComponent.selected.focus.label-text")}; textColor = ${componentColor("$dayPeriodComponent.selected.hover.label-text")};
} else { } else {
// not focused // not hovered
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
textColor = ${componentColor("$dayPeriodComponent.selected.hover.label-text")}; textColor = ${componentColor("$dayPeriodComponent.selected.focus.label-text")};
} }
} }
} }
...@@ -111,12 +111,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults { ...@@ -111,12 +111,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
textColor = ${componentColor("$dayPeriodComponent.unselected.pressed.label-text")}; textColor = ${componentColor("$dayPeriodComponent.unselected.pressed.label-text")};
} else { } else {
// not pressed // not pressed
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
textColor = ${componentColor("$dayPeriodComponent.unselected.focus.label-text")}; textColor = ${componentColor("$dayPeriodComponent.unselected.hover.label-text")};
} else { } else {
// not focused // not hovered
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
textColor = ${componentColor("$dayPeriodComponent.unselected.hover.label-text")}; textColor = ${componentColor("$dayPeriodComponent.unselected.focus.label-text")};
} }
} }
} }
...@@ -205,24 +205,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults { ...@@ -205,24 +205,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
Color overlayColor = ${componentColor('$hourMinuteComponent.selected.container')}; Color overlayColor = ${componentColor('$hourMinuteComponent.selected.container')};
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
overlayColor = ${componentColor('$hourMinuteComponent.selected.pressed.state-layer')}; 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)) { } else if (states.contains(MaterialState.hovered)) {
const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')}; const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')};
overlayColor = ${componentColor('$hourMinuteComponent.selected.hover.state-layer')}.withOpacity(hoverOpacity); 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')}); return Color.alphaBlend(overlayColor, ${componentColor('$hourMinuteComponent.selected.container')});
} else { } else {
Color overlayColor = ${componentColor('$hourMinuteComponent.unselected.container')}; Color overlayColor = ${componentColor('$hourMinuteComponent.unselected.container')};
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
overlayColor = ${componentColor('$hourMinuteComponent.unselected.pressed.state-layer')}; 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)) { } else if (states.contains(MaterialState.hovered)) {
const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')}; const double hoverOpacity = ${opacity('$hourMinuteComponent.hover.state-layer.opacity')};
overlayColor = ${componentColor('$hourMinuteComponent.unselected.hover.state-layer')}.withOpacity(hoverOpacity); 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')}); return Color.alphaBlend(overlayColor, ${componentColor('$hourMinuteComponent.unselected.container')});
} }
...@@ -271,24 +271,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults { ...@@ -271,24 +271,24 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return ${componentColor("$hourMinuteComponent.selected.pressed.label-text")}; return ${componentColor("$hourMinuteComponent.selected.pressed.label-text")};
} }
if (states.contains(MaterialState.focused)) {
return ${componentColor("$hourMinuteComponent.selected.focus.label-text")};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor("$hourMinuteComponent.selected.hover.label-text")}; 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")}; return ${componentColor("$hourMinuteComponent.selected.label-text")};
} else { } else {
// unselected // unselected
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return ${componentColor("$hourMinuteComponent.unselected.pressed.label-text")}; return ${componentColor("$hourMinuteComponent.unselected.pressed.label-text")};
} }
if (states.contains(MaterialState.focused)) {
return ${componentColor("$hourMinuteComponent.unselected.focus.label-text")};
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor("$hourMinuteComponent.unselected.hover.label-text")}; 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")}; return ${componentColor("$hourMinuteComponent.unselected.label-text")};
} }
}); });
......
...@@ -675,25 +675,25 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { ...@@ -675,25 +675,25 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get dayOverlayColor => MaterialStateProperty<Color?>? get dayOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.38);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.38); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
} }
return null; return null;
}); });
...@@ -746,25 +746,25 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { ...@@ -746,25 +746,25 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get rangeSelectionOverlayColor => MaterialStateProperty<Color?>? get rangeSelectionOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.38);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.38); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
} }
return null; return null;
}); });
...@@ -846,25 +846,25 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { ...@@ -846,25 +846,25 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get dayOverlayColor => MaterialStateProperty<Color?>? get dayOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
} }
return null; return null;
}); });
...@@ -913,25 +913,25 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { ...@@ -913,25 +913,25 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData {
MaterialStateProperty<Color?>? get yearOverlayColor => MaterialStateProperty<Color?>? get yearOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
} }
return null; return null;
}); });
...@@ -948,14 +948,14 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { ...@@ -948,14 +948,14 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData {
@override @override
MaterialStateProperty<Color?>? get rangeSelectionOverlayColor => MaterialStateProperty<Color?>? get rangeSelectionOverlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimaryContainer.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return null; return _colors.onPrimaryContainer.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return null; return _colors.onPrimaryContainer.withOpacity(0.12);
}
if (states.contains(MaterialState.pressed)) {
return null;
} }
return null; return null;
}); });
......
...@@ -426,10 +426,13 @@ class _ElevatedButtonDefaultOverlay extends MaterialStateProperty<Color?> with D ...@@ -426,10 +426,13 @@ class _ElevatedButtonDefaultOverlay extends MaterialStateProperty<Color?> with D
@override @override
Color? resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return overlay.withOpacity(0.24);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return overlay.withOpacity(0.08); return overlay.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.focused)) {
return overlay.withOpacity(0.24); return overlay.withOpacity(0.24);
} }
return null; return null;
...@@ -447,15 +450,15 @@ class _ElevatedButtonDefaultElevation extends MaterialStateProperty<double> with ...@@ -447,15 +450,15 @@ class _ElevatedButtonDefaultElevation extends MaterialStateProperty<double> with
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return 0; return 0;
} }
if (states.contains(MaterialState.pressed)) {
return elevation + 6;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return elevation + 2; return elevation + 2;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return elevation + 2; return elevation + 2;
} }
if (states.contains(MaterialState.pressed)) {
return elevation + 6;
}
return elevation; return elevation;
} }
} }
...@@ -578,15 +581,15 @@ class _ElevatedButtonDefaultsM3 extends ButtonStyle { ...@@ -578,15 +581,15 @@ class _ElevatedButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
return null; return null;
}); });
...@@ -604,15 +607,15 @@ class _ElevatedButtonDefaultsM3 extends ButtonStyle { ...@@ -604,15 +607,15 @@ class _ElevatedButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return 0.0; return 0.0;
} }
if (states.contains(MaterialState.pressed)) {
return 1.0;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return 3.0; return 3.0;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return 1.0; return 1.0;
} }
if (states.contains(MaterialState.pressed)) {
return 1.0;
}
return 1.0; return 1.0;
}); });
......
...@@ -439,10 +439,13 @@ class _FilledButtonDefaultOverlay extends MaterialStateProperty<Color?> with Dia ...@@ -439,10 +439,13 @@ class _FilledButtonDefaultOverlay extends MaterialStateProperty<Color?> with Dia
@override @override
Color? resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return overlay.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return overlay.withOpacity(0.08); return overlay.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.focused)) {
return overlay.withOpacity(0.12); return overlay.withOpacity(0.12);
} }
return null; return null;
...@@ -588,15 +591,15 @@ class _FilledButtonDefaultsM3 extends ButtonStyle { ...@@ -588,15 +591,15 @@ class _FilledButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
return null; return null;
}); });
...@@ -614,15 +617,15 @@ class _FilledButtonDefaultsM3 extends ButtonStyle { ...@@ -614,15 +617,15 @@ class _FilledButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return 0.0; return 0.0;
} }
if (states.contains(MaterialState.pressed)) {
return 0.0;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return 1.0; return 1.0;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return 0.0; return 0.0;
} }
if (states.contains(MaterialState.pressed)) {
return 0.0;
}
return 0.0; return 0.0;
}); });
...@@ -712,15 +715,15 @@ class _FilledTonalButtonDefaultsM3 extends ButtonStyle { ...@@ -712,15 +715,15 @@ class _FilledTonalButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSecondaryContainer.withOpacity(0.08); return _colors.onSecondaryContainer.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSecondaryContainer.withOpacity(0.12); return _colors.onSecondaryContainer.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
return null; return null;
}); });
...@@ -738,15 +741,15 @@ class _FilledTonalButtonDefaultsM3 extends ButtonStyle { ...@@ -738,15 +741,15 @@ class _FilledTonalButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return 0.0; return 0.0;
} }
if (states.contains(MaterialState.pressed)) {
return 0.0;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return 1.0; return 1.0;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return 0.0; return 0.0;
} }
if (states.contains(MaterialState.pressed)) {
return 0.0;
}
return 0.0; return 0.0;
}); });
......
...@@ -1117,15 +1117,18 @@ class _IconButtonDefaultsM3 extends ButtonStyle { ...@@ -1117,15 +1117,18 @@ class _IconButtonDefaultsM3 extends ButtonStyle {
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) { }
return _colors.primary.withOpacity(0.12); if (states.contains(MaterialState.pressed)) {
} return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
...@@ -1133,9 +1136,6 @@ class _IconButtonDefaultsM3 extends ButtonStyle { ...@@ -1133,9 +1136,6 @@ class _IconButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
return Colors.transparent; return Colors.transparent;
}); });
...@@ -1254,26 +1254,29 @@ class _FilledIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1254,26 +1254,29 @@ class _FilledIconButtonDefaultsM3 extends ButtonStyle {
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
} }
if (toggleable) { // toggleable but unselected case if (toggleable) { // toggleable but unselected case
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) { }
return _colors.primary.withOpacity(0.12); if (states.contains(MaterialState.pressed)) {
} return _colors.onPrimary.withOpacity(0.12);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimary.withOpacity(0.08); return _colors.onPrimary.withOpacity(0.08);
...@@ -1281,9 +1284,6 @@ class _FilledIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1281,9 +1284,6 @@ class _FilledIconButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimary.withOpacity(0.12); return _colors.onPrimary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onPrimary.withOpacity(0.12);
}
return Colors.transparent; return Colors.transparent;
}); });
...@@ -1402,26 +1402,29 @@ class _FilledTonalIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1402,26 +1402,29 @@ class _FilledTonalIconButtonDefaultsM3 extends ButtonStyle {
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSecondaryContainer.withOpacity(0.08); return _colors.onSecondaryContainer.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSecondaryContainer.withOpacity(0.12); return _colors.onSecondaryContainer.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
} }
if (toggleable) { // toggleable but unselected case if (toggleable) { // toggleable but unselected case
if (states.contains(MaterialState.pressed)) {
return _colors.onSurfaceVariant.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.12); return _colors.onSurfaceVariant.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) { }
return _colors.onSurfaceVariant.withOpacity(0.12); if (states.contains(MaterialState.pressed)) {
} return _colors.onSecondaryContainer.withOpacity(0.12);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSecondaryContainer.withOpacity(0.08); return _colors.onSecondaryContainer.withOpacity(0.08);
...@@ -1429,9 +1432,6 @@ class _FilledTonalIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1429,9 +1432,6 @@ class _FilledTonalIconButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSecondaryContainer.withOpacity(0.12); return _colors.onSecondaryContainer.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
return Colors.transparent; return Colors.transparent;
}); });
...@@ -1546,15 +1546,18 @@ class _OutlinedIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1546,15 +1546,18 @@ class _OutlinedIconButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onInverseSurface.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onInverseSurface.withOpacity(0.08); return _colors.onInverseSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onInverseSurface.withOpacity(0.08); return _colors.onInverseSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.pressed)) { }
return _colors.onInverseSurface.withOpacity(0.12); if (states.contains(MaterialState.pressed)) {
} return _colors.onSurface.withOpacity(0.12);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
...@@ -1562,9 +1565,6 @@ class _OutlinedIconButtonDefaultsM3 extends ButtonStyle { ...@@ -1562,9 +1565,6 @@ class _OutlinedIconButtonDefaultsM3 extends ButtonStyle {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant.withOpacity(0.08); return _colors.onSurfaceVariant.withOpacity(0.08);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
return Colors.transparent; return Colors.transparent;
}); });
......
...@@ -4560,95 +4560,89 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4560,95 +4560,89 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) { BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.disabled)) {
if (states.contains(MaterialState.focused)) { return BorderSide(color: _colors.onSurface.withOpacity(0.38));
return BorderSide(color: _colors.error, width: 2.0); }
} if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onErrorContainer);
}
return BorderSide(color: _colors.error);
}
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.primary, width: 2.0);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onSurface); return BorderSide(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.onSurface.withOpacity(0.38)); return BorderSide(color: _colors.error, width: 2.0);
} }
return BorderSide(color: _colors.onSurfaceVariant); return BorderSide(color: _colors.error);
}
if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onSurface);
}
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.primary, width: 2.0);
}
return BorderSide(color: _colors.onSurfaceVariant);
}); });
@override @override
BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) { BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.disabled)) {
if (states.contains(MaterialState.focused)) { return BorderSide(color: _colors.onSurface.withOpacity(0.12));
return BorderSide(color: _colors.error, width: 2.0); }
} if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onErrorContainer);
}
return BorderSide(color: _colors.error);
}
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.primary, width: 2.0);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onSurface); return BorderSide(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.onSurface.withOpacity(0.12)); return BorderSide(color: _colors.error, width: 2.0);
} }
return BorderSide(color: _colors.outline); return BorderSide(color: _colors.error);
}); }
if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onSurface);
}
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.primary, width: 2.0);
}
return BorderSide(color: _colors.outline);
});
@override @override
Color? get iconColor => _colors.onSurfaceVariant; Color? get iconColor => _colors.onSurfaceVariant;
@override @override
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38);
}
return _colors.onSurfaceVariant; return _colors.onSurfaceVariant;
}); });
@override @override
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return _colors.onErrorContainer;
}
return _colors.error;
}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38); return _colors.onSurface.withOpacity(0.38);
} }
if(states.contains(MaterialState.error)) {
return _colors.error;
}
return _colors.onSurfaceVariant; return _colors.onSurfaceVariant;
}); });
@override @override
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle(); final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle();
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38));
}
if(states.contains(MaterialState.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onErrorContainer); return textStyle.copyWith(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
return textStyle.copyWith(color: _colors.error); return textStyle.copyWith(color: _colors.error);
} }
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.primary);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onSurfaceVariant); return textStyle.copyWith(color: _colors.onSurfaceVariant);
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38)); return textStyle.copyWith(color: _colors.primary);
} }
return textStyle.copyWith(color: _colors.onSurfaceVariant); return textStyle.copyWith(color: _colors.onSurfaceVariant);
}); });
...@@ -4656,23 +4650,23 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4656,23 +4650,23 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle(); final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle();
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38));
}
if(states.contains(MaterialState.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onErrorContainer); return textStyle.copyWith(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
return textStyle.copyWith(color: _colors.error); return textStyle.copyWith(color: _colors.error);
} }
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.primary);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onSurfaceVariant); return textStyle.copyWith(color: _colors.onSurfaceVariant);
} }
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38)); return textStyle.copyWith(color: _colors.primary);
} }
return textStyle.copyWith(color: _colors.onSurfaceVariant); return textStyle.copyWith(color: _colors.onSurfaceVariant);
}); });
......
...@@ -382,10 +382,13 @@ class _OutlinedButtonDefaultOverlay extends MaterialStateProperty<Color?> with D ...@@ -382,10 +382,13 @@ class _OutlinedButtonDefaultOverlay extends MaterialStateProperty<Color?> with D
@override @override
Color? resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return foreground.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return foreground.withOpacity(0.04); return foreground.withOpacity(0.04);
} }
if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.focused)) {
return foreground.withOpacity(0.12); return foreground.withOpacity(0.12);
} }
return null; return null;
...@@ -504,15 +507,15 @@ class _OutlinedButtonDefaultsM3 extends ButtonStyle { ...@@ -504,15 +507,15 @@ class _OutlinedButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
return null; return null;
}); });
......
...@@ -591,12 +591,12 @@ class _RadioDefaultsM2 extends RadioThemeData { ...@@ -591,12 +591,12 @@ class _RadioDefaultsM2 extends RadioThemeData {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return fillColor.resolve(states).withAlpha(kRadialReactionAlpha); return fillColor.resolve(states).withAlpha(kRadialReactionAlpha);
} }
if (states.contains(MaterialState.focused)) {
return _theme.focusColor;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _theme.hoverColor; return _theme.hoverColor;
} }
if (states.contains(MaterialState.focused)) {
return _theme.focusColor;
}
return Colors.transparent; return Colors.transparent;
}); });
} }
......
...@@ -763,25 +763,25 @@ class _SegmentedButtonDefaultsM3 extends SegmentedButtonThemeData { ...@@ -763,25 +763,25 @@ class _SegmentedButtonDefaultsM3 extends SegmentedButtonThemeData {
}), }),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSecondaryContainer.withOpacity(0.08); return _colors.onSecondaryContainer.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSecondaryContainer.withOpacity(0.12); return _colors.onSecondaryContainer.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onSecondaryContainer.withOpacity(0.12); return _colors.onSurface.withOpacity(0.12);
} }
} else {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurface.withOpacity(0.08); return _colors.onSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurface.withOpacity(0.12); return _colors.onSurface.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
} }
return null; return null;
}), }),
......
...@@ -2005,15 +2005,15 @@ class _SliderDefaultsM3 extends SliderThemeData { ...@@ -2005,15 +2005,15 @@ class _SliderDefaultsM3 extends SliderThemeData {
@override @override
Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get overlayColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.dragged)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.dragged)) {
return _colors.primary.withOpacity(0.12);
}
return Colors.transparent; return Colors.transparent;
}); });
......
...@@ -1736,12 +1736,12 @@ class _SwitchDefaultsM2 extends SwitchThemeData { ...@@ -1736,12 +1736,12 @@ class _SwitchDefaultsM2 extends SwitchThemeData {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return thumbColor.resolve(states).withAlpha(kRadialReactionAlpha); return thumbColor.resolve(states).withAlpha(kRadialReactionAlpha);
} }
if (states.contains(MaterialState.focused)) {
return _theme.focusColor;
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _theme.hoverColor; return _theme.hoverColor;
} }
if (states.contains(MaterialState.focused)) {
return _theme.focusColor;
}
return null; return null;
}); });
} }
......
...@@ -2194,26 +2194,26 @@ class _TabsPrimaryDefaultsM3 extends TabBarTheme { ...@@ -2194,26 +2194,26 @@ class _TabsPrimaryDefaultsM3 extends TabBarTheme {
MaterialStateProperty<Color?> get overlayColor { MaterialStateProperty<Color?> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) { return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
return null; return null;
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurface.withOpacity(0.08); return _colors.onSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurface.withOpacity(0.12); return _colors.onSurface.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
return null; return null;
}); });
} }
...@@ -2258,26 +2258,26 @@ class _TabsSecondaryDefaultsM3 extends TabBarTheme { ...@@ -2258,26 +2258,26 @@ class _TabsSecondaryDefaultsM3 extends TabBarTheme {
MaterialStateProperty<Color?> get overlayColor { MaterialStateProperty<Color?> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) { return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurface.withOpacity(0.08); return _colors.onSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurface.withOpacity(0.12); return _colors.onSurface.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
return null; return null;
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurface.withOpacity(0.08); return _colors.onSurface.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurface.withOpacity(0.12); return _colors.onSurface.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
return null; return null;
}); });
} }
......
...@@ -417,10 +417,13 @@ class _TextButtonDefaultOverlay extends MaterialStateProperty<Color?> { ...@@ -417,10 +417,13 @@ class _TextButtonDefaultOverlay extends MaterialStateProperty<Color?> {
@override @override
Color? resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return primary.withOpacity(0.04); return primary.withOpacity(0.04);
} }
if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.focused)) {
return primary.withOpacity(0.12); return primary.withOpacity(0.12);
} }
return null; return null;
...@@ -564,15 +567,15 @@ class _TextButtonDefaultsM3 extends ButtonStyle { ...@@ -564,15 +567,15 @@ class _TextButtonDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<Color?>? get overlayColor => MaterialStateProperty<Color?>? get overlayColor =>
MaterialStateProperty.resolveWith((Set<MaterialState> states) { MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.primary.withOpacity(0.08); return _colors.primary.withOpacity(0.08);
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return _colors.primary.withOpacity(0.12); return _colors.primary.withOpacity(0.12);
} }
if (states.contains(MaterialState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
return null; return null;
}); });
......
...@@ -3402,11 +3402,11 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults { ...@@ -3402,11 +3402,11 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults {
textColor = _colors.onTertiaryContainer; textColor = _colors.onTertiaryContainer;
} else { } else {
// not pressed // not pressed
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
textColor = _colors.onTertiaryContainer; textColor = _colors.onTertiaryContainer;
} else { } else {
// not focused // not hovered
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
textColor = _colors.onTertiaryContainer; textColor = _colors.onTertiaryContainer;
} }
} }
...@@ -3417,11 +3417,11 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults { ...@@ -3417,11 +3417,11 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults {
textColor = _colors.onSurfaceVariant; textColor = _colors.onSurfaceVariant;
} else { } else {
// not pressed // not pressed
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
textColor = _colors.onSurfaceVariant; textColor = _colors.onSurfaceVariant;
} else { } else {
// not focused // not hovered
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
textColor = _colors.onSurfaceVariant; textColor = _colors.onSurfaceVariant;
} }
} }
...@@ -3511,24 +3511,24 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults { ...@@ -3511,24 +3511,24 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults {
Color overlayColor = _colors.primaryContainer; Color overlayColor = _colors.primaryContainer;
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
overlayColor = _colors.onPrimaryContainer; overlayColor = _colors.onPrimaryContainer;
} else if (states.contains(MaterialState.focused)) {
const double focusOpacity = 0.12;
overlayColor = _colors.onPrimaryContainer.withOpacity(focusOpacity);
} else if (states.contains(MaterialState.hovered)) { } else if (states.contains(MaterialState.hovered)) {
const double hoverOpacity = 0.08; const double hoverOpacity = 0.08;
overlayColor = _colors.onPrimaryContainer.withOpacity(hoverOpacity); overlayColor = _colors.onPrimaryContainer.withOpacity(hoverOpacity);
} else if (states.contains(MaterialState.focused)) {
const double focusOpacity = 0.12;
overlayColor = _colors.onPrimaryContainer.withOpacity(focusOpacity);
} }
return Color.alphaBlend(overlayColor, _colors.primaryContainer); return Color.alphaBlend(overlayColor, _colors.primaryContainer);
} else { } else {
Color overlayColor = _colors.surfaceVariant; Color overlayColor = _colors.surfaceVariant;
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
overlayColor = _colors.onSurface; overlayColor = _colors.onSurface;
} else if (states.contains(MaterialState.focused)) {
const double focusOpacity = 0.12;
overlayColor = _colors.onSurface.withOpacity(focusOpacity);
} else if (states.contains(MaterialState.hovered)) { } else if (states.contains(MaterialState.hovered)) {
const double hoverOpacity = 0.08; const double hoverOpacity = 0.08;
overlayColor = _colors.onSurface.withOpacity(hoverOpacity); overlayColor = _colors.onSurface.withOpacity(hoverOpacity);
} else if (states.contains(MaterialState.focused)) {
const double focusOpacity = 0.12;
overlayColor = _colors.onSurface.withOpacity(focusOpacity);
} }
return Color.alphaBlend(overlayColor, _colors.surfaceVariant); return Color.alphaBlend(overlayColor, _colors.surfaceVariant);
} }
...@@ -3577,10 +3577,10 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults { ...@@ -3577,10 +3577,10 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onPrimaryContainer; return _colors.onPrimaryContainer;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
return _colors.onPrimaryContainer; return _colors.onPrimaryContainer;
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
return _colors.onPrimaryContainer; return _colors.onPrimaryContainer;
} }
return _colors.onPrimaryContainer; return _colors.onPrimaryContainer;
...@@ -3589,10 +3589,10 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults { ...@@ -3589,10 +3589,10 @@ class _TimePickerDefaultsM3 extends _TimePickerDefaults {
if (states.contains(MaterialState.pressed)) { if (states.contains(MaterialState.pressed)) {
return _colors.onSurface; return _colors.onSurface;
} }
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.hovered)) {
return _colors.onSurface; return _colors.onSurface;
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.focused)) {
return _colors.onSurface; return _colors.onSurface;
} }
return _colors.onSurface; return _colors.onSurface;
......
...@@ -892,20 +892,24 @@ class _ToggleButtonDefaultOverlay extends MaterialStateProperty<Color?> { ...@@ -892,20 +892,24 @@ class _ToggleButtonDefaultOverlay extends MaterialStateProperty<Color?> {
@override @override
Color? resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (selected) { if (selected) {
if (states.contains(MaterialState.pressed)) {
return splashColor ?? colorScheme?.primary.withOpacity(0.16);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return hoverColor ?? colorScheme?.primary.withOpacity(0.04); return hoverColor ?? colorScheme?.primary.withOpacity(0.04);
} else if (states.contains(MaterialState.focused)) { }
if (states.contains(MaterialState.focused)) {
return focusColor ?? colorScheme?.primary.withOpacity(0.12); return focusColor ?? colorScheme?.primary.withOpacity(0.12);
} else if (states.contains(MaterialState.pressed)) {
return splashColor ?? colorScheme?.primary.withOpacity(0.16);
} }
} else if (unselected) { } else if (unselected) {
if (states.contains(MaterialState.pressed)) {
return splashColor ?? highlightColor ?? colorScheme?.onSurface.withOpacity(0.16);
}
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return hoverColor ?? colorScheme?.onSurface.withOpacity(0.04); return hoverColor ?? colorScheme?.onSurface.withOpacity(0.04);
} else if (states.contains(MaterialState.focused)) { }
if (states.contains(MaterialState.focused)) {
return focusColor ?? colorScheme?.onSurface.withOpacity(0.12); return focusColor ?? colorScheme?.onSurface.withOpacity(0.12);
} else if (states.contains(MaterialState.pressed)) {
return splashColor ?? highlightColor ?? colorScheme?.onSurface.withOpacity(0.16);
} }
} }
return null; return null;
......
...@@ -65,10 +65,11 @@ void main() { ...@@ -65,10 +65,11 @@ void main() {
Future<void> Function(Future<DateTime?> date) callback, { Future<void> Function(Future<DateTime?> date) callback, {
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
bool useMaterial3 = false, bool useMaterial3 = false,
ThemeData? theme,
}) async { }) async {
late BuildContext buttonContext; late BuildContext buttonContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: useMaterial3), theme: theme ?? ThemeData(useMaterial3: useMaterial3),
home: Material( home: Material(
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -786,6 +787,38 @@ void main() { ...@@ -786,6 +787,38 @@ void main() {
}); });
}); });
testWidgets('Date picker dayOverlayColor resolves pressed state', (WidgetTester tester) async {
today = DateTime(2023, 5, 4);
final ThemeData theme = ThemeData();
final bool material3 = theme.useMaterial3;
await prepareDatePicker(tester, (Future<DateTime?> date) async {
await tester.pump();
// Hovered.
final Offset center = tester.getCenter(find.text('30'));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(
Material.of(tester.element(find.text('30'))),
paints..circle(color: material3 ? theme.colorScheme.onSurfaceVariant.withOpacity(0.08) : theme.colorScheme.onSurfaceVariant.withOpacity(0.08)),
);
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(
Material.of(tester.element(find.text('30'))),
paints..circle()..circle(color: material3 ? theme.colorScheme.onSurfaceVariant.withOpacity(0.12) : theme.colorScheme.onSurfaceVariant.withOpacity(0.12))
);
await gesture.up();
await tester.pumpAndSettle();
}, theme: theme);
});
testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async { testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async {
initialDate = DateTime(2020, DateTime.may, 10); initialDate = DateTime(2020, DateTime.may, 10);
initialCalendarMode = DatePickerMode.year; initialCalendarMode = DatePickerMode.year;
......
...@@ -159,6 +159,10 @@ void main() { ...@@ -159,6 +159,10 @@ void main() {
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered}), colorScheme.onSurfaceVariant.withOpacity(0.08)); expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered}), colorScheme.onSurfaceVariant.withOpacity(0.08));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.focused}), colorScheme.onSurfaceVariant.withOpacity(0.12)); expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.focused}), colorScheme.onSurfaceVariant.withOpacity(0.12));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.pressed}), colorScheme.onSurfaceVariant.withOpacity(0.12)); expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.pressed}), colorScheme.onSurfaceVariant.withOpacity(0.12));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered, MaterialState.focused}), colorScheme.onPrimary.withOpacity(0.08));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered, MaterialState.pressed}), colorScheme.onPrimary.withOpacity(0.12));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered, MaterialState.focused}), colorScheme.onSurfaceVariant.withOpacity(0.08));
expect(m3.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered, MaterialState.pressed}), colorScheme.onSurfaceVariant.withOpacity(0.12));
expect(m3.todayForegroundColor?.resolve(<MaterialState>{}), colorScheme.primary); expect(m3.todayForegroundColor?.resolve(<MaterialState>{}), colorScheme.primary);
expect(m3.todayForegroundColor?.resolve(<MaterialState>{MaterialState.disabled}), colorScheme.primary.withOpacity(0.38)); expect(m3.todayForegroundColor?.resolve(<MaterialState>{MaterialState.disabled}), colorScheme.primary.withOpacity(0.38));
expect(m3.todayBorder, BorderSide(color: colorScheme.primary)); expect(m3.todayBorder, BorderSide(color: colorScheme.primary));
...@@ -224,6 +228,8 @@ void main() { ...@@ -224,6 +228,8 @@ void main() {
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered}), colorScheme.onPrimary.withOpacity(0.08)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered}), colorScheme.onPrimary.withOpacity(0.08));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.focused}), colorScheme.onPrimary.withOpacity(0.12)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.focused}), colorScheme.onPrimary.withOpacity(0.12));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.pressed}), colorScheme.onPrimary.withOpacity(0.38)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.pressed}), colorScheme.onPrimary.withOpacity(0.38));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered, MaterialState.focused}), colorScheme.onPrimary.withOpacity(0.08));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.selected, MaterialState.hovered, MaterialState.pressed}), colorScheme.onPrimary.withOpacity(0.38));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered}), colorScheme.onSurfaceVariant.withOpacity(0.08)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.hovered}), colorScheme.onSurfaceVariant.withOpacity(0.08));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.focused}), colorScheme.onSurfaceVariant.withOpacity(0.12)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.focused}), colorScheme.onSurfaceVariant.withOpacity(0.12));
expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.pressed}), colorScheme.onSurfaceVariant.withOpacity(0.12)); expect(m2.dayOverlayColor?.resolve(<MaterialState>{MaterialState.pressed}), colorScheme.onSurfaceVariant.withOpacity(0.12));
......
...@@ -200,6 +200,66 @@ void main() { ...@@ -200,6 +200,66 @@ void main() {
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115 skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
); );
testWidgets('ElevatedButton default overlayColor and elevation resolve pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {},
focusNode: focusNode,
child: const Text('ElevatedButton'),
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
double elevation() {
return tester.widget<PhysicalShape>(
find.descendant(
of: find.byType(ElevatedButton),
matching: find.byType(PhysicalShape),
),
).elevation;
}
// Hovered.
final Offset center = tester.getCenter(find.byType(ElevatedButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(elevation(), 3.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(elevation(), 1.0);
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(elevation(), 1.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
});
testWidgets('ElevatedButton uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('ElevatedButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
......
...@@ -277,6 +277,135 @@ void main() { ...@@ -277,6 +277,135 @@ void main() {
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115 skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
); );
testWidgets('FilledButton default overlayColor and elevation resolve pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return FilledButton(
onPressed: () {},
focusNode: focusNode,
child: const Text('FilledButton'),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
double elevation() {
return tester.widget<PhysicalShape>(
find.descendant(
of: find.byType(FilledButton),
matching: find.byType(PhysicalShape),
),
).elevation;
}
// Hovered.
final Offset center = tester.getCenter(find.byType(FilledButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(elevation(), 1.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.onPrimary.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(elevation(), 0.0);
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onPrimary.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(elevation(), 0.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.onPrimary.withOpacity(0.12)));
});
testWidgets('FilledButton.tonal default overlayColor and elevation resolve pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return FilledButton.tonal(
onPressed: () {},
focusNode: focusNode,
child: const Text('FilledButton'),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
double elevation() {
return tester.widget<PhysicalShape>(
find.descendant(
of: find.byType(FilledButton),
matching: find.byType(PhysicalShape),
),
).elevation;
}
// Hovered.
final Offset center = tester.getCenter(find.byType(FilledButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(elevation(), 1.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(elevation(), 0.0);
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(elevation(), 0.0);
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.12)));
});
testWidgets('FilledButton uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('FilledButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
......
...@@ -1133,6 +1133,59 @@ void main() { ...@@ -1133,6 +1133,59 @@ void main() {
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
}); });
testWidgets('IconButton default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return IconButton(
onPressed: () {},
focusNode: focusNode,
icon: const Icon(Icons.add),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(IconButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurfaceVariant.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSurfaceVariant.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurfaceVariant.withOpacity(0.12)));
});
testWidgets('IconButton.fill defaults - M3', (WidgetTester tester) async { testWidgets('IconButton.fill defaults - M3', (WidgetTester tester) async {
final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true); final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true);
...@@ -1219,6 +1272,59 @@ void main() { ...@@ -1219,6 +1272,59 @@ void main() {
expect(iconColor(), colorScheme.onSurface.withOpacity(0.38)); expect(iconColor(), colorScheme.onSurface.withOpacity(0.38));
}); });
testWidgets('IconButton.fill default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return IconButton.filled(
onPressed: () {},
focusNode: focusNode,
icon: const Icon(Icons.add),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(IconButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onPrimary.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onPrimary.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onPrimary.withOpacity(0.12)));
});
testWidgets('Toggleable IconButton.fill defaults - M3', (WidgetTester tester) async { testWidgets('Toggleable IconButton.fill defaults - M3', (WidgetTester tester) async {
final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true); final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true);
...@@ -1420,6 +1526,59 @@ void main() { ...@@ -1420,6 +1526,59 @@ void main() {
expect(iconColor(), colorScheme.onSurface.withOpacity(0.38)); expect(iconColor(), colorScheme.onSurface.withOpacity(0.38));
}); });
testWidgets('IconButton.filledTonal default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return IconButton.filledTonal(
onPressed: () {},
focusNode: focusNode,
icon: const Icon(Icons.add),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(IconButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSecondaryContainer.withOpacity(0.12)));
});
testWidgets('Toggleable IconButton.filledTonal defaults - M3', (WidgetTester tester) async { testWidgets('Toggleable IconButton.filledTonal defaults - M3', (WidgetTester tester) async {
final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true); final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true);
...@@ -1621,6 +1780,59 @@ void main() { ...@@ -1621,6 +1780,59 @@ void main() {
expect(iconColor(), colorScheme.onSurface.withOpacity(0.38)); expect(iconColor(), colorScheme.onSurface.withOpacity(0.38));
}); });
testWidgets('IconButton.outlined default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return IconButton.outlined(
onPressed: () {},
focusNode: focusNode,
icon: const Icon(Icons.add),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(IconButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurfaceVariant.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSurface.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurfaceVariant.withOpacity(0.08)));
});
testWidgets('Toggleable IconButton.outlined defaults - M3', (WidgetTester tester) async { testWidgets('Toggleable IconButton.outlined defaults - M3', (WidgetTester tester) async {
final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true); final ThemeData themeM3 = ThemeData.from(colorScheme: colorScheme, useMaterial3: true);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
library; library;
import 'dart:async'; import 'dart:async';
import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -1766,6 +1767,40 @@ void main() { ...@@ -1766,6 +1767,40 @@ void main() {
expect(getIconStyle(tester, Icons.close)?.color, theme.colorScheme.error); expect(getIconStyle(tester, Icons.close)?.color, theme.colorScheme.error);
}); });
testWidgets('InputDecoration default floatingLabelStyle resolves hovered/focused states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Material(
child: TextField(
focusNode: focusNode,
decoration: const InputDecoration(
labelText: 'label',
),
),
),
),
);
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(getLabelStyle(tester).color, theme.colorScheme.primary);
// Hovered.
final Offset center = tester.getCenter(find.byType(TextField));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(getLabelStyle(tester).color, theme.colorScheme.onSurfaceVariant);
});
testWidgets('InputDecorator prefix/suffix widgets', (WidgetTester tester) async { testWidgets('InputDecorator prefix/suffix widgets', (WidgetTester tester) async {
const Key pKey = Key('p'); const Key pKey = Key('p');
const Key sKey = Key('s'); const Key sKey = Key('s');
......
...@@ -176,6 +176,59 @@ void main() { ...@@ -176,6 +176,59 @@ void main() {
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
}); });
testWidgets('OutlinedButton default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return OutlinedButton(
onPressed: () {},
focusNode: focusNode,
child: const Text('OutlinedButton'),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(OutlinedButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
});
testWidgets('Does OutlinedButton work with hover', (WidgetTester tester) async { testWidgets('Does OutlinedButton work with hover', (WidgetTester tester) async {
const Color hoverColor = Color(0xff001122); const Color hoverColor = Color(0xff001122);
...@@ -285,11 +338,6 @@ void main() { ...@@ -285,11 +338,6 @@ void main() {
// Default, not disabled. // Default, not disabled.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline));
// Hovered. // Hovered.
final Offset center = tester.getCenter(find.byType(OutlinedButton)); final Offset center = tester.getCenter(find.byType(OutlinedButton));
final TestGesture gesture = await tester.createGesture( final TestGesture gesture = await tester.createGesture(
...@@ -305,7 +353,13 @@ void main() { ...@@ -305,7 +353,13 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer(); await gesture.up();
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline));
}, },
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115 skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
); );
......
...@@ -1029,7 +1029,7 @@ void main() { ...@@ -1029,7 +1029,7 @@ void main() {
color: const Color(0xffffffff), color: const Color(0xffffffff),
rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0),
) )
..circle(color: theme.useMaterial3 ? theme.colorScheme.primary.withOpacity(0.08) : Colors.black12) ..circle(color: theme.useMaterial3 ? theme.colorScheme.primary.withOpacity(0.08) : theme.hoverColor)
..circle(color: hoveredFillColor), ..circle(color: hoveredFillColor),
); );
}); });
...@@ -1438,4 +1438,69 @@ void main() { ...@@ -1438,4 +1438,69 @@ void main() {
expect(find.byType(CupertinoRadio<int>), findsNothing); expect(find.byType(CupertinoRadio<int>), findsNothing);
} }
}); });
testWidgets('Radio default overlayColor and fillColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
final bool material3 = theme.useMaterial3;
Finder findRadio() {
return find.byWidgetPredicate((Widget widget) => widget is Radio<bool>);
}
MaterialInkController? getRadioMaterial(WidgetTester tester) {
return Material.of(tester.element(findRadio()));
}
await tester.pumpWidget(MaterialApp(
theme: theme,
home: Scaffold(
body: Radio<bool>(
focusNode: focusNode,
value: true,
groupValue: true,
onChanged: (_) { },
),
),
));
// Hover
final Offset center = tester.getCenter(find.byType(Radio<bool>));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(getRadioMaterial(tester),
paints
..circle(color: material3 ? theme.colorScheme.primary.withOpacity(0.08) : theme.hoverColor)
..circle(color: material3 ? theme.colorScheme.primary : theme.colorScheme.secondary)
);
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(getRadioMaterial(tester),
paints
..circle(color: material3 ? theme.colorScheme.onSurface.withOpacity(0.12) : theme.colorScheme.secondary.withAlpha(kRadialReactionAlpha))
..circle(color: material3 ? theme.colorScheme.primary : theme.colorScheme.secondary)
);
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(getRadioMaterial(tester),
paints
..circle(color: material3 ? theme.colorScheme.primary.withOpacity(0.12) : theme.focusColor)
..circle(color: material3 ? theme.colorScheme.primary : theme.colorScheme.secondary)
);
});
} }
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
// This file is run as part of a reduced test set in CI on Mac and Windows // This file is run as part of a reduced test set in CI on Mac and Windows
// machines. // machines.
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
Widget boilerplate({required Widget child}) { Widget boilerplate({required Widget child}) {
...@@ -482,4 +485,52 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes ...@@ -482,4 +485,52 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
semantics.dispose(); semantics.dispose();
}); });
testWidgets('SegmentedButton default overlayColor and foregroundColor resolve pressed state', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: SegmentedButton<int>(
segments: const <ButtonSegment<int>>[
ButtonSegment<int>(value: 1, label: Text('1')),
ButtonSegment<int>(value: 2, label: Text('2')),
],
selected: const <int>{1},
onSelectionChanged: (Set<int> selected) {},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
final Material material = tester.widget<Material>(find.descendant(
of: find.byType(TextButton),
matching: find.byType(Material),
));
// Hovered.
final Offset center = tester.getCenter(find.text('2'));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08)));
expect(material.textStyle?.color, theme.colorScheme.onSurface);
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSurface.withOpacity(0.12)));
expect(material.textStyle?.color, theme.colorScheme.onSurface);
});
} }
...@@ -1855,6 +1855,20 @@ void main() { ...@@ -1855,6 +1855,20 @@ void main() {
paints..circle(color: theme.colorScheme.primary.withOpacity(0.08)), paints..circle(color: theme.colorScheme.primary.withOpacity(0.08)),
); );
// Slider still shows correct hovered color after pressing/dragging
await gesture.down(tester.getCenter(find.byType(Slider)));
await tester.pump();
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0.0, 100.0));
await tester.pumpAndSettle();
await gesture.moveTo(tester.getCenter(find.byType(Slider)));
await tester.pumpAndSettle();
expect(
Material.of(tester.element(find.byType(Slider))),
paints..circle(color: theme.colorScheme.primary.withOpacity(0.08)),
);
// Slider does not have an overlay when disabled and hovered. // Slider does not have an overlay when disabled and hovered.
await tester.pumpWidget(buildApp(enabled: false)); await tester.pumpWidget(buildApp(enabled: false));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
......
...@@ -461,6 +461,52 @@ void main() { ...@@ -461,6 +461,52 @@ void main() {
); );
}); });
testWidgets('Switch default overlayColor resolves hovered/focused state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Switch');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
final bool material3 = theme.useMaterial3;
Finder findSwitch() {
return find.byWidgetPredicate((Widget widget) => widget is Switch);
}
MaterialInkController? getSwitchMaterial(WidgetTester tester) {
return Material.of(tester.element(findSwitch()));
}
await tester.pumpWidget(MaterialApp(
theme: theme,
home: Scaffold(
body: Switch(
focusNode: focusNode,
value: true,
onChanged: (_) { },
),
),
));
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(getSwitchMaterial(tester),
paints
..circle(color: material3 ? theme.colorScheme.primary.withOpacity(0.12) : theme.focusColor)
);
// On both hovered and focused, the overlay color should show hovered overlay color.
final Offset center = tester.getCenter(find.byType(Switch));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(getSwitchMaterial(tester),
paints..circle(color: material3 ? theme.colorScheme.primary.withOpacity(0.08) : theme.hoverColor)
);
});
testWidgets('Switch can be set color', (WidgetTester tester) async { testWidgets('Switch can be set color', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -1320,7 +1366,7 @@ void main() { ...@@ -1320,7 +1366,7 @@ void main() {
color: const Color(0x802196f3), color: const Color(0x802196f3),
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
) )
..circle(color: const Color(0x1f000000)) ..circle() // Radial reaction
..rrect(color: const Color(0x33000000)) ..rrect(color: const Color(0x33000000))
..rrect(color: const Color(0x24000000)) ..rrect(color: const Color(0x24000000))
..rrect(color: const Color(0x1f000000)) ..rrect(color: const Color(0x1f000000))
...@@ -1341,7 +1387,7 @@ void main() { ...@@ -1341,7 +1387,7 @@ void main() {
color: const Color(0x802196f3), color: const Color(0x802196f3),
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
) )
..circle(color: const Color(0x1f000000)) ..circle()
..rrect(color: const Color(0x33000000)) ..rrect(color: const Color(0x33000000))
..rrect(color: const Color(0x24000000)) ..rrect(color: const Color(0x24000000))
..rrect(color: const Color(0x1f000000)) ..rrect(color: const Color(0x1f000000))
......
...@@ -553,16 +553,31 @@ void main() { ...@@ -553,16 +553,31 @@ void main() {
), ),
); );
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(tester.getCenter(find.text(selectedValue))); await gesture.moveTo(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.08)));
expect(inkFeatures, paints..rect(color: theme.colorScheme.primary.withOpacity(0.08)));
await gesture.down(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(tester.getCenter(find.text(unselectedValue))); await gesture.moveTo(tester.getCenter(find.text(unselectedValue)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(inkFeatures, paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08))); expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08)));
await gesture.down(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
await gesture.up();
await tester.pumpAndSettle();
}); });
testWidgets('TabBar default overlay (secondary)', (WidgetTester tester) async { testWidgets('TabBar default overlay (secondary)', (WidgetTester tester) async {
...@@ -578,16 +593,29 @@ void main() { ...@@ -578,16 +593,29 @@ void main() {
), ),
); );
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(tester.getCenter(find.text(selectedValue))); await gesture.moveTo(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08)));
expect(inkFeatures, paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08)));
await gesture.down(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSurface.withOpacity(0.12)));
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(tester.getCenter(find.text(unselectedValue))); await gesture.moveTo(tester.getCenter(find.text(unselectedValue)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(inkFeatures, paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08))); expect(overlayColor(), paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.08)));
await gesture.down(tester.getCenter(find.text(selectedValue)));
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.onSurface.withOpacity(0.12)));
}); });
testWidgets('TabBar tap selects tab', (WidgetTester tester) async { testWidgets('TabBar tap selects tab', (WidgetTester tester) async {
......
...@@ -177,11 +177,6 @@ void main() { ...@@ -177,11 +177,6 @@ void main() {
// Default, not disabled. // Default, not disabled.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline));
// Hovered. // Hovered.
final Offset center = tester.getCenter(find.byType(TextButton)); final Offset center = tester.getCenter(find.byType(TextButton));
final TestGesture gesture = await tester.createGesture( final TestGesture gesture = await tester.createGesture(
...@@ -197,8 +192,12 @@ void main() { ...@@ -197,8 +192,12 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer(); await gesture.removePointer();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline));
}, },
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115 skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
); );
...@@ -270,6 +269,59 @@ void main() { ...@@ -270,6 +269,59 @@ void main() {
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115 skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
); );
testWidgets('TextButton default overlayColor resolves pressed state', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Center(
child: Builder(
builder: (BuildContext context) {
return TextButton(
onPressed: () {},
focusNode: focusNode,
child: const Text('TextButton'),
);
},
),
),
),
),
);
RenderObject overlayColor() {
return tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
}
// Hovered.
final Offset center = tester.getCenter(find.byType(TextButton));
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer();
await gesture.moveTo(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.08)));
// Highlighted (pressed).
await gesture.down(center);
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect()..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
// Remove pressed and hovered states
await gesture.up();
await tester.pumpAndSettle();
await gesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(overlayColor(), paints..rect(color: theme.colorScheme.primary.withOpacity(0.12)));
});
testWidgets('TextButton uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('TextButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
......
...@@ -808,41 +808,42 @@ void main() { ...@@ -808,41 +808,42 @@ void main() {
final Offset center = tester.getCenter(find.text('First child')); final Offset center = tester.getCenter(find.text('First child'));
// splashColor // hoverColor
final TestGesture touchGesture = await tester.createGesture(); final TestGesture hoverGesture = await tester.createGesture(
await touchGesture.down(center); kind: PointerDeviceKind.mouse,
);
await hoverGesture.addPointer();
await hoverGesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await hoverGesture.moveTo(Offset.zero);
RenderObject inkFeatures; RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
return object.runtimeType.toString() == '_RenderInkFeatures'; return object.runtimeType.toString() == '_RenderInkFeatures';
}); });
expect( expect(
inkFeatures, inkFeatures,
paints paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.04)),
..circle(color: theme.colorScheme.onSurface.withOpacity(0.16)),
); );
await touchGesture.up(); // splashColor
await tester.pumpAndSettle(); final TestGesture touchGesture = await tester.createGesture();
await touchGesture.down(center); // The button is on hovered and pressed
// hoverColor
final TestGesture hoverGesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await hoverGesture.addPointer();
await hoverGesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await hoverGesture.moveTo(Offset.zero);
inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) { inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
return object.runtimeType.toString() == '_RenderInkFeatures'; return object.runtimeType.toString() == '_RenderInkFeatures';
}); });
expect( expect(
inkFeatures, inkFeatures,
paints..rect(color: theme.colorScheme.onSurface.withOpacity(0.04)), paints
..circle(color: theme.colorScheme.onSurface.withOpacity(0.16)),
); );
await touchGesture.up();
await tester.pumpAndSettle();
await hoverGesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// focusColor // focusColor
focusNode.requestFocus(); focusNode.requestFocus();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -874,30 +875,26 @@ void main() { ...@@ -874,30 +875,26 @@ void main() {
final Offset center = tester.getCenter(find.text('First child')); final Offset center = tester.getCenter(find.text('First child'));
// splashColor // hoverColor
final TestGesture touchGesture = await tester.createGesture(); final TestGesture hoverGesture = await tester.createGesture(
await touchGesture.down(center); kind: PointerDeviceKind.mouse,
);
await hoverGesture.addPointer();
await hoverGesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
RenderObject inkFeatures; RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
return object.runtimeType.toString() == '_RenderInkFeatures'; return object.runtimeType.toString() == '_RenderInkFeatures';
}); });
expect( expect(
inkFeatures, inkFeatures,
paints paints..rect(color: theme.colorScheme.primary.withOpacity(0.04)),
..circle(color: theme.colorScheme.primary.withOpacity(0.16)),
); );
await hoverGesture.moveTo(Offset.zero);
await touchGesture.up(); // splashColor
await tester.pumpAndSettle(); final TestGesture touchGesture = await tester.createGesture();
await touchGesture.down(center); // The button is on hovered and pressed
// hoverColor
final TestGesture hoverGesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await hoverGesture.addPointer();
await hoverGesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) { inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) {
...@@ -905,9 +902,14 @@ void main() { ...@@ -905,9 +902,14 @@ void main() {
}); });
expect( expect(
inkFeatures, inkFeatures,
paints..rect(color: theme.colorScheme.primary.withOpacity(0.04)), paints
..circle(color: theme.colorScheme.primary.withOpacity(0.16)),
); );
await hoverGesture.moveTo(Offset.zero);
await touchGesture.up();
await tester.pumpAndSettle();
await hoverGesture.moveTo(const Offset(0, 50));
await tester.pumpAndSettle();
// focusColor // focusColor
focusNode.requestFocus(); focusNode.requestFocus();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment