2025-08-27 13:12:30 +07:00

121 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'dart:async';
import '../../../common/theme/theme.dart';
import '../../components/assets/assets.gen.dart';
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage>
with SingleTickerProviderStateMixin {
late AnimationController _logoController;
late Animation<double> _logoScaleAnimation;
late Animation<double> _logoOpacityAnimation;
@override
void initState() {
super.initState();
_initAnimations();
_startAnimations();
_navigateToHome();
}
void _initAnimations() {
// Logo Animation Controller
_logoController = AnimationController(
duration: const Duration(milliseconds: 1500),
vsync: this,
);
// Logo Animations
_logoScaleAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: _logoController, curve: Curves.elasticOut),
);
_logoOpacityAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(parent: _logoController, curve: Curves.easeIn));
}
void _startAnimations() {
// Start logo animation
_logoController.forward();
}
void _navigateToHome() {
Timer(const Duration(milliseconds: 2500), () {
// Navigate to your main screen here
// Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => HomeScreen()));
print("Navigate to Home Screen");
});
}
@override
void dispose() {
_logoController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [AppColor.backgroundLight, AppColor.background],
),
),
child: Center(
child: AnimatedBuilder(
animation: _logoController,
builder: (context, child) {
return Transform.scale(
scale: _logoScaleAnimation.value,
child: Opacity(
opacity: _logoOpacityAnimation.value,
child: Container(
width: 140,
height: 140,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: AppColor.primaryGradient,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: AppColor.primaryWithOpacity(0.4),
blurRadius: 25,
offset: const Offset(0, 12),
),
],
),
child: ClipOval(
child: Padding(
padding: const EdgeInsets.all(20),
child: Assets.images.logo.image(fit: BoxFit.contain),
),
),
),
),
);
},
),
),
),
);
}
}