update Mzansi Profile & Access reviews with layout builder

This commit is contained in:
2024-09-17 13:21:37 +02:00
parent b641e07b0c
commit b037d75473
6 changed files with 335 additions and 238 deletions

View File

@@ -19,6 +19,13 @@ class MIHLayoutBuilder extends StatefulWidget {
} }
class _MIHLayoutBuilderState extends State<MIHLayoutBuilder> { class _MIHLayoutBuilderState extends State<MIHLayoutBuilder> {
List<Widget> getList() {
List<Widget> temp = [];
temp.add(widget.header);
temp.add(widget.body);
return temp;
}
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
@@ -40,7 +47,10 @@ class _MIHLayoutBuilderState extends State<MIHLayoutBuilder> {
children: [ children: [
widget.actionButton, widget.actionButton,
Column( Column(
children: [widget.header, Expanded(child: widget.body)], children: [
widget.header,
Expanded(child: widget.body),
],
), ),
], ],
), ),

View File

@@ -297,6 +297,7 @@ class _BuildPatientsListState extends State<BuildAccessRequestList> {
}); });
checkScreenSize(); checkScreenSize();
return ListView.separated( return ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, index) { separatorBuilder: (BuildContext context, index) {
return Divider( return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),

View File

@@ -1,6 +1,10 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; 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/builders/buildAccessRequestList.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart'; import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart'; import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
@@ -80,36 +84,17 @@ class _PatientAccessRequestState extends State<PatientAccessRequest> {
Widget displayAccessRequestList(List<AccessRequest> accessRequestList) { Widget displayAccessRequestList(List<AccessRequest> accessRequestList) {
if (accessRequestList.isNotEmpty) { if (accessRequestList.isNotEmpty) {
return Container( return BuildAccessRequestList(
//height: height - 254, signedInUser: widget.signedInUser,
decoration: BoxDecoration( accessRequests: accessRequestList,
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,
),
// BuildPatientQueueList( // BuildPatientQueueList(
// patientQueue: patientQueueList, // patientQueue: patientQueueList,
// signedInUser: widget.signedInUser, // signedInUser: widget.signedInUser,
// ), // ),
); );
} } else {
return Container( return Center(
//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(
child: Text( child: Text(
"No Request have been made.", "No Request have been made.",
style: TextStyle( style: TextStyle(
@@ -117,8 +102,8 @@ class _PatientAccessRequestState extends State<PatientAccessRequest> {
color: MzanziInnovationHub.of(context)!.theme.messageTextColor()), color: MzanziInnovationHub.of(context)!.theme.messageTextColor()),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), );
); }
} }
Widget viewAccessRequest(double w, double h) { Widget viewAccessRequest(double w, double h) {
@@ -171,39 +156,39 @@ class _PatientAccessRequestState extends State<PatientAccessRequest> {
); );
} else if (snapshot.connectionState == ConnectionState.done) { } else if (snapshot.connectionState == ConnectionState.done) {
List<AccessRequest> accessRequestList; List<AccessRequest> accessRequestList;
// if (searchString == "") {
// patientQueueList = [];
// } else {
accessRequestList = filterSearchResults(snapshot.requireData); accessRequestList = filterSearchResults(snapshot.requireData);
// print(patientQueueList); if (accessRequestList.isNotEmpty) {
// } return BuildAccessRequestList(
signedInUser: widget.signedInUser,
return Expanded( accessRequests: accessRequestList,
child: displayAccessRequestList(accessRequestList), );
); } else {
} else { return Center(
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(
child: Text( child: Text(
"$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody", "No Request have been made.",
style: TextStyle( style: TextStyle(
fontSize: 25, fontSize: 25,
color: MzanziInnovationHub.of(context)! color: MzanziInnovationHub.of(context)!
.theme .theme
.errorColor()), .messageTextColor()),
textAlign: TextAlign.center, 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<PatientAccessRequest> {
// }); // });
} }
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<AccessRequest> 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 @override
void dispose() { void dispose() {
filterController.dispose(); filterController.dispose();
@@ -250,50 +346,53 @@ class _PatientAccessRequestState extends State<PatientAccessRequest> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width; return MIHLayoutBuilder(
final screenHeight = MediaQuery.of(context).size.height; actionButton: getActionButton(),
return Scaffold( header: getHeader(),
// appBar: const MIHAppBar( body: getBody(),
// 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 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,
// ),
// ),
// )
// ],
// ),
// ),
// );
} }
} }

View File

@@ -3,6 +3,10 @@ import 'dart:convert';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart'; import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart'; import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
@@ -257,6 +261,123 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
} }
} }
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 @override
void dispose() { void dispose() {
proPicController.dispose(); proPicController.dispose();
@@ -288,144 +409,10 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return MIHLayoutBuilder(
// appBar: const MIHAppBar( actionButton: getActionButton(),
// barTitle: "Update Profile", header: getHeader(),
// propicFile: null, body: getBody(),
// ),
//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),
),
)
],
),
),
); );
} }
} }

View File

@@ -3,19 +3,19 @@ import 'package:patient_manager/Authentication/authCheck.dart';
import 'package:patient_manager/components/addOrViewPatient.dart'; import 'package:patient_manager/components/addOrViewPatient.dart';
import 'package:patient_manager/objects/appUser.dart'; import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.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/forgotPassword.dart';
import 'package:patient_manager/pages/authentication/resetPassword.dart'; import 'package:patient_manager/pages/authentication/resetPassword.dart';
import 'package:patient_manager/pages/fullScreenFile.dart'; import 'package:patient_manager/pages/fullScreenFile.dart';
import 'package:patient_manager/pages/manageBusinessProfile.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/patientAdd.dart';
import 'package:patient_manager/pages/patientEdit.dart'; import 'package:patient_manager/pages/patientEdit.dart';
import 'package:patient_manager/pages/patientManager.dart'; import 'package:patient_manager/pages/patientManager.dart';
import 'package:patient_manager/pages/patientView.dart'; import 'package:patient_manager/pages/patientView.dart';
import 'package:patient_manager/pages/profileBusinessAdd.dart'; import 'package:patient_manager/pages/profileBusinessAdd.dart';
import 'package:patient_manager/pages/profileBusinessUpdate.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 { class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) { static Route<dynamic> generateRoute(RouteSettings settings) {