fix settings
This commit is contained in:
@@ -6,6 +6,7 @@ import 'route_names.dart';
|
||||
import 'route_paths.dart';
|
||||
import 'route_guards.dart';
|
||||
import 'error_page.dart';
|
||||
import '../../features/auth/presentation/pages/pages.dart';
|
||||
import '../../features/home/presentation/pages/home_page.dart';
|
||||
import '../../features/settings/presentation/pages/settings_page.dart';
|
||||
import '../../features/todos/presentation/screens/home_screen.dart';
|
||||
@@ -101,7 +102,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
path: RoutePaths.login,
|
||||
name: RouteNames.login,
|
||||
pageBuilder: (context, state) => _buildPageWithTransition(
|
||||
child: const _PlaceholderPage(title: 'Login'),
|
||||
child: const LoginPage(),
|
||||
state: state,
|
||||
),
|
||||
),
|
||||
@@ -109,7 +110,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
path: RoutePaths.register,
|
||||
name: RouteNames.register,
|
||||
pageBuilder: (context, state) => _buildPageWithTransition(
|
||||
child: const _PlaceholderPage(title: 'Register'),
|
||||
child: const RegisterPage(),
|
||||
state: state,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,53 +1,26 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'route_paths.dart';
|
||||
import '../../features/auth/presentation/providers/auth_providers.dart';
|
||||
|
||||
/// Authentication state provider
|
||||
final authStateProvider = StateNotifierProvider<AuthStateNotifier, AuthState>(
|
||||
(ref) => AuthStateNotifier(),
|
||||
);
|
||||
/// Legacy auth state provider - redirecting to proper auth provider
|
||||
final authStateProvider = Provider<AuthState>((ref) {
|
||||
final authState = ref.watch(authNotifierProvider);
|
||||
return authState.when(
|
||||
initial: () => AuthState.unknown,
|
||||
loading: () => AuthState.unknown,
|
||||
authenticated: (_) => AuthState.authenticated,
|
||||
unauthenticated: (_) => AuthState.unauthenticated,
|
||||
error: (_) => AuthState.unauthenticated,
|
||||
);
|
||||
});
|
||||
|
||||
/// Authentication state
|
||||
/// Authentication state enum for routing
|
||||
enum AuthState {
|
||||
unknown,
|
||||
authenticated,
|
||||
unauthenticated,
|
||||
}
|
||||
|
||||
/// Authentication state notifier
|
||||
class AuthStateNotifier extends StateNotifier<AuthState> {
|
||||
AuthStateNotifier() : super(AuthState.unknown) {
|
||||
_checkInitialAuth();
|
||||
}
|
||||
|
||||
Future<void> _checkInitialAuth() async {
|
||||
// TODO: Implement actual auth check logic
|
||||
// For now, simulate checking stored auth token
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
// Mock authentication check
|
||||
// In a real app, you would check secure storage for auth token
|
||||
state = AuthState.unauthenticated;
|
||||
}
|
||||
|
||||
Future<void> login(String email, String password) async {
|
||||
// TODO: Implement actual login logic
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
state = AuthState.authenticated;
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
// TODO: Implement actual logout logic
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
state = AuthState.unauthenticated;
|
||||
}
|
||||
|
||||
Future<void> register(String email, String password) async {
|
||||
// TODO: Implement actual registration logic
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
state = AuthState.authenticated;
|
||||
}
|
||||
}
|
||||
|
||||
/// Route guard utility class
|
||||
class RouteGuard {
|
||||
/// Check if user can access the given route
|
||||
|
||||
Reference in New Issue
Block a user