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

75 lines
1.9 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:mchess/chess_bloc/chess_bloc.dart';
import 'package:mchess/chess/chess_board.dart';
import 'package:mchess/chess/turn_indicator_widget.dart';
import 'package:mchess/utils/widgets/server_log_widget.dart';
import 'package:uuid/uuid.dart';
class ChessGame extends StatefulWidget {
final UuidValue playerID;
final UuidValue lobbyID;
final String? passphrase;
const ChessGame(
{required this.playerID,
required this.lobbyID,
required this.passphrase,
super.key});
@override
State<ChessGame> createState() => _ChessGameState();
}
class _ChessGameState extends State<ChessGame> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: FittedBox(
fit: BoxFit.contain,
child: Column(
children: [
if (kDebugMode) const ServerLogWidget(textColor: Colors.white),
Container(
margin: const EdgeInsets.all(20),
child: BlocBuilder<ChessBloc, ChessBoardState>(
builder: (context, state) {
return ChessBoard(
bState: state,
);
},
),
),
if (kDebugMode) const TurnIndicator(),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
context.push('/');
},
child: const Icon(Icons.cancel),
),
);
}
}
class ChessGameArguments {
final UuidValue lobbyID;
final UuidValue playerID;
final String? passphrase;
ChessGameArguments({
required this.lobbyID,
required this.playerID,
required this.passphrase,
});
}