feat: Implement support chat functionality, add 2FA verification screen and routing, and update dependencies.
This commit is contained in:
@@ -22,6 +22,8 @@ import 'package:real_estate_mobile/features/agents/presentation/screens/agent_ed
|
||||
import 'package:real_estate_mobile/features/profile/presentation/screens/payment_success_screen.dart';
|
||||
import 'package:real_estate_mobile/features/splash/presentation/screens/splash_screen.dart';
|
||||
import 'package:real_estate_mobile/features/onboarding/presentation/screens/onboarding_screen.dart';
|
||||
import 'package:real_estate_mobile/features/auth/presentation/screens/verify_2fa_screen.dart';
|
||||
import 'package:real_estate_mobile/features/support_chat/presentation/screens/support_chat_screen.dart';
|
||||
|
||||
final routerProvider = Provider<GoRouter>((ref) {
|
||||
final authRefreshNotifier = _AuthRefreshNotifier();
|
||||
@@ -36,7 +38,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
|
||||
// Public routes accessible without authentication (matching web middleware)
|
||||
const publicRoutes = ['/home', '/agents/search', '/agents/detail', '/faq', '/contact', '/about'];
|
||||
const authRoutes = ['/login', '/signup'];
|
||||
const authRoutes = ['/login', '/signup', '/verify-2fa'];
|
||||
|
||||
return GoRouter(
|
||||
initialLocation: '/splash',
|
||||
@@ -52,19 +54,20 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
(route) => location == route || location.startsWith('$route/'),
|
||||
);
|
||||
|
||||
// Never redirect away from splash or onboarding — they handle their own navigation
|
||||
// Never redirect away from splash or onboarding
|
||||
if (location == '/splash' || location == '/onboarding') return null;
|
||||
|
||||
// While checking auth status, don't redirect
|
||||
if (isLoading) return null;
|
||||
|
||||
// If authenticated and on auth page (login/signup), go to home
|
||||
if (isAuthenticated && isAuthRoute) return '/home';
|
||||
// Public routes and auth routes are always accessible (no auth required)
|
||||
if (isPublicRoute || isAuthRoute) {
|
||||
// Only redirect: if authenticated user is on login/signup, send to home
|
||||
if (isAuthenticated && isAuthRoute) return '/home';
|
||||
return null;
|
||||
}
|
||||
|
||||
// Public routes are always accessible
|
||||
if (isPublicRoute || isAuthRoute) return null;
|
||||
|
||||
// Protected routes require authentication — redirect to login
|
||||
// Protected routes require authentication
|
||||
if (!isAuthenticated) return '/login';
|
||||
|
||||
return null;
|
||||
@@ -91,6 +94,10 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
path: '/signup',
|
||||
builder: (context, state) => const SignupScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/verify-2fa',
|
||||
builder: (context, state) => const Verify2faScreen(),
|
||||
),
|
||||
|
||||
// All main app routes wrapped in AppShell (shared header + bottom nav)
|
||||
ShellRoute(
|
||||
@@ -201,6 +208,14 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
transitionsBuilder: _fadeTransition,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/support/chat',
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
key: state.pageKey,
|
||||
child: const SupportChatScreen(),
|
||||
transitionsBuilder: _fadeTransition,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/payment-success',
|
||||
pageBuilder: (context, state) {
|
||||
@@ -228,9 +243,8 @@ class _HomeRouteWrapper extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authProvider);
|
||||
|
||||
// Show loader while auth is initializing or loading
|
||||
if (authState.status == AuthStatus.initial ||
|
||||
authState.status == AuthStatus.loading) {
|
||||
// Show loader only while auth is actively loading (checking token)
|
||||
if (authState.status == AuthStatus.loading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.accentOrange,
|
||||
|
||||
Reference in New Issue
Block a user