diff --git a/android/gradle.properties b/android/gradle.properties index 9742e8d9ac872ece07c6ae62a041bc05c2a8fcc6..4878903faeac600353ec559be514de7d30376f55 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.31 -app.versionCode=31 +app.versionName=0.0.32 +app.versionCode=32 diff --git a/fastlane/metadata/android/en-US/changelogs/32.txt b/fastlane/metadata/android/en-US/changelogs/32.txt new file mode 100644 index 0000000000000000000000000000000000000000..51fe2dc4f0dc77f228708983631e8236b34e42cf --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/32.txt @@ -0,0 +1 @@ +Show allowed values in select value bar diff --git a/fastlane/metadata/android/fr-FR/changelogs/32.txt b/fastlane/metadata/android/fr-FR/changelogs/32.txt new file mode 100644 index 0000000000000000000000000000000000000000..e5484ab29da00e68019f30246230e8fede66439a --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/32.txt @@ -0,0 +1 @@ +Mise en évidence des valeurs autorisées dans la barre de sélection des valeurs diff --git a/lib/entities/cell.dart b/lib/entities/cell.dart index bb56ed976caa2481cb853077bcbf9db6d67d0012..2a76eb52c6f73cfb7ada3e3d8ba4deca93c53b03 100644 --- a/lib/entities/cell.dart +++ b/lib/entities/cell.dart @@ -90,9 +90,21 @@ class Cell { imageAsset = 'assets/skins/' + myProvider.skin + '_' + this.value.toString() + '.png'; } + Color backgroundColor = Colors.grey[200]; + + if ( + myProvider.showConflicts + && myProvider.currentCellCol != null + && myProvider.currentCellRow != null + ) { + if (!BoardUtils.isValueAllowed(myProvider, myProvider.currentCellCol, myProvider.currentCellRow, this.value)) { + backgroundColor = Colors.pink[100]; + } + } + return Container( decoration: BoxDecoration( - color: Colors.grey[200], + color: backgroundColor, border: Border.all( color: Colors.black, width: 2, diff --git a/lib/utils/board_utils.dart b/lib/utils/board_utils.dart index 7e696d35a8c379b79fca7c12073420c0621229ae..baa0527133922f98ce4057ad635d0f5e5a16c364 100644 --- a/lib/utils/board_utils.dart +++ b/lib/utils/board_utils.dart @@ -178,6 +178,85 @@ class BoardUtils { return true; } + static bool isValueAllowed(Data myProvider, int candidateCol, int candidateRow, int candidateValue) { + if (candidateValue == 0) { + return true; + } + + List cells = myProvider.cells; + + int blockSizeHorizontal = myProvider.blockSizeHorizontal; + int blockSizeVertical = myProvider.blockSizeVertical; + + int boardSize = blockSizeHorizontal * blockSizeVertical; + + // check lines does not contains a value twice + for (var row = 0; row < boardSize; row++) { + List values = []; + for (var col = 0; col < boardSize; col++) { + int value = cells[row][col].value; + if (row == candidateRow && col == candidateCol) { + value = candidateValue; + } + if (value != 0) { + values.add(value); + } + } + List distinctValues = values.toSet().toList(); + if (values.length != distinctValues.length) { + return false; + } + } + + // check columns does not contains a value twice + for (var col = 0; col < boardSize; col++) { + List values = []; + for (var row = 0; row < boardSize; row++) { + int value = cells[row][col].value; + if (row == candidateRow && col == candidateCol) { + value = candidateValue; + } + if (value != 0) { + values.add(value); + } + } + List distinctValues = values.toSet().toList(); + if (values.length != distinctValues.length) { + return false; + } + } + + // check blocks does not contains a value twice + int horizontalBlocksCount = blockSizeVertical; + int verticalBlocksCount = blockSizeHorizontal; + for (var blockRow = 0; blockRow < verticalBlocksCount; blockRow++) { + for (var blockCol = 0; blockCol < horizontalBlocksCount; blockCol++) { + List values = []; + + for (var rowInBlock = 0; rowInBlock < blockSizeVertical; rowInBlock++) { + for (var colInBlock = 0; colInBlock < blockSizeHorizontal; colInBlock++) { + int row = (blockRow * blockSizeVertical) + rowInBlock; + int col = (blockCol * blockSizeHorizontal) + colInBlock; + int value = cells[row][col].value; + if (row == candidateRow && col == candidateCol) { + value = candidateValue; + } + if (value != 0) { + values.add(value); + } + } + } + + List distinctValues = values.toSet().toList(); + if (values.length != distinctValues.length) { + return false; + } + } + } + + return true; + } + static void computeConflictsInBoard(Data myProvider) { List cells = myProvider.cells;