diff --git a/android/gradle.properties b/android/gradle.properties index 81949dfd2077495aaea8a6bc81ad9c75442f9ebb..957c40bc42f3a742d2266dc3a403ad014458ba3f 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.14 -app.versionCode=14 +app.versionName=0.0.15 +app.versionCode=15 diff --git a/fastlane/metadata/android/en-US/changelogs/15.txt b/fastlane/metadata/android/en-US/changelogs/15.txt new file mode 100644 index 0000000000000000000000000000000000000000..3271f203047b8cf8d2bb5bc049e08cc08127fc49 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/15.txt @@ -0,0 +1 @@ +Animate while picking next move. diff --git a/fastlane/metadata/android/fr-FR/changelogs/15.txt b/fastlane/metadata/android/fr-FR/changelogs/15.txt new file mode 100644 index 0000000000000000000000000000000000000000..58cb13f0c55a4cf956e0cea3c3d545b5223bace8 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/15.txt @@ -0,0 +1 @@ +Animation pendant la sélection du prochain mouvement. diff --git a/lib/ui/widgets/game.dart b/lib/ui/widgets/game.dart index 51d9077828e4d5d409d419cb4f29a743705834a4..5019d58fa87f585a93a2df99193c552821bbc67b 100644 --- a/lib/ui/widgets/game.dart +++ b/lib/ui/widgets/game.dart @@ -1,3 +1,6 @@ +import 'dart:async'; +import 'dart:math'; + import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,21 +18,65 @@ class Game extends StatefulWidget { class _GameState extends State<Game> { final player = AudioPlayer(); + bool shuffling = false; + Move? shuffledMove; + + void animate() { + const interval = const Duration(milliseconds: 200); + int iterationsLeft = 10; + + shuffling = true; + shuffledMove = null; + + setState(() {}); + Timer.periodic( + interval, + (Timer timer) { + if (iterationsLeft > 1) { + shuffledMove = Move.pickRandom(); + } + + if (iterationsLeft == 1) { + shuffledMove = null; + } + + if (iterationsLeft == 0) { + shuffledMove = null; + pickNewMove(); + + timer.cancel(); + shuffling = false; + } + + setState(() {}); + iterationsLeft--; + }, + ); + } + + void pickNewMove() { + Move newMove = Move.pickRandom(); + + BlocProvider.of<GameCubit>(context).setValues( + move: newMove, + ); + + player.play(AssetSource(newMove.toSoundAsset())); + } @override Widget build(BuildContext context) { return BlocBuilder<GameCubit, GameState>( builder: (BuildContext context, GameState gameState) { return GestureDetector( - child: ShowMove(move: gameState.move ?? Move.createNull()), + child: shuffling + ? Transform.rotate( + angle: 2 * pi * Random().nextDouble(), + child: ShowMove(move: shuffledMove ?? Move.createNull()), + ) + : ShowMove(move: gameState.move ?? Move.createNull()), onTap: () { - Move newMove = Move.pickRandom(); - - BlocProvider.of<GameCubit>(context).setValues( - move: newMove, - ); - - player.play(AssetSource(newMove.toSoundAsset())); + animate(); }, ); }, diff --git a/pubspec.yaml b/pubspec.yaml index f751a47966215180a7290db6e9d97bd72f109777..a2627490a05b5fff73982c4397cf90dbc14d1928 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: twister game companion publish_to: 'none' -version: 0.0.14+14 +version: 0.0.15+15 environment: sdk: '^3.0.0'