2026-03-10 22:46:48 +05:30
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
2026-03-10 23:10:23 +05:30
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2026-03-10 22:46:48 +05:30
|
|
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
|
|
|
|
|
2026-05-06 14:59:38 +05:30
|
|
|
class SplashScreen extends StatefulWidget {
|
2026-03-10 22:46:48 +05:30
|
|
|
const SplashScreen({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
2026-05-06 14:59:38 +05:30
|
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
2026-03-10 22:46:48 +05:30
|
|
|
}
|
|
|
|
|
|
2026-05-06 14:59:38 +05:30
|
|
|
class _SplashScreenState extends State<SplashScreen>
|
2026-03-10 22:46:48 +05:30
|
|
|
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();
|
|
|
|
|
|
2026-03-10 23:10:23 +05:30
|
|
|
_navigationTimer = Timer(const Duration(seconds: 3), _navigate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _navigate() async {
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
final onboardingCompleted = prefs.getBool('onboarding_completed') ?? false;
|
|
|
|
|
|
|
|
|
|
if (!mounted) return;
|
2026-05-06 14:59:38 +05:30
|
|
|
if (onboardingCompleted) {
|
|
|
|
|
context.go('/home');
|
|
|
|
|
} else {
|
2026-03-10 23:10:23 +05:30
|
|
|
context.go('/onboarding');
|
|
|
|
|
}
|
2026-03-10 22:46:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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,
|
2026-03-27 15:39:38 +05:30
|
|
|
child: Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 40),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 150,
|
|
|
|
|
height: 108,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/splash_house.png',
|
|
|
|
|
width: 150,
|
|
|
|
|
height: 108,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
semanticLabel: 'House illustration',
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 35),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 264,
|
|
|
|
|
height: 55,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/splash_logo.png',
|
|
|
|
|
width: 264,
|
|
|
|
|
height: 55,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
semanticLabel: 'RE-Quest logo',
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-03-10 22:46:48 +05:30
|
|
|
),
|
2026-03-27 15:39:38 +05:30
|
|
|
),
|
2026-03-10 22:46:48 +05:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|