diff --git a/lib/router/RouterProvider.dart b/lib/router/RouterProvider.dart index 096046f..543949a 100644 --- a/lib/router/RouterProvider.dart +++ b/lib/router/RouterProvider.dart @@ -1,10 +1,11 @@ +import 'package:blueberry_flutter_template/screens/SettingScreen.dart'; import 'package:blueberry_flutter_template/screens/TopScreen.dart'; -import 'package:blueberry_flutter_template/screens/mbti/MBTIScreen.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import '../screens/SplashScreen.dart'; +import '../screens/mypage/SignUpScreen.dart'; import '../utils/ResponsiveLayoutBuilder.dart'; final routerProvider = Provider((ref) { @@ -17,9 +18,20 @@ final routerProvider = Provider((ref) { kIsWeb ? const TopScreen() : const SplashScreen(), )), GoRoute( - path: '/home', - builder: (context, state) => const TopScreen(), + path: '/TopScreen', + builder: (context, state) => + ResponsiveLayoutBuilder(context, const TopScreen()), ), + GoRoute( + path: '/SignUpScreen', + builder: (context, state) => + ResponsiveLayoutBuilder(context, const SignUpScreen()), + ), + GoRoute( + path: '/SettingsScreen', + builder: (context, state) => + ResponsiveLayoutBuilder(context, const SettingScreen()), + ) ], ); }); diff --git a/lib/screens/SplashScreen.dart b/lib/screens/SplashScreen.dart index 3d481c2..001185e 100644 --- a/lib/screens/SplashScreen.dart +++ b/lib/screens/SplashScreen.dart @@ -1,4 +1,3 @@ -import 'package:blueberry_flutter_template/router/RouterProvider.dart'; import 'package:blueberry_flutter_template/screens/TopScreen.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/foundation.dart'; // kIsWeb 상수 사용 @@ -6,9 +5,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; -import '../utils/ResponsiveLayoutBuilder.dart'; - class SplashScreen extends ConsumerStatefulWidget { + static const String routeName = '/SplashScreen'; const SplashScreen({super.key}); @override @@ -42,7 +40,7 @@ class _SplashScreenState extends ConsumerState { await Future.delayed(const Duration(seconds: 3)); // 초기화 완료 후 메인 화면으로 전환 if (mounted) { - context.go('/home'); // GoRouter를 사용한 라우팅 + GoRouter.of(context).go(TopScreen.routeName); } } catch (e) { // 초기화 중 발생한 오류 처리 diff --git a/lib/screens/TopScreen.dart b/lib/screens/TopScreen.dart index 430503d..acc573a 100644 --- a/lib/screens/TopScreen.dart +++ b/lib/screens/TopScreen.dart @@ -18,6 +18,7 @@ import 'friendsList/FriendsListScreen.dart'; final selectedIndexProvider = StateProvider((ref) => 0); class TopScreen extends ConsumerWidget { + static const String routeName = '/TopScreen'; const TopScreen({super.key}); @override diff --git a/lib/screens/mypage/LoginScreen.dart b/lib/screens/mypage/LoginScreen.dart index 14a89ed..7e3fe83 100644 --- a/lib/screens/mypage/LoginScreen.dart +++ b/lib/screens/mypage/LoginScreen.dart @@ -1,5 +1,7 @@ +import 'package:blueberry_flutter_template/screens/mypage/SignUpScreen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; import '../../providers/camera/PageProvider.dart'; import '../../providers/user/FirebaseAuthServiceProvider.dart'; @@ -7,8 +9,8 @@ import '../../providers/user/UserInfoProvider.dart'; import '../../services/SocialAuthService.dart'; import '../../utils/AppStrings.dart'; import '../../widgets/SquareTitleWidget.dart'; +import '../TopScreen.dart'; import 'MyPageScreen.dart'; -import 'SignUpScreen.dart'; import 'camera/ProfileCameraPage.dart'; import 'camera/ProfileGalleryPage.dart'; @@ -153,10 +155,7 @@ Widget _buildLogin(BuildContext context, WidgetRef ref) { child: const Text(AppStrings.loginButtonText), ), TextButton( - onPressed: () => Navigator.push( - context, - MaterialPageRoute(builder: (context) => const SignUpScreen()), - ), + onPressed: () => context.go(SignUpScreen.routeName), child: const Text( AppStrings.signUpButtonText, style: TextStyle(color: Colors.blue), diff --git a/lib/screens/mypage/SignUpScreen.dart b/lib/screens/mypage/SignUpScreen.dart index b649095..ad05b7d 100644 --- a/lib/screens/mypage/SignUpScreen.dart +++ b/lib/screens/mypage/SignUpScreen.dart @@ -29,6 +29,7 @@ final phoneNumberProvider = StateProvider((ref) => ''); final verificationNumberProvider = StateProvider((ref) => ''); class SignUpScreen extends StatefulWidget { + static const String routeName = '/SignUpScreen'; const SignUpScreen({super.key});