diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index bedf95f..7346343 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -97,7 +97,7 @@ }, "end_of_game_title": "End of Game", - "end_of_game_message": "{names} won the game with {points} points. Congratulations!", + "end_of_game_message": "{playerCount, plural, =1{{names} won the game with {points} points. Congratulations!} other{{names} won the game with {points} points. Congratulations to everyone!}}", "@end_of_game_message": { "placeholders": { "playerCount": { diff --git a/lib/l10n/generated/app_localizations_en.dart b/lib/l10n/generated/app_localizations_en.dart index 837c83e..eb341af 100644 --- a/lib/l10n/generated/app_localizations_en.dart +++ b/lib/l10n/generated/app_localizations_en.dart @@ -210,7 +210,14 @@ class AppLocalizationsEn extends AppLocalizations { @override String end_of_game_message(int playerCount, String names, int points) { - return '$names won the game with $points points. Congratulations!'; + String _temp0 = intl.Intl.pluralLogic( + playerCount, + locale: localeName, + other: + '$names won the game with $points points. Congratulations to everyone!', + one: '$names won the game with $points points. Congratulations!', + ); + return '$_temp0'; } @override diff --git a/lib/presentation/views/active_game_view.dart b/lib/presentation/views/active_game_view.dart index 25e88a7..230603c 100644 --- a/lib/presentation/views/active_game_view.dart +++ b/lib/presentation/views/active_game_view.dart @@ -49,7 +49,10 @@ class _ActiveGameViewState extends State { gameSession.playerScores, sortedPlayerIndices); return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( - middle: Text(gameSession.gameTitle), + middle: Text( + gameSession.gameTitle, + overflow: TextOverflow.ellipsis, + ), ), child: SafeArea( child: SingleChildScrollView( diff --git a/lib/presentation/views/create_game_view.dart b/lib/presentation/views/create_game_view.dart index 236baff..dcaa210 100644 --- a/lib/presentation/views/create_game_view.dart +++ b/lib/presentation/views/create_game_view.dart @@ -38,11 +38,16 @@ class CreateGameView extends StatefulWidget { } class _CreateGameViewState extends State { + final TextEditingController _gameTitleTextController = + TextEditingController(); + + /// List of text controllers for player names. final List _playerNameTextControllers = [ TextEditingController() ]; - final TextEditingController _gameTitleTextController = - TextEditingController(); + + /// List of focus nodes for player name text fields. + final List _playerNameFocusNodes = [FocusNode()]; /// Maximum number of players allowed in the game. final int maxPlayers = 5; @@ -94,11 +99,19 @@ class _CreateGameViewState extends State { padding: const EdgeInsets.fromLTRB(15, 10, 10, 0), child: CupertinoTextField( decoration: const BoxDecoration(), - maxLength: 16, + maxLength: 20, prefix: Text(AppLocalizations.of(context).name), textAlign: TextAlign.right, placeholder: AppLocalizations.of(context).game_title, controller: _gameTitleTextController, + onSubmitted: (_) { + _playerNameFocusNodes.isNotEmpty + ? _playerNameFocusNodes[0].requestFocus() + : FocusScope.of(context).unfocus(); + }, + textInputAction: _playerNameFocusNodes.isNotEmpty + ? TextInputAction.next + : TextInputAction.done, ), ), Padding( @@ -177,11 +190,24 @@ class _CreateGameViewState extends State { Expanded( child: CupertinoTextField( controller: _playerNameTextControllers[index], + focusNode: _playerNameFocusNodes[index], maxLength: 12, placeholder: '${AppLocalizations.of(context).player} ${index + 1}', padding: const EdgeInsets.all(12), decoration: const BoxDecoration(), + textInputAction: + index + 1 < _playerNameTextControllers.length + ? TextInputAction.next + : TextInputAction.done, + onSubmitted: (_) { + if (index + 1 < _playerNameFocusNodes.length) { + _playerNameFocusNodes[index + 1] + .requestFocus(); + } else { + FocusScope.of(context).unfocus(); + } + }, ), ), AnimatedOpacity( @@ -207,38 +233,56 @@ class _CreateGameViewState extends State { }), Padding( padding: const EdgeInsets.fromLTRB(8, 0, 8, 50), - child: Center( - child: SizedBox( - width: double.infinity, - child: CupertinoButton( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - AppLocalizations.of(context).add_player, - style: TextStyle(color: CustomTheme.primaryColor), - ), - const SizedBox(width: 8), - Icon( - CupertinoIcons.add_circled_solid, + child: Stack( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + CupertinoButton( + padding: EdgeInsets.zero, + onPressed: null, + child: Icon( + CupertinoIcons.plus_circle_fill, color: CustomTheme.primaryColor, size: 25, ), - ], - ), - onPressed: () { - if (_playerNameTextControllers.length < maxPlayers) { - setState(() { - _playerNameTextControllers - .add(TextEditingController()); - }); - } else { - _showFeedbackDialog(CreateStatus.maxPlayers); - } - }, + ), + ], ), - ), + Center( + child: CupertinoButton( + padding: const EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Center( + child: Text( + AppLocalizations.of(context).add_player, + style: TextStyle( + color: CustomTheme.primaryColor), + ), + ), + ), + ], + ), + onPressed: () { + if (_playerNameTextControllers.length < maxPlayers) { + setState(() { + _playerNameTextControllers + .add(TextEditingController()); + _playerNameFocusNodes.add(FocusNode()); + }); + WidgetsBinding.instance.addPostFrameCallback((_) { + _playerNameFocusNodes.last.requestFocus(); + }); + } else { + _showFeedbackDialog(CreateStatus.maxPlayers); + } + }, + ), + ), + ], ), ), Padding( @@ -415,6 +459,9 @@ class _CreateGameViewState extends State { for (var controller in _playerNameTextControllers) { controller.dispose(); } + for (var focusnode in _playerNameFocusNodes) { + focusnode.dispose(); + } super.dispose(); } diff --git a/lib/presentation/views/main_menu_view.dart b/lib/presentation/views/main_menu_view.dart index 6d8262b..21deb97 100644 --- a/lib/presentation/views/main_menu_view.dart +++ b/lib/presentation/views/main_menu_view.dart @@ -144,6 +144,9 @@ class _MainMenuViewState extends State { )), trailing: Row( children: [ + const SizedBox( + width: 5, + ), Text('${session.roundNumber}'), const SizedBox(width: 3), const Icon(CupertinoIcons diff --git a/pubspec.yaml b/pubspec.yaml index 01d641d..1ff6a27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: cabo_counter description: "Mobile app for the card game Cabo" publish_to: 'none' -version: 0.5.2+581 +version: 0.5.3+589 environment: sdk: ^3.5.4