66 lines
2.1 KiB
Dart
66 lines
2.1 KiB
Dart
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.',
|
|
);
|
|
}
|
|
}
|
|
} |