From 32caf86f7f5829a74fafcfcb1cadf8ffdafe7585 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 11 May 2024 19:58:29 +0200 Subject: [PATCH] Fix colors and make passphrase submittable via Enter With this change, the lobby selector gets its dark background back. Also, now the passphrase can be submitted by pressing Enter and not only by clicking the 'check' icon. --- lib/pages/lobby_selector.dart | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/pages/lobby_selector.dart b/lib/pages/lobby_selector.dart index 9748407..a0232a0 100644 --- a/lib/pages/lobby_selector.dart +++ b/lib/pages/lobby_selector.dart @@ -61,6 +61,7 @@ class _LobbySelectorState extends State { context: context, builder: (BuildContext context) { return Scaffold( + backgroundColor: Colors.transparent, body: AlertDialog( title: const Text('Host or join?'), actions: [ @@ -100,18 +101,14 @@ class _LobbySelectorState extends State { title: const Text('Enter the passphrase here:'), content: TextField( controller: phraseController, + onSubmitted: (val) { + submitPassphrase(builderContext); + }, decoration: InputDecoration( hintText: 'Enter passphrase here', suffixIcon: IconButton( onPressed: () { - joinGameFuture = joinPrivateGame(builderContext); - joinGameFuture.then((value) { - if (value != null) { - phraseController.clear(); - builderContext.pop(); - switchToGame(value); - } - }); + submitPassphrase(builderContext); }, icon: const Icon(Icons.check), )), @@ -132,6 +129,17 @@ class _LobbySelectorState extends State { ); } + void submitPassphrase(BuildContext ctx) { + joinGameFuture = joinPrivateGame(ctx); + joinGameFuture.then((value) { + if (value != null) { + phraseController.clear(); + ctx.pop(); + switchToGame(value); + } + }); + } + void switchToGame(PlayerInfo info) { var chessGameArgs = ChessGameArguments( lobbyID: info.lobbyID!,