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

Add a "moves count" indicator

parent 3f55bb0f
No related branches found
No related tags found
1 merge request!49Resolve "Add a "moves count" indicator"
Pipeline #3134 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.47 app.versionName=0.0.48
app.versionCode=47 app.versionCode=48
Add a moves counter
Ajout d'un compteur de coups
...@@ -5,11 +5,12 @@ class Data extends ChangeNotifier { ...@@ -5,11 +5,12 @@ class Data extends ChangeNotifier {
// application configuration // application configuration
int _tilesCount = 4; int _tilesCount = 4;
// application data // Game data
List _availableImages = []; List _availableImages = [];
String _selectedImage = ''; String _selectedImage = '';
List<MovingTile> _tiles = []; List<MovingTile> _tiles = [];
double _tileImageSize = 1.0; double _tileImageSize = 1.0;
int _movesCount = 0;
// application state // application state
bool _isShufflingBoard = false; bool _isShufflingBoard = false;
...@@ -19,6 +20,7 @@ class Data extends ChangeNotifier { ...@@ -19,6 +20,7 @@ class Data extends ChangeNotifier {
void updateSelectedImage(String value) { void updateSelectedImage(String value) {
_selectedImage = value; _selectedImage = value;
_movesCount = 0;
notifyListeners(); notifyListeners();
} }
...@@ -47,6 +49,16 @@ class Data extends ChangeNotifier { ...@@ -47,6 +49,16 @@ class Data extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
int get movesCount => _movesCount;
void updateMovesCount(int movesCount) {
_movesCount = movesCount;
notifyListeners();
}
void incrementMovesCount() {
updateMovesCount(movesCount + 1);
}
bool get isShufflingBoard => _isShufflingBoard; bool get isShufflingBoard => _isShufflingBoard;
void updateIsShufflingBoard(bool isShuffling) { void updateIsShufflingBoard(bool isShuffling) {
...@@ -84,6 +96,7 @@ class Data extends ChangeNotifier { ...@@ -84,6 +96,7 @@ class Data extends ChangeNotifier {
_tiles[indexTile1].currentRow = _tiles[indexTile2].currentRow; _tiles[indexTile1].currentRow = _tiles[indexTile2].currentRow;
_tiles[indexTile2].currentRow = swapRow; _tiles[indexTile2].currentRow = swapRow;
incrementMovesCount();
notifyListeners(); notifyListeners();
} }
} }
...@@ -144,7 +144,16 @@ class Game { ...@@ -144,7 +144,16 @@ class Game {
children: [ children: [
TableRow( TableRow(
children: [ children: [
Column(children: []), Column(children: [
Text(
myProvider.movesCount.toString(),
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
]),
Column(children: []), Column(children: []),
], ],
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment