91 lines
2.2 KiB
Dart
91 lines
2.2 KiB
Dart
|
|
import 'dart:async';
|
||
|
|
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:go_router/go_router.dart';
|
||
|
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||
|
|
|
||
|
|
class SplashScreen extends StatefulWidget {
|
||
|
|
const SplashScreen({super.key});
|
||
|
|
|
||
|
|
@override
|
||
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _SplashScreenState extends State<SplashScreen>
|
||
|
|
with SingleTickerProviderStateMixin {
|
||
|
|
late final AnimationController _controller;
|
||
|
|
late final Animation<double> _fadeAnimation;
|
||
|
|
Timer? _navigationTimer;
|
||
|
|
|
||
|
|
@override
|
||
|
|
void initState() {
|
||
|
|
super.initState();
|
||
|
|
|
||
|
|
_controller = AnimationController(
|
||
|
|
vsync: this,
|
||
|
|
duration: const Duration(milliseconds: 800),
|
||
|
|
);
|
||
|
|
|
||
|
|
_fadeAnimation = CurvedAnimation(
|
||
|
|
parent: _controller,
|
||
|
|
curve: Curves.easeIn,
|
||
|
|
);
|
||
|
|
|
||
|
|
_controller.forward();
|
||
|
|
|
||
|
|
_navigationTimer = Timer(const Duration(seconds: 3), () {
|
||
|
|
if (mounted) {
|
||
|
|
context.go('/home');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
void dispose() {
|
||
|
|
_navigationTimer?.cancel();
|
||
|
|
_controller.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.topCenter,
|
||
|
|
end: Alignment.bottomCenter,
|
||
|
|
colors: [
|
||
|
|
AppColors.gradientStart,
|
||
|
|
AppColors.gradientEnd,
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
child: FadeTransition(
|
||
|
|
opacity: _fadeAnimation,
|
||
|
|
child: Column(
|
||
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
|
children: [
|
||
|
|
Image.asset(
|
||
|
|
'assets/images/splash_house.png',
|
||
|
|
width: 150,
|
||
|
|
fit: BoxFit.contain,
|
||
|
|
semanticLabel: 'House illustration',
|
||
|
|
),
|
||
|
|
const SizedBox(height: 35),
|
||
|
|
Image.asset(
|
||
|
|
'assets/images/splash_logo.png',
|
||
|
|
width: 264,
|
||
|
|
fit: BoxFit.contain,
|
||
|
|
semanticLabel: 'RE-Quest logo',
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|