136 lines
3.9 KiB
Dart
136 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../providers/configuracion_provider.dart';
|
|
import '../services/notification_service.dart';
|
|
import 'dashboard_screen.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> _scaleAnim;
|
|
late Animation<double> _fadeAnim;
|
|
late Animation<Offset> _slideAnim;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = AnimationController(
|
|
duration: const Duration(milliseconds: 800),
|
|
vsync: this,
|
|
);
|
|
_scaleAnim = Tween<double>(begin: 0.5, end: 1.0).animate(
|
|
CurvedAnimation(parent: _controller, curve: Curves.elasticOut),
|
|
);
|
|
_fadeAnim = Tween<double>(begin: 0, end: 1).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.3, 0.7, curve: Curves.easeIn),
|
|
),
|
|
);
|
|
_slideAnim = Tween<Offset>(
|
|
begin: const Offset(0, 0.3),
|
|
end: Offset.zero,
|
|
).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.4, 0.8, curve: Curves.easeOutCubic),
|
|
),
|
|
);
|
|
_controller.forward();
|
|
_init();
|
|
}
|
|
|
|
Future<void> _init() async {
|
|
await NotificationService.instance.init();
|
|
await context.read<ConfiguracionProvider>().cargarConfiguracion();
|
|
await NotificationService.instance.scheduleRecordatorios();
|
|
await Future.delayed(const Duration(milliseconds: 1200));
|
|
if (mounted) {
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(builder: (_) => const DashboardScreen()),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
return Scaffold(
|
|
body: Container(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [
|
|
colorScheme.primary,
|
|
colorScheme.primaryContainer,
|
|
],
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
ScaleTransition(
|
|
scale: _scaleAnim,
|
|
child: Icon(
|
|
Icons.home_rounded,
|
|
size: 80,
|
|
color: colorScheme.onPrimary,
|
|
),
|
|
),
|
|
FadeTransition(
|
|
opacity: _fadeAnim,
|
|
child: SlideTransition(
|
|
position: _slideAnim,
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
'Factura del Hogar',
|
|
style: TextStyle(
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.bold,
|
|
color: colorScheme.onPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'Controla tus gastos del hogar',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: colorScheme.onPrimary.withValues(alpha: 0.8),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 48),
|
|
FadeTransition(
|
|
opacity: _fadeAnim,
|
|
child: CircularProgressIndicator(
|
|
color: colorScheme.onPrimary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|