102 lines
2.9 KiB
Dart
102 lines
2.9 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
|
|
class SplashScreen extends StatefulWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends State<SplashScreen>
|
|
with SingleTickerProviderStateMixin {
|
|
late AnimationController _controller;
|
|
late Animation<double> _scaleAnimation;
|
|
late Animation<double> _opacityAnimation;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_controller = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(seconds: 2),
|
|
);
|
|
|
|
_scaleAnimation = Tween<double>(begin: 0.6, end: 1.0).animate(
|
|
CurvedAnimation(parent: _controller, curve: Curves.easeOutBack),
|
|
);
|
|
|
|
_opacityAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
CurvedAnimation(parent: _controller, curve: Curves.easeIn),
|
|
);
|
|
|
|
_controller.forward();
|
|
|
|
Timer(const Duration(seconds: 3), () {
|
|
final user = FirebaseAuth.instance.currentUser;
|
|
if (user != null) {
|
|
Navigator.pushReplacementNamed(context, '/main');
|
|
} else {
|
|
Navigator.pushReplacementNamed(context, '/login');
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [Color(0xFF6B4EFF),Color(0xFF8B70FF) ],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
),
|
|
child: Center(
|
|
child: AnimatedBuilder(
|
|
animation: _controller,
|
|
builder: (context, child) {
|
|
return Opacity(
|
|
opacity: _opacityAnimation.value,
|
|
child: Transform.scale(
|
|
scale: _scaleAnimation.value,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Image.asset(
|
|
'assets/images/logo.png',
|
|
width: 80,
|
|
height: 80,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Text(
|
|
'AntiSpy Security',
|
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 1.2,
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
const CircularProgressIndicator(color: Colors.white),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|