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

Merge branch '21-highlight-all-same-cells-as-current-selected' into 'master'

Resolve "Highlight all same cells as current selected"

Closes #21

See merge request !19
parents a62ccdcc 2671c276
No related branches found
No related tags found
1 merge request!19Resolve "Highlight all same cells as current selected"
Pipeline #1610 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.19 app.versionName=0.0.20
app.versionCode=19 app.versionCode=20
...@@ -35,7 +35,7 @@ class Cell { ...@@ -35,7 +35,7 @@ class Cell {
), ),
onTap: () { onTap: () {
if (col != null && row != null) { if (col != null && row != null) {
if (!this.isFixed && (col != myProvider.currentCellCol || row != myProvider.currentCellRow)) { if (col != myProvider.currentCellCol || row != myProvider.currentCellRow) {
myProvider.selectCell(col, row); myProvider.selectCell(col, row);
} else { } else {
myProvider.selectCell(null, null); myProvider.selectCell(null, null);
...@@ -51,6 +51,8 @@ class Cell { ...@@ -51,6 +51,8 @@ class Cell {
Color editableCellColorConflict = Colors.pink[100]; Color editableCellColorConflict = Colors.pink[100];
Color fixedCellColor = Colors.grey[300]; Color fixedCellColor = Colors.grey[300];
Color fixedCellColorConflict = Colors.pink[200]; Color fixedCellColorConflict = Colors.pink[200];
Color editableSelectedValueColor = Colors.green[100];
Color fixedSelectedValueColor = Colors.green[300];
Color backgroundColor = editableCellColor; Color backgroundColor = editableCellColor;
...@@ -66,6 +68,14 @@ class Cell { ...@@ -66,6 +68,14 @@ class Cell {
} }
} }
if (myProvider.showConflicts && (this.value == myProvider.currentCellValue)) {
if (this.isFixed) {
backgroundColor = fixedSelectedValueColor;
} else {
backgroundColor = editableSelectedValueColor;
}
}
return backgroundColor; return backgroundColor;
} }
......
...@@ -30,6 +30,7 @@ class Game { ...@@ -30,6 +30,7 @@ class Game {
Color borderColor = Colors.blue; Color borderColor = Colors.blue;
bool isCellSelected = (myProvider.currentCellCol != null && myProvider.currentCellRow != null); bool isCellSelected = (myProvider.currentCellCol != null && myProvider.currentCellRow != null);
bool isUpdatableCellSelected = isCellSelected ? !myProvider.cells[myProvider.currentCellRow][myProvider.currentCellCol].isFixed : false;
int maxValue = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical; int maxValue = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical;
return Container( return Container(
...@@ -45,7 +46,7 @@ class Game { ...@@ -45,7 +46,7 @@ class Game {
Column( Column(
children: [ children: [
Cell( Cell(
isCellSelected ? value : 0, isUpdatableCellSelected ? value : 0,
false false
).widgetUpdateValue(myProvider) ).widgetUpdateValue(myProvider)
] ]
......
...@@ -24,6 +24,7 @@ class Data extends ChangeNotifier { ...@@ -24,6 +24,7 @@ class Data extends ChangeNotifier {
List _cells = []; List _cells = [];
int _currentCellCol = null; int _currentCellCol = null;
int _currentCellRow = null; int _currentCellRow = null;
int _currentCellValue = null;
String get level => _level; String get level => _level;
set updateLevel(String level) { set updateLevel(String level) {
...@@ -104,9 +105,21 @@ class Data extends ChangeNotifier { ...@@ -104,9 +105,21 @@ class Data extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
int get currentCellValue => _currentCellValue;
set updateCurrentCellValue(int currentCellValue) {
_currentCellValue = currentCellValue;
notifyListeners();
}
selectCell(int col, int row) { selectCell(int col, int row) {
_currentCellCol = col; _currentCellCol = col;
_currentCellRow = row; _currentCellRow = row;
_currentCellValue = null;
if (row != null && col != null) {
if (_cells[row][col].value != 0) {
_currentCellValue = _cells[row][col].value;
}
}
notifyListeners(); notifyListeners();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment