52 lines
1.5 KiB
Dart
52 lines
1.5 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> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_init();
|
|
}
|
|
|
|
Future<void> _init() async {
|
|
await NotificationService.instance.init();
|
|
await context.read<ConfiguracionProvider>().cargarConfiguracion();
|
|
await NotificationService.instance.scheduleRecordatorios();
|
|
if (mounted) {
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(builder: (_) => const DashboardScreen()),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.home_rounded, size: 80, color: Theme.of(context).colorScheme.onPrimary),
|
|
const SizedBox(height: 16),
|
|
Text('HogarControl',
|
|
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onPrimary)),
|
|
const SizedBox(height: 24),
|
|
CircularProgressIndicator(color: Theme.of(context).colorScheme.onPrimary),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|