Skip to content

Commit cd9791e

Browse files
authored
Merge pull request #20 from Jusicool-Ver-2-0/feature/auth-api
⚡️ :: Gorouter로 내비게이션 구현
2 parents 966d401 + 3e46a86 commit cd9791e

File tree

12 files changed

+334
-328
lines changed

12 files changed

+334
-328
lines changed

lib/main.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
33
import 'package:flutter_screenutil/flutter_screenutil.dart';
44
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
5-
import 'package:jusicool_ios/screens/splash_screen.dart';
65
import 'package:jusicool_ios/menu_bottom.dart';
6+
import 'package:jusicool_ios/router.dart';
77

88
class BaseScreen extends StatelessWidget {
99
final String title;
@@ -29,12 +29,16 @@ class MyApp extends StatelessWidget {
2929

3030
@override
3131
Widget build(BuildContext context) {
32+
final appRouter = AppRouter();
3233
return ScreenUtilInit(
3334
designSize: const Size(360, 800),
3435
minTextAdapt: true,
3536
splitScreenMode: true,
3637
builder: (context, child) {
37-
return MaterialApp(
38+
return MaterialApp.router(
39+
routerDelegate: appRouter.router.routerDelegate,
40+
routeInformationParser: appRouter.router.routeInformationParser,
41+
routeInformationProvider: appRouter.router.routeInformationProvider,
3842
title: 'Jusicool',
3943
theme: ThemeData(
4044
primarySwatch: Colors.blue,
@@ -48,7 +52,6 @@ class MyApp extends StatelessWidget {
4852
),
4953
),
5054
debugShowCheckedModeBanner: false,
51-
home: const SplashScreen(),
5255
);
5356
},
5457
);
@@ -65,14 +68,5 @@ class MainPage extends StatelessWidget {
6568
}
6669

6770
void main() {
68-
SystemChrome.setSystemUIOverlayStyle(
69-
const SystemUiOverlayStyle(
70-
statusBarColor: AppColor.white,
71-
statusBarIconBrightness: Brightness.dark,
72-
systemNavigationBarColor: AppColor.white,
73-
systemNavigationBarIconBrightness: Brightness.dark,
74-
),
75-
);
76-
7771
runApp(const MyApp());
7872
}

lib/router.dart

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
}

lib/screens/mycapital_screens/maincapital_screen.dart

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
33
import 'package:intl/intl.dart';
44
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
55
import 'package:jusicool_design_system/src/core/theme/texts/typography.dart';
6-
import 'package:jusicool_ios/screens/login_screen.dart';
7-
import 'package:jusicool_ios/screens/mycapital_screens/monthlyrevenue_screen.dart';
8-
import 'package:jusicool_ios/screens/mycapital_screens/order_detail.dart';
6+
import 'package:go_router/go_router.dart';
97

108
class StockCard extends StatelessWidget {
119
final String imagePath;
@@ -333,10 +331,7 @@ class MainCapitalScreen extends StatelessWidget {
333331
children: [
334332
GestureDetector(
335333
onTap: () {
336-
Navigator.push(
337-
context,
338-
MaterialPageRoute(builder: (context) => LoginScreen()),
339-
);
334+
context.push('/login');
340335
},
341336
child: Container(
342337
width: 312.w,
@@ -543,14 +538,7 @@ class MainCapitalScreen extends StatelessWidget {
543538
),
544539
GestureDetector(
545540
onTap: () {
546-
Navigator.push(
547-
context,
548-
MaterialPageRoute(
549-
builder:
550-
(context) =>
551-
OrderDetailScreen(),
552-
),
553-
);
541+
context.push('/order-detail');
554542
},
555543
child: Row(
556544
children: [
@@ -604,13 +592,8 @@ class MainCapitalScreen extends StatelessWidget {
604592
),
605593
GestureDetector(
606594
onTap: () {
607-
Navigator.push(
608-
context,
609-
MaterialPageRoute(
610-
builder:
611-
(context) =>
612-
MonthlyRevenueScreen(),
613-
),
595+
context.push(
596+
'/monthly-revenue',
614597
);
615598
},
616599
child: Row(
@@ -684,10 +667,7 @@ class MainCapitalScreen extends StatelessWidget {
684667
SizedBox(height: 16.h),
685668
GestureDetector(
686669
onTap: () {
687-
Navigator.push(
688-
context,
689-
MaterialPageRoute(builder: (context) => LoginScreen()),
690-
);
670+
context.push('/login');
691671
},
692672
child: Container(
693673
width: 312.w,

lib/screens/mycapital_screens/monthlyrevenue_screen.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'package:intl/intl.dart';
44
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
55
import 'package:jusicool_design_system/src/core/theme/texts/typography.dart';
66
import 'package:jusicool_ios/screens/mycapital_screens/revenuecard.dart';
7+
import 'package:go_router/go_router.dart';
8+
9+
const adjustedTopPadding = 16.0;
710

811
class MonthlyRevenueScreen extends StatefulWidget {
912
const MonthlyRevenueScreen({super.key});
@@ -128,6 +131,7 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
128131
? AppColor.main
129132
: AppColor.gray400;
130133

134+
131135
List<Map<String, dynamic>> filteredData = revenueData;
132136
if (_tabController.index == 1) {
133137
filteredData =
@@ -154,7 +158,7 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
154158
leading: IconButton(
155159
icon: const Icon(Icons.arrow_back, color: AppColor.black),
156160
onPressed: () {
157-
Navigator.pop(context);
161+
context.pop();
158162
},
159163
),
160164
),
@@ -220,7 +224,7 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
220224
body: Container(
221225
color: AppColor.white,
222226
child: Padding(
223-
padding: EdgeInsets.only(left: 24.sp, top: 16.h),
227+
padding: EdgeInsets.only(left: 24.sp, top: adjustedTopPadding.h),
224228
child: ListView.builder(
225229
itemCount: filteredData.length,
226230
itemBuilder: (context, index) {

lib/screens/mycapital_screens/order_detail.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class _OrderDetailScreenState extends State<OrderDetailScreen>
201201
),
202202
),
203203
),
204-
205204
Container(
206205
color: AppColor.white,
207206
child: SingleChildScrollView(

0 commit comments

Comments
 (0)