Fix CupertinoTimerPicker
dark mode text color (#100311)
This commit is contained in:
parent
a3c6395c0d
commit
adb8b607e3
@ -1974,6 +1974,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
||||
TextStyle _textStyleFrom(BuildContext context, [double magnification = 1.0]) {
|
||||
final TextStyle textStyle = CupertinoTheme.of(context).textTheme.pickerTextStyle;
|
||||
return textStyle.copyWith(
|
||||
color: CupertinoDynamicColor.maybeResolve(textStyle.color, context),
|
||||
fontSize: textStyle.fontSize! * magnification,
|
||||
);
|
||||
}
|
||||
|
@ -1543,6 +1543,33 @@ void main() {
|
||||
// Text style should not return unresolved color.
|
||||
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
|
||||
Widget _buildTimerPicker(Brightness brightness) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(brightness: brightness),
|
||||
home: CupertinoTimerPicker(
|
||||
mode: CupertinoTimerPickerMode.hm,
|
||||
onTimerDurationChanged: (Duration newDuration) {},
|
||||
initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// CupertinoTimerPicker with light theme.
|
||||
await tester.pumpWidget(_buildTimerPicker(Brightness.light));
|
||||
RenderParagraph paragraph = tester.renderObject(find.text('hours'));
|
||||
expect(paragraph.text.style!.color, CupertinoColors.label);
|
||||
// Text style should not return unresolved color.
|
||||
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
|
||||
|
||||
// CupertinoTimerPicker with light theme.
|
||||
await tester.pumpWidget(_buildTimerPicker(Brightness.dark));
|
||||
paragraph = tester.renderObject(find.text('hours'));
|
||||
expect(paragraph.text.style!.color, CupertinoColors.label);
|
||||
// Text style should not return unresolved color.
|
||||
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildPicker({
|
||||
|
Loading…
x
Reference in New Issue
Block a user