79 lines
2.1 KiB
Dart
79 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../core/auth/auth_state.dart';
|
|
import '../../core/theme/app_theme.dart';
|
|
import '../../providers/auth_provider.dart';
|
|
|
|
class SplashScreen extends ConsumerStatefulWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends ConsumerState<SplashScreen> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Trigger session restoration on startup
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_checkSession();
|
|
});
|
|
}
|
|
|
|
Future<void> _checkSession() async {
|
|
await ref.read(authProvider.notifier).restoreSession();
|
|
if (!mounted) return;
|
|
|
|
final authState = ref.read(authProvider);
|
|
if (authState.status == AuthStatus.authenticated) {
|
|
context.go('/dashboard');
|
|
} else {
|
|
context.go('/login');
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Scaffold(
|
|
backgroundColor: AppTheme.primaryDark,
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.school_rounded,
|
|
size: 80,
|
|
color: Colors.white,
|
|
),
|
|
SizedBox(height: 24),
|
|
Text(
|
|
'Metatron Student ERP',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 0.5,
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
Text(
|
|
'Education Management System',
|
|
style: TextStyle(
|
|
color: AppTheme.textMuted,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
SizedBox(height: 48),
|
|
CircularProgressIndicator(
|
|
color: Colors.white,
|
|
strokeWidth: 2.5,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|