diff --git a/android/gradle.properties b/android/gradle.properties index 4bb5439f682100f8ef4ba80a557fe4f2f0ab14c2..6bf54a6ed821c19f76d860d4a24e7c85d440b575 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.9 -app.versionCode=9 +app.versionName=0.0.10 +app.versionCode=10 diff --git a/lib/entities/cell.dart b/lib/entities/cell.dart index 9129f4da0bd6d77403423991776698996cea8b70..5a9a347619f649cd4cc142560c8df144dbc20819 100644 --- a/lib/entities/cell.dart +++ b/lib/entities/cell.dart @@ -14,16 +14,10 @@ class Cell { String imageAsset = this.getImageAssetName(myProvider); return Container( - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 100), - transitionBuilder: (Widget child, Animation<double> animation) { - return ScaleTransition(child: child, scale: animation); - }, - child: Image( - image: AssetImage(imageAsset), - fit: BoxFit.fill, - key: ValueKey<int>(imageAsset.hashCode), - ), + child: Image( + image: AssetImage(imageAsset), + fit: BoxFit.fill, + key: ValueKey<int>(imageAsset.hashCode), ), ); } diff --git a/lib/utils/board_utils.dart b/lib/utils/board_utils.dart index 21a892224ce09b1e72596c4878e0ed02c30959fd..c638652cb81e65b4f2fbb8ecc73f8c89d93adb88 100644 --- a/lib/utils/board_utils.dart +++ b/lib/utils/board_utils.dart @@ -1,4 +1,5 @@ import 'dart:math'; +import 'dart:async'; import '../entities/cell.dart'; import '../provider/data.dart'; @@ -56,16 +57,30 @@ class BoardUtils { List cellsToFill = BoardUtils.getSiblingFillableCells(myProvider, 0, 0, [[0, 0]]); int progressBeforeMove = cellsToFill.length; - for (var cellIndex = 0; cellIndex < cellsToFill.length; cellIndex++) { - myProvider.updateCellValue(cellsToFill[cellIndex][1], cellsToFill[cellIndex][0], value); - } - - int progressAfterMove = BoardUtils.getSiblingFillableCells(myProvider, 0, 0, [[0, 0]]).length; - int progressDelta = progressAfterMove - progressBeforeMove; - myProvider.updateProgressDelta(progressDelta); - myProvider.updateProgress(progressAfterMove); - - myProvider.incrementMovesCount(); + // Sort cells from the closest to the furthest, relatively to the top left corner + cellsToFill.sort((a, b) => (pow(a[0], 2) + pow(a[1], 2)).compareTo(pow(b[0], 2) + pow(b[1], 2))); + + Timer _timerAnimateBoard; + const interval = const Duration(milliseconds: 10); + int cellIndex = 0; + _timerAnimateBoard = new Timer.periodic( + interval, + (Timer timer) { + if (cellIndex < cellsToFill.length) { + myProvider.updateCellValue(cellsToFill[cellIndex][1], cellsToFill[cellIndex][0], value); + cellIndex++; + } else { + timer.cancel(); + + int progressAfterMove = BoardUtils.getSiblingFillableCells(myProvider, 0, 0, [[0, 0]]).length; + int progressDelta = progressAfterMove - progressBeforeMove; + myProvider.updateProgressDelta(progressDelta); + myProvider.updateProgress(progressAfterMove); + + myProvider.incrementMovesCount(); + } + }, + ); } static List getSiblingFillableCells(Data myProvider, row, col, siblingCells) {