Mi primer commit

This commit is contained in:
Kimberly
2026-05-22 23:18:37 -06:00
commit ea0b7e0f75
138 changed files with 6398 additions and 0 deletions

66
lib/alertas_provider.dart Normal file
View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'notificaciones_service.dart';
class AlertasOperativasProvider with ChangeNotifier {
final NotificacionesService _notificacionesService = NotificacionesService();
// Estados de los interruptores configurables por el usuario
bool _notificarInicioRuta = true;
bool _notificarAproximacion = true;
bool _notificarRetrasosFallas = true;
// Getters para leer el estado desde las pantallas
bool get notificarInicioRuta => _notificarInicioRuta;
bool get notificarAproximacion => _notificarAproximacion;
bool get notificarRetrasosFallas => _notificarRetrasosFallas;
// Funciones para cambiar los interruptores (Switches)
void cambiarNotificarInicioRuta(bool valor) {
_notificarInicioRuta = valor;
notifyListeners(); // Notifica a la interfaz que se redibuje
}
void cambiarNotificarAproximacion(bool valor) {
_notificarAproximacion = valor;
notifyListeners();
}
void cambiarNotificarRetrasosFallas(bool valor) {
_notificarRetrasosFallas = valor;
notifyListeners();
}
// =========================================================
// SIMULACIÓN DE DISPAROS DE ALERTAS PUSH REALES
// =========================================================
void simularAlertaInicioRuta() {
if (_notificarInicioRuta) {
_notificacionesService.mostrarNotificacionPush(
id: 1,
titulo: 'Ruta Iniciada 🟢',
mensaje: 'El camión recolector ha comenzado su recorrido hacia tu sector.',
);
}
}
void simularAlertaAproximacion() {
if (_notificarAproximacion) {
_notificacionesService.mostrarNotificacionPush(
id: 2,
titulo: 'Camión Cercano ⏰',
mensaje: 'El recolector llegará a tu domicilio en aproximadamente 15 minutos.',
);
}
}
void simularAlertaRetrasoOConversion() {
if (_notificarRetrasosFallas) {
_notificacionesService.mostrarNotificacionPush(
id: 3,
titulo: 'Retraso en la Ruta ⚠️',
mensaje: 'Aviso: Retraso operativo por tráfico pesado o fallas mecánicas en la zona.',
);
}
}
}