feat: add SQLite data layer, local auth and security settings

- Add offline-first SQLite architecture with DatabaseHelper singleton,
  12 CREATE TABLE statements and full seed data on first launch
- Add 10 models (fromMap/toMap) and 12 DAOs with CRUD + getPendientes()
- Add ApiAuthService (JWT via SharedPreferences) and Sincronizador skeleton
- Move login auth from SQLite to SharedPreferences with SHA-256 PIN hash;
  default PIN 123456, platform-independent (no native plugin required)
- Add seguridad_page.dart: change PIN form (current → new → confirm)
- Add Cerrar Sesión with confirmation dialog and full stack clear
- Redesign settings_page.dart with AppColors dark theme; add Sistema
  section with "Inicializar base de datos" and "Inicializar sincronización"
- Fix Linux desktop: sqflite_common_ffi with platform detection in DatabaseHelper
- Fix ScrollController conflict on Linux: primary: false on all IndexedStack pages
- Update plan_proyecto.md with session 2–3 progress and auth roadmap

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Pablinux
2026-04-14 01:56:13 -05:00
co-authored by Claude Sonnet 4.6
parent 8f13d57839
commit 1184ab5fe2
35 changed files with 2735 additions and 346 deletions
+1 -74
View File
@@ -51,14 +51,13 @@ class _MonitoreoAlarmaPageState extends State<MonitoreoAlarmaPage>
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
primary: false,
padding: const EdgeInsets.fromLTRB(24, 24, 24, 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_statusBento(),
const SizedBox(height: 32),
_frequencyChart(),
const SizedBox(height: 32),
_criticalEvents(),
const SizedBox(height: 32),
_eventLog(),
@@ -149,78 +148,6 @@ class _MonitoreoAlarmaPageState extends State<MonitoreoAlarmaPage>
);
// ── Gráfico de frecuencia ───────────────────────────────────────────────────
Widget _frequencyChart() {
const maxH = 110.0;
final fracciones = [0.40, 0.65, 0.95, 0.55, 0.30, 0.45, 0.20];
final dias = ['LUN', 'MAR', 'MIÉ', 'JUE', 'VIE', 'SÁB', 'DOM'];
const picoIdx = 2;
return Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(color: AppColors.surfaceLow,
borderRadius: BorderRadius.circular(12)),
child: Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text('FRECUENCIA DE ALARMAS',
style: appHeadline(size: 13, spacing: 1.5)),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(color: AppColors.secondaryContainer,
borderRadius: BorderRadius.circular(99)),
child: Text('TENDENCIA SEMANAL',
style: appLabel(size: 10, weight: FontWeight.bold,
color: AppColors.onSecondaryContainer)),
),
]),
const SizedBox(height: 24),
SizedBox(
height: maxH + 20,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: List.generate(fracciones.length, (i) {
final isPico = i == picoIdx;
return Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (isPico)
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text('PICO', style: appLabel(
size: 9, weight: FontWeight.bold,
color: AppColors.error)),
),
Container(
height: maxH * fracciones[i],
decoration: BoxDecoration(
color: isPico
? AppColors.error.withOpacity(0.4)
: AppColors.primary.withOpacity(0.2),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(4)),
),
),
],
),
),
);
}),
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(dias.length, (i) => Text(dias[i],
style: appLabel(size: 10,
weight: i == picoIdx ? FontWeight.bold : FontWeight.normal,
color: i == picoIdx ? AppColors.onSurface : AppColors.onSurfaceVariant))),
),
]),
);
}
// ── Eventos críticos ────────────────────────────────────────────────────────
Widget _criticalEvents() => Column(
crossAxisAlignment: CrossAxisAlignment.start,