Skip to content

Commit

Permalink
change path and path Name
Browse files Browse the repository at this point in the history
  • Loading branch information
jwson-automation committed Jul 24, 2024
1 parent 43e6263 commit da76e2e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
18 changes: 15 additions & 3 deletions lib/router/RouterProvider.dart
Original file line number Diff line number Diff line change
@@ -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<GoRouter>((ref) {
Expand All @@ -17,9 +18,20 @@ final routerProvider = Provider<GoRouter>((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()),
)
],
);
});
6 changes: 2 additions & 4 deletions lib/screens/SplashScreen.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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 상수 사용
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
Expand Down Expand Up @@ -42,7 +40,7 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {
await Future.delayed(const Duration(seconds: 3));
// 초기화 완료 후 메인 화면으로 전환
if (mounted) {
context.go('/home'); // GoRouter를 사용한 라우팅
GoRouter.of(context).go(TopScreen.routeName);
}
} catch (e) {
// 초기화 중 발생한 오류 처리
Expand Down
1 change: 1 addition & 0 deletions lib/screens/TopScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'friendsList/FriendsListScreen.dart';
final selectedIndexProvider = StateProvider<int>((ref) => 0);

class TopScreen extends ConsumerWidget {
static const String routeName = '/TopScreen';
const TopScreen({super.key});

@override
Expand Down
9 changes: 4 additions & 5 deletions lib/screens/mypage/LoginScreen.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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';
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';

Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions lib/screens/mypage/SignUpScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final phoneNumberProvider = StateProvider<String>((ref) => '');
final verificationNumberProvider = StateProvider<String>((ref) => '');

class SignUpScreen extends StatefulWidget {
static const String routeName = '/SignUpScreen';
const SignUpScreen({super.key});


Expand Down

0 comments on commit da76e2e

Please sign in to comment.