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
![Screenshot 2024-02-20 at 15 06 40](https://github.com/flutter/flutter/assets/48603081/5198a5da-314d-401e-8d7f-d4a68b86e43c)
![Screenshot 2024-02-20 at 15 07 22](https://github.com/flutter/flutter/assets/48603081/79436ce4-fef6-480a-bc43-b628497e860f)

### 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:
Taha Tesser
2024-02-21 12:39:35 +02:00
committed by GitHub
parent 35fd706256
commit 3403ca413f
4 changed files with 55 additions and 13 deletions

View File

@@ -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)),
};
});
}