feat: implementacion completa de 8 modulos, sincronizador centinel, mcp y bitacora de errores
This commit is contained in:
@@ -1,18 +1,149 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme.dart';
|
||||
import '../db/dao/operadores_dao.dart';
|
||||
|
||||
class OperadoresPage extends StatelessWidget {
|
||||
// Comentario explicativo: Pantalla de Operadores conectada a OperadoresDao.
|
||||
// Permite visualizar los operadores de turno y activos en la central de monitoreo,
|
||||
// garantizando datos completos y coherentes durante la revisión de tienda.
|
||||
class OperadorPageItem {
|
||||
final int id;
|
||||
final String nombre;
|
||||
final String iniciales;
|
||||
final int nivel;
|
||||
final bool activo;
|
||||
final bool enTurno;
|
||||
OperadorPageItem({
|
||||
required this.id,
|
||||
required this.nombre,
|
||||
required this.iniciales,
|
||||
required this.nivel,
|
||||
required this.activo,
|
||||
required this.enTurno,
|
||||
});
|
||||
}
|
||||
|
||||
class OperadoresPage extends StatefulWidget {
|
||||
const OperadoresPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OperadoresPage> createState() => _OperadoresPageState();
|
||||
}
|
||||
|
||||
class _OperadoresPageState extends State<OperadoresPage> {
|
||||
final _operadoresDao = OperadoresDao();
|
||||
List<Map<String, dynamic>> _operadores = [];
|
||||
bool _cargando = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cargarOperadores();
|
||||
}
|
||||
|
||||
Future<void> _cargarOperadores() async {
|
||||
final lista = await _operadoresDao.getTodos();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_operadores = lista;
|
||||
_cargando = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
primary: false,
|
||||
padding: const EdgeInsets.all(32),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text('Operadores', style: appHeadline(size: 28, weight: FontWeight.w800)),
|
||||
const SizedBox(height: 8),
|
||||
Text('Gestión de operadores y turnos', style: appLabel(size: 14)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text('Operadores de la Central',
|
||||
style: appHeadline(size: 22, weight: FontWeight.w800, color: AppColors.onSurface)),
|
||||
const SizedBox(height: 4),
|
||||
Text('Control de personal en turno y niveles de autorización',
|
||||
style: appLabel(size: 13, color: AppColors.outline)),
|
||||
]),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh, color: AppColors.primary),
|
||||
onPressed: _cargarOperadores,
|
||||
tooltip: 'Refrescar operadores',
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
if (_cargando)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
else if (_operadores.isEmpty)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(32),
|
||||
alignment: Alignment.center,
|
||||
child: Text('No hay operadores registrados.', style: appLabel(color: AppColors.outline)),
|
||||
)
|
||||
else
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: _operadores.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 12),
|
||||
itemBuilder: (_, i) {
|
||||
final op = _operadores[i];
|
||||
final enTurno = (op['en_turno'] as int? ?? 0) == 1;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceLow,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: enTurno ? AppColors.primary.withOpacity(0.5) : AppColors.outlineVariant,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: AppColors.primaryContainer,
|
||||
child: Text(
|
||||
op['iniciales'] as String? ?? 'OP',
|
||||
style: appHeadline(size: 13, weight: FontWeight.bold, color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
op['nombre'] as String? ?? 'Operador',
|
||||
style: appHeadline(size: 14, weight: FontWeight.w700, color: AppColors.onSurface),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Nivel de acceso: Tier ${op['nivel']} • ${enTurno ? "En Turno Activo" : "Fuera de Turno"}',
|
||||
style: appLabel(size: 12, color: AppColors.outline),
|
||||
),
|
||||
]),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: enTurno ? const Color(0xFF1B382B) : AppColors.surfaceLowest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
enTurno ? 'ACTIVO' : 'INACTIVO',
|
||||
style: appLabel(
|
||||
size: 11,
|
||||
weight: FontWeight.bold,
|
||||
color: enTurno ? AppColors.clienteOk : AppColors.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user