diff --git a/Frontend/patient_manager/lib/components/MIH_Layout/MIH_LayoutBuilder.dart b/Frontend/patient_manager/lib/components/MIH_Layout/MIH_LayoutBuilder.dart index 6e1762a3..49e84ea0 100644 --- a/Frontend/patient_manager/lib/components/MIH_Layout/MIH_LayoutBuilder.dart +++ b/Frontend/patient_manager/lib/components/MIH_Layout/MIH_LayoutBuilder.dart @@ -19,6 +19,13 @@ class MIHLayoutBuilder extends StatefulWidget { } class _MIHLayoutBuilderState extends State { + List getList() { + List temp = []; + temp.add(widget.header); + temp.add(widget.body); + return temp; + } + @override void dispose() { super.dispose(); @@ -40,7 +47,10 @@ class _MIHLayoutBuilderState extends State { children: [ widget.actionButton, Column( - children: [widget.header, Expanded(child: widget.body)], + children: [ + widget.header, + Expanded(child: widget.body), + ], ), ], ), diff --git a/Frontend/patient_manager/lib/components/builders/buildAccessRequestList.dart b/Frontend/patient_manager/lib/components/builders/buildAccessRequestList.dart index 35ded1c8..1bfb7abd 100644 --- a/Frontend/patient_manager/lib/components/builders/buildAccessRequestList.dart +++ b/Frontend/patient_manager/lib/components/builders/buildAccessRequestList.dart @@ -297,6 +297,7 @@ class _BuildPatientsListState extends State { }); checkScreenSize(); return ListView.separated( + shrinkWrap: true, separatorBuilder: (BuildContext context, index) { return Divider( color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), diff --git a/Frontend/patient_manager/lib/pages/about/MIH_About.dart b/Frontend/patient_manager/lib/pages/about_MIH/MIH_About.dart similarity index 100% rename from Frontend/patient_manager/lib/pages/about/MIH_About.dart rename to Frontend/patient_manager/lib/pages/about_MIH/MIH_About.dart diff --git a/Frontend/patient_manager/lib/pages/patientAccessReview.dart b/Frontend/patient_manager/lib/pages/access_review/patientAccessReview.dart similarity index 53% rename from Frontend/patient_manager/lib/pages/patientAccessReview.dart rename to Frontend/patient_manager/lib/pages/access_review/patientAccessReview.dart index aeaae519..b8faa4cd 100644 --- a/Frontend/patient_manager/lib/pages/patientAccessReview.dart +++ b/Frontend/patient_manager/lib/pages/access_review/patientAccessReview.dart @@ -1,6 +1,10 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart'; import 'package:patient_manager/components/builders/buildAccessRequestList.dart'; import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart'; import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart'; @@ -80,36 +84,17 @@ class _PatientAccessRequestState extends State { Widget displayAccessRequestList(List accessRequestList) { if (accessRequestList.isNotEmpty) { - return Container( - //height: height - 254, - decoration: BoxDecoration( - color: MzanziInnovationHub.of(context)!.theme.primaryColor(), - borderRadius: BorderRadius.circular(25.0), - border: Border.all( - color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 3.0, - ), - ), - child: BuildAccessRequestList( - signedInUser: widget.signedInUser, - accessRequests: accessRequestList, - ), + return BuildAccessRequestList( + signedInUser: widget.signedInUser, + accessRequests: accessRequestList, + // BuildPatientQueueList( // patientQueue: patientQueueList, // signedInUser: widget.signedInUser, // ), ); - } - return Container( - //height: height - 254, - decoration: BoxDecoration( - color: MzanziInnovationHub.of(context)!.theme.primaryColor(), - borderRadius: BorderRadius.circular(25.0), - border: Border.all( - color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 3.0), - ), - child: Center( + } else { + return Center( child: Text( "No Request have been made.", style: TextStyle( @@ -117,8 +102,8 @@ class _PatientAccessRequestState extends State { color: MzanziInnovationHub.of(context)!.theme.messageTextColor()), textAlign: TextAlign.center, ), - ), - ); + ); + } } Widget viewAccessRequest(double w, double h) { @@ -171,39 +156,39 @@ class _PatientAccessRequestState extends State { ); } else if (snapshot.connectionState == ConnectionState.done) { List accessRequestList; - // if (searchString == "") { - // patientQueueList = []; - // } else { accessRequestList = filterSearchResults(snapshot.requireData); - // print(patientQueueList); - // } - - return Expanded( - child: displayAccessRequestList(accessRequestList), - ); - } else { - return Container( - height: h - 105, - decoration: BoxDecoration( - color: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - borderRadius: BorderRadius.circular(25.0), - border: Border.all( - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - width: 3.0), - ), - child: Center( + if (accessRequestList.isNotEmpty) { + return BuildAccessRequestList( + signedInUser: widget.signedInUser, + accessRequests: accessRequestList, + ); + } else { + return Center( child: Text( - "$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody", + "No Request have been made.", style: TextStyle( fontSize: 25, color: MzanziInnovationHub.of(context)! .theme - .errorColor()), + .messageTextColor()), textAlign: TextAlign.center, ), + ); + } + + // return Expanded( + // child: displayAccessRequestList(accessRequestList), + // ); + } else { + return Center( + child: Text( + "$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody", + style: TextStyle( + fontSize: 25, + color: MzanziInnovationHub.of(context)! + .theme + .errorColor()), + textAlign: TextAlign.center, ), ); } @@ -231,6 +216,117 @@ class _PatientAccessRequestState extends State { // }); } + MIHAction getActionButton() { + return MIHAction( + icon: Icons.arrow_back, + iconSize: 35, + onTap: () { + Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); + }, + ); + } + + MIHHeader getHeader() { + return const MIHHeader( + headerAlignment: MainAxisAlignment.center, + headerItems: [ + Text( + "Access Reviews", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), + ), + ], + ); + } + + MIHBody getBody() { + return MIHBody( + borderOn: true, + bodyItems: [ + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + child: MIHDropdownField( + controller: filterController, + hintText: "Access Types", + dropdownOptions: const [ + "All", + "Approved", + "Pending", + "Declined" + ], + required: true, + editable: true, + ), + ), + IconButton( + onPressed: () { + setState(() { + forceRefresh = true; + }); + refreshList(); + }, + icon: const Icon( + Icons.refresh, + ), + ), + ], + ), + const SizedBox(height: 10), + FutureBuilder( + future: accessRequestResults, + builder: (context, snapshot) { + //print("patient Queue List ${snapshot.hasData}"); + if (snapshot.connectionState == ConnectionState.waiting) { + return const Mihloadingcircle(); + } else if (snapshot.connectionState == ConnectionState.done) { + List accessRequestList; + accessRequestList = filterSearchResults(snapshot.requireData); + if (accessRequestList.isNotEmpty) { + return BuildAccessRequestList( + signedInUser: widget.signedInUser, + accessRequests: accessRequestList, + ); + } else { + return Center( + child: Text( + "No Request have been made.", + style: TextStyle( + fontSize: 25, + color: MzanziInnovationHub.of(context)! + .theme + .messageTextColor()), + textAlign: TextAlign.center, + ), + ); + } + + // return Expanded( + // child: displayAccessRequestList(accessRequestList), + // ); + } else { + return Center( + child: Text( + "$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody", + style: TextStyle( + fontSize: 25, + color: + MzanziInnovationHub.of(context)!.theme.errorColor()), + textAlign: TextAlign.center, + ), + ); + } + }, + ), + ], + ); + } + @override void dispose() { filterController.dispose(); @@ -250,50 +346,53 @@ class _PatientAccessRequestState extends State { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; - final screenHeight = MediaQuery.of(context).size.height; - return Scaffold( - // appBar: const MIHAppBar( - // barTitle: "Access Reviews", - // propicFile: null, - // ), - //drawer: MIHAppDrawer(signedInUser: widget.signedInUser), - body: SafeArea( - child: Stack( - children: [ - viewAccessRequest(screenWidth, screenHeight), - Positioned( - top: 10, - left: 5, - width: 50, - height: 50, - child: IconButton( - onPressed: () { - Navigator.of(context).pop(); - }, - icon: const Icon(Icons.arrow_back), - ), - ), - Positioned( - top: 10, - right: 5, - width: 50, - height: 50, - child: IconButton( - onPressed: () { - setState(() { - forceRefresh = true; - }); - refreshList(); - }, - icon: const Icon( - Icons.refresh, - ), - ), - ) - ], - ), - ), + return MIHLayoutBuilder( + actionButton: getActionButton(), + header: getHeader(), + body: getBody(), ); + // return Scaffold( + // // appBar: const MIHAppBar( + // // barTitle: "Access Reviews", + // // propicFile: null, + // // ), + // //drawer: MIHAppDrawer(signedInUser: widget.signedInUser), + // body: SafeArea( + // child: Stack( + // children: [ + // viewAccessRequest(screenWidth, screenHeight), + // Positioned( + // top: 10, + // left: 5, + // width: 50, + // height: 50, + // child: IconButton( + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // icon: const Icon(Icons.arrow_back), + // ), + // ), + // Positioned( + // top: 10, + // right: 5, + // width: 50, + // height: 50, + // child: IconButton( + // onPressed: () { + // setState(() { + // forceRefresh = true; + // }); + // refreshList(); + // }, + // icon: const Icon( + // Icons.refresh, + // ), + // ), + // ) + // ], + // ), + // ), + // ); } } diff --git a/Frontend/patient_manager/lib/pages/profileUserUpdate.dart b/Frontend/patient_manager/lib/pages/mzansi_profile/profileUserUpdate.dart similarity index 62% rename from Frontend/patient_manager/lib/pages/profileUserUpdate.dart rename to Frontend/patient_manager/lib/pages/mzansi_profile/profileUserUpdate.dart index 7ec228d7..36d78acf 100644 --- a/Frontend/patient_manager/lib/pages/profileUserUpdate.dart +++ b/Frontend/patient_manager/lib/pages/mzansi_profile/profileUserUpdate.dart @@ -3,6 +3,10 @@ import 'dart:convert'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart'; +import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart'; import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart'; import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart'; import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart'; @@ -257,6 +261,123 @@ class _ProfileUserUpdateState extends State { } } + MIHAction getActionButton() { + return MIHAction( + icon: Icons.arrow_back, + iconSize: 35, + onTap: () { + Navigator.of(context).pop(); + }, + ); + } + + MIHHeader getHeader() { + return const MIHHeader( + headerAlignment: MainAxisAlignment.center, + headerItems: [ + Text( + "Mzansi Profile", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), + ), + ], + ); + } + + MIHBody getBody() { + return MIHBody( + borderOn: false, + bodyItems: [ + displayProPic(), + const SizedBox(height: 25.0), + MIHFileField( + controller: proPicController, + hintText: "Profile Picture", + editable: false, + required: false, + onPressed: () async { + FilePickerResult? result = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['jpg', 'png'], + ); + if (result == null) return; + final selectedFile = result.files.first; + setState(() { + proPic = selectedFile; + propicPreview = MemoryImage(proPic.bytes!); + }); + + setState(() { + proPicController.text = selectedFile.name; + }); + }, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: usernameController, + hintText: "Username", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: fnameController, + hintText: "First Name", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: lnameController, + hintText: "Last Name", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + "Activate Business Account", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), + const SizedBox( + width: 10, + ), + Switch( + value: businessUser, + onChanged: (bool value) { + setState(() { + businessUser = value; + }); + }, + ), + ], + ), + const SizedBox(height: 30.0), + SizedBox( + width: 500.0, + height: 50.0, + child: MIHButton( + buttonText: "Update", + buttonColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + onTap: () { + submitForm(); + }, + ), + ), + ], + ); + } + @override void dispose() { proPicController.dispose(); @@ -288,144 +409,10 @@ class _ProfileUserUpdateState extends State { @override Widget build(BuildContext context) { - return Scaffold( - // appBar: const MIHAppBar( - // barTitle: "Update Profile", - // propicFile: null, - // ), - //drawer: MIHAppDrawer(signedInUser: widget.signedInUser), - body: SafeArea( - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.all(15.0), - child: Center( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - submitForm(); - } - }, - child: Column( - children: [ - const Text( - "Mzansi Profile", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - const SizedBox(height: 25.0), - displayProPic(), - const SizedBox(height: 25.0), - MIHFileField( - controller: proPicController, - hintText: "Profile Picture", - editable: false, - required: false, - onPressed: () async { - FilePickerResult? result = - await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['jpg', 'png'], - ); - if (result == null) return; - final selectedFile = result.files.first; - setState(() { - proPic = selectedFile; - propicPreview = MemoryImage(proPic.bytes!); - }); - - setState(() { - proPicController.text = selectedFile.name; - }); - }, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: usernameController, - hintText: "Username", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: fnameController, - hintText: "First Name", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: lnameController, - hintText: "Last Name", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Text( - "Activate Business Account", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - ), - ), - const SizedBox( - width: 10, - ), - Switch( - value: businessUser, - onChanged: (bool value) { - setState(() { - businessUser = value; - }); - }, - ), - ], - ), - const SizedBox(height: 30.0), - SizedBox( - width: 500.0, - height: 50.0, - child: MIHButton( - buttonText: "Update", - buttonColor: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - textColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - onTap: () { - submitForm(); - }, - ), - ), - ], - )), - ), - ), - Positioned( - top: 10, - left: 5, - width: 50, - height: 50, - child: IconButton( - onPressed: () { - Navigator.of(context).pop(); - }, - icon: const Icon(Icons.arrow_back), - ), - ) - ], - ), - ), + return MIHLayoutBuilder( + actionButton: getActionButton(), + header: getHeader(), + body: getBody(), ); } } diff --git a/Frontend/patient_manager/lib/router/routeGenerator.dart b/Frontend/patient_manager/lib/router/routeGenerator.dart index 166ff543..fecd69f0 100644 --- a/Frontend/patient_manager/lib/router/routeGenerator.dart +++ b/Frontend/patient_manager/lib/router/routeGenerator.dart @@ -3,19 +3,19 @@ import 'package:patient_manager/Authentication/authCheck.dart'; import 'package:patient_manager/components/addOrViewPatient.dart'; import 'package:patient_manager/objects/appUser.dart'; import 'package:patient_manager/objects/arguments.dart'; -import 'package:patient_manager/pages/about/MIH_About.dart'; +import 'package:patient_manager/pages/about_MIH/MIH_About.dart'; import 'package:patient_manager/pages/authentication/forgotPassword.dart'; import 'package:patient_manager/pages/authentication/resetPassword.dart'; import 'package:patient_manager/pages/fullScreenFile.dart'; import 'package:patient_manager/pages/manageBusinessProfile.dart'; -import 'package:patient_manager/pages/patientAccessReview.dart'; +import 'package:patient_manager/pages/access_review/patientAccessReview.dart'; import 'package:patient_manager/pages/patientAdd.dart'; import 'package:patient_manager/pages/patientEdit.dart'; import 'package:patient_manager/pages/patientManager.dart'; import 'package:patient_manager/pages/patientView.dart'; import 'package:patient_manager/pages/profileBusinessAdd.dart'; import 'package:patient_manager/pages/profileBusinessUpdate.dart'; -import 'package:patient_manager/pages/profileUserUpdate.dart'; +import 'package:patient_manager/pages/mzansi_profile/profileUserUpdate.dart'; class RouteGenerator { static Route generateRoute(RouteSettings settings) {