From e5a4e7cc9b425e0f3999ba2d4d9ad8e1ac78ee1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Mon, 5 Feb 2024 00:00:49 +0100
Subject: [PATCH] Add "shuffle colors" button

---
 android/gradle.properties                         | 4 ++--
 fastlane/metadata/android/en-US/changelogs/18.txt | 1 +
 fastlane/metadata/android/fr-FR/changelogs/18.txt | 1 +
 lib/cubit/game_cubit.dart                         | 4 ++++
 lib/models/game.dart                              | 4 ++++
 lib/ui/widgets/game_top_indicator.dart            | 8 ++++++++
 pubspec.yaml                                      | 2 +-
 7 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 fastlane/metadata/android/en-US/changelogs/18.txt
 create mode 100644 fastlane/metadata/android/fr-FR/changelogs/18.txt

diff --git a/android/gradle.properties b/android/gradle.properties
index cd2d833..30298b3 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.0.17
-app.versionCode=17
+app.versionName=0.0.18
+app.versionCode=18
diff --git a/fastlane/metadata/android/en-US/changelogs/18.txt b/fastlane/metadata/android/en-US/changelogs/18.txt
new file mode 100644
index 0000000..8998d70
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/18.txt
@@ -0,0 +1 @@
+Add shuffle colors button.
diff --git a/fastlane/metadata/android/fr-FR/changelogs/18.txt b/fastlane/metadata/android/fr-FR/changelogs/18.txt
new file mode 100644
index 0000000..f333e24
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/18.txt
@@ -0,0 +1 @@
+Ajout d'un bouton pour mélanger les couleurs.
diff --git a/lib/cubit/game_cubit.dart b/lib/cubit/game_cubit.dart
index cc446d6..4bcda5b 100644
--- a/lib/cubit/game_cubit.dart
+++ b/lib/cubit/game_cubit.dart
@@ -67,6 +67,10 @@ class GameCubit extends HydratedCubit<GameState> {
     refresh();
   }
 
+  void shuffleColors() {
+    this.state.currentGame.shuffleColorsAgain();
+  }
+
   moveCellsDown() {
     final Game currentGame = this.state.currentGame;
 
diff --git a/lib/models/game.dart b/lib/models/game.dart
index 94f2538..423654a 100644
--- a/lib/models/game.dart
+++ b/lib/models/game.dart
@@ -53,6 +53,10 @@ class Game {
     return values;
   }
 
+  void shuffleColorsAgain() {
+    this.shuffledColors = shuffleColors();
+  }
+
   GameCell getCell(CellLocation cellLocation) {
     return this.board.cells[cellLocation.row][cellLocation.col];
   }
diff --git a/lib/ui/widgets/game_top_indicator.dart b/lib/ui/widgets/game_top_indicator.dart
index 298c502..1e692b3 100644
--- a/lib/ui/widgets/game_top_indicator.dart
+++ b/lib/ui/widgets/game_top_indicator.dart
@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:unicons/unicons.dart';
 
 import 'package:jeweled/cubit/game_cubit.dart';
 import 'package:jeweled/models/game.dart';
@@ -55,6 +56,13 @@ class GameTopIndicatorWidget extends StatelessWidget {
                         color: availableBlocksCountTextColor,
                       ),
                     ),
+                    TextButton(
+                      child: Icon(UniconsSolid.refresh),
+                      onPressed: () {
+                        final GameCubit gameCubit = BlocProvider.of<GameCubit>(context);
+                        gameCubit.shuffleColors();
+                      },
+                    )
                   ],
                 ),
               ],
diff --git a/pubspec.yaml b/pubspec.yaml
index 542bbc6..52d05e3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@ description: Jeweled Game
 
 publish_to: 'none'
 
-version: 0.0.17+17
+version: 0.0.18+18
 
 environment:
   sdk: '^3.0.0'
-- 
GitLab