import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:posyandu/screens/auth/login_screen.dart'; class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation _fadeAnimation; late Animation _scaleAnimation; late Animation _logoScaleAnimation; late Animation _progressAnimation; @override void initState() { super.initState(); // Set system UI overlay style SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.light, )); _animationController = AnimationController( vsync: this, duration: Duration(milliseconds: 2500), ); _fadeAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation( parent: _animationController, curve: Interval(0.0, 0.5, curve: Curves.easeIn), ), ); _scaleAnimation = Tween(begin: 0.8, end: 1.0).animate( CurvedAnimation( parent: _animationController, curve: Interval(0.0, 0.5, curve: Curves.easeOut), ), ); _logoScaleAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation( parent: _animationController, curve: Interval(0.0, 0.5, curve: Curves.elasticOut), ), ); _progressAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation( parent: _animationController, curve: Interval(0.6, 1.0, curve: Curves.easeInOut), ), ); _animationController.forward(); // Navigate to login screen after animation completes Future.delayed(Duration(milliseconds: 3200), () { Navigator.pushReplacement( context, PageRouteBuilder( transitionDuration: Duration(milliseconds: 800), pageBuilder: (_, __, ___) => LoginScreen(), transitionsBuilder: (_, animation, __, child) { return FadeTransition( opacity: animation, child: child, ); }, ), ); }); } @override void dispose() { _animationController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; return Scaffold( body: Stack( children: [ // Background gradient Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xFF4CAF50), // Green Color(0xFF2E7D32), // Dark Green ], ), ), ), // Background patterns Positioned( right: -100, top: -50, child: Container( width: 300, height: 300, decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), shape: BoxShape.circle, ), ), ), Positioned( left: -150, bottom: screenSize.height * 0.3, child: Container( width: 350, height: 350, decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), shape: BoxShape.circle, ), ), ), // Content Center( child: AnimatedBuilder( animation: _animationController, builder: (context, child) { return FadeTransition( opacity: _fadeAnimation, child: ScaleTransition( scale: _scaleAnimation, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // Logo container with scale animation ScaleTransition( scale: _logoScaleAnimation, child: Container( width: screenSize.width * 0.4, height: screenSize.width * 0.4, decoration: BoxDecoration( shape: BoxShape.circle, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), blurRadius: 20, offset: Offset(0, 8), spreadRadius: 2, ), ], border: Border.all( color: Colors.white, width: 4, ), ), child: ClipOval( child: Image.asset( 'assets/logo.jpg', fit: BoxFit.cover, ), ), ), ), SizedBox(height: 30), Text( 'POSYANDU', style: TextStyle( fontSize: screenSize.width * 0.09, fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 4.0, shadows: [ Shadow( color: Colors.black.withOpacity(0.3), offset: Offset(0, 3), blurRadius: 6, ), ], ), ), SizedBox(height: 12), Text( 'Aplikasi Kesehatan Ibu dan Anak', style: TextStyle( fontSize: screenSize.width * 0.045, color: Colors.white, fontWeight: FontWeight.w500, letterSpacing: 0.5, shadows: [ Shadow( color: Colors.black.withOpacity(0.3), offset: Offset(0, 1), blurRadius: 3, ), ], ), ), SizedBox(height: 50), AnimatedBuilder( animation: _progressAnimation, builder: (context, child) { return Container( width: screenSize.width * 0.5, height: 6, decoration: BoxDecoration( color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(3), ), child: ClipRRect( borderRadius: BorderRadius.circular(3), child: LinearProgressIndicator( value: _progressAnimation.value, backgroundColor: Colors.transparent, valueColor: AlwaysStoppedAnimation(Colors.white), ), ), ); }, ), SizedBox(height: 20), Text( 'Version 1.0', style: TextStyle( fontSize: screenSize.width * 0.035, color: Colors.white.withOpacity(0.8), fontWeight: FontWeight.w400, ), ), ], ), ), ); }, ), ), ], ), ); } }