fix settings

This commit is contained in:
2025-09-26 20:54:32 +07:00
parent 30ed6b39b5
commit 74d0e3d44c
36 changed files with 5040 additions and 192 deletions

View File

@@ -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,
),
),

View File

@@ -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