From 4f6c7e059370f34313fe7acf48030ceedcbce842 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Mon, 17 Mar 2025 10:45:26 +0200 Subject: [PATCH] update Biz Profile to use MihSignlewScroll --- .../app_tools/mih_business_profile.dart | 468 +++++++++--------- .../app_tools/mih_business_user_search.dart | 117 ++--- .../app_tools/mih_my_business_team.dart | 78 +-- 3 files changed, 332 insertions(+), 331 deletions(-) diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_profile.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_profile.dart index eda76b95..e0e7a644 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_profile.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_profile.dart @@ -6,6 +6,7 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_ import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_file_input.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart'; +import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_single_child_scroll.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_body.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_loading_circle.dart'; @@ -317,255 +318,246 @@ class _MihBusinessProfileState extends State { } Widget getBody() { - return ScrollConfiguration( - behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false), - child: SingleChildScrollView( - child: SafeArea( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - //print(business_id); - submitForm(business_id); - } - }, - child: Column( - children: [ - Visibility( - visible: isFullAccess(), - child: Column( + return MihSingleChildScroll( + child: KeyboardListener( + focusNode: _focusNode, + autofocus: true, + onKeyEvent: (event) async { + if (event is KeyDownEvent && + event.logicalKey == LogicalKeyboardKey.enter) { + //print(business_id); + submitForm(business_id); + } + }, + child: Column( + children: [ + Visibility( + visible: isFullAccess(), + child: Column( + children: [ + const Text( + "Business Profile", + 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, + enableSearch: false, + ), + const SizedBox(height: 10.0), + ValueListenableBuilder( + valueListenable: busType, + builder: + (BuildContext context, String value, Widget? child) { + return Visibility( + visible: value == "Doctors Office", + child: MIHTextField( + controller: practiceNoController, + hintText: "Practice Number", + editable: true, + required: true, + ), + ); + }, + ), + const SizedBox(height: 10.0), + MIHTextField( + controller: vatNoController, + hintText: "VAT Number", + editable: true, + required: 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: 10.0), + Row( children: [ - const Text( - "Business Profile", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, + Flexible( + child: MIHTextField( + controller: locationController, + hintText: "Location", + editable: false, + required: false, ), ), - 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, - enableSearch: false, - ), - const SizedBox(height: 10.0), - ValueListenableBuilder( - valueListenable: busType, - builder: (BuildContext context, String value, - Widget? child) { - return Visibility( - visible: value == "Doctors Office", - child: MIHTextField( - controller: practiceNoController, - hintText: "Practice Number", - editable: true, - required: true, - ), - ); - }, - ), - const SizedBox(height: 10.0), - MIHTextField( - controller: vatNoController, - hintText: "VAT Number", - editable: true, - required: 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: 10.0), - Row( - children: [ - Flexible( - child: MIHTextField( - controller: locationController, - hintText: "Location", - editable: false, - required: false, - ), - ), - const SizedBox(width: 10.0), - SizedBox( - width: 80.0, - height: 50.0, - child: MIHButton( - buttonText: "Set", - buttonColor: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - textColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - onTap: () { - MIHLocationAPI() - .getGPSPosition(context) - .then((position) { - if (position != null) { - setState(() { - locationController.text = - "${position.latitude}, ${position.longitude}"; - }); - } + const SizedBox(width: 10.0), + SizedBox( + width: 80.0, + height: 50.0, + child: MIHButton( + buttonText: "Set", + buttonColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + textColor: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + onTap: () { + MIHLocationAPI() + .getGPSPosition(context) + .then((position) { + if (position != null) { + setState(() { + locationController.text = + "${position.latitude}, ${position.longitude}"; }); - }, - ), - ), - ], + } + }); + }, + ), ), - const SizedBox(height: 15.0), ], ), + const SizedBox(height: 15.0), + ], + ), + ), + Column( + children: [ + //const SizedBox(height: 15.0), + const Text( + "My Business User", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), ), - Column( - children: [ - //const SizedBox(height: 15.0), - const Text( - "My Business User", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - 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, - enableSearch: false, - ), - 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, - enableSearch: false, - ), - const SizedBox(height: 30.0), - SizedBox( - width: 500.0, - height: 50.0, - child: MIHButton( - buttonText: "Update", - buttonColor: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - textColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - onTap: () { - //print(business_id); - submitForm(business_id); - }, - ), - ), - ], + 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, + enableSearch: false, + ), + 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, + enableSearch: false, + ), + const SizedBox(height: 30.0), + SizedBox( + width: 500.0, + height: 50.0, + child: MIHButton( + buttonText: "Update", + buttonColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + textColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + onTap: () { + //print(business_id); + submitForm(business_id); + }, + ), ), ], ), - ), + ], ), ), ); diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_user_search.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_user_search.dart index f99285f2..c8880353 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_user_search.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_business_user_search.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:Mzansi_Innovation_Hub/main.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_search_input.dart'; +import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_single_child_scroll.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_body.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_loading_circle.dart'; @@ -97,65 +98,69 @@ class _MihBusinessUserSearchState extends State { } Widget getBody() { - return KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - submitUserForm(); - } - }, - child: Column(mainAxisSize: MainAxisSize.max, children: [ - const Text( - "User Search", - style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), - ), - //spacer - Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), - const SizedBox(height: 10), - MIHSearchField( - controller: searchController, - hintText: "Username or Email Search", - required: true, - editable: true, - onTap: () { + return MihSingleChildScroll( + child: KeyboardListener( + focusNode: _focusNode, + autofocus: true, + onKeyEvent: (event) async { + if (event is KeyDownEvent && + event.logicalKey == LogicalKeyboardKey.enter) { submitUserForm(); - }, - ), - //spacer - const SizedBox(height: 10), - FutureBuilder( - future: userSearchResults, - builder: (context, snapshot) { - //print("patient Liust ${snapshot.data}"); - if (snapshot.connectionState == ConnectionState.waiting) { - return const Mihloadingcircle(); - } else if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - List patientsList; - if (userSearch == "") { - patientsList = []; + } + }, + child: Column(mainAxisSize: MainAxisSize.max, children: [ + const Text( + "User Search", + style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), + ), + //spacer + Divider( + color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), + const SizedBox(height: 10), + MIHSearchField( + controller: searchController, + hintText: "Username or Email Search", + required: true, + editable: true, + onTap: () { + submitUserForm(); + }, + ), + //spacer + const SizedBox(height: 10), + FutureBuilder( + future: userSearchResults, + builder: (context, snapshot) { + //print("patient Liust ${snapshot.data}"); + if (snapshot.connectionState == ConnectionState.waiting) { + return const Mihloadingcircle(); + } else if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + List patientsList; + if (userSearch == "") { + patientsList = []; + } else { + patientsList = snapshot.data!; + //print(patientsList); + } + return displayUserList(patientsList); } else { - patientsList = snapshot.data!; - //print(patientsList); + return Center( + child: Text( + "$errorCode: Error pulling Patients Data\n/patients/search/$userSearch\n$errorBody", + style: TextStyle( + fontSize: 25, + color: MzanziInnovationHub.of(context)! + .theme + .errorColor()), + textAlign: TextAlign.center, + ), + ); } - return displayUserList(patientsList); - } else { - return Center( - child: Text( - "$errorCode: Error pulling Patients Data\n/patients/search/$userSearch\n$errorBody", - style: TextStyle( - fontSize: 25, - color: - MzanziInnovationHub.of(context)!.theme.errorColor()), - textAlign: TextAlign.center, - ), - ); - } - }, - ), - ]), + }, + ), + ]), + ), ); } } diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_my_business_team.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_my_business_team.dart index 11b86bbf..7f903c92 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_my_business_team.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/app_tools/mih_my_business_team.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:Mzansi_Innovation_Hub/main.dart'; +import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_single_child_scroll.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_body.dart'; import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:Mzansi_Innovation_Hub/mih_env/env.dart'; @@ -80,45 +81,48 @@ class _MihMyBusinessTeamState extends State { } Widget getBody() { - return Column(mainAxisSize: MainAxisSize.max, children: [ - const Text( - "Business Team", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, + return MihSingleChildScroll( + child: Column(mainAxisSize: MainAxisSize.max, children: [ + const Text( + "Business Team", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), ), - ), - Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), - const SizedBox(height: 10), - FutureBuilder( - future: employeeList, - builder: (context, snapshot) { - //print("patient Queue List ${snapshot.hasData}"); - if (snapshot.connectionState == ConnectionState.waiting) { - return const Mihloadingcircle(); - } else if (snapshot.connectionState == ConnectionState.done) { - //List employeeListResults; - // if (searchString == "") { - // patientQueueList = []; - // } else { + Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), + const SizedBox(height: 10), + FutureBuilder( + future: employeeList, + builder: (context, snapshot) { + //print("patient Queue List ${snapshot.hasData}"); + if (snapshot.connectionState == ConnectionState.waiting) { + return const Mihloadingcircle(); + } else if (snapshot.connectionState == ConnectionState.done) { + //List employeeListResults; + // if (searchString == "") { + // patientQueueList = []; + // } else { - // print(patientQueueList); - // } + // print(patientQueueList); + // } - return displayEmployeeList(snapshot.requireData); - } else { - return Center( - child: Text( - "$errorCode: Error pulling Patients Data\n${AppEnviroment.baseApiUrl}/business-user/users/${widget.arguments.businessUser!.business_id}\n$errorBody", - style: TextStyle( - fontSize: 25, - color: MzanziInnovationHub.of(context)!.theme.errorColor()), - textAlign: TextAlign.center, - ), - ); - } - }, - ), - ]); + return displayEmployeeList(snapshot.requireData); + } else { + return Center( + child: Text( + "$errorCode: Error pulling Patients Data\n${AppEnviroment.baseApiUrl}/business-user/users/${widget.arguments.businessUser!.business_id}\n$errorBody", + style: TextStyle( + fontSize: 25, + color: + MzanziInnovationHub.of(context)!.theme.errorColor()), + textAlign: TextAlign.center, + ), + ); + } + }, + ), + ]), + ); } }