216 lines
8.2 KiB
Dart
216 lines
8.2 KiB
Dart
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|