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
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.47
app.versionCode=47
app.versionName=0.0.48
app.versionCode=48
Add a moves counter
Ajout d'un compteur de coups
......@@ -5,11 +5,12 @@ class Data extends ChangeNotifier {
// application configuration
int _tilesCount = 4;
// application data
// Game data
List _availableImages = [];
String _selectedImage = '';
List<MovingTile> _tiles = [];
double _tileImageSize = 1.0;
int _movesCount = 0;
// application state
bool _isShufflingBoard = false;
......@@ -19,6 +20,7 @@ class Data extends ChangeNotifier {
void updateSelectedImage(String value) {
_selectedImage = value;
_movesCount = 0;
notifyListeners();
}
......@@ -47,6 +49,16 @@ class Data extends ChangeNotifier {
notifyListeners();
}
int get movesCount => _movesCount;
void updateMovesCount(int movesCount) {
_movesCount = movesCount;
notifyListeners();
}
void incrementMovesCount() {
updateMovesCount(movesCount + 1);
}
bool get isShufflingBoard => _isShufflingBoard;
void updateIsShufflingBoard(bool isShuffling) {
......@@ -84,6 +96,7 @@ class Data extends ChangeNotifier {
_tiles[indexTile1].currentRow = _tiles[indexTile2].currentRow;
_tiles[indexTile2].currentRow = swapRow;
incrementMovesCount();
notifyListeners();
}
}
......@@ -144,7 +144,16 @@ class Game {
children: [
TableRow(
children: [
Column(children: []),
Column(children: [
Text(
myProvider.movesCount.toString(),
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
]),
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