122 lines
3.4 KiB
Dart
Raw Normal View History

2025-08-27 15:07:49 +07:00
import 'package:auto_route/auto_route.dart';
2025-08-27 12:43:25 +07:00
import 'package:flutter/material.dart';
2025-08-27 13:12:30 +07:00
import 'dart:async';
import '../../../common/theme/theme.dart';
import '../../components/assets/assets.gen.dart';
2025-08-27 15:07:49 +07:00
import '../../router/app_router.gr.dart';
2025-08-27 12:43:25 +07:00
2025-08-27 15:07:49 +07:00
@RoutePage()
2025-08-27 12:43:25 +07:00
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
2025-08-27 13:12:30 +07:00
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), () {
2025-08-27 15:07:49 +07:00
context.router.push(OnboardingRoute());
2025-08-27 13:12:30 +07:00
});
}
@override
void dispose() {
_logoController.dispose();
super.dispose();
}
2025-08-27 12:43:25 +07:00
@override
Widget build(BuildContext context) {
return Scaffold(
2025-08-27 13:12:30 +07:00
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),
),
),
),
),
);
},
),
),
2025-08-27 12:43:25 +07:00
),
);
}
}