Update hourMinuteTextStyle defaults for Material 3 Time Picker (#143749)
fixes [`hourMinuteTextStyle` Material 3 default doesn't match the specs](https://github.com/flutter/flutter/issues/143748) This updates `hourMinuteTextStyle` defaults to match Material 3 specs. `hourMinuteTextStyle` should use different font style for different entry modes based on the specs. ### Specs   ### Before ```dart return _textTheme.displayMedium!.copyWith(color: _hourMinuteTextColor.resolve(states)); ``` ### After ```dart return entryMode == TimePickerEntryMode.dial ? _textTheme.displayLarge!.copyWith(color: _hourMinuteTextColor.resolve(states)) : _textTheme.displayMedium!.copyWith(color: _hourMinuteTextColor.resolve(states)); ```
This commit is contained in:
@@ -19,9 +19,10 @@ class TimePickerTemplate extends TokenTemplate {
|
||||
@override
|
||||
String generate() => '''
|
||||
class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
_${blockName}DefaultsM3(this.context);
|
||||
_${blockName}DefaultsM3(this.context, { this.entryMode = TimePickerEntryMode.dial });
|
||||
|
||||
final BuildContext context;
|
||||
final TimePickerEntryMode entryMode;
|
||||
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final TextTheme _textTheme = Theme.of(context).textTheme;
|
||||
@@ -284,7 +285,12 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
// TODO(tahatesser): Update this when https://github.com/flutter/flutter/issues/131247 is fixed.
|
||||
// This is using the correct text style from Material 3 spec.
|
||||
// https://m3.material.io/components/time-pickers/specs#fd0b6939-edab-4058-82e1-93d163945215
|
||||
return _textTheme.displayMedium!.copyWith(color: _hourMinuteTextColor.resolve(states));
|
||||
return switch (entryMode) {
|
||||
TimePickerEntryMode.dial || TimePickerEntryMode.dialOnly
|
||||
=> _textTheme.displayLarge!.copyWith(color: _hourMinuteTextColor.resolve(states)),
|
||||
TimePickerEntryMode.input || TimePickerEntryMode.inputOnly
|
||||
=> _textTheme.displayMedium!.copyWith(color: _hourMinuteTextColor.resolve(states)),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user