From dc038b05958b8ef1e6431eb4e463afb515ebac9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Sun, 7 Jul 2024 23:32:32 +0200
Subject: [PATCH] Fix "all categories" game theme

---
 android/gradle.properties                     |  4 +-
 .../metadata/android/en-US/changelogs/28.txt  |  1 +
 .../metadata/android/fr-FR/changelogs/28.txt  |  1 +
 lib/cubit/game_cubit.dart                     |  2 +-
 lib/data/fetch_data_helper.dart               |  4 +-
 lib/models/data/game_item.dart                |  6 +--
 lib/models/data/game_theme.dart               |  2 +-
 lib/ui/game/game_end.dart                     | 47 ++++++++-----------
 lib/ui/layouts/parameters_layout.dart         |  2 +-
 lib/ui/widgets/actions/button_game_quit.dart  |  2 +-
 .../widgets/indicators/indicator_score.dart   |  2 +-
 pubspec.yaml                                  |  2 +-
 12 files changed, 35 insertions(+), 40 deletions(-)
 create mode 100644 fastlane/metadata/android/en-US/changelogs/28.txt
 create mode 100644 fastlane/metadata/android/fr-FR/changelogs/28.txt

diff --git a/android/gradle.properties b/android/gradle.properties
index c7c59fb..846d702 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx1536M
 android.useAndroidX=true
 android.enableJetifier=true
-app.versionName=0.1.0
-app.versionCode=27
+app.versionName=0.1.1
+app.versionCode=28
diff --git a/fastlane/metadata/android/en-US/changelogs/28.txt b/fastlane/metadata/android/en-US/changelogs/28.txt
new file mode 100644
index 0000000..cc64aed
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/28.txt
@@ -0,0 +1 @@
+Fix "all" categories game theme.
diff --git a/fastlane/metadata/android/fr-FR/changelogs/28.txt b/fastlane/metadata/android/fr-FR/changelogs/28.txt
new file mode 100644
index 0000000..4f90f60
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/28.txt
@@ -0,0 +1 @@
+Correction sur le jeu "toutes catégories".
diff --git a/lib/cubit/game_cubit.dart b/lib/cubit/game_cubit.dart
index ec76c9a..eba2fa6 100644
--- a/lib/cubit/game_cubit.dart
+++ b/lib/cubit/game_cubit.dart
@@ -100,7 +100,7 @@ class GameCubit extends HydratedCubit<GameState> {
   @override
   Map<String, dynamic>? toJson(GameState state) {
     return <String, dynamic>{
-      'currentGame': state.currentGame.toJson(),
+      'currentGame': state.currentGame,
     };
   }
 }
diff --git a/lib/data/fetch_data_helper.dart b/lib/data/fetch_data_helper.dart
index 405199e..db8b430 100644
--- a/lib/data/fetch_data_helper.dart
+++ b/lib/data/fetch_data_helper.dart
@@ -101,8 +101,8 @@ class FetchDataHelper {
     List<GameItem> items = _mapping;
 
     // Remove unwanted categories if theme is selected
-    if (themeCode != '') {
-      final GameTheme gameTheme = getTheme(code: themeCode);
+    final GameTheme gameTheme = getTheme(code: themeCode);
+    if (gameTheme.categories.isNotEmpty) {
       for (GameItem item in items) {
         item.isCategory.removeWhere((Category category) =>
             (!gameTheme.categories.map((Category c) => c.key).contains(category.key)));
diff --git a/lib/models/data/game_item.dart b/lib/models/data/game_item.dart
index f1c8cc3..02e614d 100644
--- a/lib/models/data/game_item.dart
+++ b/lib/models/data/game_item.dart
@@ -19,9 +19,9 @@ class GameItem {
 
   Map<String, dynamic>? toJson() {
     return <String, dynamic>{
-      'item': item.toJson(),
-      'isCategory': isCategory.toString(),
-      'isNotCategory': isNotCategory.toString(),
+      'item': item,
+      'isCategory': isCategory,
+      'isNotCategory': isNotCategory,
     };
   }
 }
diff --git a/lib/models/data/game_theme.dart b/lib/models/data/game_theme.dart
index e0ecc61..40a6ce7 100644
--- a/lib/models/data/game_theme.dart
+++ b/lib/models/data/game_theme.dart
@@ -17,7 +17,7 @@ class GameTheme {
   Map<String, dynamic>? toJson() {
     return <String, dynamic>{
       'code': code,
-      'categories': categories.toString(),
+      'categories': categories,
     };
   }
 }
diff --git a/lib/ui/game/game_end.dart b/lib/ui/game/game_end.dart
index 468138c..2b5f9ba 100644
--- a/lib/ui/game/game_end.dart
+++ b/lib/ui/game/game_end.dart
@@ -15,36 +15,29 @@ class GameEndWidget extends StatelessWidget {
         final Game currentGame = gameState.currentGame;
 
         final Image decorationImage = Image(
-          image: AssetImage(
-              currentGame.gameWon ? 'assets/ui/game_win.png' : 'assets/ui/game_fail.png'),
+          image: AssetImage('assets/ui/game_${currentGame.gameWon ? 'win' : 'fail'}.png'),
           fit: BoxFit.fill,
         );
 
-        return Container(
-          margin: const EdgeInsets.all(2),
-          padding: const EdgeInsets.all(2),
-          child: Table(
-            defaultColumnWidth: const IntrinsicColumnWidth(),
-            children: [
-              TableRow(
-                children: [
-                  Column(
-                    children: [decorationImage],
-                  ),
-                  Column(
-                    children: [
-                      currentGame.animationInProgress == true
-                          ? decorationImage
-                          : const QuitGameButton()
-                    ],
-                  ),
-                  Column(
-                    children: [decorationImage],
-                  ),
-                ],
-              ),
-            ],
-          ),
+        return Table(
+          defaultColumnWidth: const IntrinsicColumnWidth(),
+          children: [
+            TableRow(
+              children: [
+                Column(
+                  children: [decorationImage],
+                ),
+                Column(
+                  children: [
+                    currentGame.animationInProgress ? decorationImage : const QuitGameButton()
+                  ],
+                ),
+                Column(
+                  children: [decorationImage],
+                ),
+              ],
+            ),
+          ],
         );
       },
     );
diff --git a/lib/ui/layouts/parameters_layout.dart b/lib/ui/layouts/parameters_layout.dart
index 52a22be..fcb13d1 100644
--- a/lib/ui/layouts/parameters_layout.dart
+++ b/lib/ui/layouts/parameters_layout.dart
@@ -37,7 +37,7 @@ class ParametersLayout extends StatelessWidget {
 
     lines.add(SizedBox(height: separatorHeight));
 
-    if (canResume == false) {
+    if (!canResume) {
       // Start new game
       lines.add(const Expanded(
         child: StartNewGameButton(),
diff --git a/lib/ui/widgets/actions/button_game_quit.dart b/lib/ui/widgets/actions/button_game_quit.dart
index 7e8d2ec..1a27356 100644
--- a/lib/ui/widgets/actions/button_game_quit.dart
+++ b/lib/ui/widgets/actions/button_game_quit.dart
@@ -8,7 +8,7 @@ class QuitGameButton extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    return TextButton(
+    return ElevatedButton(
       child: const Image(
         image: AssetImage('assets/ui/button_back.png'),
         fit: BoxFit.fill,
diff --git a/lib/ui/widgets/indicators/indicator_score.dart b/lib/ui/widgets/indicators/indicator_score.dart
index 22fed09..d234ea7 100644
--- a/lib/ui/widgets/indicators/indicator_score.dart
+++ b/lib/ui/widgets/indicators/indicator_score.dart
@@ -16,7 +16,7 @@ class ScoreIndicator extends StatelessWidget {
         final Color outlineColor = baseColor.darken();
 
         return OutlinedText(
-          text: gameState.currentGame.score.toString(),
+          text: '${gameState.currentGame.score}',
           fontSize: 70,
           textColor: baseColor,
           outlineColor: outlineColor,
diff --git a/pubspec.yaml b/pubspec.yaml
index ca06f93..dc0a237 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@ description: A sorting game application.
 
 publish_to: "none"
 
-version: 0.1.0+27
+version: 0.1.1+28
 
 environment:
   sdk: "^3.0.0"
-- 
GitLab