From 02e6a52bfff4aa0a38d199fb5f9b7e5243b40769 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 22 Sep 2026 16:01:21 -0400 Subject: [PATCH] feat(clinical-docs): expand writing canvas and optimize height for insurance auth and referral modals --- .../views/insurance_auth_modal_view.dart | 506 +++++++++--------- .../views/department_referral_modal_view.dart | 206 +++---- .../views/doctor_referral_modal_view.dart | 206 +++---- 3 files changed, 495 insertions(+), 423 deletions(-) diff --git a/lib/features/insurance_auth/presentation/views/insurance_auth_modal_view.dart b/lib/features/insurance_auth/presentation/views/insurance_auth_modal_view.dart index 65908e0..ba84732 100644 --- a/lib/features/insurance_auth/presentation/views/insurance_auth_modal_view.dart +++ b/lib/features/insurance_auth/presentation/views/insurance_auth_modal_view.dart @@ -159,12 +159,15 @@ class _InsuranceAuthModalViewState extends State { @override Widget build(BuildContext context) { final formattedDate = DateFormat('dd/MM/yyyy').format(DateTime.now()); + final mediaQuery = MediaQuery.sizeOf(context); + final modalHeight = (mediaQuery.height * 0.90).clamp(650.0, 780.0); + final modalWidth = (mediaQuery.width * 0.90).clamp(840.0, 920.0); return Observer( builder: (_) { return MedicalModalDialog( - maxWidth: 820, - maxHeight: 650, + maxWidth: modalWidth, + maxHeight: modalHeight, title: 'Autorización De Seguro (ARS)', titleIcon: Container( padding: const EdgeInsets.all(8), @@ -271,260 +274,285 @@ class _InsuranceAuthModalViewState extends State { ], ), ), - child: SingleChildScrollView( - padding: const EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - // Membrete Informativo del Médico - Container( - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: const Color(0xFFF8FAFC), - borderRadius: BorderRadius.circular(12), - border: Border.all(color: const Color(0xFFE2E8F0)), + child: LayoutBuilder( + builder: (context, constraints) { + final isCompact = constraints.maxHeight < 460; + + final surgeryField = TextField( + controller: _surgeryController, + maxLines: isCompact ? 3 : null, + minLines: isCompact ? 2 : null, + expands: !isCompact, + textAlignVertical: TextAlignVertical.top, + style: const TextStyle(fontSize: 13, height: 1.4), + decoration: InputDecoration( + labelText: 'La cirugía de: *', + hintText: 'Especifique el procedimiento quirúrgico o intervención (ej. Ureterolitotomía endoscópica láser, Biopsia de próstata...)', + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + contentPadding: const EdgeInsets.all(12), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), ), - child: Column( + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), + ), + ); + + final diagnosisField = TextField( + controller: _diagnosisController, + maxLines: isCompact ? 3 : null, + minLines: isCompact ? 2 : null, + expands: !isCompact, + textAlignVertical: TextAlignVertical.top, + style: const TextStyle(fontSize: 13, height: 1.4), + decoration: InputDecoration( + labelText: 'Diagnóstico: *', + hintText: 'Diagnóstico principal, patología o hallazgo clínico que justifica la cirugía...', + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + contentPadding: const EdgeInsets.all(12), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), + ), + ); + + final bodyContent = Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // Membrete Informativo del Médico + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + decoration: BoxDecoration( + color: const Color(0xFFF8FAFC), + borderRadius: BorderRadius.circular(10), + border: Border.all(color: const Color(0xFFE2E8F0)), + ), + child: Column( + children: [ + Text( + _configStore.nombreDoctor.isNotEmpty + ? _configStore.nombreDoctor + : 'Dr. Luis A. Castro Sosa', + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 17, + fontWeight: FontWeight.w700, + color: AppColors.textPrimary, + letterSpacing: -0.3, + ), + ), + if (_configStore.especialidad.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + _configStore.especialidad.toUpperCase(), + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: AppColors.primary, + letterSpacing: 0.5, + ), + ), + ], + if (_configStore.descripEspecialidad.isNotEmpty) ...[ + const SizedBox(height: 1), + Text( + _configStore.descripEspecialidad.toUpperCase(), + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 9.5, + color: AppColors.textMuted, + ), + ), + ], + const SizedBox(height: 3), + Text( + 'Fecha: $formattedDate', + style: const TextStyle( + fontSize: 10.5, + fontWeight: FontWeight.w500, + color: AppColors.textSecondary, + ), + ), + ], + ), + ), + const SizedBox(height: 10), + + // Fila 1: Señores ARS y Paciente (Favor autorizar al Sr. a) + Row( children: [ - Text( - _configStore.nombreDoctor.isNotEmpty - ? _configStore.nombreDoctor - : 'Dr. Luis A. Castro Sosa', - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w700, - color: AppColors.textPrimary, - letterSpacing: -0.3, + Expanded( + flex: 5, + child: Autocomplete( + initialValue: TextEditingValue(text: _arsController.text), + optionsBuilder: (textEditingValue) { + if (textEditingValue.text.isEmpty) { + return arsList; + } + return arsList.where((ars) => ars + .toLowerCase() + .contains(textEditingValue.text.toLowerCase())); + }, + onSelected: (selection) => _arsController.text = selection, + fieldViewBuilder: (context, controller, focusNode, onEditingComplete) { + controller.addListener(() { + _arsController.text = controller.text; + }); + return TextField( + controller: controller, + focusNode: focusNode, + onEditingComplete: onEditingComplete, + decoration: InputDecoration( + labelText: 'Señores ARS *', + hintText: 'Seleccione o escriba la ARS', + isDense: true, + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + prefixIcon: const Icon(Icons.security_rounded, size: 18, color: AppColors.primary), + contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), + ), + style: const TextStyle(fontSize: 12.5, fontWeight: FontWeight.w600), + ); + }, ), ), - if (_configStore.especialidad.isNotEmpty) ...[ - const SizedBox(height: 2), - Text( - _configStore.especialidad.toUpperCase(), - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 11.5, - fontWeight: FontWeight.w600, - color: AppColors.primary, - letterSpacing: 0.5, + const SizedBox(width: 12), + Expanded( + flex: 5, + child: TextField( + controller: _patientController, + decoration: InputDecoration( + labelText: 'Favor autorizar al Sr. (a) *', + hintText: 'Nombre del paciente', + isDense: true, + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + prefixIcon: const Icon(Icons.person_outline_rounded, size: 18, color: AppColors.primary), + contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), ), - ), - ], - if (_configStore.descripEspecialidad.isNotEmpty) ...[ - const SizedBox(height: 2), - Text( - _configStore.descripEspecialidad.toUpperCase(), - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 10, - color: AppColors.textMuted, - ), - ), - ], - const SizedBox(height: 4), - Text( - 'Fecha: $formattedDate', - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w500, - color: AppColors.textSecondary, + style: const TextStyle(fontSize: 12.5, fontWeight: FontWeight.w600), ), ), ], ), - ), - const SizedBox(height: 16), + const SizedBox(height: 10), - // Fila 1: Señores ARS y Paciente (Favor autorizar al Sr. a) - Row( - children: [ - Expanded( - flex: 5, - child: Autocomplete( - initialValue: TextEditingValue(text: _arsController.text), - optionsBuilder: (textEditingValue) { - if (textEditingValue.text.isEmpty) { - return arsList; - } - return arsList.where((ars) => ars - .toLowerCase() - .contains(textEditingValue.text.toLowerCase())); - }, - onSelected: (selection) => _arsController.text = selection, - fieldViewBuilder: (context, controller, focusNode, onEditingComplete) { - controller.addListener(() { - _arsController.text = controller.text; - }); - return TextField( - controller: controller, - focusNode: focusNode, - onEditingComplete: onEditingComplete, - decoration: InputDecoration( - labelText: 'Señores ARS *', - hintText: 'Seleccione o escriba la ARS', - isDense: true, - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - prefixIcon: const Icon(Icons.security_rounded, size: 18, color: AppColors.primary), - contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), - ), + // Campo: La cirugía de: + if (isCompact) surgeryField else Expanded(flex: 1, child: surgeryField), + const SizedBox(height: 10), + + // Campo: Diagnóstico: + if (isCompact) diagnosisField else Expanded(flex: 1, child: diagnosisField), + const SizedBox(height: 10), + + // Fila 3: Bajo Anestesia y Días de ingreso + Row( + children: [ + Expanded( + flex: 6, + child: TextField( + controller: _anesthesiaController, + decoration: InputDecoration( + labelText: 'Bajo Anestesia', + hintText: 'General, Raquídea, Sedación, Local...', + isDense: true, + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + prefixIcon: const Icon(Icons.vaccines_outlined, size: 18, color: AppColors.primary), + contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), ), - style: const TextStyle(fontSize: 12.5, fontWeight: FontWeight.w600), - ); - }, - ), - ), - const SizedBox(width: 12), - Expanded( - flex: 5, - child: TextField( - controller: _patientController, - decoration: InputDecoration( - labelText: 'Favor autorizar al Sr. (a) *', - hintText: 'Nombre del paciente', - isDense: true, - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - prefixIcon: const Icon(Icons.person_outline_rounded, size: 18, color: AppColors.primary), - contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), ), + style: const TextStyle(fontSize: 12.5), ), - style: const TextStyle(fontSize: 12.5, fontWeight: FontWeight.w600), ), - ), - ], - ), - const SizedBox(height: 14), - - // Campo: La cirugía de: - TextField( - controller: _surgeryController, - maxLines: 3, - style: const TextStyle(fontSize: 13, height: 1.4), - decoration: InputDecoration( - labelText: 'La cirugía de: *', - hintText: 'Especifique el procedimiento quirúrgico o intervención (ej. Ureterolitotomía endoscópica láser, Biopsia de próstata...)', - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - contentPadding: const EdgeInsets.all(12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), - ), + const SizedBox(width: 12), + Expanded( + flex: 4, + child: TextField( + controller: _daysController, + decoration: InputDecoration( + labelText: 'Días de ingreso', + hintText: 'Ej. 1, 2, Ambulatorio', + isDense: true, + floatingLabelBehavior: FloatingLabelBehavior.always, + filled: true, + fillColor: Colors.white, + prefixIcon: const Icon(Icons.hotel_outlined, size: 18, color: AppColors.primary), + contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), + ), + style: const TextStyle(fontSize: 12.5), + ), + ), + ], ), - ), - const SizedBox(height: 14), + ], + ); - // Campo: Diagnóstico: - TextField( - controller: _diagnosisController, - maxLines: 3, - style: const TextStyle(fontSize: 13, height: 1.4), - decoration: InputDecoration( - labelText: 'Diagnóstico: *', - hintText: 'Diagnóstico principal, patología o hallazgo clínico que justifica la cirugía...', - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - contentPadding: const EdgeInsets.all(12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), - ), - ), - ), - const SizedBox(height: 14), + if (isCompact) { + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: bodyContent, + ); + } - // Fila 3: Bajo Anestesia y Días de ingreso - Row( - children: [ - Expanded( - flex: 6, - child: TextField( - controller: _anesthesiaController, - decoration: InputDecoration( - labelText: 'Bajo Anestesia', - hintText: 'General, Raquídea, Sedación, Local...', - isDense: true, - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - prefixIcon: const Icon(Icons.vaccines_outlined, size: 18, color: AppColors.primary), - contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), - ), - ), - style: const TextStyle(fontSize: 12.5), - ), - ), - const SizedBox(width: 12), - Expanded( - flex: 4, - child: TextField( - controller: _daysController, - decoration: InputDecoration( - labelText: 'Días de ingreso', - hintText: 'Ej. 1, 2, Ambulatorio', - isDense: true, - floatingLabelBehavior: FloatingLabelBehavior.always, - filled: true, - fillColor: Colors.white, - prefixIcon: const Icon(Icons.hotel_outlined, size: 18, color: AppColors.primary), - contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), - ), - ), - style: const TextStyle(fontSize: 12.5), - ), - ), - ], - ), - ], - ), + return Padding( + padding: const EdgeInsets.fromLTRB(20, 14, 20, 16), + child: bodyContent, + ); + }, ), ); }, diff --git a/lib/features/referrals/presentation/views/department_referral_modal_view.dart b/lib/features/referrals/presentation/views/department_referral_modal_view.dart index 34f1bc2..092adea 100644 --- a/lib/features/referrals/presentation/views/department_referral_modal_view.dart +++ b/lib/features/referrals/presentation/views/department_referral_modal_view.dart @@ -103,12 +103,15 @@ class _DepartmentReferralModalViewState extends State { @override Widget build(BuildContext context) { final formattedDate = DateFormat('dd/MM/yyyy').format(DateTime.now()); + final mediaQuery = MediaQuery.sizeOf(context); + final modalHeight = (mediaQuery.height * 0.90).clamp(650.0, 780.0); + final modalWidth = (mediaQuery.width * 0.90).clamp(840.0, 920.0); return Observer( builder: (_) { return MedicalModalDialog( - maxWidth: 820, - maxHeight: 650, + maxWidth: modalWidth, + maxHeight: modalHeight, title: 'Referir a Doctor (a)', titleIcon: Container( padding: const EdgeInsets.all(8), @@ -214,105 +217,124 @@ class _DoctorReferralModalViewState extends State { ], ), ), - child: SingleChildScrollView( - padding: const EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - // Membrete Informativo del Médico - Container( - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: const Color(0xFFF8FAFC), - borderRadius: BorderRadius.circular(12), - border: Border.all(color: const Color(0xFFE2E8F0)), + child: LayoutBuilder( + builder: (context, constraints) { + final isCompact = constraints.maxHeight < 420; + + final textField = TextField( + controller: _referralController, + maxLines: isCompact ? 10 : null, + minLines: isCompact ? 5 : null, + expands: !isCompact, + textAlignVertical: TextAlignVertical.top, + style: const TextStyle(fontSize: 13.5, height: 1.5, color: AppColors.textPrimary), + decoration: InputDecoration( + hintText: 'Redacte el referimiento médico...', + filled: true, + fillColor: Colors.white, + contentPadding: const EdgeInsets.all(16), + border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), ), - child: Column( - children: [ - Text( - _configStore.nombreDoctor.isNotEmpty - ? _configStore.nombreDoctor - : 'Dr. Luis A. Castro Sosa', - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w700, - color: AppColors.textPrimary, - letterSpacing: -0.3, - ), - ), - if (_configStore.especialidad.isNotEmpty) ...[ - const SizedBox(height: 2), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: AppColors.primary, width: 1.5), + ), + ), + ); + + final bodyContent = Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // Membrete Informativo del Médico + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + decoration: BoxDecoration( + color: const Color(0xFFF8FAFC), + borderRadius: BorderRadius.circular(10), + border: Border.all(color: const Color(0xFFE2E8F0)), + ), + child: Column( + children: [ Text( - _configStore.especialidad.toUpperCase(), + _configStore.nombreDoctor.isNotEmpty + ? _configStore.nombreDoctor + : 'Dr. Luis A. Castro Sosa', textAlign: TextAlign.center, style: const TextStyle( - fontSize: 11.5, - fontWeight: FontWeight.w600, - color: AppColors.primary, - letterSpacing: 0.5, + fontSize: 17, + fontWeight: FontWeight.w700, + color: AppColors.textPrimary, + letterSpacing: -0.3, + ), + ), + if (_configStore.especialidad.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + _configStore.especialidad.toUpperCase(), + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: AppColors.primary, + letterSpacing: 0.5, + ), + ), + ], + if (_configStore.descripEspecialidad.isNotEmpty) ...[ + const SizedBox(height: 1), + Text( + _configStore.descripEspecialidad.toUpperCase(), + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 9.5, + color: AppColors.textMuted, + ), + ), + ], + const SizedBox(height: 3), + Text( + 'Fecha: $formattedDate', + style: const TextStyle( + fontSize: 10.5, + fontWeight: FontWeight.w500, + color: AppColors.textSecondary, ), ), ], - if (_configStore.descripEspecialidad.isNotEmpty) ...[ - const SizedBox(height: 2), - Text( - _configStore.descripEspecialidad.toUpperCase(), - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 10, - color: AppColors.textMuted, - ), - ), - ], - const SizedBox(height: 4), - Text( - 'Fecha: $formattedDate', - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w500, - color: AppColors.textSecondary, - ), - ), - ], - ), - ), - const SizedBox(height: 16), - - const Text( - 'Detalle de la Interconsulta / Referimiento:', - style: TextStyle( - fontSize: 13, - fontWeight: FontWeight.w700, - color: AppColors.textPrimary, - ), - ), - const SizedBox(height: 8), - - // Área de texto multilínea idéntica a ScrolledText de AlfaMedical - TextField( - controller: _referralController, - maxLines: 12, - minLines: 9, - style: const TextStyle(fontSize: 13.5, height: 1.5, color: AppColors.textPrimary), - decoration: InputDecoration( - hintText: 'Redacte el referimiento médico...', - filled: true, - fillColor: Colors.white, - contentPadding: const EdgeInsets.all(16), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: Color(0xFFE2E8F0)), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: AppColors.primary, width: 1.5), ), ), - ), - ], - ), + const SizedBox(height: 12), + + const Text( + 'Detalle de la Interconsulta / Referimiento:', + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w700, + color: AppColors.textPrimary, + ), + ), + const SizedBox(height: 8), + + // Área de texto multilínea que se expande para rellenar todo el espacio inferior + if (isCompact) textField else Expanded(child: textField), + ], + ); + + if (isCompact) { + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: bodyContent, + ); + } + + return Padding( + padding: const EdgeInsets.fromLTRB(20, 14, 20, 16), + child: bodyContent, + ); + }, ), ); },