modificaciones en el sistema

This commit is contained in:
Kimberly
2026-05-23 09:30:42 -06:00
parent 7ebce39671
commit 476a6e08e4
5 changed files with 1690 additions and 296 deletions

View File

@@ -1,8 +1,20 @@
import 'package:flutter/material.dart';
import 'notificaciones_service.dart';
// ← Lista de colonias disponibles (igual que en ruta_exclusiva.dart)
const List<String> _coloniasDisponibles = [
'Zona Centro',
'Las Arboledas',
'Trojes',
'San Juanico',
'Los Olivos',
'Rancho Seco',
'Las Insurgentes',
];
class PanelConfiguracionBottomSheet extends StatefulWidget {
final Function(String etiqueta, String direccion) onDomicilioGuardado;
// ← colonia agregada al callback
final Function(String etiqueta, String direccion, String colonia) onDomicilioGuardado;
final bool notificarInicioRuta;
final bool notificarAproximacion;
final bool notificarRetrasosFallas;
@@ -18,13 +30,19 @@ class PanelConfiguracionBottomSheet extends StatefulWidget {
});
@override
State<PanelConfiguracionBottomSheet> createState() => _PanelConfiguracionBottomSheetState();
State<PanelConfiguracionBottomSheet> createState() =>
_PanelConfiguracionBottomSheetState();
}
class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottomSheet> {
final _formKey = GlobalKey<FormState>();
class _PanelConfiguracionBottomSheetState
extends State<PanelConfiguracionBottomSheet> {
final _formKey = GlobalKey<FormState>();
final _direccionController = TextEditingController();
String _etiquetaSeleccionada = 'Casa';
String _coloniaSeleccionada = _coloniasDisponibles[0]; // ← NUEVO
final List<String> _opcionesEtiquetas = ['Casa', 'Trabajo', 'Otro'];
late bool _inicioRuta;
@@ -34,8 +52,8 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
@override
void initState() {
super.initState();
_inicioRuta = widget.notificarInicioRuta;
_aproximacion = widget.notificarAproximacion;
_inicioRuta = widget.notificarInicioRuta;
_aproximacion = widget.notificarAproximacion;
_retrasosFallas = widget.notificarRetrasosFallas;
}
@@ -59,46 +77,112 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Registrar Nuevo Domicilio',
style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Etiqueta:', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.green[800])),
const SizedBox(height: 8),
Row(
children: _opcionesEtpciones(),
// ── Etiqueta ──
Text(
'Etiqueta:',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green[800],
),
),
const SizedBox(height: 8),
Row(children: _opcionesEtpciones()),
const SizedBox(height: 16),
// ── Dirección ──
TextFormField(
controller: _direccionController,
decoration: InputDecoration(
labelText: 'Dirección completa',
prefixIcon: const Icon(Icons.location_on, color: Colors.green),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
validator: (value) {
if (value == null || value.trim().isEmpty) return 'Ingresa una dirección';
if (value == null || value.trim().isEmpty) {
return 'Ingresa una dirección';
}
return null;
},
),
const SizedBox(height: 12),
const SizedBox(height: 16),
// ── Selector de colonia ── NUEVO
Text(
'Colonia:',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green[800],
),
),
const SizedBox(height: 8),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(12),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: _coloniaSeleccionada,
isExpanded: true,
icon: const Icon(Icons.arrow_drop_down, color: Colors.green),
items: _coloniasDisponibles.map((colonia) {
return DropdownMenuItem(
value: colonia,
child: Text(colonia),
);
}).toList(),
onChanged: (value) {
setState(() {
_coloniaSeleccionada = value!;
});
},
),
),
),
const SizedBox(height: 16),
// ── Botón guardar ──
SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green[700],
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
onPressed: () {
if (_formKey.currentState!.validate()) {
widget.onDomicilioGuardado(_etiquetaSeleccionada, _direccionController.text);
// ← pasa también la colonia
widget.onDomicilioGuardado(
_etiquetaSeleccionada,
_direccionController.text,
_coloniaSeleccionada,
);
Navigator.pop(context);
}
},
@@ -108,23 +192,30 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
],
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Divider(color: Colors.black),
),
Row(
children: [
Icon(Icons.notifications_active_rounded, color: Colors.green[800]),
const SizedBox(width: 8),
Text(
'Alertas Operativas Push',
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 8),
SwitchListTile(
title: const Text('Inicio de Ruta', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
title: const Text('Inicio de Ruta',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
value: _inicioRuta,
activeThumbColor: Colors.green[700],
onChanged: (bool value) {
@@ -132,8 +223,10 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
widget.onAlertasChanged(value, 'inicio');
},
),
SwitchListTile(
title: const Text('Camión Próximo', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
title: const Text('Camión Próximo',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
value: _aproximacion,
activeThumbColor: Colors.green[700],
onChanged: (bool value) {
@@ -141,8 +234,10 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
widget.onAlertasChanged(value, 'aproximacion');
},
),
SwitchListTile(
title: const Text('Imprevistos y Retrasos', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
title: const Text('Imprevistos y Retrasos',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
value: _retrasosFallas,
activeThumbColor: Colors.green[700],
onChanged: (bool value) {
@@ -167,9 +262,7 @@ class _PanelConfiguracionBottomSheetState extends State<PanelConfiguracionBottom
selectedColor: Colors.green[100],
checkmarkColor: Colors.green[800],
onSelected: (bool selected) {
setState(() {
_etiquetaSeleccionada = etiqueta;
});
setState(() => _etiquetaSeleccionada = etiqueta);
},
),
);