From b9a5cd7683c5e9d235ab8db4cde7fbdb14e0c1d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Thu, 17 Jun 2021 10:52:36 +0200
Subject: [PATCH] Forbid change on initial cells

---
 android/gradle.properties | 4 ++--
 lib/entities/cell.dart    | 6 ++++--
 lib/screens/home.dart     | 7 ++++---
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/android/gradle.properties b/android/gradle.properties
index 135006f..85b94f8 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.6
-app.versionCode=6
+app.versionName=0.0.7
+app.versionCode=7
diff --git a/lib/entities/cell.dart b/lib/entities/cell.dart
index f573542..8b9039d 100644
--- a/lib/entities/cell.dart
+++ b/lib/entities/cell.dart
@@ -7,11 +7,13 @@ class Cell {
   int value;
   final int col;
   final int row;
+  final bool isFixed;
 
   Cell(
     @required this.value,
     @required this.col,
     @required this.row,
+    @required this.isFixed,
   );
 
   Container widget(Data myProvider) {
@@ -26,7 +28,7 @@ class Cell {
     Color borderDarkColor = Colors.black;
     Color borderLightColor = Colors.grey;
     Color borderSelectedColor = Colors.red;
-    Color backgroundColor = Colors.grey[200];
+    Color backgroundColor = this.isFixed ? Colors.grey[300] : Colors.grey[100];
 
     Border borders = Border(
       top: BorderSide(width: borderWidth, color: ((this.row % size) == 0) ? borderDarkColor : borderLightColor),
@@ -54,7 +56,7 @@ class Cell {
         ),
         onTap: () {
           if (this.col != null && this.row != null) {
-            if (this.col != myProvider.currentCellCol || this.row != myProvider.currentCellRow) {
+            if (!this.isFixed && (this.col != myProvider.currentCellCol || this.row != myProvider.currentCellRow)) {
               myProvider.selectCell(this.col, this.row);
             } else {
               myProvider.selectCell(null, null);
diff --git a/lib/screens/home.dart b/lib/screens/home.dart
index b295f79..108ef70 100644
--- a/lib/screens/home.dart
+++ b/lib/screens/home.dart
@@ -51,7 +51,7 @@ class Home extends StatelessWidget {
       List row = [];
       for (var colIndex = 0; colIndex < pow(size, 2); colIndex++) {
         int value = int.parse(grid[index++]);
-        row.add(Cell(value, colIndex, rowIndex));
+        row.add(Cell(value, colIndex, rowIndex, (value != 0)));
       }
       cells.add(row);
     }
@@ -67,7 +67,7 @@ class Home extends StatelessWidget {
     for (var rowIndex = 0; rowIndex < pow(size, 2); rowIndex++) {
       List row = [];
       for (var colIndex = 0; colIndex < pow(size, 2); colIndex++) {
-        row.add(Cell(0, colIndex, rowIndex));
+        row.add(Cell(0, colIndex, rowIndex, false));
       }
       cells.add(row);
     }
@@ -231,7 +231,8 @@ class Home extends StatelessWidget {
                     Cell(
                       isCellSelected ? value : 0,
                       isCellSelected ? myProvider.currentCellCol : null,
-                      isCellSelected ? myProvider.currentCellRow : null
+                      isCellSelected ? myProvider.currentCellRow : null,
+                      false
                     ).widgetUpdateValue(myProvider)
                   ]
                 ),
-- 
GitLab