♻️ Refactor router, moved from auto_router to go_router

This commit is contained in:
2025-06-26 14:13:44 +08:00
parent 825e6b5b6d
commit f2829b2012
67 changed files with 587 additions and 2876 deletions

View File

@ -1,26 +1,26 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/route.gr.dart';
import 'package:island/screens/tabs.dart';
class ConditionalBottomNav extends HookConsumerWidget {
final Widget child;
const ConditionalBottomNav({super.key, required this.child});
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentRouteName = ref.watch(currentRouteProvider);
final currentLocation = GoRouterState.of(context).uri.toString();
const mainTabRoutes = {
ExploreRoute.name,
ChatListRoute.name,
RealmListRoute.name,
AccountRoute.name,
};
// Force rebuild when route changes
useEffect(() {
// This effect will run whenever currentLocation changes
return null;
}, [currentLocation]);
debugPrint(currentRouteName);
final shouldShowBottomNav = mainTabRoutes.contains(currentRouteName);
// Use the same route logic as TabsScreen for consistency
const mainTabRoutes = ['/', '/chat', '/realms', '/account'];
final shouldShowBottomNav = mainTabRoutes.contains(currentLocation);
return shouldShowBottomNav ? child : const SizedBox.shrink();
}