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

View File

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

View File

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

View File

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

View File

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

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/patientDetails.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientFiles.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/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/env/env.dart';
import 'package:patient_manager/main.dart'; import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.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 @override
void dispose() { void dispose() {
// TODO: implement dispose // TODO: implement dispose
@@ -114,81 +176,86 @@ class _PatientViewState extends State<PatientView> {
height = size.height; height = size.height;
}); });
checkScreenSize(); checkScreenSize();
return Scaffold( return MIHLayoutBuilder(
body: SafeArea( actionButton: getActionButton(),
child: SingleChildScrollView( header: getHeader(),
child: Stack( body: getBody(),
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 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),
// ),
// )
// ],
// ),
// ),
// ),
// );
} }
} }