Skip to content

Commit

Permalink
Background colors fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Dec 4, 2023
1 parent 0451a9c commit 434e2ec
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ec8b70a489dd1f81e53ef185cf7ad30fce8f8d00

COCOAPODS: 1.14.2
COCOAPODS: 1.14.3
2 changes: 2 additions & 0 deletions lib/src/feature/about/widget/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:url_launcher/link.dart';
import 'package:wordly/src/core/constants/constants.dart';
import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';

class AboutPage extends StatelessWidget {
const AboutPage({super.key});
Expand All @@ -13,6 +14,7 @@ class AboutPage extends StatelessWidget {
color: Colors.black,
title: context.r.about,
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/feature/components/widget/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:wordly/src/feature/about/widget/about_page.dart';
import 'package:wordly/src/feature/game/bloc/game_bloc.dart';
import 'package:wordly/src/feature/game/model/game_mode.dart';
import 'package:wordly/src/feature/game/widget/game_page.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/widget/setting_page.dart';
import 'package:wordly/src/feature/tutorial/widget/tutorial_page.dart';

Expand All @@ -14,7 +15,7 @@ class CustomDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return NavigationDrawer(
backgroundColor: context.theme.colorScheme.background,
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
children: [
ListTile(
title: Text(context.r.daily, style: const TextStyle(fontWeight: FontWeight.w500)),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/feature/game/widget/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:wordly/src/feature/game/widget/game_result_dialog.dart';
import 'package:wordly/src/feature/game/widget/keyboard_by_language.dart';
import 'package:wordly/src/feature/game/widget/words_grid.dart';
import 'package:wordly/src/feature/level/widget/level_page.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/widget/settings_scope.dart';
import 'package:wordly/src/feature/statistic/widget/statistic_page.dart';
import 'package:wordly/src/feature/tutorial/widget/tutorial_page.dart';
Expand Down Expand Up @@ -80,6 +81,7 @@ class _GamePageState extends State<GamePage> {
}
},
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: BlocBuilder<GameBloc, GameState>(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/feature/level/widget/level_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/components/widget/not_played.dart';
import 'package:wordly/src/feature/game/model/game_result.dart';
import 'package:wordly/src/feature/level/widget/level_dialog.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';

class LevelPage extends StatefulWidget {
const LevelPage({required this.dictionary, super.key});
Expand All @@ -30,6 +31,7 @@ class _LevelPageState extends State<LevelPage> {
color: Colors.black,
title: context.r.levels,
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
23 changes: 23 additions & 0 deletions lib/src/feature/settings/model/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ final class AppTheme with Diagnosticable {
this.otherColors,
}) : lightTheme = ThemeData(
brightness: Brightness.light,
extensions: const [BackgroundCustomColors(background: Colors.white)],
colorSchemeSeed: colorMode == ColorMode.other ? otherColors?.$1 ?? AppColors.green : AppColors.green,
fontFamily: FontFamily.nunito,
),
darkTheme = ThemeData(
brightness: Brightness.dark,
extensions: const [BackgroundCustomColors(background: AppColors.darkBackground)],
colorSchemeSeed: colorMode == ColorMode.other ? otherColors?.$1 ?? AppColors.green : AppColors.green,
fontFamily: FontFamily.nunito,
);
Expand Down Expand Up @@ -124,3 +126,24 @@ final class AppTheme with Diagnosticable {
);
}
}

@immutable
class BackgroundCustomColors extends ThemeExtension<BackgroundCustomColors> {
const BackgroundCustomColors({
required this.background,
});

final Color? background;

@override
ThemeExtension<BackgroundCustomColors> copyWith({Color? background}) =>
BackgroundCustomColors(background: background ?? this.background);

@override
ThemeExtension<BackgroundCustomColors> lerp(covariant ThemeExtension<BackgroundCustomColors>? other, double t) {
if (other is! BackgroundCustomColors) {
return this;
}
return BackgroundCustomColors(background: Color.lerp(background, other.background, t));
}
}
2 changes: 2 additions & 0 deletions lib/src/feature/settings/widget/change_color_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/components/widget/letter_tile.dart';
import 'package:wordly/src/feature/game/model/letter_info.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/model/change_color_result.dart';
import 'package:wordly/src/feature/settings/widget/settings_scope.dart';

Expand Down Expand Up @@ -49,6 +50,7 @@ class _ChangeColorPageState extends State<ChangeColorPage> {
Widget build(BuildContext context) {
final word = _wordByDictionary(widget.dictionary);
return Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/feature/settings/widget/setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/game/bloc/game_bloc.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/model/change_color_result.dart';
import 'package:wordly/src/feature/settings/widget/change_color_page.dart';
import 'package:wordly/src/feature/settings/widget/list_item_selector.dart';
Expand All @@ -22,6 +23,7 @@ class _SettingsPageState extends State<SettingsPage> {
color: Colors.black,
title: context.r.settings,
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/feature/statistic/widget/statistic_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/components/widget/not_played.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/widget/settings_scope.dart';
import 'package:wordly/src/feature/statistic/model/game_statistics.dart';

Expand All @@ -30,6 +31,7 @@ class _StatisticPageState extends State<StatisticPage> {
color: Colors.black,
title: context.r.statistic,
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/feature/tutorial/widget/tutorial_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/components/widget/constraint_screen.dart';
import 'package:wordly/src/feature/components/widget/letter_tile.dart';
import 'package:wordly/src/feature/game/model/letter_info.dart';
import 'package:wordly/src/feature/settings/model/app_theme.dart';
import 'package:wordly/src/feature/settings/widget/settings_scope.dart';

class TutorialPage extends StatelessWidget {
Expand All @@ -19,6 +20,7 @@ class TutorialPage extends StatelessWidget {
color: Colors.black,
title: context.r.tutorial,
child: Scaffold(
backgroundColor: context.theme.extension<BackgroundCustomColors>()?.background,
appBar: AppBar(
centerTitle: true,
title: Text(
Expand Down
2 changes: 1 addition & 1 deletion macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367

COCOAPODS: 1.14.2
COCOAPODS: 1.14.3

0 comments on commit 434e2ec

Please sign in to comment.