feat: add user profile page with stats and account options
Perfil con avatar, badge de nivel de acceso, estadísticas del turno y menú de cuenta (Configuración, Seguridad, Historial, Ayuda). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
93e61da450
commit
e1795410ec
@@ -0,0 +1,201 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme.dart';
|
||||
import 'settings_page.dart';
|
||||
|
||||
class PerfilUsuarioPage extends StatelessWidget {
|
||||
const PerfilUsuarioPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(24, 24, 24, 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_avatarCard(context),
|
||||
const SizedBox(height: 24),
|
||||
_statsGrid(),
|
||||
const SizedBox(height: 32),
|
||||
_seccionOpciones(context),
|
||||
const SizedBox(height: 32),
|
||||
_botonCerrarSesion(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Avatar + info ───────────────────────────────────────────────────────────
|
||||
Widget _avatarCard(BuildContext context) => Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceHigh,
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(children: [
|
||||
Stack(clipBehavior: Clip.none, children: [
|
||||
Container(
|
||||
width: 80, height: 80,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: const LinearGradient(
|
||||
colors: [AppColors.primary, AppColors.primaryContainer],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 20, spreadRadius: 2,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text('JD',
|
||||
style: appHeadline(
|
||||
size: 28, weight: FontWeight.w800,
|
||||
color: AppColors.primaryContainer)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0, right: 0,
|
||||
child: Container(
|
||||
width: 24, height: 24,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceHighest,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: AppColors.surfaceHigh, width: 2),
|
||||
),
|
||||
child: const Icon(Icons.edit, size: 13, color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
Text('Juan Díaz',
|
||||
style: appHeadline(size: 20, weight: FontWeight.w800)),
|
||||
const SizedBox(height: 4),
|
||||
Text('Operador de Seguridad',
|
||||
style: appLabel(size: 13)),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primaryContainer,
|
||||
borderRadius: BorderRadius.circular(99)),
|
||||
child: Text('NIVEL 3 · ACCESO TOTAL',
|
||||
style: appLabel(size: 10, weight: FontWeight.bold,
|
||||
color: AppColors.primary, spacing: 1.5)),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
// ── Estadísticas ────────────────────────────────────────────────────────────
|
||||
Widget _statsGrid() => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('ESTADÍSTICAS DEL TURNO',
|
||||
style: appLabel(size: 10, weight: FontWeight.bold,
|
||||
color: AppColors.onSurfaceVariant, spacing: 2.0)),
|
||||
const SizedBox(height: 12),
|
||||
Row(children: [
|
||||
Expanded(child: _statItem('142', 'Alarmas\ngestionadas',
|
||||
Icons.notifications_active, AppColors.primary)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _statItem('38', 'Accesos\nautorizados',
|
||||
Icons.lock_open, AppColors.secondary)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _statItem('03', 'Alertas\nactivas',
|
||||
Icons.warning, AppColors.error)),
|
||||
]),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _statItem(String valor, String label, IconData icon, Color color) =>
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceLow,
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(children: [
|
||||
Icon(icon, color: color, size: 20),
|
||||
const SizedBox(height: 8),
|
||||
Text(valor, style: appHeadline(size: 22, color: color)),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: appLabel(size: 10), textAlign: TextAlign.center),
|
||||
]),
|
||||
);
|
||||
|
||||
// ── Opciones ────────────────────────────────────────────────────────────────
|
||||
Widget _seccionOpciones(BuildContext context) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('CUENTA',
|
||||
style: appLabel(size: 10, weight: FontWeight.bold,
|
||||
color: AppColors.onSurfaceVariant, spacing: 2.0)),
|
||||
const SizedBox(height: 12),
|
||||
_opcionItem(Icons.settings, 'Configuración',
|
||||
'Notificaciones, sonido y alarmas', () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsPage()));
|
||||
}),
|
||||
const Divider(color: AppColors.outlineVariant, height: 1),
|
||||
_opcionItem(Icons.shield_outlined, 'Seguridad',
|
||||
'Cambiar PIN de acceso', () {}),
|
||||
const Divider(color: AppColors.outlineVariant, height: 1),
|
||||
_opcionItem(Icons.history, 'Historial de sesiones',
|
||||
'Últimos accesos al sistema', () {}),
|
||||
const Divider(color: AppColors.outlineVariant, height: 1),
|
||||
_opcionItem(Icons.help_outline, 'Ayuda y soporte',
|
||||
'Manual del operador', () {}),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _opcionItem(IconData icon, String titulo, String subtitulo,
|
||||
VoidCallback onTap) =>
|
||||
InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 40, height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceHighest,
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
child: Icon(icon, color: AppColors.primary, size: 20),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(titulo, style: appHeadline(size: 14)),
|
||||
const SizedBox(height: 2),
|
||||
Text(subtitulo, style: appLabel(size: 12)),
|
||||
],
|
||||
)),
|
||||
const Icon(Icons.chevron_right,
|
||||
color: AppColors.outlineVariant, size: 20),
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
// ── Cerrar sesión ───────────────────────────────────────────────────────────
|
||||
Widget _botonCerrarSesion(BuildContext context) => SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((r) => r.isFirst);
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: AppColors.error, size: 18),
|
||||
label: Text('Cerrar Sesión',
|
||||
style: appLabel(size: 14, weight: FontWeight.bold,
|
||||
color: AppColors.error)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: AppColors.error, width: 1),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user