53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:mchess/pages/chess_game.dart';
|
|
import 'package:mchess/pages/lobby_selector.dart';
|
|
import 'package:mchess/pages/create_game.dart';
|
|
|
|
final navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
class ChessAppRouter {
|
|
static final ChessAppRouter _instance = ChessAppRouter._internal();
|
|
|
|
ChessAppRouter._internal();
|
|
|
|
static ChessAppRouter getInstance() {
|
|
return _instance;
|
|
}
|
|
|
|
final router = GoRouter(
|
|
navigatorKey: navigatorKey,
|
|
debugLogDiagnostics: true,
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
name: 'lobbySelector',
|
|
builder: (context, state) {
|
|
return const LobbySelector();
|
|
},
|
|
routes: [
|
|
GoRoute(
|
|
path: 'createGame',
|
|
name: 'createGame',
|
|
builder: (context, state) {
|
|
return const CreateGameWidget();
|
|
}),
|
|
GoRoute(
|
|
path: 'game/:phrase',
|
|
name: 'game',
|
|
builder: (context, state) {
|
|
var args = state.extra as ChessGameArguments;
|
|
|
|
return ChessGame(
|
|
lobbyID: args.lobbyID,
|
|
playerID: args.playerID,
|
|
passphrase: args.passphrase,
|
|
);
|
|
},
|
|
)
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|