From 043e2b6a05f872b791ab1aecf158fee64c77e038 Mon Sep 17 00:00:00 2001 From: fredrir Date: Sun, 27 Oct 2024 23:21:21 +0100 Subject: [PATCH] fix bits routing --- lib/pages/games/bits/bits_home_page.dart | 8 +++++--- lib/router.dart | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/pages/games/bits/bits_home_page.dart b/lib/pages/games/bits/bits_home_page.dart index 5e89866..b59d8bc 100644 --- a/lib/pages/games/bits/bits_home_page.dart +++ b/lib/pages/games/bits/bits_home_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:online/components/separator.dart'; import 'package:online/pages/games/bits/bits_page.dart'; import '../../../components/animated_button.dart'; @@ -128,7 +129,7 @@ class BitsHomePageState extends State { return filledFields >= 2; } - void _startGame() { + void _startGame(BuildContext context) { bool anyFieldEmpty = controllers.any((controller) => controller.text.trim().isEmpty); if (anyFieldEmpty) { @@ -136,7 +137,8 @@ class BitsHomePageState extends State { } List playerNames = controllers.map((c) => c.text.trim()).toList(); - AppNavigator.navigateToPage(BitsGame(playerNames: playerNames), withHeaderNavbar: false); + + context.go('/social/games/bitsgame', extra: playerNames); } @override @@ -226,7 +228,7 @@ class BitsHomePageState extends State { Expanded( child: AnimatedButton( onTap: () async { - _startGame(); + _startGame(context); }, childBuilder: (context, hover, pointerDown) { return Padding( diff --git a/lib/router.dart b/lib/router.dart index 606f422..aba905c 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:go_router/go_router.dart'; +import 'package:online/pages/games/bits/bits_page.dart'; import 'package:url_launcher/url_launcher.dart'; import '/pages/games/bits/bits_home_page.dart'; @@ -307,6 +308,13 @@ final GoRouter router = GoRouter( return BitsHomePage(); }, ), + GoRoute( + path: 'bitsgame', + builder: (context, state) { + final playerNames = state.extra as List? ?? []; + return BitsGame(playerNames: playerNames); + }, + ), ], ), ],