feat: Implement the home screen with new UI components and assets, and refine authentication screens and routing.

This commit is contained in:
pradeepkumar
2026-02-24 03:19:55 +05:30
parent 4f8ad7fe49
commit 0bc8852c17
31 changed files with 1540 additions and 24 deletions

View File

@@ -1,22 +1,64 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
import 'package:real_estate_mobile/features/auth/presentation/screens/login_screen.dart';
import 'package:real_estate_mobile/features/auth/presentation/screens/signup_screen.dart';
import 'package:real_estate_mobile/features/home/presentation/screens/home_screen.dart';
class AppRouter {
AppRouter._();
final routerProvider = Provider<GoRouter>((ref) {
final authRefreshNotifier = _AuthRefreshNotifier();
static final GoRouter router = GoRouter(
initialLocation: '/signup',
ref.listen(authProvider, (_, __) {
authRefreshNotifier.notify();
});
ref.onDispose(() {
authRefreshNotifier.dispose();
});
return GoRouter(
initialLocation: '/login',
refreshListenable: authRefreshNotifier,
redirect: (context, state) {
final authState = ref.read(authProvider);
final isAuthenticated = authState.status == AuthStatus.authenticated;
final isLoading = authState.status == AuthStatus.loading;
final isAuthRoute = state.matchedLocation == '/login' ||
state.matchedLocation == '/signup';
// While checking auth status, don't redirect
if (isLoading) return null;
// If authenticated and on auth page, go to home
if (isAuthenticated && isAuthRoute) return '/home';
// If not authenticated and on protected page, go to login
if (!isAuthenticated && !isAuthRoute) return '/login';
return null;
},
routes: [
GoRoute(
path: '/login',
builder: (context, state) => const LoginScreen(),
),
GoRoute(
path: '/signup',
builder: (context, state) => const SignupScreen(),
),
GoRoute(
path: '/login',
builder: (context, state) => const LoginScreen(),
path: '/home',
builder: (context, state) => const HomeScreen(),
),
],
);
});
/// Notifier that triggers GoRouter refresh when auth state changes.
class _AuthRefreshNotifier extends ChangeNotifier {
void notify() {
notifyListeners();
}
}