import 'package:flutter/material.dart'; import '../../core/theme.dart'; import '../../core/cache_manager.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State createState() => _SplashScreenState(); } class _SplashScreenState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _fadeAnimation; late Animation _scaleAnimation; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, duration: const Duration(seconds: 2), ); _fadeAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation(parent: _controller, curve: Curves.easeIn), ); _scaleAnimation = Tween(begin: 0.8, end: 1.0).animate( CurvedAnimation(parent: _controller, curve: Curves.easeOutBack), ); _controller.forward(); Future.delayed(const Duration(seconds: 3), () { _checkAuthAndNavigate(); }); } void _checkAuthAndNavigate() { if (!mounted) return; final token = CacheManager.authBox.get('auth_token'); if (token != null && token.toString().isNotEmpty) { Navigator.pushReplacementNamed(context, '/onboarding/check'); } else { Navigator.pushReplacementNamed(context, '/login'); } } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppTheme.primaryDark, body: Center( child: FadeTransition( opacity: _fadeAnimation, child: ScaleTransition( scale: _scaleAnimation, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 100, height: 100, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(AppTheme.radiusLg), boxShadow: AppTheme.shadowLg, ), child: const Icon( Icons.diamond_outlined, size: 60, color: AppTheme.primaryDark, ), ), const SizedBox(height: AppTheme.spacingLg), Text( "MPG HRIS", style: AppTheme.heading1.copyWith(color: Colors.white), ), Text( "Sistem Informasi SDM", style: AppTheme.bodyMedium.copyWith(color: Colors.white70), ), ], ), ), ), ), ); } }