From 52bf4ed1b6e7d76e5691066ecf60ae1f65b9984f Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Fri, 6 Jun 2025 13:15:47 +0200 Subject: [PATCH] fix pat man padding --- .../build_my_patient_list_list.dart | 411 +++++++++--------- .../package_tools/waiting_room.dart | 168 +++---- 2 files changed, 303 insertions(+), 276 deletions(-) diff --git a/Frontend/lib/mih_packages/patient_profile/pat_manager/list_builders/build_my_patient_list_list.dart b/Frontend/lib/mih_packages/patient_profile/pat_manager/list_builders/build_my_patient_list_list.dart index eb4661ff..216583a6 100644 --- a/Frontend/lib/mih_packages/patient_profile/pat_manager/list_builders/build_my_patient_list_list.dart +++ b/Frontend/lib/mih_packages/patient_profile/pat_manager/list_builders/build_my_patient_list_list.dart @@ -79,10 +79,9 @@ class _BuildPatientsListState extends State { } } - void appointmentPopUp(int index) { + void appointmentPopUp(int index, double width) { var firstLetterFName = widget.patientAccesses[index].fname; var firstLetterLName = widget.patientAccesses[index].lname; - setState(() { idController.text = widget.patientAccesses[index].id_no; fnameController.text = firstLetterFName; @@ -97,104 +96,111 @@ class _BuildPatientsListState extends State { onWindowTapClose: () { Navigator.pop(context); }, - windowBody: Column( - children: [ - MihForm( - formKey: _formKey, - formFields: [ - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: idController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "ID No.", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10.0), - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: fnameController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "First Name", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10.0), - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: lnameController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "Surname", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10.0), - MIHDateField( - controller: dateController, - lableText: "Date", - required: true, - ), - const SizedBox(height: 10.0), - MIHTimeField( - controller: timeController, - lableText: "Time", - required: true, - ), - const SizedBox(height: 30.0), - Center( - child: MihButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - bool filled = isAppointmentFieldsFilled(); - if (filled) { - submitApointment(index); - } else { - showDialog( - context: context, - builder: (context) { - return const MIHErrorMessage( - errorType: "Input Error"); - }, - ); - } - } - }, - buttonColor: + windowBody: Padding( + padding: + MzanziInnovationHub.of(context)!.theme.screenType == "desktop" + ? EdgeInsets.symmetric(horizontal: width * 0.056) + : const EdgeInsets.symmetric(horizontal: 0), + child: Column( + children: [ + MihForm( + formKey: _formKey, + formFields: [ + MihTextFormField( + fillColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 300, - child: Text( - "Book Appointment", - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: idController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "ID No.", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 10.0), + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: fnameController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "First Name", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 10.0), + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: lnameController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "Surname", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 10.0), + MIHDateField( + controller: dateController, + lableText: "Date", + required: true, + ), + const SizedBox(height: 10.0), + MIHTimeField( + controller: timeController, + lableText: "Time", + required: true, + ), + const SizedBox(height: 30.0), + Center( + child: MihButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + bool filled = isAppointmentFieldsFilled(); + if (filled) { + submitApointment(index); + } else { + showDialog( + context: context, + builder: (context) { + return const MIHErrorMessage( + errorType: "Input Error"); + }, + ); + } + } + }, + buttonColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + width: 300, + child: Text( + "Book Appointment", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); @@ -229,10 +235,10 @@ class _BuildPatientsListState extends State { return hasAccess; } - void patientProfileChoicePopUp(int index, Patient? patientProfile) async { + void patientProfileChoicePopUp( + int index, Patient? patientProfile, double width) async { var firstLetterFName = widget.patientAccesses[index].fname; var firstLetterLName = widget.patientAccesses[index].lname; - setState(() { idController.text = widget.patientAccesses[index].id_no; fnameController.text = firstLetterFName; @@ -247,109 +253,119 @@ class _BuildPatientsListState extends State { onWindowTapClose: () { Navigator.pop(context); }, - windowBody: Column( - children: [ - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: idController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "ID No.", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10.0), - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: fnameController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "First Name", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10.0), - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: lnameController, - multiLineInput: false, - requiredText: true, - readOnly: true, - hintText: "Surname", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 30.0), - Center( - child: Wrap( - runSpacing: 10, - spacing: 10, - children: [ - MihButton( - onPressed: () { - appointmentPopUp(index); - }, - buttonColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 300, - child: Text( - "Book Appointment", - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - onPressed: () { - Navigator.of(context) - .pushNamed('/patient-manager/patient', - arguments: PatientViewArguments( - widget.signedInUser, - patientProfile, - widget.businessUser, - widget.business, - "business", - )); - }, - buttonColor: - MzanziInnovationHub.of(context)!.theme.successColor(), - width: 300, - child: Text( - "View Medical Records", - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], + windowBody: Padding( + padding: + MzanziInnovationHub.of(context)!.theme.screenType == "desktop" + ? EdgeInsets.symmetric(horizontal: width * 0.05) + : const EdgeInsets.symmetric(horizontal: 0), + child: Column( + children: [ + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: idController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "ID No.", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, ), - ) - ], + const SizedBox(height: 10.0), + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: fnameController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "First Name", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 10.0), + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: lnameController, + multiLineInput: false, + requiredText: true, + readOnly: true, + hintText: "Surname", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 30.0), + Center( + child: Wrap( + runSpacing: 10, + spacing: 10, + children: [ + MihButton( + onPressed: () { + appointmentPopUp(index, width); + }, + buttonColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + width: 300, + child: Text( + "Book Appointment", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + Navigator.of(context) + .pushNamed('/patient-manager/patient', + arguments: PatientViewArguments( + widget.signedInUser, + patientProfile, + widget.businessUser, + widget.business, + "business", + )); + }, + buttonColor: + MzanziInnovationHub.of(context)!.theme.successColor(), + width: 300, + child: Text( + "View Medical Records", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ) + ], + ), ), ), ); } - Widget displayMyPatientTile(int index) { + Widget displayMyPatientTile(int index, double width) { var firstName = ""; var lastName = ""; String access = widget.patientAccesses[index].status.toUpperCase(); @@ -407,7 +423,7 @@ class _BuildPatientsListState extends State { p = result; }); }); - patientProfileChoicePopUp(index, p); + patientProfileChoicePopUp(index, p, width); } else { noAccessWarning(index); } @@ -431,6 +447,7 @@ class _BuildPatientsListState extends State { @override Widget build(BuildContext context) { + double screenWidth = MediaQuery.of(context).size.width; return ListView.separated( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), @@ -441,7 +458,7 @@ class _BuildPatientsListState extends State { }, itemCount: widget.patientAccesses.length, itemBuilder: (context, index) { - return displayMyPatientTile(index); + return displayMyPatientTile(index, screenWidth); }, ); } diff --git a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/waiting_room.dart b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/waiting_room.dart index a66db041..ef2d2bd1 100644 --- a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/waiting_room.dart +++ b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/waiting_room.dart @@ -63,7 +63,7 @@ class _WaitingRoomState extends State { final _formKey = GlobalKey(); // Business Appointment Tool - Widget getBusinessAppointmentsTool() { + Widget getBusinessAppointmentsTool(double width) { return Stack( children: [ MihSingleChildScroll( @@ -139,7 +139,7 @@ class _WaitingRoomState extends State { MzanziInnovationHub.of(context)!.theme.successColor(), onTap: () { // addAppointmentWindow(); - appointmentTypeSelection(); + appointmentTypeSelection(width); }, ) ], @@ -205,7 +205,7 @@ class _WaitingRoomState extends State { ); } - void appointmentTypeSelection() { + void appointmentTypeSelection(double width) { String question = "What type of appointment would you like to add?"; question += "\n\nExisting Patient: Add an appointment for an patient your practice has access to."; @@ -276,7 +276,7 @@ class _WaitingRoomState extends State { MihButton( onPressed: () { Navigator.pop(context); - addAppointmentWindow(); + addAppointmentWindow(width); }, buttonColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), @@ -298,7 +298,7 @@ class _WaitingRoomState extends State { ); } - void addAppointmentWindow() { + void addAppointmentWindow(double width) { showDialog( context: context, barrierDismissible: false, @@ -314,83 +314,92 @@ class _WaitingRoomState extends State { _appointmentDescriptionIDController.clear(); _patientController.clear(); }, - windowBody: Column( - children: [ - MihForm( - formKey: _formKey, - formFields: [ - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: _appointmentTitleController, - multiLineInput: false, - requiredText: true, - hintText: "Appointment Title", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 10), - SizedBox( - // width: 500, - child: MIHDateField( - controller: _appointmentDateController, - lableText: "Date", - required: true, - ), - ), - const SizedBox(height: 10), - SizedBox( - // width: 500, - child: MIHTimeField( - controller: _appointmentTimeController, - lableText: "Time", - required: true, - ), - ), - const SizedBox(height: 10), - MihTextFormField( - height: 250, - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: _appointmentDescriptionIDController, - multiLineInput: true, - requiredText: true, - hintText: "Description", - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - const SizedBox(height: 20), - Center( - child: MihButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - addAppointmentCall(); - } + windowBody: Padding( + padding: + MzanziInnovationHub.of(context)!.theme.screenType == "desktop" + ? EdgeInsets.symmetric(horizontal: width * 0.05) + : const EdgeInsets.symmetric(horizontal: 0), + child: Column( + children: [ + MihForm( + formKey: _formKey, + formFields: [ + MihTextFormField( + fillColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: _appointmentTitleController, + multiLineInput: false, + requiredText: true, + hintText: "Appointment Title", + validator: (value) { + return MihValidationServices().isEmpty(value); }, - buttonColor: - MzanziInnovationHub.of(context)!.theme.successColor(), - width: 300, - child: Text( - "Add", - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, + ), + const SizedBox(height: 10), + SizedBox( + // width: 500, + child: MIHDateField( + controller: _appointmentDateController, + lableText: "Date", + required: true, + ), + ), + const SizedBox(height: 10), + SizedBox( + // width: 500, + child: MIHTimeField( + controller: _appointmentTimeController, + lableText: "Time", + required: true, + ), + ), + const SizedBox(height: 10), + MihTextFormField( + height: 250, + fillColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: _appointmentDescriptionIDController, + multiLineInput: true, + requiredText: true, + hintText: "Description", + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + const SizedBox(height: 20), + Center( + child: MihButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + addAppointmentCall(); + } + }, + buttonColor: MzanziInnovationHub.of(context)! + .theme + .successColor(), + width: 300, + child: Text( + "Add", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ); }, @@ -477,9 +486,10 @@ class _WaitingRoomState extends State { @override Widget build(BuildContext context) { + double screenWidth = MediaQuery.of(context).size.width; return MihPackageToolBody( borderOn: false, - bodyItem: getBusinessAppointmentsTool(), + bodyItem: getBusinessAppointmentsTool(screenWidth), ); } }