From b4d6c23f32e910dc4323d61ec301c129e3da1815 Mon Sep 17 00:00:00 2001 From: Mo Date: Sat, 19 Jun 2021 21:38:30 -0700 Subject: [PATCH] fix: textTheme should have onBackground color by default --- client/lib/custom_theme.dart | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/client/lib/custom_theme.dart b/client/lib/custom_theme.dart index 62159927..5cdf4b7e 100644 --- a/client/lib/custom_theme.dart +++ b/client/lib/custom_theme.dart @@ -14,19 +14,24 @@ const _kHeadline1 = TextStyle(fontFamily: 'PermanentMarker', fontSize: 25); class CustomTheme extends ChangeNotifier { static ThemeData get lightTheme { final themeData = ThemeData(); - - return themeData.copyWith( - textTheme: themeData.textTheme.copyWith(headline1: _kHeadline1)); + final colorScheme = themeData.colorScheme + .copyWith(onPrimary: Colors.white, onBackground: Colors.black87); + return _themeData(themeData, colorScheme); } static ThemeData get darkTheme { final themeData = ThemeData.dark(); - final textTheme = themeData.textTheme; + final colorScheme = themeData.colorScheme + .copyWith(onPrimary: Colors.white, onBackground: Colors.white); + return _themeData(themeData, colorScheme); + } + + static ThemeData _themeData(ThemeData baseTheme, ColorScheme colorScheme) { + final textTheme = baseTheme.textTheme + .copyWith(headline1: _kHeadline1) + .apply(displayColor: colorScheme.onBackground); - return themeData.copyWith( - textTheme: textTheme.copyWith( - headline1: textTheme.headline1?.merge(_kHeadline1) ?? - _kHeadline1.copyWith(color: Colors.white))); + return baseTheme.copyWith(colorScheme: colorScheme, textTheme: textTheme); } bool _isDarkMode = false; @@ -41,4 +46,4 @@ class CustomTheme extends ChangeNotifier { Icon get icon => _isDarkMode ? const Icon(Icons.dark_mode_outlined) : const Icon(Icons.light_mode_outlined); -} \ No newline at end of file +}