first commit

This commit is contained in:
=
2026-09-21 16:33:51 -04:00
commit a899479dc9
204 changed files with 21132 additions and 0 deletions
@@ -0,0 +1,173 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../../../core/theme/app_colors.dart';
import '../widgets/quick_actions_dropdown.dart';
class DashboardAppBar extends StatelessWidget implements PreferredSizeWidget {
final String doctorName;
final String specialty;
final bool isSecretary;
final VoidCallback? onLogoutPressed;
final ValueChanged<QuickActionType>? onQuickActionSelected;
const DashboardAppBar({
super.key,
required this.doctorName,
required this.specialty,
this.isSecretary = false,
this.onLogoutPressed,
this.onQuickActionSelected,
});
@override
Size get preferredSize => const Size.fromHeight(70);
@override
Widget build(BuildContext context) {
return Container(
height: preferredSize.height,
padding: const EdgeInsets.symmetric(horizontal: 20),
decoration: const BoxDecoration(
color: AppColors.surface,
border: Border(
bottom: BorderSide(color: AppColors.border, width: 1),
),
),
child: SafeArea(
bottom: false,
child: Row(
children: [
// 1. Parte Izquierda: Nombre del Doctor y Especialidad (Flexible)
Expanded(
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.primaryContainer,
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.medical_services_rounded,
color: AppColors.primary,
size: 22,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
doctorName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 15,
color: AppColors.textPrimary,
),
),
Row(
children: [
Flexible(
child: Text(
specialty,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 12,
color: AppColors.textSecondary,
),
),
),
if (isSecretary) ...[
const SizedBox(width: 6),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1.5),
decoration: BoxDecoration(
color: const Color(0xFF00A65A).withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(4),
),
child: const Text(
'RECEPCIÓN',
style: TextStyle(
fontSize: 9.5,
fontWeight: FontWeight.w700,
color: Color(0xFF00A65A),
letterSpacing: 0.4,
),
),
),
],
],
),
],
),
),
],
),
),
// 2. Parte Central: Logo de Hidalyx
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SvgPicture.asset(
'assets/images/hidalyx_logo_blue.svg',
height: 32,
fit: BoxFit.contain,
),
),
// 3. Parte Derecha: Dropdown de Acciones Rápidas + Botón Cerrar Sesión
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
QuickActionsDropdown(
onActionSelected: onQuickActionSelected,
isSecretary: isSecretary,
),
const SizedBox(width: 10),
Tooltip(
message: 'Cerrar sesión',
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: onLogoutPressed,
child: Container(
height: 36,
width: 36,
decoration: BoxDecoration(
color: AppColors.background,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.border),
),
child: const Icon(
Icons.logout_rounded,
color: AppColors.textSecondary,
size: 18,
),
),
),
),
),
],
),
),
),
),
],
),
),
);
}
}
@@ -0,0 +1,266 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_colors.dart';
import '../../data/models/dashboard_metrics_model.dart';
class DashboardMetricsCards extends StatelessWidget {
final DashboardMetricsModel metrics;
const DashboardMetricsCards({super.key, required this.metrics});
String _formatNumber(int n) {
return n.toString().replaceAllMapped(
RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'),
(Match m) => '${m[1]},',
);
}
@override
Widget build(BuildContext context) {
final cards = [
// 1. Total de Nuevos Pacientes
_buildMetricCard(
title: 'Total Nuevos Pacientes',
value: _formatNumber(metrics.nuevosPacientes),
subtitle: 'Registrados en la plataforma',
icon: Icons.person_add_alt_1_rounded,
iconColor: AppColors.primary,
bgColor: AppColors.primaryContainer,
),
// 2. Total de Consultados Hoy
_buildMetricCard(
title: 'Total Consultados Hoy',
value: _formatNumber(metrics.consultadosHoy),
subtitle: 'Atenciones médicas realizadas',
icon: Icons.assignment_turned_in_rounded,
iconColor: AppColors.teal,
bgColor: AppColors.teal.withValues(alpha: 0.12),
),
// 3. Total de Citas para Hoy
_buildMetricCard(
title: 'Total Citas para Hoy',
value: _formatNumber(metrics.citasHoy),
subtitle: 'Pacientes agendados',
icon: Icons.event_available_rounded,
iconColor: AppColors.warning,
bgColor: AppColors.warning.withValues(alpha: 0.12),
),
// 4. Total de Pacientes por Sexo
_buildGenderCard(),
];
return LayoutBuilder(
builder: (context, constraints) {
const spacing = 16.0;
// Distribución equitativa en 4 columnas (pantallas amplias)
if (constraints.maxWidth >= 1000) {
return IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: cards[0]),
const SizedBox(width: spacing),
Expanded(child: cards[1]),
const SizedBox(width: spacing),
Expanded(child: cards[2]),
const SizedBox(width: spacing),
Expanded(child: cards[3]),
],
),
);
}
// Distribución equitativa en 2 columnas (pantallas medianas)
if (constraints.maxWidth >= 550) {
return Column(
children: [
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: cards[0]),
const SizedBox(width: spacing),
Expanded(child: cards[1]),
],
),
),
const SizedBox(height: spacing),
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: cards[2]),
const SizedBox(width: spacing),
Expanded(child: cards[3]),
],
),
),
],
);
}
// 1 columna ocupando 100% del ancho (pantallas móviles / compactas)
return Column(
children: [
cards[0],
const SizedBox(height: spacing),
cards[1],
const SizedBox(height: spacing),
cards[2],
const SizedBox(height: spacing),
cards[3],
],
);
},
);
}
Widget _buildMetricCard({
required String title,
String? value,
Widget? valueWidget,
required String subtitle,
required IconData icon,
required Color iconColor,
required Color bgColor,
}) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(color: AppColors.border),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.02),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(12),
),
child: Icon(icon, color: iconColor, size: 24),
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: AppColors.textSecondary,
),
),
const SizedBox(height: 4),
valueWidget ??
Text(
value ?? '',
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
color: AppColors.textPrimary,
),
),
const SizedBox(height: 2),
Text(
subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 11,
color: AppColors.textMuted,
),
),
],
),
),
],
),
);
}
Widget _buildGenderCard() {
final total = metrics.pacientesMasculinos + metrics.pacientesFemeninos;
final mascPct = total > 0 ? ((metrics.pacientesMasculinos / total) * 100).toInt() : 81;
final femPct = total > 0 ? ((metrics.pacientesFemeninos / total) * 100).toInt() : 19;
return _buildMetricCard(
title: 'Pacientes por Sexo',
valueWidget: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
_formatNumber(metrics.pacientesMasculinos),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: AppColors.primary,
),
),
const Text(
' M',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: AppColors.primary,
),
),
const SizedBox(width: 8),
const Text(
'/',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: AppColors.border,
),
),
const SizedBox(width: 8),
Text(
_formatNumber(metrics.pacientesFemeninos),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Color(0xFFEC4899),
),
),
const Text(
' F',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Color(0xFFEC4899),
),
),
],
),
),
subtitle: '$mascPct% Masc · $femPct% Fem',
icon: Icons.people_alt_rounded,
iconColor: AppColors.secondary,
bgColor: AppColors.secondary.withValues(alpha: 0.12),
);
}
}
@@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_colors.dart';
enum QuickActionType {
nuevoPaciente,
buscarPaciente,
configuracion,
}
typedef QuickActionBar = QuickActionsDropdown;
class QuickActionsDropdown extends StatelessWidget {
final ValueChanged<QuickActionType>? onActionSelected;
final bool isSecretary;
const QuickActionsDropdown({
super.key,
this.onActionSelected,
this.isSecretary = false,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
// 1. Botón Buscar Paciente (Acción Secundaria / Buscador Rápido)
Tooltip(
message: 'Buscar paciente por nombre, cédula o teléfono',
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: () => onActionSelected?.call(QuickActionType.buscarPaciente),
child: Container(
height: 36,
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: AppColors.background,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.border),
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.search_rounded,
color: AppColors.textSecondary,
size: 17,
),
SizedBox(width: 7),
Text(
'Buscar Paciente',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: AppColors.textSecondary,
),
),
],
),
),
),
),
),
const SizedBox(width: 8),
// 2. Botón Nuevo Paciente (Acción Primaria Destacada de 1 clic)
Tooltip(
message: 'Registrar nuevo paciente',
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: () => onActionSelected?.call(QuickActionType.nuevoPaciente),
child: Container(
height: 36,
padding: const EdgeInsets.symmetric(horizontal: 14),
decoration: BoxDecoration(
color: AppColors.primary,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: AppColors.primary.withValues(alpha: 0.22),
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.person_add_rounded,
color: Colors.white,
size: 17,
),
SizedBox(width: 7),
Text(
'Nuevo Paciente',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
],
),
),
),
),
),
// 3. Botón Configuración (Solo Doctor / Administrador, oculto para Secretaria)
if (!isSecretary) ...[
const SizedBox(width: 8),
Tooltip(
message: 'Configuración del Consultorio',
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: () => onActionSelected?.call(QuickActionType.configuracion),
child: Container(
height: 36,
width: 36,
decoration: BoxDecoration(
color: AppColors.background,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.border),
),
child: const Icon(
Icons.settings_outlined,
color: AppColors.textSecondary,
size: 18,
),
),
),
),
),
],
],
);
}
}
@@ -0,0 +1,215 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_colors.dart';
import '../../data/models/patient_summary_model.dart';
class RecentPatientsCard extends StatelessWidget {
final List<PatientSummaryModel> patients;
const RecentPatientsCard({
super.key,
required this.patients,
});
String _getInitials(String name, String lastName) {
final n = name.trim().isNotEmpty ? name.trim()[0] : '';
final l = lastName.trim().isNotEmpty ? lastName.trim()[0] : '';
final res = '$n$l'.toUpperCase();
return res.isNotEmpty ? res : 'P';
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(22),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.border),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.02),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Encabezado
Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: AppColors.primaryContainer,
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.person_add_alt_1_rounded,
color: AppColors.primary,
size: 20,
),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Pacientes Nuevos',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: AppColors.textPrimary,
),
),
Text(
'Últimos registros ingresados al sistema',
style: TextStyle(
fontSize: 12,
color: AppColors.textSecondary,
),
),
],
),
),
],
),
const SizedBox(height: 18),
const Divider(color: AppColors.divider, height: 1),
const SizedBox(height: 14),
// Contenido con Scroll Interno delimitado
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 330),
child: Scrollbar(
child: SingleChildScrollView(
child: patients.isEmpty
? const Padding(
padding: EdgeInsets.symmetric(vertical: 32),
child: Center(
child: Column(
children: [
Icon(Icons.people_outline_rounded, size: 40, color: AppColors.textMuted),
SizedBox(height: 8),
Text(
'No se encontraron pacientes recientes',
style: TextStyle(color: AppColors.textSecondary, fontSize: 13),
),
],
),
),
)
: Padding(
padding: const EdgeInsets.only(right: 6),
child: Column(
children: [
for (var i = 0; i < patients.length; i++) ...[
if (i > 0) const Divider(color: AppColors.divider, height: 16),
Row(
children: [
// Avatar con iniciales
CircleAvatar(
radius: 19,
backgroundColor: AppColors.primaryContainer,
child: Text(
_getInitials(patients[i].nombre, patients[i].apellido),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: AppColors.primary,
),
),
),
const SizedBox(width: 14),
// Nombre y Detalles
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
patients[i].fullName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
),
),
const SizedBox(height: 2),
Wrap(
spacing: 8,
runSpacing: 2,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
if (patients[i].telefono.isNotEmpty)
Text(
patients[i].telefono,
style: const TextStyle(
fontSize: 11,
color: AppColors.textSecondary,
),
),
Text(
patients[i].cedula.isNotEmpty
? patients[i].cedula
: (patients[i].seguro.isNotEmpty ? patients[i].seguro : 'Particular'),
style: const TextStyle(
fontSize: 11,
color: AppColors.textMuted,
),
),
],
),
],
),
),
const SizedBox(width: 10),
// Badge de Fecha de Registro
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: AppColors.background,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.border),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.calendar_today_rounded,
size: 11,
color: AppColors.textSecondary,
),
const SizedBox(width: 5),
Text(
patients[i].fecReg.isNotEmpty
? patients[i].fecReg.split(' ').first
: 'Reciente',
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w500,
color: AppColors.textSecondary,
),
),
],
),
),
],
),
],
],
),
),
),
),
),
],
),
);
}
}
@@ -0,0 +1,470 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_colors.dart';
import '../../data/models/patient_summary_model.dart';
class TodayAppointmentsCard extends StatelessWidget {
final List<PatientSummaryModel> appointments;
final VoidCallback? onSchedulePressed;
final ValueChanged<PatientSummaryModel>? onPatientTap;
final bool isSecretary;
final Future<void> Function(PatientSummaryModel patient, String newStatus)? onStatusChange;
const TodayAppointmentsCard({
super.key,
required this.appointments,
this.onSchedulePressed,
this.onPatientTap,
this.isSecretary = false,
this.onStatusChange,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(22),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.border),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.02),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Encabezado
Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: AppColors.warning.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.event_available_rounded,
color: AppColors.warning,
size: 20,
),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Citas para Hoy',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: AppColors.textPrimary,
),
),
Text(
'Agenda y turnos de consulta médica',
style: TextStyle(
fontSize: 12,
color: AppColors.textSecondary,
),
),
],
),
),
if (onSchedulePressed != null)
TextButton(
onPressed: onSchedulePressed,
child: const Text(
'Ver todos',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: AppColors.primary,
),
),
),
],
),
const SizedBox(height: 18),
const Divider(color: AppColors.divider, height: 1),
const SizedBox(height: 14),
// Contenido de Citas con Scroll Interno delimitado
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 330),
child: Scrollbar(
child: SingleChildScrollView(
child: appointments.isEmpty
? Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.event_note_rounded,
size: 40,
color: AppColors.textMuted.withValues(alpha: 0.6),
),
const SizedBox(height: 8),
const Text(
'No hay citas registradas para el día de hoy',
style: TextStyle(color: AppColors.textSecondary, fontSize: 13),
),
const SizedBox(height: 4),
const Text(
'Los nuevos turnos agendados aparecerán aquí',
style: TextStyle(color: AppColors.textMuted, fontSize: 11),
),
],
),
),
)
: Padding(
padding: const EdgeInsets.only(right: 6),
child: Column(
children: [
for (var i = 0; i < appointments.length; i++) ...[
if (i > 0) const Divider(color: AppColors.divider, height: 16),
Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(10),
child: InkWell(
onTap: onPatientTap != null && appointments[i].id > 0
? () => onPatientTap!(appointments[i])
: null,
borderRadius: BorderRadius.circular(10),
hoverColor: AppColors.primary.withValues(alpha: 0.05),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
child: Row(
children: [
// Icono de Cita
Container(
width: 38,
height: 38,
decoration: BoxDecoration(
color: AppColors.teal.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.access_time_rounded,
color: AppColors.teal,
size: 20,
),
),
const SizedBox(width: 14),
// Paciente y Motivo de Consulta
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
appointments[i].fullName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
),
),
const SizedBox(height: 2),
Wrap(
spacing: 8,
runSpacing: 2,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
if (appointments[i].telefono.isNotEmpty)
Text(
appointments[i].telefono,
style: const TextStyle(
fontSize: 11,
color: AppColors.textSecondary,
),
),
Text(
appointments[i].motCons.isNotEmpty
? appointments[i].motCons.replaceAll('\n', ' ').trim()
: 'Consulta de rutina',
style: const TextStyle(
fontSize: 11,
color: AppColors.textMuted,
),
),
],
),
],
),
),
const SizedBox(width: 10),
// Estado de Sala de Espera y Acciones Rápidas
_buildStatusAndAction(context, appointments[i]),
],
),
),
),
),
],
],
),
),
),
),
),
],
),
);
}
Widget _buildStatusAndAction(BuildContext context, PatientSummaryModel patient) {
const double uniformHeight = 28.0;
const double uniformRadius = 6.0;
if (patient.isEnEspera) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
// Badge En Espera
Container(
height: uniformHeight,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: const Color(0xFFDCFCE7),
borderRadius: BorderRadius.circular(uniformRadius),
border: Border.all(color: const Color(0xFF86EFAC)),
),
alignment: Alignment.center,
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.hourglass_top_rounded, size: 12, color: Color(0xFF15803D)),
SizedBox(width: 4),
Text(
'En Espera',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Color(0xFF15803D),
),
),
],
),
),
// Botón Doctor: Llamar a Consulta
if (!isSecretary) ...[
const SizedBox(width: 6),
Tooltip(
message: 'Llamar a consulta médica ahora',
child: SizedBox(
height: uniformHeight,
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.primary,
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(uniformRadius),
),
visualDensity: VisualDensity.compact,
),
onPressed: () async {
if (onStatusChange != null) {
await onStatusChange!(patient, 'en_consulta');
}
if (onPatientTap != null) {
onPatientTap!(patient);
}
},
icon: const Icon(Icons.arrow_forward_rounded, size: 12),
label: const Text(
'Atender',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
),
),
),
),
],
// Botón Secretaria: Revertir si fue error
if (isSecretary && onStatusChange != null) ...[
const SizedBox(width: 4),
Tooltip(
message: 'Quitar de la sala de espera',
child: InkWell(
onTap: () => onStatusChange!(patient, 'no_presente'),
borderRadius: BorderRadius.circular(uniformRadius),
child: Container(
height: uniformHeight,
width: uniformHeight,
alignment: Alignment.center,
child: const Icon(Icons.close_rounded, size: 15, color: AppColors.textMuted),
),
),
),
],
],
);
}
if (patient.isEnConsulta) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: onPatientTap != null ? () => onPatientTap!(patient) : null,
borderRadius: BorderRadius.circular(uniformRadius),
child: Container(
height: uniformHeight,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: const Color(0xFFE0F2FE),
borderRadius: BorderRadius.circular(uniformRadius),
border: Border.all(color: const Color(0xFF7DD3FC)),
),
alignment: Alignment.center,
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.medical_services_rounded, size: 12, color: Color(0xFF0369A1)),
SizedBox(width: 4),
Text(
'En Consulta',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Color(0xFF0369A1),
),
),
],
),
),
),
if (!isSecretary && onStatusChange != null) ...[
const SizedBox(width: 6),
Tooltip(
message: 'Finalizar consulta médica y marcar como Atendido',
child: SizedBox(
height: uniformHeight,
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF0284C7),
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(uniformRadius),
),
visualDensity: VisualDensity.compact,
),
onPressed: () => onStatusChange!(patient, 'atendido'),
icon: const Icon(Icons.check_rounded, size: 13),
label: const Text(
'Finalizar',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
),
),
),
),
],
],
);
}
if (patient.isAtendido) {
return Container(
height: uniformHeight,
padding: const EdgeInsets.symmetric(horizontal: 9),
decoration: BoxDecoration(
color: const Color(0xFFF1F5F9),
borderRadius: BorderRadius.circular(uniformRadius),
border: Border.all(color: const Color(0xFFE2E8F0)),
),
alignment: Alignment.center,
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.check_circle_rounded, size: 12, color: Color(0xFF64748B)),
SizedBox(width: 4),
Text(
'Atendido',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: Color(0xFF64748B),
),
),
],
),
);
}
// Estado no_presente (No ha llegado aún)
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (isSecretary && onStatusChange != null)
SizedBox(
height: uniformHeight,
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF10B981),
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(uniformRadius),
),
visualDensity: VisualDensity.compact,
),
onPressed: () => onStatusChange!(patient, 'en_espera'),
icon: const Icon(Icons.how_to_reg_rounded, size: 13),
label: const Text(
'Llegó',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
),
),
)
else
Container(
height: uniformHeight,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: AppColors.primaryContainer,
borderRadius: BorderRadius.circular(uniformRadius),
),
alignment: Alignment.center,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.calendar_month_rounded,
size: 11,
color: AppColors.primary,
),
const SizedBox(width: 4),
Text(
patient.fecProxCita.isNotEmpty
? patient.fecProxCita.split(' ').first
: 'Hoy',
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: AppColors.primary,
),
),
],
),
),
],
);
}
}