Skip to content

Commit

Permalink
fix: textTheme should have onBackground color by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kkweon committed Jun 20, 2021
1 parent a23d1d7 commit b4d6c23
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions client/lib/custom_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,4 +46,4 @@ class CustomTheme extends ChangeNotifier {
Icon get icon => _isDarkMode
? const Icon(Icons.dark_mode_outlined)
: const Icon(Icons.light_mode_outlined);
}
}

0 comments on commit b4d6c23

Please sign in to comment.