feat: add home and profile screens

This commit is contained in:
soragui
2026-01-19 14:56:39 +08:00
parent 0ade16350a
commit 12ff1d61c2
4 changed files with 116 additions and 13 deletions

View File

@@ -3,16 +3,43 @@ import 'package:go_router/go_router.dart';
import 'package:phone_login/auth/auth_state.dart';
import 'package:phone_login/auth/phone_input_screen.dart';
import 'package:phone_login/auth/sms_verification_screen.dart';
import 'package:phone_login/home/home_screen.dart';
import 'package:phone_login/profile/profile_screen.dart';
import 'package:provider/provider.dart';
final _router = GoRouter(
routes: [
GoRoute(path: '/', builder: (context, state) => const PhoneInputScreen()),
GoRoute(path: '/', builder: (context, state) => const HomeScreen()),
GoRoute(
path: '/login',
builder: (context, state) => const PhoneInputScreen(),
),
GoRoute(
path: '/sms_verify',
builder: (context, state) => const SmsVerificationScreen(),
),
GoRoute(
path: '/profile',
builder: (context, state) => const ProfileScreen(),
),
],
redirect: (BuildContext context, GoRouterState state) {
final authState = Provider.of<AuthState>(context, listen: false);
final bool loggedIn = authState.isLoggedIn;
final bool loggingIn =
state.matchedLocation == '/login' ||
state.matchedLocation == '/sms_verify';
if (!loggedIn && !loggingIn) {
return '/login';
}
if (loggedIn && loggingIn) {
return '/';
}
return null;
},
);
class App extends StatelessWidget {