From b1c7ecd8dcd1e4e4bc093c00f35bdb10d5dbbd3f Mon Sep 17 00:00:00 2001 From: yaso Date: Wed, 18 Sep 2024 12:18:43 +0200 Subject: [PATCH] set up business layout builder enhancement --- .../manage_business/profile_business_add.dart | 593 ++++++++++++------ 1 file changed, 403 insertions(+), 190 deletions(-) diff --git a/Frontend/patient_manager/lib/mih_packages/manage_business/profile_business_add.dart b/Frontend/patient_manager/lib/mih_packages/manage_business/profile_business_add.dart index ad9c3971..4e027b44 100644 --- a/Frontend/patient_manager/lib/mih_packages/manage_business/profile_business_add.dart +++ b/Frontend/patient_manager/lib/mih_packages/manage_business/profile_business_add.dart @@ -2,6 +2,10 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.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/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_error_message.dart'; @@ -197,6 +201,209 @@ class _ProfileBusinessAddState extends State { return regex.hasMatch(text); } + 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 Business Profile", + 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: SingleChildScrollView( + child: Column( + children: [ + //const SizedBox(height: 15), + const Text( + "My Business Details", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), + ), + Divider( + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor()), + const SizedBox(height: 10.0), + MIHTextField( + controller: regController, + hintText: "Registration No.", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: nameController, + hintText: "Business Name", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHDropdownField( + controller: typeController, + hintText: "Business Type", + dropdownOptions: const ["Doctors Office", "Other"], + required: true, + editable: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: contactController, + hintText: "Contact Number", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: emailController, + hintText: "Email", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), + MIHFileField( + controller: logonameController, + hintText: "Logo", + editable: false, + required: true, + onPressed: () async { + FilePickerResult? result = + await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['jpg', 'png', 'pdf'], + ); + if (result == null) return; + final selectedFile = result.files.first; + setState(() { + selectedLogo = selectedFile; + }); + setState(() { + logonameController.text = selectedFile.name; + }); + }, + ), + const SizedBox(height: 15.0), + Divider( + color: + MzanziInnovationHub.of(context)?.theme.secondaryColor(), + ), + //const SizedBox(height: 15.0), + const Text( + "My Business User", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 22, + ), + ), + Divider( + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor()), + const SizedBox(height: 10.0), + MIHDropdownField( + controller: titleController, + hintText: "Title", + dropdownOptions: const ["Doctor", "Assistant"], + required: true, + editable: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: fnameController, + hintText: "Name", + editable: false, + required: true, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: lnameController, + hintText: "Surname", + editable: false, + required: true, + ), + const SizedBox(height: 10.0), + MIHFileField( + controller: signtureController, + hintText: "Signature", + editable: false, + required: true, + onPressed: () async { + FilePickerResult? result = + await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['jpg', 'png', 'pdf'], + ); + if (result == null) return; + final selectedFile = result.files.first; + setState(() { + selectedSignature = selectedFile; + }); + setState(() { + signtureController.text = selectedFile.name; + }); + }, + ), + const SizedBox(height: 15.0), + MIHDropdownField( + controller: accessController, + hintText: "Access", + dropdownOptions: const ["Full", "Partial"], + required: true, + editable: false, + ), + const SizedBox(height: 30.0), + SizedBox( + width: 500.0, + height: 50.0, + child: MIHButton( + buttonText: "Add", + buttonColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + textColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + onTap: () { + submitForm(); + }, + ), + ), + ], + ), + ), + ), + ], + ); + } + @override void dispose() { nameController.dispose(); @@ -226,196 +433,202 @@ class _ProfileBusinessAddState extends State { @override Widget build(BuildContext context) { - return Scaffold( - // appBar: const MIHAppBar( - // barTitle: "Add Business", - // 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: SingleChildScrollView( - padding: const EdgeInsets.all(15), - child: Column( - children: [ - //const SizedBox(height: 15), - const Text( - "Add Business Profile", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - const SizedBox(height: 25.0), - MIHTextField( - controller: regController, - hintText: "Registration No.", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: nameController, - hintText: "Business Name", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHDropdownField( - controller: typeController, - hintText: "Business Type", - dropdownOptions: const ["Doctors Office", "Other"], - required: true, - editable: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: contactController, - hintText: "Contact Number", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: emailController, - hintText: "Email", - editable: true, - required: true, - ), - const SizedBox(height: 10.0), - MIHFileField( - controller: logonameController, - hintText: "Logo", - editable: false, - required: true, - onPressed: () async { - FilePickerResult? result = - await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['jpg', 'png', 'pdf'], - ); - if (result == null) return; - final selectedFile = result.files.first; - setState(() { - selectedLogo = selectedFile; - }); - setState(() { - logonameController.text = selectedFile.name; - }); - }, - ), - const SizedBox(height: 15.0), - Divider( - color: MzanziInnovationHub.of(context) - ?.theme - .secondaryColor(), - ), - //const SizedBox(height: 15.0), - const Text( - "My Business User", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - const SizedBox(height: 25.0), - MIHDropdownField( - controller: titleController, - hintText: "Title", - dropdownOptions: const ["Doctor", "Assistant"], - required: true, - editable: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: fnameController, - hintText: "Name", - editable: false, - required: true, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: lnameController, - hintText: "Surname", - editable: false, - required: true, - ), - const SizedBox(height: 10.0), - MIHFileField( - controller: signtureController, - hintText: "Signature", - editable: false, - required: true, - onPressed: () async { - FilePickerResult? result = - await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['jpg', 'png', 'pdf'], - ); - if (result == null) return; - final selectedFile = result.files.first; - setState(() { - selectedSignature = selectedFile; - }); - setState(() { - signtureController.text = selectedFile.name; - }); - }, - ), - const SizedBox(height: 15.0), - MIHDropdownField( - controller: accessController, - hintText: "Access", - dropdownOptions: const ["Full", "Partial"], - required: true, - editable: false, - ), - const SizedBox(height: 30.0), - SizedBox( - width: 500.0, - height: 50.0, - child: MIHButton( - buttonText: "Add", - 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), - ), - ) - ], - ), - ), + return MIHLayoutBuilder( + actionButton: getActionButton(), + header: getHeader(), + body: getBody(), ); + + // return Scaffold( + // // appBar: const MIHAppBar( + // // barTitle: "Add Business", + // // 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: SingleChildScrollView( + // padding: const EdgeInsets.all(15), + // child: Column( + // children: [ + // //const SizedBox(height: 15), + // const Text( + // "Add Business Profile", + // style: TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 25, + // ), + // ), + // const SizedBox(height: 25.0), + // MIHTextField( + // controller: regController, + // hintText: "Registration No.", + // editable: true, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHTextField( + // controller: nameController, + // hintText: "Business Name", + // editable: true, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHDropdownField( + // controller: typeController, + // hintText: "Business Type", + // dropdownOptions: const ["Doctors Office", "Other"], + // required: true, + // editable: true, + // ), + // const SizedBox(height: 10.0), + // MIHTextField( + // controller: contactController, + // hintText: "Contact Number", + // editable: true, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHTextField( + // controller: emailController, + // hintText: "Email", + // editable: true, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHFileField( + // controller: logonameController, + // hintText: "Logo", + // editable: false, + // required: true, + // onPressed: () async { + // FilePickerResult? result = + // await FilePicker.platform.pickFiles( + // type: FileType.custom, + // allowedExtensions: ['jpg', 'png', 'pdf'], + // ); + // if (result == null) return; + // final selectedFile = result.files.first; + // setState(() { + // selectedLogo = selectedFile; + // }); + // setState(() { + // logonameController.text = selectedFile.name; + // }); + // }, + // ), + // const SizedBox(height: 15.0), + // Divider( + // color: MzanziInnovationHub.of(context) + // ?.theme + // .secondaryColor(), + // ), + // //const SizedBox(height: 15.0), + // const Text( + // "My Business User", + // style: TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 25, + // ), + // ), + // const SizedBox(height: 25.0), + // MIHDropdownField( + // controller: titleController, + // hintText: "Title", + // dropdownOptions: const ["Doctor", "Assistant"], + // required: true, + // editable: true, + // ), + // const SizedBox(height: 10.0), + // MIHTextField( + // controller: fnameController, + // hintText: "Name", + // editable: false, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHTextField( + // controller: lnameController, + // hintText: "Surname", + // editable: false, + // required: true, + // ), + // const SizedBox(height: 10.0), + // MIHFileField( + // controller: signtureController, + // hintText: "Signature", + // editable: false, + // required: true, + // onPressed: () async { + // FilePickerResult? result = + // await FilePicker.platform.pickFiles( + // type: FileType.custom, + // allowedExtensions: ['jpg', 'png', 'pdf'], + // ); + // if (result == null) return; + // final selectedFile = result.files.first; + // setState(() { + // selectedSignature = selectedFile; + // }); + // setState(() { + // signtureController.text = selectedFile.name; + // }); + // }, + // ), + // const SizedBox(height: 15.0), + // MIHDropdownField( + // controller: accessController, + // hintText: "Access", + // dropdownOptions: const ["Full", "Partial"], + // required: true, + // editable: false, + // ), + // const SizedBox(height: 30.0), + // SizedBox( + // width: 500.0, + // height: 50.0, + // child: MIHButton( + // buttonText: "Add", + // 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), + // ), + // ) + // ], + // ), + // ), + // ); } }