patient add with new layout builder

This commit is contained in:
2024-09-18 12:05:14 +02:00
parent c0a211e36d
commit ac9bbc8058

View File

@@ -3,6 +3,10 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart'; import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_action.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_body.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_header.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_layout_builder.dart';
//import 'package:patient_manager/MIH_Components/mihAppDrawer.dart'; //import 'package:patient_manager/MIH_Components/mihAppDrawer.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_success_message.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_success_message.dart';
@@ -159,7 +163,6 @@ class _AddPatientState extends State<AddPatient> {
Widget displayForm() { Widget displayForm() {
return SingleChildScrollView( return SingleChildScrollView(
padding: const EdgeInsets.all(15.0),
child: Column( child: Column(
children: [ children: [
Text( Text(
@@ -167,11 +170,13 @@ class _AddPatientState extends State<AddPatient> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 25.0, fontSize: 22.0,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),
), ),
const SizedBox(height: 25.0), Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
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",
@@ -219,10 +224,12 @@ class _AddPatientState extends State<AddPatient> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 25.0, fontSize: 22.0,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),
), ),
Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10.0), const SizedBox(height: 10.0),
MIHDropdownField( MIHDropdownField(
controller: medAidController, controller: medAidController,
@@ -309,6 +316,50 @@ class _AddPatientState extends State<AddPatient> {
} }
} }
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(
"Add Patient Details",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
],
);
}
MIHBody getBody() {
return MIHBody(
borderOn: true,
bodyItems: [
KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
submitForm();
}
},
child: displayForm(),
),
],
);
}
@override @override
void dispose() { void dispose() {
idController.dispose(); idController.dispose();
@@ -341,41 +392,46 @@ class _AddPatientState extends State<AddPatient> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return MIHLayoutBuilder(
// appBar: const MIHAppBar( actionButton: getActionButton(),
// barTitle: "Add Patient", header: getHeader(),
// propicFile: null, body: getBody(),
// ),
//drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
body: SafeArea(
child: Stack(
children: [
KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
submitForm();
}
},
child: displayForm(),
),
Positioned(
top: 10,
left: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back),
),
)
],
),
),
); );
// return Scaffold(
// // appBar: const MIHAppBar(
// // barTitle: "Add Patient",
// // propicFile: null,
// // ),
// //drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
// body: SafeArea(
// child: Stack(
// children: [
// KeyboardListener(
// focusNode: _focusNode,
// autofocus: true,
// onKeyEvent: (event) async {
// if (event is KeyDownEvent &&
// event.logicalKey == LogicalKeyboardKey.enter) {
// submitForm();
// }
// },
// child: displayForm(),
// ),
// Positioned(
// top: 10,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.of(context).pop();
// },
// icon: const Icon(Icons.arrow_back),
// ),
// )
// ],
// ),
// ),
// );
} }
} }