Use layout Builder for patient profile

This commit is contained in:
2024-09-17 13:55:12 +02:00
parent 7e9729e10a
commit bffd4ea323
6 changed files with 287 additions and 352 deletions

View File

@@ -298,68 +298,57 @@ class _BuildFilesListState extends State<BuildFilesList> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
//double width = size.width;
double height = size.height;
if (widget.files.isNotEmpty) {
return SizedBox(
height: height - 177,
child: ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.files.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
widget.files[index].file_name,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
widget.files[index].insert_date,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
trailing: Icon(
Icons.arrow_forward,
return ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.files.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
widget.files[index].file_name,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onTap: () async {
await getFileUrlApiCall(widget.files[index].file_path)
.then((urlHere) {
//print(url);
setState(() {
fileUrl = urlHere;
});
),
subtitle: Text(
widget.files[index].insert_date,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onTap: () async {
await getFileUrlApiCall(widget.files[index].file_path)
.then((urlHere) {
//print(url);
setState(() {
fileUrl = urlHere;
});
});
viewFilePopUp(
widget.files[index].file_name,
widget.files[index].file_path,
widget.files[index].idpatient_files,
fileUrl);
},
);
},
),
viewFilePopUp(
widget.files[index].file_name,
widget.files[index].file_path,
widget.files[index].idpatient_files,
fileUrl);
},
);
},
);
} else {
return SizedBox(
height: height - 150,
child: const Center(
child: Text(
"No Documents Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
return const Center(
child: Text(
"No Documents Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
);
}

View File

@@ -275,60 +275,49 @@ class _BuildNotesListState extends State<BuildNotesList> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
//double width = size.width;
double height = size.height;
if (widget.notes.isNotEmpty) {
return SizedBox(
height: height - 173,
child: ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.notes.length,
itemBuilder: (context, index) {
String notePreview = widget.notes[index].note_text;
if (notePreview.length > 30) {
notePreview = "${notePreview.substring(0, 30)} ...";
}
return ListTile(
title: Text(
"${widget.notes[index].note_name}\n${widget.notes[index].doc_office} - ${widget.notes[index].doctor}",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
"${widget.notes[index].insert_date}:\n$notePreview",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
), //Text(widget.notes[index].note_text),
trailing: Icon(
Icons.arrow_forward,
return ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.notes.length,
itemBuilder: (context, index) {
String notePreview = widget.notes[index].note_text;
if (notePreview.length > 30) {
notePreview = "${notePreview.substring(0, 30)} ...";
}
return ListTile(
title: Text(
"${widget.notes[index].note_name}\n${widget.notes[index].doc_office} - ${widget.notes[index].doctor}",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onTap: () {
viewNotePopUp(widget.notes[index]);
},
);
},
),
),
subtitle: Text(
"${widget.notes[index].insert_date}:\n$notePreview",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
), //Text(widget.notes[index].note_text),
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onTap: () {
viewNotePopUp(widget.notes[index]);
},
);
},
);
} else {
return SizedBox(
height: height - 173,
child: const Center(
child: Text(
"No Notes Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
return const Center(
child: Text(
"No Notes Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
);
}

View File

@@ -269,56 +269,34 @@ class _PatientDetailsState extends State<PatientDetails> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
//double width = size.width;
double height = size.height;
return Container(
alignment: Alignment.topCenter,
height: height - 100,
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
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),
),
//constraints: const BoxConstraints.expand(height: 250.0),
child: SelectionArea(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: ,
children: setIcons(),
return SelectionArea(
child: SingleChildScrollView(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: ,
children: setIcons(),
),
Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
getPatientDetailsField(),
const SizedBox(height: 10),
Text(
"Medical Aid Details",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
Divider(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
getPatientDetailsField(),
const SizedBox(height: 10),
Text(
"Medical Aid Details",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
Divider(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
getMedAidDetailsFields(),
],
),
),
Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
getMedAidDetailsFields(),
],
),
),
);

View File

@@ -643,78 +643,34 @@ class _PatientFilesState extends State<PatientFiles> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
//double width = size.width;
double height = size.height;
return FutureBuilder(
future: futueFiles,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Container(
height: height - 100,
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: const Center(
child: Mihloadingcircle(),
),
return const Center(
child: Mihloadingcircle(),
);
} else if (snapshot.hasData) {
final filesList = snapshot.data!;
return Container(
//height: 300.0,
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),
return Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: setIcons(),
),
child: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: setIcons(),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Divider(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor()),
),
const SizedBox(height: 10),
BuildFilesList(
files: filesList,
signedInUser: widget.signedInUser,
selectedPatient: widget.selectedPatient,
business: widget.business,
businessUser: widget.businessUser,
),
]),
Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
BuildFilesList(
files: filesList,
signedInUser: widget.signedInUser,
selectedPatient: widget.selectedPatient,
business: widget.business,
businessUser: widget.businessUser,
),
);
]);
} else {
return Container(
height: height - 175,
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: const Center(
child: Text("Error Loading Notes"),
),
return const Center(
child: Text("Error Loading Notes"),
);
}
},

View File

@@ -331,78 +331,34 @@ class _PatientNotesState extends State<PatientNotes> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
//double width = size.width;
double height = size.height;
return FutureBuilder(
future: futueNotes,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Container(
height: height - 100,
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: const Center(
child: Mihloadingcircle(),
),
return const Center(
child: Mihloadingcircle(),
);
} else if (snapshot.hasData) {
final notesList = snapshot.data!;
return Container(
//height: 300.0,
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),
return Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: setIcons(),
),
child: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: setIcons(),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Divider(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor()),
),
const SizedBox(height: 10),
BuildNotesList(
notes: notesList,
signedInUser: widget.signedInUser,
selectedPatient: widget.selectedPatient,
business: widget.business,
businessUser: widget.businessUser,
),
]),
Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
BuildNotesList(
notes: notesList,
signedInUser: widget.signedInUser,
selectedPatient: widget.selectedPatient,
business: widget.business,
businessUser: widget.businessUser,
),
);
]);
} else {
return Container(
height: height - 100,
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: const Center(
child: Text("Error Loading Notes"),
),
return const Center(
child: Text("Error Loading Notes"),
);
}
},

View File

@@ -4,6 +4,10 @@ import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientDetails.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientFiles.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientNotes.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/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';
@@ -100,6 +104,64 @@ class _PatientViewState extends State<PatientView> {
}
}
MIHAction getActionButton() {
return MIHAction(
icon: Icons.arrow_back,
iconSize: 35,
onTap: () {
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
},
);
}
MIHHeader getHeader() {
return MIHHeader(
headerAlignment: MainAxisAlignment.end,
headerItems: [
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 0;
});
},
icon: const Icon(
Icons.perm_identity,
size: 35,
),
),
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 1;
});
},
icon: const Icon(
Icons.article_outlined,
size: 35,
),
),
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 2;
});
},
icon: const Icon(
Icons.file_present,
size: 35,
),
),
],
);
}
MIHBody getBody() {
return MIHBody(
borderOn: true,
bodyItems: [showSelection(_selectedIndex)],
);
}
@override
void dispose() {
// TODO: implement dispose
@@ -114,81 +176,86 @@ class _PatientViewState extends State<PatientView> {
height = size.height;
});
checkScreenSize();
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Stack(
children: [
Container(
width: width,
height: height,
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 15.0),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 0;
});
},
icon: const Icon(
Icons.perm_identity,
size: 35,
),
),
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 1;
});
},
icon: const Icon(
Icons.article_outlined,
size: 35,
),
),
IconButton(
onPressed: () {
setState(() {
_selectedIndex = 2;
});
},
icon: const Icon(
Icons.file_present,
size: 35,
),
),
],
),
const SizedBox(
height: 10.0,
),
showSelection(_selectedIndex),
],
),
),
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(),
);
// return Scaffold(
// body: SafeArea(
// child: SingleChildScrollView(
// child: Stack(
// children: [
// Container(
// width: width,
// height: height,
// padding: const EdgeInsets.symmetric(
// vertical: 10.0, horizontal: 15.0),
// child: Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// IconButton(
// onPressed: () {
// setState(() {
// _selectedIndex = 0;
// });
// },
// icon: const Icon(
// Icons.perm_identity,
// size: 35,
// ),
// ),
// IconButton(
// onPressed: () {
// setState(() {
// _selectedIndex = 1;
// });
// },
// icon: const Icon(
// Icons.article_outlined,
// size: 35,
// ),
// ),
// IconButton(
// onPressed: () {
// setState(() {
// _selectedIndex = 2;
// });
// },
// icon: const Icon(
// Icons.file_present,
// size: 35,
// ),
// ),
// ],
// ),
// const SizedBox(
// height: 10.0,
// ),
// showSelection(_selectedIndex),
// ],
// ),
// ),
// Positioned(
// top: 10,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.of(context).pop();
// },
// icon: const Icon(Icons.arrow_back),
// ),
// )
// ],
// ),
// ),
// ),
// );
}
}