Fix CupertinoTimerPicker dark mode text color (#100311)

This commit is contained in:
Taha Tesser 2022-05-03 19:49:07 +03:00 committed by GitHub
parent a3c6395c0d
commit adb8b607e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

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

View File

@ -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({