|
| 1 | +import 'package:go_router/go_router.dart'; |
| 2 | +import 'package:jusicool_ios/screens/signup_screens/name_input_screen.dart'; |
| 3 | +import 'package:jusicool_ios/screens/signup_screens/email_auth_screen.dart'; |
| 4 | +import 'package:jusicool_ios/screens/signup_screens/password_create_screen.dart'; |
| 5 | +import 'package:jusicool_ios/screens/signup_screens/find_school_screen.dart'; |
| 6 | +import 'package:jusicool_ios/screens/login_screen.dart'; |
| 7 | +import 'package:jusicool_ios/screens/splash_screen.dart'; |
| 8 | +import 'package:jusicool_ios/screens/mycapital_screens/maincapital_screen.dart'; |
| 9 | +import 'package:jusicool_ios/screens/mycapital_screens/monthlyrevenue_screen.dart'; |
| 10 | +import 'package:jusicool_ios/screens/mycapital_screens/order_detail.dart'; |
| 11 | + |
| 12 | +class RoutePaths { |
| 13 | + static const String splash = '/splash'; |
| 14 | + static const String login = '/login'; |
| 15 | + static const String nameInput = '/name-input'; |
| 16 | + static const String emailAuth = '/email-auth'; |
| 17 | + static const String passwordCreate = '/password-create'; |
| 18 | + static const String findSchool = '/find-school'; |
| 19 | + static const String mainCapital = '/main-capital'; |
| 20 | + static const String monthlyRevenue = '/monthly-revenue'; |
| 21 | + static const String orderDetail = '/order-detail'; |
| 22 | +} |
| 23 | + |
| 24 | +class AppRouter { |
| 25 | + AppRouter._internal(); |
| 26 | + static final AppRouter _instance = AppRouter._internal(); |
| 27 | + factory AppRouter() => _instance; |
| 28 | + |
| 29 | + late final GoRouter router = GoRouter( |
| 30 | + initialLocation: RoutePaths.splash, |
| 31 | + routes: [ |
| 32 | + GoRoute( |
| 33 | + path: RoutePaths.splash, |
| 34 | + builder: (context, state) => const SplashScreen(), |
| 35 | + ), |
| 36 | + GoRoute( |
| 37 | + path: RoutePaths.login, |
| 38 | + builder: (context, state) => const LoginScreen(), |
| 39 | + ), |
| 40 | + GoRoute( |
| 41 | + path: RoutePaths.nameInput, |
| 42 | + builder: (context, state) => const NameInputScreen(), |
| 43 | + ), |
| 44 | + GoRoute( |
| 45 | + path: RoutePaths.emailAuth, |
| 46 | + builder: (context, state) { |
| 47 | + final username = state.extra as String?; |
| 48 | + return EmailAuthScreen(username: username ?? ''); |
| 49 | + }, |
| 50 | + ), |
| 51 | + GoRoute( |
| 52 | + path: RoutePaths.passwordCreate, |
| 53 | + builder: (context, state) { |
| 54 | + final extra = state.extra as Map<String, String>?; |
| 55 | + return PasswordCreateScreen( |
| 56 | + username: extra?['username'] ?? '', |
| 57 | + email: extra?['email'] ?? '', |
| 58 | + ); |
| 59 | + }, |
| 60 | + ), |
| 61 | + GoRoute( |
| 62 | + path: RoutePaths.findSchool, |
| 63 | + builder: (context, state) { |
| 64 | + final extra = state.extra as Map<String, String>?; |
| 65 | + return FindSchoolScreen( |
| 66 | + username: extra?['username'] ?? '', |
| 67 | + email: extra?['email'] ?? '', |
| 68 | + password: extra?['password'] ?? '', |
| 69 | + ); |
| 70 | + }, |
| 71 | + ), |
| 72 | + GoRoute( |
| 73 | + path: RoutePaths.mainCapital, |
| 74 | + builder: (context, state) => const MainCapitalScreen(), |
| 75 | + ), |
| 76 | + GoRoute( |
| 77 | + path: RoutePaths.monthlyRevenue, |
| 78 | + builder: (context, state) => const MonthlyRevenueScreen(), |
| 79 | + ), |
| 80 | + GoRoute( |
| 81 | + path: RoutePaths.orderDetail, |
| 82 | + builder: (context, state) => const OrderDetailScreen(), |
| 83 | + ), |
| 84 | + ], |
| 85 | + ); |
| 86 | +} |
0 commit comments