Add GoRouter and do a lot of renaming.
This commit is contained in:
parent
bff46e6f3d
commit
80a24bafd6
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
|
|
||||||
import 'chess_square.dart';
|
import 'chess_square.dart';
|
||||||
import 'chess_utils.dart';
|
import '../utils/chess_utils.dart';
|
||||||
|
|
||||||
class ChessBoard extends StatelessWidget {
|
class ChessBoard extends StatelessWidget {
|
||||||
final ChessBoardState bState;
|
final ChessBoardState bState;
|
@ -4,7 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
|
|
||||||
import '../connection/ws_connection.dart';
|
import '../connection/ws_connection.dart';
|
||||||
import 'chess_utils.dart';
|
import '../utils/chess_utils.dart';
|
||||||
|
|
||||||
int messageIndex = 0;
|
int messageIndex = 0;
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
|
|
||||||
import 'chess_utils.dart';
|
import '../utils/chess_utils.dart';
|
||||||
|
|
||||||
class TurnIndicator extends StatelessWidget {
|
class TurnIndicator extends StatelessWidget {
|
||||||
const TurnIndicator({super.key});
|
const TurnIndicator({super.key});
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_events.dart';
|
import 'package:mchess/chess_bloc/chess_events.dart';
|
||||||
import 'package:mchess/chessapp/chess_utils.dart';
|
import 'package:mchess/utils/chess_utils.dart';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:mchess/chessapp/chess_utils.dart';
|
import 'package:mchess/utils/chess_utils.dart';
|
||||||
|
|
||||||
abstract class ChessEvent {}
|
abstract class ChessEvent {}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import 'dart:io';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_events.dart';
|
import 'package:mchess/chess_bloc/chess_events.dart';
|
||||||
import 'package:mchess/chessapp/chess_utils.dart';
|
import 'package:mchess/utils/chess_utils.dart';
|
||||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
|
|
||||||
class ServerConnection {
|
class ServerConnection {
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'chessapp/chess_app.dart';
|
import 'package:mchess/utils/chess_router.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const ChessApp());
|
runApp(const MyApp());
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyApp extends StatelessWidget {
|
||||||
|
const MyApp({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialApp.router(
|
||||||
|
routerConfig: router,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||||
|
|
||||||
import 'package:mchess/chessapp/chess_board.dart';
|
import 'package:mchess/chess/chess_board.dart';
|
||||||
import 'package:mchess/chessapp/turn_indicator_widget.dart';
|
import 'package:mchess/chess/turn_indicator_widget.dart';
|
||||||
import 'package:mchess/connection_cubit/connection_cubit.dart';
|
import 'package:mchess/connection_cubit/connection_cubit.dart';
|
||||||
|
|
||||||
import '../connection/ws_connection.dart';
|
import 'package:mchess/connection/ws_connection.dart';
|
||||||
import '../utils/widgets/server_log_widget.dart';
|
import 'package:mchess/utils/widgets/server_log_widget.dart';
|
||||||
|
|
||||||
class ChessApp extends StatelessWidget {
|
class ChessApp extends StatelessWidget {
|
||||||
const ChessApp({super.key});
|
const ChessApp({super.key});
|
19
lib/pages/lobby_selector.dart
Normal file
19
lib/pages/lobby_selector.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
class LobbySelector extends StatelessWidget {
|
||||||
|
const LobbySelector({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.go("/play");
|
||||||
|
},
|
||||||
|
child: const Text('Random lobby'),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
16
lib/utils/chess_router.dart
Normal file
16
lib/utils/chess_router.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:mchess/pages/chess_app.dart';
|
||||||
|
import 'package:mchess/pages/lobby_selector.dart';
|
||||||
|
|
||||||
|
final router = GoRouter(
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: '/',
|
||||||
|
builder: (context, state) => const LobbySelector(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/play',
|
||||||
|
builder: (context, state) => const ChessApp(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
35
pubspec.lock
35
pubspec.lock
@ -107,14 +107,27 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
go_router:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: go_router
|
||||||
|
sha256: "788a89932142b0059c319e3153e73308e0fc8bbab78e9a66b0128423090c4e01"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.0"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: js
|
name: js
|
||||||
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
sha256: "323b7c70073cccf6b9b8d8b334be418a3293cfb612a560dc2737160a37bf61bd"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.5"
|
version: "0.6.6"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -123,14 +136,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
logging:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: logging
|
||||||
|
sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.13"
|
version: "0.12.14"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -252,10 +273,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
sha256: c9282698e2982b6c3817037554e52f99d4daba493e8028f8112a83d68ccd0b12
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.16"
|
version: "0.4.17"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -290,4 +311,4 @@ packages:
|
|||||||
version: "6.2.2"
|
version: "6.2.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.19.0-392.0.dev <4.0.0"
|
dart: ">=2.19.0-392.0.dev <4.0.0"
|
||||||
flutter: ">=2.11.0-0.1.pre"
|
flutter: ">=3.3.0"
|
||||||
|
@ -39,6 +39,7 @@ dependencies:
|
|||||||
flutter_bloc: ^8.1.1
|
flutter_bloc: ^8.1.1
|
||||||
quiver: ^3.1.0
|
quiver: ^3.1.0
|
||||||
web_socket_channel: ^2.2.0
|
web_socket_channel: ^2.2.0
|
||||||
|
go_router: ^6.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:mchess/chessapp/chess_app.dart';
|
import 'package:mchess/pages/chess_app.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
|
Loading…
Reference in New Issue
Block a user