Skip to content
Snippets Groups Projects
Commit b9a5cd76 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Forbid change on initial cells

parent 2186f567
No related branches found
No related tags found
1 merge request!7Resolve "Forbid change on initial cells"
Pipeline #1382 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.0.6 app.versionName=0.0.7
app.versionCode=6 app.versionCode=7
...@@ -7,11 +7,13 @@ class Cell { ...@@ -7,11 +7,13 @@ class Cell {
int value; int value;
final int col; final int col;
final int row; final int row;
final bool isFixed;
Cell( Cell(
@required this.value, @required this.value,
@required this.col, @required this.col,
@required this.row, @required this.row,
@required this.isFixed,
); );
Container widget(Data myProvider) { Container widget(Data myProvider) {
...@@ -26,7 +28,7 @@ class Cell { ...@@ -26,7 +28,7 @@ class Cell {
Color borderDarkColor = Colors.black; Color borderDarkColor = Colors.black;
Color borderLightColor = Colors.grey; Color borderLightColor = Colors.grey;
Color borderSelectedColor = Colors.red; Color borderSelectedColor = Colors.red;
Color backgroundColor = Colors.grey[200]; Color backgroundColor = this.isFixed ? Colors.grey[300] : Colors.grey[100];
Border borders = Border( Border borders = Border(
top: BorderSide(width: borderWidth, color: ((this.row % size) == 0) ? borderDarkColor : borderLightColor), top: BorderSide(width: borderWidth, color: ((this.row % size) == 0) ? borderDarkColor : borderLightColor),
...@@ -54,7 +56,7 @@ class Cell { ...@@ -54,7 +56,7 @@ class Cell {
), ),
onTap: () { onTap: () {
if (this.col != null && this.row != null) { 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); myProvider.selectCell(this.col, this.row);
} else { } else {
myProvider.selectCell(null, null); myProvider.selectCell(null, null);
......
...@@ -51,7 +51,7 @@ class Home extends StatelessWidget { ...@@ -51,7 +51,7 @@ class Home extends StatelessWidget {
List row = []; List row = [];
for (var colIndex = 0; colIndex < pow(size, 2); colIndex++) { for (var colIndex = 0; colIndex < pow(size, 2); colIndex++) {
int value = int.parse(grid[index++]); int value = int.parse(grid[index++]);
row.add(Cell(value, colIndex, rowIndex)); row.add(Cell(value, colIndex, rowIndex, (value != 0)));
} }
cells.add(row); cells.add(row);
} }
...@@ -67,7 +67,7 @@ class Home extends StatelessWidget { ...@@ -67,7 +67,7 @@ class Home extends StatelessWidget {
for (var rowIndex = 0; rowIndex < pow(size, 2); rowIndex++) { for (var rowIndex = 0; rowIndex < pow(size, 2); rowIndex++) {
List row = []; List row = [];
for (var colIndex = 0; colIndex < pow(size, 2); colIndex++) { 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); cells.add(row);
} }
...@@ -231,7 +231,8 @@ class Home extends StatelessWidget { ...@@ -231,7 +231,8 @@ class Home extends StatelessWidget {
Cell( Cell(
isCellSelected ? value : 0, isCellSelected ? value : 0,
isCellSelected ? myProvider.currentCellCol : null, isCellSelected ? myProvider.currentCellCol : null,
isCellSelected ? myProvider.currentCellRow : null isCellSelected ? myProvider.currentCellRow : null,
false
).widgetUpdateValue(myProvider) ).widgetUpdateValue(myProvider)
] ]
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment