diff --git a/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart b/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart index 294f313e..45cbb990 100644 --- a/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart +++ b/Frontend/lib/mih_packages/mih_home/package_tools/mih_business_home.dart @@ -46,7 +46,6 @@ class _MihBusinessHomeState extends State late final AnimationController _marqueeController; late final ScrollController _scrollController; final FocusNode _searchFocusNode = FocusNode(); - final FocusNode _focusNode = FocusNode(); final String maintenanceMsg = "\tHeads up! We're doing maintenance on Thur, 15 May 2025 at 10 PM (CAT). MIH may be unavailable briefly."; @@ -204,108 +203,90 @@ class _MihBusinessHomeState extends State Widget getBody(double width, double height) { return MihSingleChildScroll( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - Navigator.of(context).pushNamed( - '/mzansi-ai', - arguments: MzansiAiArguments( - widget.signedInUser, - searchController.text.isEmpty ? null : searchController.text, - ), - ); - searchController.clear(); - } - }, - child: Column( - children: [ - const SizedBox(height: 10), - Padding( - padding: EdgeInsets.symmetric(horizontal: width / 20), - child: MihSearchBar( - controller: searchController, - hintText: "Ask Mzansi", - prefixIcon: Icons.search, - prefixAltIcon: MihIcons.mzansiAi, - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - hintColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - onPrefixIconTap: () { - Navigator.of(context).pushNamed( - '/mzansi-ai', - arguments: MzansiAiArguments( - widget.signedInUser, - searchController.text.isEmpty - ? null - : searchController.text, - ), - ); - searchController.clear(); - }, - searchFocusNode: _searchFocusNode, - ), + child: Column( + children: [ + const SizedBox(height: 10), + Padding( + padding: EdgeInsets.symmetric(horizontal: width / 20), + child: MihSearchBar( + controller: searchController, + hintText: "Ask Mzansi", + prefixIcon: Icons.search, + prefixAltIcon: MihIcons.mzansiAi, + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + onPrefixIconTap: () { + Navigator.of(context).pushNamed( + '/mzansi-ai', + arguments: MzansiAiArguments( + widget.signedInUser, + searchController.text.isEmpty + ? null + : searchController.text, + ), + ); + searchController.clear(); + }, + searchFocusNode: _searchFocusNode, ), - const SizedBox(height: 10), - ValueListenableBuilder( - valueListenable: searchPackageName, - builder: (context, value, child) { - List filteredPackages = value - .where((package) => package.keys.first - .toLowerCase() - .contains(searchController.text.toLowerCase())) - .map((package) => package.values.first) - .toList(); - if (filteredPackages.isNotEmpty) { - return GridView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: getPadding(width, height), - // shrinkWrap: true, - itemCount: filteredPackages.length, - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: packageSize, - crossAxisSpacing: 5, + ), + const SizedBox(height: 10), + ValueListenableBuilder( + valueListenable: searchPackageName, + builder: (context, value, child) { + List filteredPackages = value + .where((package) => package.keys.first + .toLowerCase() + .contains(searchController.text.toLowerCase())) + .map((package) => package.values.first) + .toList(); + if (filteredPackages.isNotEmpty) { + return GridView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: getPadding(width, height), + // shrinkWrap: true, + itemCount: filteredPackages.length, + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: packageSize, + crossAxisSpacing: 5, + ), + itemBuilder: (context, index) { + return filteredPackages[index]; + }, + ); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + MihIcons.mzansiAi, + size: 165, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), ), - itemBuilder: (context, index) { - return filteredPackages[index]; - }, - ); - } else { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - MihIcons.mzansiAi, - size: 165, + const SizedBox(height: 10), + Text( + "Mzansi AI is here to help you!", + textAlign: TextAlign.center, + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, color: MzanziInnovationHub.of(context)! .theme .secondaryColor(), ), - const SizedBox(height: 10), - Text( - "Mzansi AI is here to help you!", - textAlign: TextAlign.center, - overflow: TextOverflow.visible, - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - ), - ), - ], - ); - } - }, - ), - ], - ), + ), + ], + ); + } + }, + ), + ], ), ); } diff --git a/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart b/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart index 3880abdf..6838837b 100644 --- a/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart +++ b/Frontend/lib/mih_packages/mih_home/package_tools/mih_personal_home.dart @@ -54,7 +54,6 @@ class _MihPersonalHomeState extends State late final AnimationController _marqueeController; late final ScrollController _scrollController; final FocusNode _searchFocusNode = FocusNode(); - final FocusNode _focusNode = FocusNode(); final String maintenanceMsg = "\tHeads up! We're doing maintenance on Thur, 15 May 2025 at 10 PM (CAT). MIH may be unavailable briefly."; @@ -247,109 +246,91 @@ class _MihPersonalHomeState extends State Widget getBody(double width, double height) { return MihSingleChildScroll( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - Navigator.of(context).pushNamed( - '/mzansi-ai', - arguments: MzansiAiArguments( - widget.signedInUser, - searchController.text.isEmpty ? null : searchController.text, - ), - ); - searchController.clear(); - } - }, - child: Column( - children: [ - const SizedBox(height: 10), - Padding( - padding: EdgeInsets.symmetric(horizontal: width / 20), - child: MihSearchBar( - controller: searchController, - hintText: "Ask Mzansi", - prefixIcon: Icons.search, - prefixAltIcon: MihIcons.mzansiAi, - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - hintColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - onPrefixIconTap: () { - Navigator.of(context).pushNamed( - '/mzansi-ai', - arguments: MzansiAiArguments( - widget.signedInUser, - searchController.text.isEmpty - ? null - : searchController.text, - ), - ); - searchController.clear(); - }, - searchFocusNode: _searchFocusNode, - ), + child: Column( + children: [ + const SizedBox(height: 10), + Padding( + padding: EdgeInsets.symmetric(horizontal: width / 20), + child: MihSearchBar( + controller: searchController, + hintText: "Ask Mzansi", + prefixIcon: Icons.search, + prefixAltIcon: MihIcons.mzansiAi, + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + onPrefixIconTap: () { + Navigator.of(context).pushNamed( + '/mzansi-ai', + arguments: MzansiAiArguments( + widget.signedInUser, + searchController.text.isEmpty + ? null + : searchController.text, + ), + ); + searchController.clear(); + }, + searchFocusNode: _searchFocusNode, ), - const SizedBox(height: 10), - ValueListenableBuilder( - valueListenable: searchPackageName, - builder: (context, value, child) { - List filteredPackages = value - .where((package) => package.keys.first - .toLowerCase() - .contains(searchController.text.toLowerCase())) - .map((package) => package.values.first) - .toList(); - if (filteredPackages.isNotEmpty) { - return GridView.builder( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: getPadding(width, height), - // shrinkWrap: true, - itemCount: filteredPackages.length, - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: packageSize, - crossAxisSpacing: 5, + ), + const SizedBox(height: 10), + ValueListenableBuilder( + valueListenable: searchPackageName, + builder: (context, value, child) { + List filteredPackages = value + .where((package) => package.keys.first + .toLowerCase() + .contains(searchController.text.toLowerCase())) + .map((package) => package.values.first) + .toList(); + if (filteredPackages.isNotEmpty) { + return GridView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: getPadding(width, height), + // shrinkWrap: true, + itemCount: filteredPackages.length, + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: packageSize, + crossAxisSpacing: 5, + ), + itemBuilder: (context, index) { + return filteredPackages[index]; + // return personalPackages[index]; + }, + ); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + MihIcons.mzansiAi, + size: 165, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), ), - itemBuilder: (context, index) { - return filteredPackages[index]; - // return personalPackages[index]; - }, - ); - } else { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - MihIcons.mzansiAi, - size: 165, + const SizedBox(height: 10), + Text( + "Mzansi AI is here to help you!", + textAlign: TextAlign.center, + overflow: TextOverflow.visible, + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, color: MzanziInnovationHub.of(context)! .theme .secondaryColor(), ), - const SizedBox(height: 10), - Text( - "Mzansi AI is here to help you!", - textAlign: TextAlign.center, - overflow: TextOverflow.visible, - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - ), - ), - ], - ); - } - }, - ), - ], - ), + ), + ], + ); + } + }, + ), + ], ), ); } diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart index 90522dbd..a7f11b56 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart @@ -24,7 +24,6 @@ class MihBusinessUserSearch extends StatefulWidget { } class _MihBusinessUserSearchState extends State { - final FocusNode _focusNode = FocusNode(); final TextEditingController searchController = TextEditingController(); late Future> userSearchResults; final FocusNode _searchFocusNode = FocusNode(); @@ -101,72 +100,60 @@ class _MihBusinessUserSearchState extends State { Widget getBody(double width) { return MihSingleChildScroll( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - submitUserForm(); - } - }, - child: Column(mainAxisSize: MainAxisSize.max, children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: width / 20), - child: MihSearchBar( - controller: searchController, - hintText: "Search Users", - prefixIcon: Icons.search, - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - onPrefixIconTap: () { - submitUserForm(); - }, - onClearIconTap: () { - setState(() { - searchController.clear(); - userSearch = ""; - }); - submitUserForm(); - }, - searchFocusNode: _searchFocusNode, - ), - ), - 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 { - 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, - ), - ); - } + child: Column(mainAxisSize: MainAxisSize.max, children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: width / 20), + child: MihSearchBar( + controller: searchController, + hintText: "Search Users", + prefixIcon: Icons.search, + fillColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + onPrefixIconTap: () { + submitUserForm(); }, + onClearIconTap: () { + setState(() { + searchController.clear(); + userSearch = ""; + }); + submitUserForm(); + }, + searchFocusNode: _searchFocusNode, ), - ]), - ), + ), + 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 { + 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/patient_profile/pat_manager/package_tools/my_patient_list.dart b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart index 207e7304..324064a1 100644 --- a/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart +++ b/Frontend/lib/mih_packages/patient_profile/pat_manager/package_tools/my_patient_list.dart @@ -42,82 +42,66 @@ class _MyPatientListState extends State { Widget myPatientListTool(double width) { return MihSingleChildScroll( - child: KeyboardListener( - focusNode: _focusNode, - autofocus: true, - onKeyEvent: (event) async { - if (event is KeyDownEvent && - event.logicalKey == LogicalKeyboardKey.enter) { - setState(() { - _myPatientIdSearchString = _myPatientSearchController.text; - _myPatientList = MIHApiCalls.getPatientAccessListOfBusiness( - widget.business!.business_id); - }); - } - }, - child: Column(mainAxisSize: MainAxisSize.max, children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: width / 20), - child: MihSearchBar( - controller: _myPatientSearchController, - hintText: "Search Patient ID", - prefixIcon: Icons.search, - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - onPrefixIconTap: () { - setState(() { - _myPatientIdSearchString = _myPatientSearchController.text; - _myPatientList = MIHApiCalls.getPatientAccessListOfBusiness( - widget.business!.business_id); - }); - }, - onClearIconTap: () { - setState(() { - _myPatientSearchController.clear(); - _myPatientIdSearchString = ""; - }); - getMyPatientList(); - }, - searchFocusNode: _searchFocusNode, - ), - ), - //spacer - const SizedBox(height: 10), - FutureBuilder( - future: _myPatientList, - 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 patientsAccessList; - if (_myPatientIdSearchString == "") { - patientsAccessList = snapshot.data!; - } else { - patientsAccessList = filterAccessResults( - snapshot.data!, _myPatientIdSearchString); - //print(patientsList); - } - return displayMyPatientList(patientsAccessList); - } else { - return Center( - child: Text( - "Error pulling Patient Access Data\n$baseUrl/access-requests/business/patient/${widget.business!.business_id}", - style: TextStyle( - fontSize: 25, - color: MzanziInnovationHub.of(context)! - .theme - .errorColor()), - textAlign: TextAlign.center, - ), - ); - } + child: Column(mainAxisSize: MainAxisSize.max, children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: width / 20), + child: MihSearchBar( + controller: _myPatientSearchController, + hintText: "Search Patient ID", + prefixIcon: Icons.search, + fillColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + hintColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), + onPrefixIconTap: () { + setState(() { + _myPatientIdSearchString = _myPatientSearchController.text; + _myPatientList = MIHApiCalls.getPatientAccessListOfBusiness( + widget.business!.business_id); + }); }, + onClearIconTap: () { + setState(() { + _myPatientSearchController.clear(); + _myPatientIdSearchString = ""; + }); + getMyPatientList(); + }, + searchFocusNode: _searchFocusNode, ), - ]), - ), + ), + //spacer + const SizedBox(height: 10), + FutureBuilder( + future: _myPatientList, + 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 patientsAccessList; + if (_myPatientIdSearchString == "") { + patientsAccessList = snapshot.data!; + } else { + patientsAccessList = filterAccessResults( + snapshot.data!, _myPatientIdSearchString); + //print(patientsList); + } + return displayMyPatientList(patientsAccessList); + } else { + return Center( + child: Text( + "Error pulling Patient Access Data\n$baseUrl/access-requests/business/patient/${widget.business!.business_id}", + style: TextStyle( + fontSize: 25, + color: + MzanziInnovationHub.of(context)!.theme.errorColor()), + textAlign: TextAlign.center, + ), + ); + } + }, + ), + ]), ); }