mchess-client/lib/utils/chess_router.dart

58 lines
1.5 KiB
Dart
Raw Normal View History

2022-12-25 15:16:23 +00:00
import 'package:go_router/go_router.dart';
2023-06-29 23:49:18 +00:00
import 'package:mchess/pages/chess_game.dart';
import 'package:mchess/pages/join_game.dart';
2022-12-25 15:16:23 +00:00
import 'package:mchess/pages/lobby_selector.dart';
2023-06-29 23:49:18 +00:00
import 'package:mchess/pages/host_game.dart';
import 'package:mchess/pages/prepare_random_game.dart';
2022-12-25 15:16:23 +00:00
2022-12-25 19:30:42 +00:00
class ChessAppRouter {
static final ChessAppRouter _instance = ChessAppRouter._internal();
ChessAppRouter._internal();
static ChessAppRouter getInstance() {
return _instance;
}
final router = GoRouter(
routes: [
GoRoute(
path: '/',
name: 'lobbySelector',
2022-12-25 19:30:42 +00:00
builder: (context, state) => const LobbySelector(),
),
GoRoute(
2023-06-29 23:49:18 +00:00
path: '/prepareRandom',
name: 'prepareRandom',
builder: (context, state) {
2023-06-29 23:49:18 +00:00
return const PrepareRandomGameWidget();
}),
GoRoute(
path: '/host',
name: 'host',
builder: (context, state) {
return const HostGameWidget();
}),
GoRoute(
path: '/join',
name: 'join',
builder: (context, state) {
return const JoinGameWidget();
}),
GoRoute(
path: '/game',
name: 'game',
builder: (context, state) {
var args = state.extra as ChessGameArguments;
return ChessGame(
lobbyID: args.lobbyID,
playerID: args.playerID,
passphrase: args.passphrase,
);
},
)
2022-12-25 19:30:42 +00:00
],
);
}