diff --git a/android/gradle.properties b/android/gradle.properties index eeed3ef5a3d04530f5624cce71b2a57976938aed..ed86f0f26922ea79f4d0c8e0e84f6d74259952bb 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.21 -app.versionCode=21 +app.versionName=0.0.22 +app.versionCode=22 diff --git a/fastlane/metadata/android/en-US/changelogs/22.txt b/fastlane/metadata/android/en-US/changelogs/22.txt new file mode 100644 index 0000000000000000000000000000000000000000..f5f06e834c365053228f0df651e637514b8e3342 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/22.txt @@ -0,0 +1 @@ +Improve some code/design. diff --git a/fastlane/metadata/android/fr-FR/changelogs/22.txt b/fastlane/metadata/android/fr-FR/changelogs/22.txt new file mode 100644 index 0000000000000000000000000000000000000000..3be1a617fab1e3b8cfe9eb9d88ba825172be564f --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/22.txt @@ -0,0 +1 @@ +Améliorations de code et de design. diff --git a/lib/cubit/game_cubit.dart b/lib/cubit/game_cubit.dart index 8a2551c889ff95a9c6ae8d42389f6b1fc9a931df..3841e16671be04e785e4c20d6b6e85574cdaab0e 100644 --- a/lib/cubit/game_cubit.dart +++ b/lib/cubit/game_cubit.dart @@ -30,7 +30,6 @@ class GameCubit extends HydratedCubit<GameState> { position: state.currentGame.position, score: state.currentGame.score, ); - game.dump(); updateState(game); } diff --git a/lib/data/fetch_data_helper.dart b/lib/data/fetch_data_helper.dart index 2b5148c194338d497a9b2ef79d10ecddf0d0395f..fd7ac7ad4b769668e49a2174191195cab43eb513 100644 --- a/lib/data/fetch_data_helper.dart +++ b/lib/data/fetch_data_helper.dart @@ -35,8 +35,15 @@ class FetchDataHelper { final Map<String, dynamic> rawMappingItems = rawMapping['items'] as Map<String, dynamic>; rawMappingItems.forEach( (String itemName, itemMappings) { - List<String> rawIsCategories = itemMappings['is'] as List<String>; - List<String> rawIsNotCategories = itemMappings['isnot'] as List<String>; + final List<String> rawIsCategories = []; + for (var category in itemMappings['is'] as List<dynamic>) { + rawIsCategories.add(category.toString()); + } + + final List<String> rawIsNotCategories = []; + for (var category in itemMappings['isnot'] as List<dynamic>) { + rawIsNotCategories.add(category.toString()); + } _mapping.add(GameItem( item: Item( @@ -65,8 +72,8 @@ class FetchDataHelper { List<GameItem> items = _mapping; // Remove items without enough data - items.removeWhere((GameItem question) => - (question.isCategory.isEmpty || question.isNotCategory.isEmpty)); + items.removeWhere((GameItem gameItem) => + (gameItem.isCategory.isEmpty || gameItem.isNotCategory.isEmpty)); items.shuffle(); diff --git a/lib/models/game.dart b/lib/models/game.dart index 797ac0b2bac87b3e691bc1a4ad364a0e9e5ba38f..fcc9097db07c42cc69326884dc8032b799c4a720 100644 --- a/lib/models/game.dart +++ b/lib/models/game.dart @@ -64,7 +64,7 @@ class Game { isFinished = gameIsFinished; } - GameItem getCurrentQuestion() { + GameItem getCurrentGameItem() { return items[position - 1]; } diff --git a/lib/ui/screens/screen_game.dart b/lib/ui/screens/screen_game.dart index 154842b3c627266ad2e6727980a11c8e40480b27..f285927cf6a0afb91c3fa1de05158a850b6f4a44 100644 --- a/lib/ui/screens/screen_game.dart +++ b/lib/ui/screens/screen_game.dart @@ -16,20 +16,22 @@ class ScreenGame extends StatelessWidget { builder: (BuildContext context, GameState gameState) { final Game currentGame = gameState.currentGame; - return Container( - padding: const EdgeInsets.all(4), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 8), - const GameTopIndicatorWidget(), - const SizedBox(height: 8), - !currentGame.isFinished + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 8), + const GameTopIndicatorWidget(), + const SizedBox(height: 8), + Expanded( + child: !currentGame.isFinished ? const GameQuestionWidget() - : const GameBottomButtonsWidget(), - ], - ), + : const SizedBox(height: 8), + ), + !currentGame.isFinished + ? const SizedBox(height: 8) + : const GameBottomButtonsWidget(), + ], ); }, ); diff --git a/lib/ui/widgets/game_question.dart b/lib/ui/widgets/game_question.dart index 83153dc46dc7111b58321611d52d73ff7cb1d6fa..1f0c6da809f57bafac18f0d4f7803b3e7fbc9b41 100644 --- a/lib/ui/widgets/game_question.dart +++ b/lib/ui/widgets/game_question.dart @@ -16,12 +16,12 @@ class GameQuestionWidget extends StatelessWidget { builder: (BuildContext context, GameState gameState) { final Game currentGame = gameState.currentGame; - final GameItem currentQuestion = currentGame.getCurrentQuestion(); + final GameItem currentGameItem = currentGame.getCurrentGameItem(); return Column( children: [ OutlinedText( - text: currentQuestion.item.text, + text: currentGameItem.item.text, fontSize: 50, textColor: Theme.of(context).colorScheme.onSurface, ), @@ -36,7 +36,7 @@ class GameQuestionWidget extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(20)), color: Theme.of(context).colorScheme.inversePrimary, ), - child: GameButtonsYesNo(question: currentQuestion), + child: GameButtonsYesNo(gameItem: currentGameItem), ), ], ); diff --git a/lib/ui/widgets/games/buttons_yes_no.dart b/lib/ui/widgets/games/buttons_yes_no.dart index 44f92806d1f0990a2a21e9c89cff22182fa4ed5a..3efd687d692c3cf97ace1a1c7e0ac1c5bd7e129a 100644 --- a/lib/ui/widgets/games/buttons_yes_no.dart +++ b/lib/ui/widgets/games/buttons_yes_no.dart @@ -7,12 +7,11 @@ import 'package:unicons/unicons.dart'; import 'package:sortgame/cubit/game_cubit.dart'; import 'package:sortgame/models/data/category.dart'; import 'package:sortgame/models/data/game_item.dart'; -import 'package:sortgame/ui/widgets/helpers/outlined_text_widget.dart'; class GameButtonsYesNo extends StatelessWidget { - const GameButtonsYesNo({super.key, required this.question}); + const GameButtonsYesNo({super.key, required this.gameItem}); - final GameItem question; + final GameItem gameItem; @override Widget build(BuildContext context) { @@ -21,46 +20,47 @@ class GameButtonsYesNo extends StatelessWidget { final bool pickInIsCategory = Random().nextBool(); final List<Category> categories = - pickInIsCategory ? question.isCategory : question.isNotCategory; + pickInIsCategory ? gameItem.isCategory : gameItem.isNotCategory; categories.shuffle(); final Category category = categories.first; - final List<Widget> buttons = [ - IconButton( - color: Theme.of(context).colorScheme.onSurface, - iconSize: 80, - onPressed: () { - if (pickInIsCategory) { - gameCubit.increaseScore(1); - } - gameCubit.increasePosition(); - }, - icon: const Icon(UniconsLine.thumbs_up), - ), - IconButton( - color: Theme.of(context).colorScheme.onSurface, - iconSize: 80, - onPressed: () { - if (!pickInIsCategory) { - gameCubit.increaseScore(1); - } - gameCubit.increasePosition(); - }, - icon: const Icon(UniconsLine.thumbs_down), - ), - ]; - return Column( children: [ - OutlinedText( - text: category.text, - fontSize: 40, - textColor: Theme.of(context).colorScheme.onSurface, + Text( + category.text, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + fontSize: 40, + fontWeight: FontWeight.bold, + ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: buttons, + children: [ + IconButton( + color: Theme.of(context).colorScheme.onSurface, + iconSize: 80, + onPressed: () { + if (pickInIsCategory) { + gameCubit.increaseScore(1); + } + gameCubit.increasePosition(); + }, + icon: const Icon(UniconsLine.thumbs_up), + ), + IconButton( + color: Theme.of(context).colorScheme.onSurface, + iconSize: 80, + onPressed: () { + if (!pickInIsCategory) { + gameCubit.increaseScore(1); + } + gameCubit.increasePosition(); + }, + icon: const Icon(UniconsLine.thumbs_down), + ), + ], ) ], ); diff --git a/lib/ui/widgets/helpers/outlined_text_widget.dart b/lib/ui/widgets/helpers/outlined_text_widget.dart index bdf29f25e24105c2d7137b8d9cffd421ad9c0f46..79644ac8dfdf8c2f5f0e202225f02f62645aa281 100644 --- a/lib/ui/widgets/helpers/outlined_text_widget.dart +++ b/lib/ui/widgets/helpers/outlined_text_widget.dart @@ -18,7 +18,7 @@ class OutlinedText extends StatelessWidget { @override Widget build(BuildContext context) { - final double delta = fontSize / 35; + final double delta = fontSize / 30; return Text( text, diff --git a/pubspec.yaml b/pubspec.yaml index b43ae33c5ab0fd564a7a0b6a60595f3d540341b5..220bed61660eee38dc7609059903093f782f0aa6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A sorting game application. publish_to: 'none' -version: 0.0.21+21 +version: 0.0.22+22 environment: sdk: '^3.0.0'