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.
This commit is contained in:
Greg Spencer
2022-12-06 18:07:25 -08:00
committed by GitHub
parent fb9133b881
commit 31719941c0
9 changed files with 60 additions and 44 deletions

View File

@@ -134,7 +134,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
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.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.label-text')});
@@ -158,7 +158,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.label-text')});
@@ -182,7 +182,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.supporting-text')});
}'''}${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : '''
@@ -197,7 +197,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.supporting-text')});
}'''}${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''

View File

@@ -67,10 +67,6 @@ class _${blockName}DefaultsM3 extends SnackBarThemeData {
@override
bool get showCloseIcon => false;
@override
Color get iconColor => _colors.onInverseSurface;
}
}
''';
}

View File

@@ -26,7 +26,7 @@ abstract class TokenTemplate {
/// Defaults to 'Theme.of(context).colorScheme.'
final String colorSchemePrefix;
/// Optional prefix prepended to text style definitians.
/// Optional prefix prepended to text style definitions.
///
/// Defaults to 'Theme.of(context).textTheme.'
final String textThemePrefix;
@@ -145,13 +145,17 @@ abstract class TokenTemplate {
}
/// Generate the opacity value for the given token.
String? opacity(String token) {
final dynamic value = tokens[token];
String? opacity(String token) => _numToString(tokens[token]);
String? _numToString(Object? value, [int? digits]) {
if (value == null) {
return null;
}
if (value is double) {
return value.toString();
if (value is num) {
if (value == double.infinity) {
return 'double.infinity';
}
return digits == null ? value.toString() : value.toStringAsFixed(digits);
}
return tokens[value].toString();
}
@@ -161,6 +165,24 @@ abstract class TokenTemplate {
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.
///
/// Currently supports family: