import 'dart:async'; import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State createState() => _SplashScreenState(); } class _SplashScreenState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _scaleAnimation; late Animation _opacityAnimation; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, duration: const Duration(seconds: 2), ); _scaleAnimation = Tween(begin: 0.6, end: 1.0).animate( CurvedAnimation(parent: _controller, curve: Curves.easeOutBack), ); _opacityAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation(parent: _controller, curve: Curves.easeIn), ); _controller.forward(); Timer(const Duration(seconds: 3), () { final user = FirebaseAuth.instance.currentUser; if (user != null) { Navigator.pushReplacementNamed(context, '/main'); } else { Navigator.pushReplacementNamed(context, '/login'); } }); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [Color(0xFF6B4EFF),Color(0xFF8B70FF) ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), child: Center( child: AnimatedBuilder( animation: _controller, builder: (context, child) { return Opacity( opacity: _opacityAnimation.value, child: Transform.scale( scale: _scaleAnimation.value, child: Column( mainAxisSize: MainAxisSize.min, children: [ Image.asset( 'assets/images/logo.png', width: 80, height: 80, ), const SizedBox(height: 20), Text( 'AntiSpy Security', style: Theme.of(context).textTheme.headlineMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.bold, letterSpacing: 1.2, ), ), const SizedBox(height: 20), const CircularProgressIndicator(color: Colors.white), ], ), ), ); }, ), ), ), ); } }