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

Disable buttons while fill animation is in progress

parent d8557737
No related branches found
No related tags found
1 merge request!15Resolve "Disable fill buttons while animation is in progress"
Pipeline #2804 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.14 app.versionName=0.0.15
app.versionCode=14 app.versionCode=15
...@@ -39,7 +39,9 @@ class Cell { ...@@ -39,7 +39,9 @@ class Cell {
fit: BoxFit.fill fit: BoxFit.fill
), ),
onTap: () { onTap: () {
if (!myProvider.animationInProgress) {
BoardUtils.fillBoardFromFirstCell(myProvider, this.value); BoardUtils.fillBoardFromFirstCell(myProvider, this.value);
}
}, },
) )
); );
......
...@@ -32,6 +32,7 @@ class Data extends ChangeNotifier { ...@@ -32,6 +32,7 @@ class Data extends ChangeNotifier {
// Game data // Game data
bool _gameIsRunning = false; bool _gameIsRunning = false;
bool _animationInProgress = false;
bool _gameWon = false; bool _gameWon = false;
int _boardSize = 0; int _boardSize = 0;
int _colorsCount = 0; int _colorsCount = 0;
...@@ -224,6 +225,12 @@ class Data extends ChangeNotifier { ...@@ -224,6 +225,12 @@ class Data extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool get animationInProgress => _animationInProgress;
void updateAnimationInProgress(bool animationInProgress) {
_animationInProgress = animationInProgress;
notifyListeners();
}
void resetGame() { void resetGame() {
_gameIsRunning = false; _gameIsRunning = false;
_gameWon = false; _gameWon = false;
......
...@@ -66,6 +66,7 @@ class BoardUtils { ...@@ -66,6 +66,7 @@ class BoardUtils {
Timer _timerAnimateBoard; Timer _timerAnimateBoard;
const interval = const Duration(milliseconds: 10); const interval = const Duration(milliseconds: 10);
int cellIndex = 0; int cellIndex = 0;
myProvider.updateAnimationInProgress(true);
_timerAnimateBoard = new Timer.periodic( _timerAnimateBoard = new Timer.periodic(
interval, interval,
(Timer timer) { (Timer timer) {
...@@ -81,6 +82,7 @@ class BoardUtils { ...@@ -81,6 +82,7 @@ class BoardUtils {
myProvider.updateProgress(progressAfterMove); myProvider.updateProgress(progressAfterMove);
myProvider.incrementMovesCount(); myProvider.incrementMovesCount();
myProvider.updateAnimationInProgress(false);
if (BoardUtils.checkBoardIsSolved(myProvider)) { if (BoardUtils.checkBoardIsSolved(myProvider)) {
myProvider.updateGameWon(true); myProvider.updateGameWon(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment