mchess-client/lib/pages/lobby_selector.dart
2023-06-30 01:49:18 +02:00

80 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class LobbySelector extends StatelessWidget {
const LobbySelector({super.key});
final buttonStyle = const ButtonStyle();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
context.push('/prepareRandom');
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.question_mark),
SizedBox(
width: 10,
),
Text('Random')
],
),
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
_dialogBuilder(context);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.lock),
SizedBox(
width: 10,
),
Text('Private')
],
),
),
],
),
),
);
}
Future<void> _dialogBuilder(BuildContext context) {
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Host or join?'),
actions: <Widget>[
TextButton(
child: const Text('Host'),
onPressed: () {
context.push('/host');
},
),
TextButton(
child: const Text('Join'),
onPressed: () {
context.push('/join');
},
),
],
);
},
);
}
}