Commit 86c99335 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '55-add-a-moves-count-indicator' into 'master'

Resolve "Add a "moves count" indicator"

Closes #55

See merge request !49
parents 3f55bb0f 99c1d1d2
Pipeline #3152 canceled with stages
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
......@@ -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: []),
],
),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment