diff --git a/lib/bloc/theme/theme_state.dart b/lib/bloc/theme/theme_state.dart index 134e0c6..2480965 100644 --- a/lib/bloc/theme/theme_state.dart +++ b/lib/bloc/theme/theme_state.dart @@ -11,12 +11,12 @@ class LightThemeState extends ThemeState { const LightThemeState(); @override - AppTheme get theme => LightTheme(); + AppTheme get theme => const LightTheme(); } class DarkThemeState extends ThemeState { const DarkThemeState(); @override - AppTheme get theme => DarkTheme(); + AppTheme get theme => const DarkTheme(); } diff --git a/lib/models/themes/dark.dart b/lib/models/themes/dark.dart index cc7a903..16dc12d 100644 --- a/lib/models/themes/dark.dart +++ b/lib/models/themes/dark.dart @@ -1,46 +1,61 @@ part of './theme.dart'; class DarkTheme extends AppTheme { - @override - ColorSet get kanjiResultColor => const ColorSet( - foreground: Colors.white, - background: Colors.green, - ); + const DarkTheme() : super(); + + static const ColorSet defaultKanjiResultColor = ColorSet( + foreground: Colors.white, + background: Colors.green, + ); + + static const ColorSet defaultOnyomiColor = ColorSet( + foreground: Colors.white, + background: Colors.orange, + ); + + static const ColorSet defaultKunyomiColor = ColorSet( + foreground: Colors.white, + background: Colors.lightBlue, + ); + + static const Color defaultForeground = Colors.white; + static const Color defaultBackground = Colors.black; + + static final defaultMenuGreyLight = ColorSet( + foreground: Colors.white, + background: Colors.grey.shade700, + ); + static const defaultMenuGreyNormal = ColorSet( + foreground: Colors.white, + background: Colors.grey, + ); + + static final defaultMenuGreyDark = ColorSet( + foreground: Colors.black, + background: Colors.grey.shade300, + ); @override - ColorSet get onyomiColor => const ColorSet( - foreground: Colors.white, - background: Colors.orange, - ); + ColorSet get kanjiResultColor => defaultKanjiResultColor; @override - ColorSet get kunyomiColor => const ColorSet( - foreground: Colors.white, - background: Colors.lightBlue, - ); + ColorSet get onyomiColor => defaultOnyomiColor; @override - Color get foreground => Colors.black; - @override - Color get background => Colors.white; + ColorSet get kunyomiColor => defaultKunyomiColor; @override - ColorSet get menuGreyLight => ColorSet( - foreground: Colors.white, - background: Colors.grey.shade700, - ); + Color get foreground => defaultForeground; + @override + Color get background => defaultBackground; @override - ColorSet get menuGreyNormal => const ColorSet( - foreground: Colors.white, - background: Colors.grey, - ); + ColorSet get menuGreyLight => defaultMenuGreyLight; + @override + ColorSet get menuGreyNormal => defaultMenuGreyNormal; @override - ColorSet get menuGreyDark => ColorSet( - foreground: Colors.black, - background: Colors.grey.shade300, - ); + ColorSet get menuGreyDark => defaultMenuGreyDark; @override ThemeData getMaterialTheme() { diff --git a/lib/models/themes/light.dart b/lib/models/themes/light.dart index 6b7fcc1..40d76da 100644 --- a/lib/models/themes/light.dart +++ b/lib/models/themes/light.dart @@ -1,45 +1,60 @@ part of './theme.dart'; class LightTheme extends AppTheme { - @override - ColorSet get kanjiResultColor => const ColorSet( - foreground: Colors.white, - background: Colors.blue, - ); + const LightTheme() : super(); + + static const ColorSet defaultKanjiResultColor = ColorSet( + foreground: Colors.white, + background: Colors.blue, + ); + + static const ColorSet defaultOnyomiColor = ColorSet( + foreground: Colors.white, + background: Colors.orange, + ); + + static const ColorSet defaultKunyomiColor = ColorSet( + foreground: Colors.white, + background: Colors.lightBlue, + ); + + static const Color defaultForeground = Colors.black; + static const Color defaultBackground = Colors.white; + + static final defaultMenuGreyLight = ColorSet( + foreground: Colors.black, + background: Colors.grey.shade300, + ); + static const defaultMenuGreyNormal = ColorSet( + foreground: Colors.white, + background: Colors.grey, + ); + static final defaultMenuGreyDark = ColorSet( + foreground: Colors.white, + background: Colors.grey.shade700, + ); @override - ColorSet get onyomiColor => const ColorSet( - foreground: Colors.white, - background: Colors.orange, - ); + ColorSet get kanjiResultColor => defaultKanjiResultColor; @override - ColorSet get kunyomiColor => const ColorSet( - foreground: Colors.white, - background: Colors.lightBlue, - ); + ColorSet get onyomiColor => defaultOnyomiColor; @override - Color get foreground => Colors.black; - @override - Color get background => Colors.white; + ColorSet get kunyomiColor => defaultKunyomiColor; @override - ColorSet get menuGreyLight => ColorSet( - foreground: Colors.black, - background: Colors.grey.shade300, - ); + Color get foreground => defaultForeground; @override - ColorSet get menuGreyNormal => const ColorSet( - foreground: Colors.white, - background: Colors.grey, - ); + Color get background => defaultBackground; @override - ColorSet get menuGreyDark => ColorSet( - foreground: Colors.white, - background: Colors.grey.shade700, - ); + ColorSet get menuGreyLight => defaultMenuGreyLight; + @override + ColorSet get menuGreyNormal => defaultMenuGreyNormal; + + @override + ColorSet get menuGreyDark => defaultMenuGreyDark; @override ThemeData getMaterialTheme() { diff --git a/lib/models/themes/theme.dart b/lib/models/themes/theme.dart index 705be40..5f85b93 100644 --- a/lib/models/themes/theme.dart +++ b/lib/models/themes/theme.dart @@ -4,6 +4,8 @@ part 'light.dart'; part 'dark.dart'; abstract class AppTheme { + const AppTheme(); + static const ColorSet jishoGreen = ColorSet( foreground: Colors.white, background: Color(0xFF3EDD00), diff --git a/lib/view/screens/search/search_mechanisms/radical_list.dart b/lib/view/screens/search/search_mechanisms/radical_list.dart index 11b2bff..aab617d 100644 --- a/lib/view/screens/search/search_mechanisms/radical_list.dart +++ b/lib/view/screens/search/search_mechanisms/radical_list.dart @@ -59,14 +59,11 @@ class _KanjiRadicalSearchState extends State { } Widget radicalGridElement(String radical, {bool isNumber = false}) { - // final theme = BlocProvider.of(context).state.theme; - final theme = LightTheme(); - final color = isNumber - ? theme.menuGreyDark + ? LightTheme.defaultMenuGreyDark : radicalToggles[radical]! ? AppTheme.jishoGreen - : theme.menuGreyNormal; + : LightTheme.defaultMenuGreyNormal; return InkWell( onTap: isNumber @@ -123,7 +120,7 @@ class _KanjiRadicalSearchState extends State { .toList(); Widget kanjiGridElement(String kanji) { - final color = LightTheme().menuGreyNormal; + const color = LightTheme.defaultMenuGreyNormal; return InkWell( onTap: () => Navigator.popAndPushNamed( context,