64 lines
1.9 KiB
Dart
64 lines
1.9 KiB
Dart
import 'package:boardgames_app/network/channel.dart';
|
|
import 'package:boardgames_app/widgets/game_site.dart';
|
|
import 'package:boardgames_core/games.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:logging/logging.dart';
|
|
|
|
void main() {
|
|
final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
|
|
assert(binding.debugCheckZone('runApp'));
|
|
Logger.root.level = Level.INFO; // defaults to Level.INFO
|
|
Logger.root.onRecord.listen((record) {
|
|
print(
|
|
'${record.time} [${record.level.name}] ${record.loggerName}: ${record.message}');
|
|
});
|
|
// TODO: Make loading screen while waiting
|
|
Channel.init();
|
|
|
|
runApp(
|
|
MaterialApp(
|
|
initialRoute: "/",
|
|
onGenerateRoute: (settings) {
|
|
print(settings.arguments);
|
|
if (settings.name == "/") {
|
|
return MaterialPageRoute(
|
|
builder: (BuildContext ctx) {
|
|
return TextButton(
|
|
onPressed: () {
|
|
Checkers game = Checkers();
|
|
Navigator.pushNamed(ctx, "/checkers/${game.id}",
|
|
arguments: {
|
|
"game": game,
|
|
});
|
|
},
|
|
child: const Text("Checkers"),
|
|
);
|
|
},
|
|
maintainState: true,
|
|
settings: settings);
|
|
}
|
|
|
|
return MaterialPageRoute(
|
|
builder: (BuildContext ctx) {
|
|
return GameSite();
|
|
},
|
|
maintainState: true,
|
|
settings: settings);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
// GameWidget(
|
|
// overlayBuilderMap: {
|
|
// "${GameOverlay.gameMenu}": (context, game) {
|
|
// return Container(
|
|
// decoration: const BoxDecoration(
|
|
// color: Colors.black38,
|
|
// ),
|
|
// alignment: Alignment.center,
|
|
// child: const Text("Game menu", style: TextStyle(color: Colors.amber)),
|
|
// );
|
|
// }
|
|
// },
|
|
// game: game,
|
|
// ) |