feat: submenu tactico (camaras, rastreo OSM/CartoDB), comunicacion, consola datos SQLite, clientes tipo_servicio y documentacion estandar
This commit is contained in:
+301
-62
@@ -4,6 +4,10 @@ import 'services/api_auth_service.dart';
|
||||
import 'db/dao/sesiones_dao.dart';
|
||||
import 'pages/dashboard_page.dart';
|
||||
import 'pages/monitoreo_page.dart';
|
||||
// Comentario explicativo: Importaciones de las sub-vistas tácticas de Monitoreo (Cámaras y Rastreo) y la consola de Estado de Comunicación
|
||||
import 'pages/camaras_page.dart';
|
||||
import 'pages/rastreo_page.dart';
|
||||
import 'pages/comunicacion_page.dart';
|
||||
import 'pages/clientes_page.dart';
|
||||
import 'pages/operadores_page.dart';
|
||||
import 'pages/incidentes_page.dart';
|
||||
@@ -15,6 +19,11 @@ import 'services/sincronizador.dart';
|
||||
class ShellPage extends StatefulWidget {
|
||||
const ShellPage({Key? key}) : super(key: key);
|
||||
|
||||
// Comentario explicativo: Método estático público para permitir saltos de navegación cruzada desde cualquier sub-pantalla (ej: Monitoreo -> Comunicación)
|
||||
static void irA(BuildContext context, int nuevoIndice) {
|
||||
context.findAncestorStateOfType<_ShellPageState>()?.cambiarIndice(nuevoIndice);
|
||||
}
|
||||
|
||||
@override
|
||||
State<ShellPage> createState() => _ShellPageState();
|
||||
}
|
||||
@@ -23,30 +32,39 @@ class _ShellPageState extends State<ShellPage> {
|
||||
int _indice = 0;
|
||||
String _operadorNombre = 'Operador';
|
||||
bool _apiConectada = false;
|
||||
bool _monitoreoExpandido = true;
|
||||
|
||||
final _sesionesDao = SesionesDao();
|
||||
|
||||
// Comentario explicativo: Lista de páginas indexadas en ShellPage.
|
||||
// 0: Dashboard, 1: Alarmas, 2: Cámaras, 3: Rastreo, 4: Clientes, 5: Operadores,
|
||||
// 6: Incidentes, 7: Dispositivos, 8: Comunicación, 9: Reportes, 10: Configuración
|
||||
static const _paginas = [
|
||||
DashboardPage(),
|
||||
MonitoreoPage(),
|
||||
ClientesPage(),
|
||||
OperadoresPage(),
|
||||
IncidentesPage(),
|
||||
DispositivosPage(),
|
||||
ReportesPage(),
|
||||
ConfiguracionPage(),
|
||||
DashboardPage(), // 0
|
||||
MonitoreoPage(), // 1 (Alarmas)
|
||||
CamarasPage(), // 2 (Cámaras)
|
||||
RastreoPage(), // 3 (Rastreo)
|
||||
ClientesPage(), // 4
|
||||
OperadoresPage(), // 5
|
||||
IncidentesPage(), // 6
|
||||
DispositivosPage(), // 7
|
||||
ComunicacionPage(), // 8 (Estado de Comunicación)
|
||||
ReportesPage(), // 9
|
||||
ConfiguracionPage(),// 10
|
||||
];
|
||||
|
||||
static const _navItems = [
|
||||
_NavItem(Icons.dashboard_outlined, Icons.dashboard, 'Dashboard'),
|
||||
_NavItem(Icons.track_changes_outlined, Icons.track_changes, 'Monitoreo'),
|
||||
_NavItem(Icons.business_outlined, Icons.business, 'Clientes'),
|
||||
_NavItem(Icons.group_outlined, Icons.group, 'Operadores'),
|
||||
_NavItem(Icons.assignment_outlined, Icons.assignment, 'Incidentes'),
|
||||
_NavItem(Icons.devices_outlined, Icons.devices, 'Dispositivos'),
|
||||
_NavItem(Icons.bar_chart_outlined, Icons.bar_chart, 'Reportes'),
|
||||
_NavItem(Icons.settings_outlined, Icons.settings, 'Configuración'),
|
||||
];
|
||||
// Comentario explicativo: Actualiza el índice activo y mantiene expandido el acordeón si se navega a una sub-vista de Monitoreo
|
||||
void cambiarIndice(int nuevoIndice) {
|
||||
setState(() {
|
||||
_indice = nuevoIndice;
|
||||
if (nuevoIndice >= 1 && nuevoIndice <= 3) {
|
||||
_monitoreoExpandido = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Comentario explicativo: La navegación ahora se gestiona directamente en _buildNavigationList para
|
||||
// soportar la estructura jerárquica con acordeón de Monitoreo (Alarmas, Cámaras, Rastreo) y Estado de Comunicación.
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -148,11 +166,7 @@ class _ShellPageState extends State<ShellPage> {
|
||||
),
|
||||
const Divider(color: AppColors.outlineVariant, height: 1),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
itemCount: _navItems.length,
|
||||
itemBuilder: (_, i) => _navTile(i, cerrarDrawerAlTocar: true),
|
||||
),
|
||||
child: _buildNavigationList(cerrarDrawerAlTocar: true),
|
||||
),
|
||||
]),
|
||||
),
|
||||
@@ -185,8 +199,8 @@ class _ShellPageState extends State<ShellPage> {
|
||||
bottomNavigationBar: esMovil
|
||||
? BottomNavigationBar(
|
||||
// Comentario explicativo: Mapeo de índices de navegación móvil:
|
||||
// 0: Dashboard, 1: Monitoreo, 2: Clientes, 4: Incidentes
|
||||
currentIndex: _indice == 4 ? 3 : (_indice < 3 ? _indice : 0),
|
||||
// 0: Dashboard, 1: Monitoreo (Alarmas), 4: Clientes, 6: Incidentes, 8: Comunicación
|
||||
currentIndex: _indice == 8 ? 4 : (_indice == 6 ? 3 : (_indice == 4 ? 2 : (_indice >= 1 && _indice <= 3 ? 1 : 0))),
|
||||
backgroundColor: AppColors.surfaceLow,
|
||||
selectedItemColor: AppColors.primary,
|
||||
unselectedItemColor: AppColors.onSurfaceVariant,
|
||||
@@ -194,8 +208,8 @@ class _ShellPageState extends State<ShellPage> {
|
||||
selectedFontSize: 11,
|
||||
unselectedFontSize: 10,
|
||||
onTap: (i) {
|
||||
const indicesMovil = [0, 1, 2, 4];
|
||||
setState(() => _indice = indicesMovil[i]);
|
||||
const indicesMovil = [0, 1, 4, 6, 8];
|
||||
cambiarIndice(indicesMovil[i]);
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
@@ -218,6 +232,11 @@ class _ShellPageState extends State<ShellPage> {
|
||||
activeIcon: Icon(Icons.assignment),
|
||||
label: 'Incidentes',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.cell_tower_outlined),
|
||||
activeIcon: Icon(Icons.cell_tower),
|
||||
label: 'Comunicación',
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
@@ -285,7 +304,7 @@ class _ShellPageState extends State<ShellPage> {
|
||||
),
|
||||
]),
|
||||
),
|
||||
// Comentario explicativo: Indicador visual prioritario de alarmas críticas en el header con salto directo a Monitoreo
|
||||
// Comentario explicativo: Indicador visual prioritario de alarmas críticas en el header con salto directo a Monitoreo (Alarmas)
|
||||
ValueListenableBuilder<int>(
|
||||
valueListenable: Sincronizador.instance.criticalAlarmsCount,
|
||||
builder: (ctx, count, _) {
|
||||
@@ -293,7 +312,7 @@ class _ShellPageState extends State<ShellPage> {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 6),
|
||||
child: InkWell(
|
||||
onTap: () => setState(() => _indice = 1),
|
||||
onTap: () => cambiarIndice(1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
@@ -366,24 +385,251 @@ class _ShellPageState extends State<ShellPage> {
|
||||
);
|
||||
|
||||
// ── Sidebar ─────────────────────────────────────────────────────────────────
|
||||
// Comentario explicativo: Sidebar lateral fijo para escritorio con menú interactivo y acordeón en Monitoreo
|
||||
Widget _sidebar() => Container(
|
||||
width: 220,
|
||||
color: AppColors.surfaceLow,
|
||||
child: Column(children: [
|
||||
const SizedBox(height: 8),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
itemCount: _navItems.length,
|
||||
itemBuilder: (_, i) => _navTile(i),
|
||||
),
|
||||
child: _buildNavigationList(cerrarDrawerAlTocar: false),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
Widget _navTile(int i, {bool cerrarDrawerAlTocar = false}) {
|
||||
final item = _navItems[i];
|
||||
final activo = _indice == i;
|
||||
// Comentario explicativo: Construye la lista de navegación compartida entre el Sidebar de escritorio y el Drawer móvil
|
||||
Widget _buildNavigationList({bool cerrarDrawerAlTocar = false}) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
children: [
|
||||
// 0: Dashboard
|
||||
_navItemTile(
|
||||
indice: 0,
|
||||
label: 'Dashboard',
|
||||
icon: Icons.dashboard_outlined,
|
||||
iconActivo: Icons.dashboard,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
// Acordeón Monitoreo con submenú (Alarmas, Cámaras, Rastreo)
|
||||
_monitoreoAccordionTile(cerrarDrawerAlTocar: cerrarDrawerAlTocar),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
// 4: Clientes
|
||||
_navItemTile(
|
||||
indice: 4,
|
||||
label: 'Clientes',
|
||||
icon: Icons.business_outlined,
|
||||
iconActivo: Icons.business,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 5: Operadores
|
||||
_navItemTile(
|
||||
indice: 5,
|
||||
label: 'Operadores',
|
||||
icon: Icons.group_outlined,
|
||||
iconActivo: Icons.group,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 6: Incidentes
|
||||
_navItemTile(
|
||||
indice: 6,
|
||||
label: 'Incidentes',
|
||||
icon: Icons.assignment_outlined,
|
||||
iconActivo: Icons.assignment,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 7: Dispositivos
|
||||
_navItemTile(
|
||||
indice: 7,
|
||||
label: 'Dispositivos',
|
||||
icon: Icons.devices_outlined,
|
||||
iconActivo: Icons.devices,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 8: Estado de Comunicación
|
||||
_navItemTile(
|
||||
indice: 8,
|
||||
label: 'Comunicación',
|
||||
icon: Icons.cell_tower_outlined,
|
||||
iconActivo: Icons.cell_tower,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 9: Reportes
|
||||
_navItemTile(
|
||||
indice: 9,
|
||||
label: 'Reportes',
|
||||
icon: Icons.bar_chart_outlined,
|
||||
iconActivo: Icons.bar_chart,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// 10: Configuración
|
||||
_navItemTile(
|
||||
indice: 10,
|
||||
label: 'Configuración',
|
||||
icon: Icons.settings_outlined,
|
||||
iconActivo: Icons.settings,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Comentario explicativo: Acordeón desplegable para la sección de Monitoreo con submenú: Alarmas, Cámaras y Rastreo
|
||||
Widget _monitoreoAccordionTile({bool cerrarDrawerAlTocar = false}) {
|
||||
final estaEnSubMenu = _indice >= 1 && _indice <= 3;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (!_monitoreoExpandido) {
|
||||
_monitoreoExpandido = true;
|
||||
if (!estaEnSubMenu) cambiarIndice(1);
|
||||
} else {
|
||||
if (estaEnSubMenu) {
|
||||
_monitoreoExpandido = false;
|
||||
} else {
|
||||
cambiarIndice(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: estaEnSubMenu ? AppColors.primaryContainer.withOpacity(0.35) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: estaEnSubMenu ? AppColors.primary.withOpacity(0.3) : Colors.transparent,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
estaEnSubMenu ? Icons.track_changes : Icons.track_changes_outlined,
|
||||
size: 20,
|
||||
color: estaEnSubMenu ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Monitoreo',
|
||||
style: appLabel(
|
||||
size: 13,
|
||||
weight: estaEnSubMenu ? FontWeight.w700 : FontWeight.normal,
|
||||
color: estaEnSubMenu ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
_monitoreoExpandido ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
|
||||
size: 16,
|
||||
color: AppColors.outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_monitoreoExpandido) ...[
|
||||
const SizedBox(height: 2),
|
||||
// Sub-ítem 1: Alarmas
|
||||
_subItemTile(
|
||||
indice: 1,
|
||||
label: 'Alarmas',
|
||||
icon: Icons.notifications_active_outlined,
|
||||
iconActivo: Icons.notifications_active,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// Sub-ítem 2: Cámaras
|
||||
_subItemTile(
|
||||
indice: 2,
|
||||
label: 'Cámaras',
|
||||
icon: Icons.videocam_outlined,
|
||||
iconActivo: Icons.videocam,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
// Sub-ítem 3: Rastreo
|
||||
_subItemTile(
|
||||
indice: 3,
|
||||
label: 'Rastreo',
|
||||
icon: Icons.near_me_outlined,
|
||||
iconActivo: Icons.near_me,
|
||||
cerrarDrawerAlTocar: cerrarDrawerAlTocar,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Comentario explicativo: Sub-ítem sangrado para las opciones internas de Monitoreo
|
||||
Widget _subItemTile({
|
||||
required int indice,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required IconData iconActivo,
|
||||
bool cerrarDrawerAlTocar = false,
|
||||
}) {
|
||||
final activo = _indice == indice;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 2, top: 2, bottom: 2),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () {
|
||||
cambiarIndice(indice);
|
||||
if (cerrarDrawerAlTocar) Navigator.of(context).pop();
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: activo ? AppColors.primaryContainer : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
activo ? iconActivo : icon,
|
||||
size: 17,
|
||||
color: activo ? AppColors.primary : AppColors.outline,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
label,
|
||||
style: appLabel(
|
||||
size: 12,
|
||||
weight: activo ? FontWeight.w700 : FontWeight.normal,
|
||||
color: activo ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Comentario explicativo: Ítem de nivel principal en el menú de navegación lateral
|
||||
Widget _navItemTile({
|
||||
required int indice,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required IconData iconActivo,
|
||||
bool cerrarDrawerAlTocar = false,
|
||||
}) {
|
||||
final activo = _indice == indice;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Material(
|
||||
@@ -392,10 +638,8 @@ class _ShellPageState extends State<ShellPage> {
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
onTap: () {
|
||||
setState(() => _indice = i);
|
||||
if (cerrarDrawerAlTocar) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
cambiarIndice(indice);
|
||||
if (cerrarDrawerAlTocar) Navigator.of(context).pop();
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
@@ -404,32 +648,27 @@ class _ShellPageState extends State<ShellPage> {
|
||||
color: activo ? AppColors.primaryContainer : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(children: [
|
||||
Icon(
|
||||
activo ? item.iconActivo : item.icon,
|
||||
size: 20,
|
||||
color: activo ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
item.label,
|
||||
style: appLabel(
|
||||
size: 13,
|
||||
weight: activo ? FontWeight.w600 : FontWeight.normal,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
activo ? iconActivo : icon,
|
||||
size: 20,
|
||||
color: activo ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
label,
|
||||
style: appLabel(
|
||||
size: 13,
|
||||
weight: activo ? FontWeight.w600 : FontWeight.normal,
|
||||
color: activo ? AppColors.primary : AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NavItem {
|
||||
final IconData icon;
|
||||
final IconData iconActivo;
|
||||
final String label;
|
||||
const _NavItem(this.icon, this.iconActivo, this.label);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user