♻️ Refactor router, moved from auto_router to go_router
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user