Fix colors and make passphrase submittable via Enter #10

Merged
marco merged 1 commits from fix-dialog-colors into master 2024-05-11 18:01:26 +00:00

View File

@ -61,6 +61,7 @@ class _LobbySelectorState extends State<LobbySelector> {
context: context,
builder: (BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: AlertDialog(
title: const Text('Host or join?'),
actions: <Widget>[
@ -100,18 +101,14 @@ class _LobbySelectorState extends State<LobbySelector> {
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<LobbySelector> {
);
}
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!,