diff --git a/android/gradle.properties b/android/gradle.properties index 65eed6426393974efb5a056ec44936d42b5ef2a1..4bb5439f682100f8ef4ba80a557fe4f2f0ab14c2 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.8 -app.versionCode=8 +app.versionName=0.0.9 +app.versionCode=9 diff --git a/fastlane/metadata/android/en-US/changelogs/9.txt b/fastlane/metadata/android/en-US/changelogs/9.txt new file mode 100644 index 0000000000000000000000000000000000000000..bc4028620cbed9a198b9794c8541022c87a49706 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/9.txt @@ -0,0 +1 @@ +Fix end game display. diff --git a/fastlane/metadata/android/fr-FR/changelogs/9.txt b/fastlane/metadata/android/fr-FR/changelogs/9.txt new file mode 100644 index 0000000000000000000000000000000000000000..a1e93a9be5d7799719fe998a885a5e5df76fea4a --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/9.txt @@ -0,0 +1 @@ +Correction sur affichage de fin de partie. diff --git a/lib/ui/layouts/game_layout.dart b/lib/ui/layouts/game_layout.dart index 127b3098b425191df9c66dc2f3bd4b869530e3eb..92abe6c4569e53965192e18b63ec5efbcd422e37 100644 --- a/lib/ui/layouts/game_layout.dart +++ b/lib/ui/layouts/game_layout.dart @@ -1,3 +1,4 @@ +import 'package:awale/ui/widgets/game/game_player.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -15,6 +16,13 @@ class GameLayout extends StatelessWidget { builder: (BuildContext context, GameState gameState) { final Game currentGame = gameState.currentGame; + var screenSize = MediaQuery.of(context).size; + + const totalMargins = 9 * 4; + final availableHeight = screenSize.height - totalMargins; + + final double baseSize = availableHeight / 10; + return Container( alignment: AlignmentDirectional.topCenter, padding: const EdgeInsets.all(4), @@ -23,10 +31,32 @@ class GameLayout extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ const SizedBox(height: 8), - const GameBoardWidget(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + currentGame.isFinished + ? GameEndWidget( + playerIndex: 0, + widgetSize: baseSize, + ) + : GamePlayerWidget( + playerIndex: 0, + widgetSize: baseSize, + ), + GameBoardWidget(houseSize: baseSize), + currentGame.isFinished + ? GameEndWidget( + playerIndex: 1, + widgetSize: baseSize, + ) + : GamePlayerWidget( + playerIndex: 1, + widgetSize: baseSize, + ), + ], + ), const SizedBox(height: 8), - // const Expanded(child: SizedBox.shrink()), - currentGame.isFinished ? const GameEndWidget() : const SizedBox.shrink(), ], ), ); diff --git a/lib/ui/widgets/game/game_board.dart b/lib/ui/widgets/game/game_board.dart index 578fc06aac52420243cc0ff475050850489b5064..d83690cd7488f1b01f14854c3d08c1170cf562a6 100644 --- a/lib/ui/widgets/game/game_board.dart +++ b/lib/ui/widgets/game/game_board.dart @@ -2,154 +2,70 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:awale/cubit/game_cubit.dart'; -import 'package:awale/models/game/game.dart'; import 'package:awale/ui/widgets/game/game_house.dart'; -import 'package:awale/ui/widgets/game/game_player.dart'; import 'package:awale/ui/widgets/game/game_score.dart'; class GameBoardWidget extends StatelessWidget { - const GameBoardWidget({super.key}); + const GameBoardWidget({ + super.key, + required this.houseSize, + }); + + final double houseSize; @override Widget build(BuildContext context) { return Center( child: BlocBuilder<GameCubit, GameState>( builder: (BuildContext context, GameState gameState) { - final Game currentGame = gameState.currentGame; final Color borderColor = Theme.of(context).colorScheme.onSurface; - var screenSize = MediaQuery.of(context).size; - - const totalMargins = 9 * 4; - final availableHeight = screenSize.height - totalMargins; - - final double houseHeight = availableHeight / 10; - final double houseWidth = houseHeight; + Widget house(int houseIndex) { + return SizedBox( + width: houseSize, + height: houseSize, + child: GameHouseWidget(cellIndex: houseIndex), + ); + } - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - currentGame.isFinished - ? const SizedBox.shrink() - : SizedBox( - width: houseWidth, - height: houseHeight, - child: const GamePlayerWidget(playerIndex: 0), - ), - Container( - margin: const EdgeInsets.all(2), - padding: const EdgeInsets.all(2), - decoration: BoxDecoration( - color: borderColor, - borderRadius: BorderRadius.circular(40), - border: Border.all( - color: borderColor, - width: 6, - ), + return Container( + margin: const EdgeInsets.all(2), + padding: const EdgeInsets.all(2), + decoration: BoxDecoration( + color: borderColor, + borderRadius: BorderRadius.circular(40), + border: Border.all( + color: borderColor, + width: 6, + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 2 * houseSize, + height: houseSize, + child: const GameScoreWidget(playerIndex: 1), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + Table( + defaultColumnWidth: const IntrinsicColumnWidth(), children: [ - SizedBox( - width: 2 * houseWidth, - height: houseHeight, - child: const GameScoreWidget(playerIndex: 1), - ), - Table( - defaultColumnWidth: const IntrinsicColumnWidth(), - children: [ - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 0), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 11), - ), - ]), - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 1), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 10), - ), - ]), - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 2), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 9), - ), - ]), - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 3), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 8), - ), - ]), - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 4), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 7), - ), - ]), - TableRow(children: [ - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 5), - ), - SizedBox( - width: houseWidth, - height: houseHeight, - child: const GameHouseWidget(cellIndex: 6), - ), - ]), - ], - ), - SizedBox( - width: 2 * houseWidth, - height: houseHeight, - child: const GameScoreWidget(playerIndex: 0), - ), + TableRow(children: [house(0), house(11)]), + TableRow(children: [house(1), house(10)]), + TableRow(children: [house(2), house(9)]), + TableRow(children: [house(3), house(8)]), + TableRow(children: [house(4), house(7)]), + TableRow(children: [house(5), house(6)]), ], ), - ), - currentGame.isFinished - ? const SizedBox.shrink() - : SizedBox( - width: houseWidth, - height: houseHeight, - child: const GamePlayerWidget(playerIndex: 1), - ), - ], + SizedBox( + width: 2 * houseSize, + height: houseSize, + child: const GameScoreWidget(playerIndex: 0), + ), + ], + ), ); }, ), diff --git a/lib/ui/widgets/game/game_end.dart b/lib/ui/widgets/game/game_end.dart index 12add5f0d2a92c88b29e0eded194067bcd15bb25..81e15536e13b42df9422192613beb7b2d0e1045d 100644 --- a/lib/ui/widgets/game/game_end.dart +++ b/lib/ui/widgets/game/game_end.dart @@ -3,10 +3,16 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:awale/cubit/game_cubit.dart'; import 'package:awale/models/game/game.dart'; -import 'package:awale/ui/widgets/actions/button_game_quit.dart'; class GameEndWidget extends StatelessWidget { - const GameEndWidget({super.key}); + const GameEndWidget({ + super.key, + required this.playerIndex, + required this.widgetSize, + }); + + final int playerIndex; + final double widgetSize; @override Widget build(BuildContext context) { @@ -14,48 +20,60 @@ class GameEndWidget extends StatelessWidget { builder: (BuildContext context, GameState gameState) { final Game currentGame = gameState.currentGame; - const Image imageWinner = Image( - image: AssetImage('assets/ui/game_win.png'), - fit: BoxFit.fill, - ); - const Image imageLoser = Image( - image: AssetImage('assets/ui/game_fail.png'), - fit: BoxFit.fill, - ); - const Image imageDraw = Image( - image: AssetImage('assets/ui/game_draw.png'), + final String playerImageAsset = + currentGame.scores[playerIndex] == currentGame.scores[1 - playerIndex] + ? 'assets/ui/game_draw.png' + : (currentGame.scores[playerIndex] > currentGame.scores[1 - playerIndex] + ? 'assets/ui/game_win.png' + : 'assets/ui/game_fail.png'); + + final Image playerImage = Image( + image: AssetImage(playerImageAsset), fit: BoxFit.fill, + height: widgetSize, ); - final Image player1 = currentGame.scores[0] == currentGame.scores[1] - ? imageDraw - : (currentGame.scores[0] > currentGame.scores[1] ? imageWinner : imageLoser); - final Image player2 = currentGame.scores[0] == currentGame.scores[1] - ? imageDraw - : (currentGame.scores[1] > currentGame.scores[0] ? imageWinner : imageLoser); - - return Container( - margin: const EdgeInsets.all(2), - padding: const EdgeInsets.all(2), - child: Table( - defaultColumnWidth: const IntrinsicColumnWidth(), - children: [ - TableRow( - children: [ - Column( - children: [player1], - ), - Column( - children: [ - currentGame.animationInProgress ? imageWinner : const QuitGameButton() - ], - ), - Column( - children: [player2], - ), - ], - ), - ], + return RotatedBox( + quarterTurns: 1 + 2 * playerIndex, + child: Container( + margin: const EdgeInsets.all(2), + padding: const EdgeInsets.all(2), + height: widgetSize, + child: Table( + defaultColumnWidth: const IntrinsicColumnWidth(), + children: [ + TableRow( + children: [ + Column( + children: [playerImage], + ), + Column( + children: [ + currentGame.animationInProgress + ? Image( + image: const AssetImage('assets/ui/placeholder.png'), + fit: BoxFit.fill, + height: widgetSize, + ) + : ElevatedButton( + child: Image( + image: const AssetImage('assets/ui/button_back.png'), + fit: BoxFit.fill, + height: widgetSize, + ), + onPressed: () { + BlocProvider.of<GameCubit>(context).quitGame(); + }, + ) + ], + ), + Column( + children: [playerImage], + ), + ], + ), + ], + ), ), ); }, diff --git a/lib/ui/widgets/game/game_player.dart b/lib/ui/widgets/game/game_player.dart index 84fed3c0a06c04b1858d7684b4f80b1701983b71..2806e67be491435ef99bb0026b0d3578b824a1a6 100644 --- a/lib/ui/widgets/game/game_player.dart +++ b/lib/ui/widgets/game/game_player.dart @@ -10,9 +10,11 @@ class GamePlayerWidget extends StatelessWidget { const GamePlayerWidget({ super.key, required this.playerIndex, + required this.widgetSize, }); final int playerIndex; + final double widgetSize; @override Widget build(BuildContext context) { @@ -37,6 +39,8 @@ class GamePlayerWidget extends StatelessWidget { width: 6, ), ), + width: widgetSize, + height: widgetSize, child: GameSeedsWidget(seedsCount: seedsCount), ); }, diff --git a/pubspec.yaml b/pubspec.yaml index b49be71e1b70474b0b3be5df9d15667eae7b0e90..bf3eaabff1b368f5e00647ac13f7c523c895bc48 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Awale game publish_to: "none" -version: 0.0.8+8 +version: 0.0.9+9 environment: sdk: "^3.0.0"