- 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>
52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
class Usuario {
|
|
final int id;
|
|
final String nombre;
|
|
final String iniciales;
|
|
final int nivelAcceso;
|
|
final String pinHash;
|
|
final String? areas;
|
|
final String? fechaInicio;
|
|
final String? fechaFin;
|
|
final bool activo;
|
|
final bool sincronizado;
|
|
|
|
const Usuario({
|
|
required this.id,
|
|
required this.nombre,
|
|
required this.iniciales,
|
|
required this.nivelAcceso,
|
|
required this.pinHash,
|
|
this.areas,
|
|
this.fechaInicio,
|
|
this.fechaFin,
|
|
this.activo = true,
|
|
this.sincronizado = false,
|
|
});
|
|
|
|
factory Usuario.fromMap(Map<String, dynamic> m) => Usuario(
|
|
id: m['id'] as int,
|
|
nombre: m['nombre'] as String,
|
|
iniciales: m['iniciales'] as String,
|
|
nivelAcceso: m['nivel_acceso'] as int,
|
|
pinHash: m['pin_hash'] as String,
|
|
areas: m['areas'] as String?,
|
|
fechaInicio: m['fecha_inicio'] as String?,
|
|
fechaFin: m['fecha_fin'] as String?,
|
|
activo: (m['activo'] as int) == 1,
|
|
sincronizado: (m['sincronizado'] as int) == 1,
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'nombre': nombre,
|
|
'iniciales': iniciales,
|
|
'nivel_acceso': nivelAcceso,
|
|
'pin_hash': pinHash,
|
|
'areas': areas,
|
|
'fecha_inicio': fechaInicio,
|
|
'fecha_fin': fechaFin,
|
|
'activo': activo ? 1 : 0,
|
|
'sincronizado': sincronizado ? 1 : 0,
|
|
};
|
|
}
|