import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:go_router/go_router.dart'; import 'package:proxibuy/presentation/providers/cubit/user_info_cubit.dart'; import 'package:proxibuy/presentation/ui/screens/auth/auth_page.dart'; import 'package:proxibuy/presentation/ui/screens/home/home_page.dart'; class AppRouter { static final initial = '/'; static final home = '/home'; static final explore = '/explore'; static final setting = '/settings'; static final GlobalKey navigatorKey = GlobalKey(); GoRouter createRouter = GoRouter( navigatorKey: navigatorKey, initialLocation: home, routes: [ GoRoute( path: home, builder: (BuildContext context, GoRouterState state) { return BlocConsumer( listener: (context, state) { if (state is UserInfoSuccess || state is UserInfoFail) { FlutterNativeSplash.remove(); } }, builder: (context, state) { if (state is UserInfoSuccess) { return const HomePage(); } else { return const AuthPage(); } }, ); }, routes: [], ), // StatefulShellRoute.indexedStack( // builder: (context, state, navigationShell) => // BlocBuilder( // builder: (context, state) { // if (state is UserInfoSuccess) { // return CustomBottomNav(child: navigationShell); // } else { // return AuthPage(); // } // }, // ), // branches: [ // StatefulShellBranch(routes: [ // GoRoute( // path: initial, // builder: (context, state) { // return HomeScreen(); // }, // ), // ]), // StatefulShellBranch(routes: [ // GoRoute( // path: explore, // builder: (context, state) => ExploreScreen(), // ), // ]), // StatefulShellBranch(routes: [ // GoRoute( // path: setting, // builder: (context, state) => SettingScreen(), // ), // ]), // ], // ), ], ); }