From f21675035dc23caf500aa9bdabfebc8e67aa1142 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Wed, 24 Jan 2024 22:14:33 +0100
Subject: [PATCH] Disable remove cell from board when animation is in progress

---
 android/gradle.properties           |  4 ++--
 lib/ui/widgets/game/game_board.dart | 29 +++++++++++++++++++++--------
 pubspec.yaml                        |  2 +-
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/android/gradle.properties b/android/gradle.properties
index 16365f2..cfe1f46 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=1.0.42
-app.versionCode=43
+app.versionName=1.0.43
+app.versionCode=44
diff --git a/lib/ui/widgets/game/game_board.dart b/lib/ui/widgets/game/game_board.dart
index 47453ba..6f11e5b 100644
--- a/lib/ui/widgets/game/game_board.dart
+++ b/lib/ui/widgets/game/game_board.dart
@@ -153,14 +153,27 @@ class _GameBoardWidget extends State<GameBoardWidget> with TickerProviderStateMi
     return GestureDetector(
       child: buildBoard(),
       onTapUp: (details) {
-        double xTap = details.localPosition.dx;
-        double yTap = details.localPosition.dy;
-
-        int x = (xTap / widgetWidth * columnsCount).toInt();
-        int y = (yTap / widgetHeight * rowsCount).toInt();
-        print('[' + x.toString() + ',' + y.toString() + ']');
-
-        removeCell(context, x, y);
+        bool canRemoveCell = true;
+        animations.forEach((row) {
+          row.forEach((cell) {
+            if (cell != null) {
+              canRemoveCell = false;
+            }
+          });
+        });
+
+        if (canRemoveCell) {
+          double xTap = details.localPosition.dx;
+          double yTap = details.localPosition.dy;
+
+          int x = (xTap / widgetWidth * columnsCount).toInt();
+          int y = (yTap / widgetHeight * rowsCount).toInt();
+          print('[' + x.toString() + ',' + y.toString() + ']');
+
+          removeCell(context, x, y);
+        } else {
+          print('animation in progress...');
+        }
       },
     );
   }
diff --git a/pubspec.yaml b/pubspec.yaml
index fd959ba..499f579 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@ description: A random application, for testing purpose only.
 
 publish_to: 'none'
 
-version: 1.0.42+43
+version: 1.0.43+44
 
 environment:
   sdk: '^3.0.0'
-- 
GitLab