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.
This commit is contained in:
Marco 2024-05-11 19:58:29 +02:00
parent 67a4be17cd
commit 32caf86f7f

View File

@ -61,6 +61,7 @@ class _LobbySelectorState extends State<LobbySelector> {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent,
body: AlertDialog( body: AlertDialog(
title: const Text('Host or join?'), title: const Text('Host or join?'),
actions: <Widget>[ actions: <Widget>[
@ -100,18 +101,14 @@ class _LobbySelectorState extends State<LobbySelector> {
title: const Text('Enter the passphrase here:'), title: const Text('Enter the passphrase here:'),
content: TextField( content: TextField(
controller: phraseController, controller: phraseController,
onSubmitted: (val) {
submitPassphrase(builderContext);
},
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter passphrase here', hintText: 'Enter passphrase here',
suffixIcon: IconButton( suffixIcon: IconButton(
onPressed: () { onPressed: () {
joinGameFuture = joinPrivateGame(builderContext); submitPassphrase(builderContext);
joinGameFuture.then((value) {
if (value != null) {
phraseController.clear();
builderContext.pop();
switchToGame(value);
}
});
}, },
icon: const Icon(Icons.check), icon: const Icon(Icons.check),
)), )),
@ -132,6 +129,17 @@ class _LobbySelectorState extends State<LobbySelector> {
); );
} }
void submitPassphrase(BuildContext ctx) {
joinGameFuture = joinPrivateGame(ctx);
joinGameFuture.then((value) {
if (value != null) {
phraseController.clear();
ctx.pop();
switchToGame(value);
}
});
}
void switchToGame(PlayerInfo info) { void switchToGame(PlayerInfo info) {
var chessGameArgs = ChessGameArguments( var chessGameArgs = ChessGameArguments(
lobbyID: info.lobbyID!, lobbyID: info.lobbyID!,