fix reload on field press

This commit is contained in:
2025-03-28 11:09:11 +02:00
parent 1b5d37d689
commit 5a45550036
2 changed files with 153 additions and 138 deletions

View File

@@ -26,6 +26,7 @@ class _AddOrViewPatientState extends State<AddOrViewPatient> {
late double width; late double width;
late double height; late double height;
late Widget loading; late Widget loading;
late Future<Patient?> patient;
Future<Patient?> fetchPatient() async { Future<Patient?> fetchPatient() async {
//print("Patien manager page: $endpoint"); //print("Patien manager page: $endpoint");
@@ -55,15 +56,23 @@ class _AddOrViewPatientState extends State<AddOrViewPatient> {
super.dispose(); super.dispose();
} }
@override
void initState() {
// TODO: implement initState
super.initState();
patient = fetchPatient();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("AddOrViewPatient");
var size = MediaQuery.of(context).size; var size = MediaQuery.of(context).size;
setState(() { setState(() {
width = size.width; width = size.width;
height = size.height; height = size.height;
}); });
return FutureBuilder( return FutureBuilder(
future: fetchPatient(), future: patient,
builder: (ctx, snapshot) { builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.done && if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) { snapshot.hasData) {

View File

@@ -8,6 +8,7 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_action.dart'
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_body.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_body.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_header.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_header.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_layout_builder.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_layout_builder.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_single_child_scroll.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_success_message.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
import 'package:Mzansi_Innovation_Hub/mih_env/env.dart'; import 'package:Mzansi_Innovation_Hub/mih_env/env.dart';
@@ -158,147 +159,151 @@ class _AddPatientState extends State<AddPatient> {
} }
Widget displayForm() { Widget displayForm() {
return Column( return MihSingleChildScroll(
children: [ child: Column(
Text( children: [
"Personal Details", Text(
textAlign: TextAlign.center, "Personal Details",
style: TextStyle( textAlign: TextAlign.center,
fontWeight: FontWeight.bold, style: TextStyle(
fontSize: 22.0, fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), fontSize: 22.0,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
), ),
), Divider(
Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10.0), const SizedBox(height: 10.0),
MIHTextField( MIHTextField(
controller: idController, controller: idController,
hintText: "13 digit ID Number or Passport", hintText: "13 digit ID Number or Passport",
editable: true, editable: true,
required: true, required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Last Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: cellController,
hintText: "Cell Number",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: emailController,
hintText: "Email",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: addressController,
hintText: "Address",
editable: true,
required: true,
),
const SizedBox(height: 15.0),
Text(
"Medical Aid Details",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22.0,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),
), const SizedBox(height: 10.0),
Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), MIHTextField(
const SizedBox(height: 10.0), controller: fnameController,
MIHDropdownField( hintText: "First Name",
controller: medAidController, editable: false,
hintText: "Medical Aid", required: true,
editable: true, ),
enableSearch: false, const SizedBox(height: 10.0),
// onSelect: (_) { MIHTextField(
// isRequired(); controller: lnameController,
// }, hintText: "Last Name",
required: true, editable: false,
dropdownOptions: const ["Yes", "No"], required: true,
), ),
ValueListenableBuilder( const SizedBox(height: 10.0),
valueListenable: medRequired, MIHTextField(
builder: (BuildContext context, bool value, Widget? child) { controller: cellController,
return Visibility( hintText: "Cell Number",
visible: value, editable: true,
child: Column( required: true,
children: [ ),
const SizedBox(height: 10.0), const SizedBox(height: 10.0),
MIHDropdownField( MIHTextField(
controller: medMainMemController, controller: emailController,
hintText: "Main Member", hintText: "Email",
editable: value, editable: false,
required: value, required: true,
enableSearch: false, ),
dropdownOptions: const ["Yes", "No"], const SizedBox(height: 10.0),
), MIHTextField(
const SizedBox(height: 10.0), controller: addressController,
MIHTextField( hintText: "Address",
controller: medNoController, editable: true,
hintText: "Medical Aid No.", required: true,
editable: value, ),
required: value, const SizedBox(height: 15.0),
), Text(
const SizedBox(height: 10.0), "Medical Aid Details",
MIHTextField( textAlign: TextAlign.center,
controller: medAidCodeController, style: TextStyle(
hintText: "Medical Aid Code", fontWeight: FontWeight.bold,
editable: value, fontSize: 22.0,
required: value, color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),
const SizedBox(height: 10.0), ),
MIHTextField( Divider(
controller: medNameController, color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
hintText: "Medical Aid Name", const SizedBox(height: 10.0),
editable: value, MIHDropdownField(
required: value, controller: medAidController,
), hintText: "Medical Aid",
const SizedBox(height: 10.0), editable: true,
MIHTextField( enableSearch: false,
controller: medSchemeController, // onSelect: (_) {
hintText: "Medical Aid Plan", // isRequired();
editable: value, // },
required: value, required: true,
), dropdownOptions: const ["Yes", "No"],
], ),
), ValueListenableBuilder(
); valueListenable: medRequired,
}, builder: (BuildContext context, bool value, Widget? child) {
), return Visibility(
const SizedBox(height: 30.0), visible: value,
SizedBox( child: Column(
width: 450.0, children: [
height: 50.0, const SizedBox(height: 10.0),
child: MIHButton( MIHDropdownField(
onTap: () { controller: medMainMemController,
submitForm(); hintText: "Main Member",
editable: value,
required: value,
enableSearch: false,
dropdownOptions: const ["Yes", "No"],
),
const SizedBox(height: 10.0),
MIHTextField(
controller: medNoController,
hintText: "Medical Aid No.",
editable: value,
required: value,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: medAidCodeController,
hintText: "Medical Aid Code",
editable: value,
required: value,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: medNameController,
hintText: "Medical Aid Name",
editable: value,
required: value,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: medSchemeController,
hintText: "Medical Aid Plan",
editable: value,
required: value,
),
],
),
);
}, },
buttonText: "Add",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
), ),
), const SizedBox(height: 30.0),
], SizedBox(
width: 450.0,
height: 50.0,
child: MIHButton(
onTap: () {
submitForm();
},
buttonText: "Add",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
),
); );
} }
@@ -393,6 +398,7 @@ class _AddPatientState extends State<AddPatient> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("Add Patient");
return MIHLayoutBuilder( return MIHLayoutBuilder(
actionButton: getActionButton(), actionButton: getActionButton(),
header: getHeader(), header: getHeader(),