Unverified Commit 31719941 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Time picker precursors (#116450)

* Make some minor changes in preparation for updating the Time Picker to M3

* Revert OutlineInputBorder.borderRadius type change

* Revert more OutlineInputBorder.borderRadius changes.
parent fb9133b8
...@@ -134,7 +134,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -134,7 +134,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@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.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) { 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.focus.label-text')});
...@@ -158,7 +158,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -158,7 +158,7 @@ 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.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) { 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.focus.label-text')});
...@@ -182,7 +182,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -182,7 +182,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@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();${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.supporting-text')}); return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.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') ? '' : '''
...@@ -197,7 +197,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -197,7 +197,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@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.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
if (states.contains(MaterialState.focused)) { 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.focus.supporting-text')});
}'''}${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : ''' }'''}${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
......
...@@ -67,10 +67,6 @@ class _${blockName}DefaultsM3 extends SnackBarThemeData { ...@@ -67,10 +67,6 @@ class _${blockName}DefaultsM3 extends SnackBarThemeData {
@override @override
bool get showCloseIcon => false; bool get showCloseIcon => false;
}
@override
Color get iconColor => _colors.onInverseSurface;
}
'''; ''';
} }
...@@ -26,7 +26,7 @@ abstract class TokenTemplate { ...@@ -26,7 +26,7 @@ abstract class TokenTemplate {
/// Defaults to 'Theme.of(context).colorScheme.' /// Defaults to 'Theme.of(context).colorScheme.'
final String colorSchemePrefix; final String colorSchemePrefix;
/// Optional prefix prepended to text style definitians. /// Optional prefix prepended to text style definitions.
/// ///
/// Defaults to 'Theme.of(context).textTheme.' /// Defaults to 'Theme.of(context).textTheme.'
final String textThemePrefix; final String textThemePrefix;
...@@ -145,13 +145,17 @@ abstract class TokenTemplate { ...@@ -145,13 +145,17 @@ abstract class TokenTemplate {
} }
/// Generate the opacity value for the given token. /// Generate the opacity value for the given token.
String? opacity(String token) { String? opacity(String token) => _numToString(tokens[token]);
final dynamic value = tokens[token];
String? _numToString(Object? value, [int? digits]) {
if (value == null) { if (value == null) {
return null; return null;
} }
if (value is double) { if (value is num) {
return value.toString(); if (value == double.infinity) {
return 'double.infinity';
}
return digits == null ? value.toString() : value.toStringAsFixed(digits);
} }
return tokens[value].toString(); return tokens[value].toString();
} }
...@@ -161,6 +165,24 @@ abstract class TokenTemplate { ...@@ -161,6 +165,24 @@ abstract class TokenTemplate {
return tokens[tokens['$componentToken.elevation']!]!.toString(); return tokens[tokens['$componentToken.elevation']!]!.toString();
} }
/// Generate a size value for the given component token.
///
/// Non-square sizes are specified as width and height.
String size(String componentToken) {
final String sizeToken = '$componentToken.size';
if (!tokens.containsKey(sizeToken)) {
final String widthToken = '$componentToken.width';
final String heightToken = '$componentToken.height';
if (!tokens.containsKey(widthToken) && !tokens.containsKey(heightToken)) {
throw Exception('Unable to find width, height, or size tokens for $componentToken');
}
final String? width = _numToString(tokens.containsKey(widthToken) ? tokens[widthToken]! as num : double.infinity, 0);
final String? height = _numToString(tokens.containsKey(heightToken) ? tokens[heightToken]! as num : double.infinity, 0);
return 'const Size($width, $height)';
}
return 'const Size.square(${_numToString(tokens[sizeToken])})';
}
/// Generate a shape constant for the given component token. /// Generate a shape constant for the given component token.
/// ///
/// Currently supports family: /// Currently supports family:
......
...@@ -4580,7 +4580,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4580,7 +4580,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@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.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:_colors.error); return textStyle.copyWith(color:_colors.error);
...@@ -4604,7 +4604,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4604,7 +4604,7 @@ 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.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:_colors.error); return textStyle.copyWith(color:_colors.error);
...@@ -4628,7 +4628,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4628,7 +4628,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle(); final TextStyle textStyle = _textTheme.bodySmall ?? const TextStyle();
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38)); return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38));
} }
...@@ -4637,7 +4637,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4637,7 +4637,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle(); final TextStyle textStyle = _textTheme.bodySmall ?? const TextStyle();
return textStyle.copyWith(color:_colors.error); return textStyle.copyWith(color:_colors.error);
}); });
} }
......
...@@ -409,7 +409,6 @@ abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements Mat ...@@ -409,7 +409,6 @@ abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements Mat
OutlinedBorder? resolve(Set<MaterialState> states); OutlinedBorder? resolve(Set<MaterialState> states);
} }
/// Defines a [TextStyle] that is also a [MaterialStateProperty]. /// Defines a [TextStyle] that is also a [MaterialStateProperty].
/// ///
/// This class exists to enable widgets with [TextStyle] valued properties /// This class exists to enable widgets with [TextStyle] valued properties
......
...@@ -3572,6 +3572,7 @@ class _MenuBarDefaultsM3 extends MenuStyle { ...@@ -3572,6 +3572,7 @@ class _MenuBarDefaultsM3 extends MenuStyle {
shape: const MaterialStatePropertyAll<OutlinedBorder>(_defaultMenuBorder), shape: const MaterialStatePropertyAll<OutlinedBorder>(_defaultMenuBorder),
alignment: AlignmentDirectional.bottomStart, alignment: AlignmentDirectional.bottomStart,
); );
static const RoundedRectangleBorder _defaultMenuBorder = static const RoundedRectangleBorder _defaultMenuBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))); RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
...@@ -3614,6 +3615,7 @@ class _MenuButtonDefaultsM3 extends ButtonStyle { ...@@ -3614,6 +3615,7 @@ class _MenuButtonDefaultsM3 extends ButtonStyle {
enableFeedback: true, enableFeedback: true,
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
); );
final BuildContext context; final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme; late final ColorScheme _colors = Theme.of(context).colorScheme;
...@@ -3756,6 +3758,7 @@ class _MenuDefaultsM3 extends MenuStyle { ...@@ -3756,6 +3758,7 @@ class _MenuDefaultsM3 extends MenuStyle {
shape: const MaterialStatePropertyAll<OutlinedBorder>(_defaultMenuBorder), shape: const MaterialStatePropertyAll<OutlinedBorder>(_defaultMenuBorder),
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
); );
static const RoundedRectangleBorder _defaultMenuBorder = static const RoundedRectangleBorder _defaultMenuBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))); RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
......
...@@ -883,10 +883,6 @@ class _SnackbarDefaultsM3 extends SnackBarThemeData { ...@@ -883,10 +883,6 @@ class _SnackbarDefaultsM3 extends SnackBarThemeData {
@override @override
bool get showCloseIcon => false; bool get showCloseIcon => false;
}
@override
Color get closeIconColor => _colors.onInverseSurface;
}
// END GENERATED TOKEN PROPERTIES - Snackbar // END GENERATED TOKEN PROPERTIES - Snackbar
...@@ -1429,6 +1429,6 @@ TextStyle _m2CounterErrorStyle(BuildContext context) => ...@@ -1429,6 +1429,6 @@ TextStyle _m2CounterErrorStyle(BuildContext context) =>
TextStyle _m3InputStyle(BuildContext context) => Theme.of(context).textTheme.bodyLarge!; TextStyle _m3InputStyle(BuildContext context) => Theme.of(context).textTheme.bodyLarge!;
TextStyle _m3CounterErrorStyle(BuildContext context) => TextStyle _m3CounterErrorStyle(BuildContext context) =>
Theme.of(context).textTheme.bodySmall!.copyWith(color:Theme.of(context).colorScheme.error); Theme.of(context).textTheme.bodySmall!.copyWith(color: Theme.of(context).colorScheme.error);
// END GENERATED TOKEN PROPERTIES - TextField // END GENERATED TOKEN PROPERTIES - TextField
...@@ -283,8 +283,8 @@ void main() { ...@@ -283,8 +283,8 @@ void main() {
final RenderObject renderObject = tester.renderObject( final RenderObject renderObject = tester.renderObject(
find.descendant( find.descendant(
of: find.byKey(const Key('parent')), of: find.byKey(const Key('parent')),
matching: find.byType(CustomPaint), matching: find.byKey(const ValueKey<String>('time-picker-dial')),
).first, ),
); );
expect(renderObject.debugNeedsPaint, isTrue); expect(renderObject.debugNeedsPaint, isTrue);
}); });
......
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