diff --git a/Frontend/lib/mih_package_components/Example/package_test.dart b/Frontend/lib/mih_package_components/Example/package_test.dart index cd1a500d..a85355ec 100644 --- a/Frontend/lib/mih_package_components/Example/package_test.dart +++ b/Frontend/lib/mih_package_components/Example/package_test.dart @@ -1,4 +1,5 @@ import 'package:go_router/go_router.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/Example/package_tools/package_tool_zero.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart'; @@ -59,16 +60,21 @@ class _PackageTestState extends State { MihPackageTools getTools() { Map temp = Map(); - temp[const Icon(Icons.inbox)] = () { + temp[const Icon(Icons.warning)] = () { setState(() { _selcetedIndex = 0; }); }; - temp[const Icon(Icons.outbond)] = () { + temp[const Icon(Icons.inbox)] = () { setState(() { _selcetedIndex = 1; }); }; + temp[const Icon(Icons.outbond)] = () { + setState(() { + _selcetedIndex = 2; + }); + }; return MihPackageTools( tools: temp, selcetedIndex: _selcetedIndex, @@ -76,13 +82,14 @@ class _PackageTestState extends State { } void showAlert() { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } List getToolBody() { MzansiProfileProvider profileProvider = context.read(); List toolBodies = [ + const PackageToolZero(), PackageToolOne( user: profileProvider.user!, business: profileProvider.business, @@ -94,6 +101,7 @@ class _PackageTestState extends State { List getToolTitle() { List toolTitles = [ + "Tool Zero", "Tool One", "Tool Two", ]; diff --git a/Frontend/lib/mih_package_components/Example/package_tools/package_tool_one.dart b/Frontend/lib/mih_package_components/Example/package_tools/package_tool_one.dart index 662142c8..0bb85e04 100644 --- a/Frontend/lib/mih_package_components/Example/package_tools/package_tool_one.dart +++ b/Frontend/lib/mih_package_components/Example/package_tools/package_tool_one.dart @@ -645,7 +645,7 @@ class _PackageToolOneState extends State { const SnackBar(content: Text("Input Valid")), ); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getSecondaryColor( diff --git a/Frontend/lib/mih_package_components/Example/package_tools/package_tool_zero.dart b/Frontend/lib/mih_package_components/Example/package_tools/package_tool_zero.dart new file mode 100644 index 00000000..2bd84414 --- /dev/null +++ b/Frontend/lib/mih_package_components/Example/package_tools/package_tool_zero.dart @@ -0,0 +1,403 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:mzansi_innovation_hub/main.dart'; +import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; + +class PackageToolZero extends StatefulWidget { + const PackageToolZero({super.key}); + + @override + State createState() => _PackageToolZeroState(); +} + +class _PackageToolZeroState extends State { + @override + Widget build(BuildContext context) { + return MihPackageToolBody( + borderOn: false, + bodyItem: getBody(), + ); + } + + Widget getBody() { + return MihSingleChildScroll( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "This is Package Tool Zero to test MIH Alerts", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + ), + const SizedBox(height: 20), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().successBasicAlert( + "Success!", + "This is the message for the success message", + context, + ); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + child: Text( + "Basic Success Alert", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().successAdvancedAlert( + "Success!", + "This is the advanced alert message", + [ + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Okay", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, + ); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + child: Text( + "Advanced Success Alert", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().warningAlert( + "Warning Alert!", "This is a friendly warning mee", context); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + child: Text( + "Warning Alert", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().errorBasicAlert( + "Error!", + "Thisis the basic error alert message", + context, + ); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Basic Error Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().errorAdvancedAlert( + "Error!", + "This is the advanced alert message", + [ + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Okay", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, + ); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Advanced Error Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().deleteConfirmationAlert( + "THis is a delete confirmation", + () { + context.pop(); + }, + context, + ); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Delete Confirmation Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().internetConnectionAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Internet Connection Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().locationPermissionAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Location Permission Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().inputErrorAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Input Error Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().passwordRequirementAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: FittedBox( + child: Text( + "Password Requirement Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().passwordMatchAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Password Match Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().loginErrorAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Login Error Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().emailExistsAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Email Exists Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + MihButton( + width: 300, + onPressed: () { + MihAlertServices().invalidEmailAlert(context); + }, + buttonColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + child: Text( + "Invalid Email Alert", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 10), + ], + ), + ); + } +} diff --git a/Frontend/lib/mih_package_components/mih_notification_drawer.dart b/Frontend/lib/mih_package_components/mih_notification_drawer.dart index 33f12eca..c11f6b1b 100644 --- a/Frontend/lib/mih_package_components/mih_notification_drawer.dart +++ b/Frontend/lib/mih_package_components/mih_notification_drawer.dart @@ -43,7 +43,7 @@ class _MIHNotificationDrawerState extends State { arguments: widget.signedInUser, ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } diff --git a/Frontend/lib/mih_package_components/mih_package_alert.dart b/Frontend/lib/mih_package_components/mih_package_alert.dart deleted file mode 100644 index a087be0c..00000000 --- a/Frontend/lib/mih_package_components/mih_package_alert.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'package:go_router/go_router.dart'; -import 'package:mzansi_innovation_hub/main.dart'; -import 'package:flutter/material.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; - -class MihPackageAlert extends StatefulWidget { - final Widget alertIcon; - final String alertTitle; - final Widget alertBody; - final Color alertColour; - const MihPackageAlert({ - super.key, - required this.alertIcon, - required this.alertTitle, - required this.alertBody, - required this.alertColour, - }); - - @override - State createState() => _MihPackageAlertState(); -} - -class _MihPackageAlertState extends State { - late double popUpWidth; - late double? popUpheight; - late double popUpTitleSize; - late double popUpSubtitleSize; - late double popUpBodySize; - late double popUpIconSize; - late double popUpPaddingSize; - Size? size; - - void checkScreenSize() { - if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") { - setState(() { - popUpWidth = (size!.width / 4) * 2; - popUpheight = null; - popUpTitleSize = 30.0; - popUpSubtitleSize = 20.0; - popUpBodySize = 15; - popUpPaddingSize = 25.0; - popUpIconSize = 100; - }); - } else { - setState(() { - popUpWidth = size!.width - (size!.width * 0.1); - popUpheight = null; - popUpTitleSize = 25.0; - popUpSubtitleSize = 18.0; - popUpBodySize = 15; - popUpPaddingSize = 15.0; - popUpIconSize = 100; - }); - } - } - - @override - Widget build(BuildContext context) { - size = MediaQuery.of(context).size; - checkScreenSize(); - return Dialog( - child: Stack( - children: [ - Container( - padding: EdgeInsets.all(popUpPaddingSize), - width: popUpWidth, - height: popUpheight, - decoration: BoxDecoration( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - borderRadius: BorderRadius.circular(25.0), - border: Border.all(color: widget.alertColour, width: 5.0), - ), - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - widget.alertIcon, - //const SizedBox(height: 5), - Text( - widget.alertTitle, - textAlign: TextAlign.center, - style: TextStyle( - color: widget.alertColour, - fontSize: popUpTitleSize, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - widget.alertBody, - const SizedBox(height: 10), - ], - ), - ), - ), - Positioned( - top: 5, - right: 5, - width: 50, - height: 50, - child: IconButton( - onPressed: () { - context.pop(); - }, - icon: Icon( - Icons.close, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 35, - ), - ), - ), - ], - ), - ); - } -} diff --git a/Frontend/lib/mih_package_components/mih_package_tile.dart b/Frontend/lib/mih_package_components/mih_package_tile.dart index 1236ea65..dadf0cab 100644 --- a/Frontend/lib/mih_package_components/mih_package_tile.dart +++ b/Frontend/lib/mih_package_components/mih_package_tile.dart @@ -3,11 +3,11 @@ import 'package:flutter/foundation.dart'; import 'package:local_auth/local_auth.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_yt_video_player.dart'; import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; class MihPackageTile extends StatefulWidget { final String appName; @@ -40,6 +40,7 @@ class _MihPackageTileState extends State { void displayHint() { if (widget.ytVideoID != null) { showDialog( + barrierDismissible: false, context: context, builder: (context) { return MihPackageWindow( @@ -89,82 +90,67 @@ class _MihPackageTileState extends State { } void authErrorPopUp() { - Widget alertpopUp = MihPackageAlert( - alertIcon: Icon( - Icons.fingerprint, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, - ), - alertTitle: "Biometric Authentication Required", - alertBody: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Hi there! To jump into the ${widget.appName} Package, you'll need to authenticate yourself with your devices biometrics, please set up biometric authentication (like fingerprint, face ID, pattern or pin) on your device first.\n\nIf you have already set up biometric authentication, press \"Authenticate now\" to try again or press \"Set Up Authentication\" to go to your device settings.", + MihAlertServices().errorAdvancedAlert( + "Biometric Authentication Required", + "Hi there! To jump into the ${widget.appName} Package, you'll need to authenticate yourself with your devices biometrics, please set up biometric authentication (like fingerprint, face ID, pattern or pin) on your device first.\n\nIf you have already set up biometric authentication, press \"Authenticate now\" to try again or press \"Set Up Authentication\" to go to your device settings.", + [ + MihButton( + onPressed: () { + Navigator.of(context).pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Dismiss", style: TextStyle( - fontSize: 15, - color: MihColors.getSecondaryColor( + color: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, ), ), - const SizedBox(height: 20), - Wrap( - runAlignment: WrapAlignment.center, - crossAxisAlignment: WrapCrossAlignment.center, - spacing: 10, - runSpacing: 10, - children: [ - MihButton( - onPressed: () { - AppSettings.openAppSettings( - type: AppSettingsType.security, - ); - Navigator.of(context).pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Set Up Authentication", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - onPressed: () { - Navigator.of(context).pop(); - authenticateUser(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Authenticate Now", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], + ), + MihButton( + onPressed: () { + AppSettings.openAppSettings( + type: AppSettingsType.security, + ); + Navigator.of(context).pop(); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Set Up Authentication", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - showDialog( - context: context, - builder: (context) { - return alertpopUp; - }, + ), + MihButton( + onPressed: () { + Navigator.of(context).pop(); + authenticateUser(); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Authenticate Now", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/access_review/builder/build_access_request_list.dart b/Frontend/lib/mih_packages/access_review/builder/build_access_request_list.dart index d79a27f0..2ca66184 100644 --- a/Frontend/lib/mih_packages/access_review/builder/build_access_request_list.dart +++ b/Frontend/lib/mih_packages/access_review/builder/build_access_request_list.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; @@ -68,78 +67,16 @@ class _BuildPatientsListState extends State { message = "You've declined the access request. ${widget.accessRequests[index].Name} will not have access to your profile."; } - successPopUp(message); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: popUpIconSize, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: popUpTitleSize, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: popUpBodySize, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - Widget displayQueue(int index) { String line1 = "Appointment: ${widget.accessRequests[index].date_time.substring(0, 16).replaceAll("T", " ")}"; @@ -210,7 +147,7 @@ class _BuildPatientsListState extends State { // ), onTap: () { if (access == "CANCELLED") { - MihAlertServices().warningMessage( + MihAlertServices().warningAlert( "Access Cancelled", "This appointment has been canceled. As a result, access has been cancelled and the doctor no longer have access to the patient's profile. If you would like them to view the patient's profile again, please book a new appointment through them.", context, diff --git a/Frontend/lib/mih_packages/access_review/builder/build_business_access_list.dart b/Frontend/lib/mih_packages/access_review/builder/build_business_access_list.dart index ab9f6ee7..f5508113 100644 --- a/Frontend/lib/mih_packages/access_review/builder/build_business_access_list.dart +++ b/Frontend/lib/mih_packages/access_review/builder/build_business_access_list.dart @@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/patient_access.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_access_controlls_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; @@ -350,7 +349,7 @@ class _BuildPatientsListState extends State { successPopUp("Successfully Actioned Request", "You have successfully Declined access request"); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } }, buttonColor: MihColors.getRedColor( @@ -391,7 +390,7 @@ class _BuildPatientsListState extends State { successPopUp("Successfully Actioned Request", "You have successfully Accepted access request"); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -424,60 +423,34 @@ class _BuildPatientsListState extends State { } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - KenLogger.warning("dismissing pop up and refreshing list"); - if (widget.onSuccessUpate != null) { - widget.onSuccessUpate!(); - } - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + KenLogger.warning("dismissing pop up and refreshing list"); + if (widget.onSuccessUpate != null) { + widget.onSuccessUpate!(); + } + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/calculator/package_tools/currency_exchange_rate.dart b/Frontend/lib/mih_packages/calculator/package_tools/currency_exchange_rate.dart index f9f2f380..7c49f855 100644 --- a/Frontend/lib/mih_packages/calculator/package_tools/currency_exchange_rate.dart +++ b/Frontend/lib/mih_packages/calculator/package_tools/currency_exchange_rate.dart @@ -169,6 +169,7 @@ class _CurrencyExchangeRateState extends State { final String companyName = 'Mzansi Innovation Hub'; showDialog( + barrierDismissible: false, context: context, builder: (context) => MihPackageWindow( fullscreen: false, @@ -383,7 +384,7 @@ class _CurrencyExchangeRateState extends State { FocusScope.of(context) .requestFocus(FocusNode()); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/calculator/package_tools/tip_calc.dart b/Frontend/lib/mih_packages/calculator/package_tools/tip_calc.dart index 6582755c..9516f533 100644 --- a/Frontend/lib/mih_packages/calculator/package_tools/tip_calc.dart +++ b/Frontend/lib/mih_packages/calculator/package_tools/tip_calc.dart @@ -392,7 +392,7 @@ class _TipCalcState extends State { if (_formKey.currentState!.validate()) { validateInput(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/calendar/builder/build_access_request_list.dart b/Frontend/lib/mih_packages/calendar/builder/build_access_request_list.dart index 26fc990f..1756bffe 100644 --- a/Frontend/lib/mih_packages/calendar/builder/build_access_request_list.dart +++ b/Frontend/lib/mih_packages/calendar/builder/build_access_request_list.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/access_request.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; @@ -68,78 +67,16 @@ class _BuildPatientsListState extends State { message = "You've declined the access request. ${widget.accessRequests[index].Name} will not have access to your profile."; } - successPopUp(message); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: popUpIconSize, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: popUpTitleSize, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: popUpBodySize, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - Widget displayQueue(int index) { String line1 = "Appointment: ${widget.accessRequests[index].date_time.substring(0, 16).replaceAll("T", " ")}"; @@ -210,7 +147,7 @@ class _BuildPatientsListState extends State { // ), onTap: () { if (access == "CANCELLED") { - MihAlertServices().warningMessage( + MihAlertServices().warningAlert( "Access Cancelled", "This appointment has been canceled. As a result, access has been cancelled and the doctor no longer have access to the patient's profile. If you would like them to view the patient's profile again, please book a new appointment through them.", context, diff --git a/Frontend/lib/mih_packages/calendar/builder/build_appointment_list.dart b/Frontend/lib/mih_packages/calendar/builder/build_appointment_list.dart index cf372aea..04ede238 100644 --- a/Frontend/lib/mih_packages/calendar/builder/build_appointment_list.dart +++ b/Frontend/lib/mih_packages/calendar/builder/build_appointment_list.dart @@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/appointment.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; @@ -523,7 +522,7 @@ class _BuildAppointmentListState extends State { updateAppointmentCall(mzansiProfileProvider, mihCalendarProvider, index); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -569,7 +568,7 @@ class _BuildAppointmentListState extends State { MzansiProfileProvider mzansiProfileProvider, MihCalendarProvider mihCalendarProvider, int index) { - MihAlertServices().deleteConfirmationMessage( + MihAlertServices().deleteConfirmationAlert( "This appointment will be deleted permanently from your calendar. Are you certain you want to delete it?", () { deleteAppointmentCall( @@ -635,10 +634,10 @@ class _BuildAppointmentListState extends State { successPopUp("Successfully Updated Appointment", "You appointment has been successfully updated."); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } @@ -662,65 +661,40 @@ class _BuildAppointmentListState extends State { if (statucCode == 200) { context.pop(); context.pop(); - successPopUp("Successfully Deleted Appointment", - "You appointment has been successfully deleted from your calendar."); + clearControllers(); + // successPopUp("Successfully Deleted Appointment", + // "You appointment has been successfully deleted from your calendar."); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - clearControllers(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + clearControllers(); + Navigator.of(context).pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/calendar/package_tools/appointments.dart b/Frontend/lib/mih_packages/calendar/package_tools/appointments.dart index 35a70b37..3a81d8df 100644 --- a/Frontend/lib/mih_packages/calendar/package_tools/appointments.dart +++ b/Frontend/lib/mih_packages/calendar/package_tools/appointments.dart @@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_calendar.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -212,7 +211,7 @@ class _PatientAccessRequestState extends State { addAppointmentCall( mzansiProfileProvider, mihCalendarProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -301,71 +300,45 @@ class _PatientAccessRequestState extends State { ); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } checkforchange(); } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - setState(() { - _appointmentDateController.clear(); - _appointmentTimeController.clear(); - _appointmentTitleController.clear(); - _appointmentDescriptionIDController.clear(); - }); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + setState(() { + _appointmentDateController.clear(); + _appointmentTimeController.clear(); + _appointmentTitleController.clear(); + _appointmentDescriptionIDController.clear(); + }); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_forgot_password.dart b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_forgot_password.dart index 09e92a68..a19f11f5 100644 --- a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_forgot_password.dart +++ b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_forgot_password.dart @@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; @@ -49,123 +48,69 @@ class _MihForgotPasswordState extends State { } void prePassResteWarning() { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Password Reset Confirmation", - alertBody: Column( - //mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 25.0), - child: Text( - "Before you reset your password, please be aware that you'll receive an email with a link to confirm your identity and set a new password. Make sure to check your inbox, including spam or junk folders. If you don't receive the email within a few minutes, please try resending the reset request.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 25), - MihButton( - onPressed: () { - setState(() { - acceptWarning = true; - }); - Navigator.of(context).pop(); - validateInput(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Continue", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - alertColour: MihColors.getSecondaryColor( + MihAlertServices().successAdvancedAlert( + "Password Reset Confirmation", + "Before you reset your password, please be aware that you'll receive an email with a link to confirm your identity and set a new password. Make sure to check your inbox, including spam or junk folders. If you don't receive the email within a few minutes, please try resending the reset request.", + [ + MihButton( + onPressed: () { + setState(() { + acceptWarning = true; + }); + context.pop(); + validateInput(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + width: 300, + child: Text( + "Continue", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } void resetLinkSentSuccessfully() { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Sent Reset Link", - alertBody: Column( - children: [ - Text( - "We've sent a password reset link to your email address. Please check your inbox, including spam or junk folders.\n\nOnce you find the email, click on the link to reset your password.\n\nIf you don't receive the email within a few minutes, please try resending the reset request.\n\nThe reset link will expire after 2 hours", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: true, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Sent Reset Link", + "We've sent a password reset link to your email address. Please check your inbox, including spam or junk folders.\n\nOnce you find the email, click on the link to reset your password.\n\nIf you don't receive the email within a few minutes, please try resending the reset request.\n\nThe reset link will expire after 2 hours", + [ + MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: true, + ); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } void validateInput() async { if (emailController.text.isEmpty) { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } else { await submitPasswodReset(); if (successfulForgotPassword) { @@ -254,7 +199,7 @@ class _MihForgotPasswordState extends State { if (_formKey.currentState!.validate()) { prePassResteWarning(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_register.dart b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_register.dart index a9e5bb6c..ba9ce004 100644 --- a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_register.dart +++ b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_register.dart @@ -5,7 +5,6 @@ import 'package:flutter/services.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; @@ -77,9 +76,9 @@ class _MihRegisterState extends State { Future signUserUp() async { context.read().reset(); if (!validEmail()) { - MihAlertServices().invalidEmailError(context); + MihAlertServices().invalidEmailAlert(context); } else if (passwordController.text != confirmPasswordController.text) { - MihAlertServices().passwordMatchError(context); + MihAlertServices().passwordMatchAlert(context); } else { //var _backgroundColor = Colors.transparent; showDialog( @@ -99,7 +98,7 @@ class _MihRegisterState extends State { var userExists = jsonDecode(response.body); if (userExists["exists"]) { Navigator.of(context).pop(); - MihAlertServices().emailExistsError(context); + MihAlertServices().emailExistsAlert(context); } else { var response2 = await http.post( Uri.parse("$baseAPI/auth/signup"), @@ -126,10 +125,10 @@ class _MihRegisterState extends State { //print("Here1"); } else if (userCreated["status"] == "FIELD_ERROR") { Navigator.of(context).pop(); - MihAlertServices().passwordRequiredError(context); + MihAlertServices().passwordRequirementAlert(context); } else { Navigator.of(context).pop(); - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } } @@ -155,29 +154,29 @@ class _MihRegisterState extends State { } void loginError(error) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, - ), - alertTitle: "Error While Signing Up", - alertBody: Text( - "An error occurred while signing up. Please try again later.", + MihAlertServices().errorAdvancedAlert( + "Sign Up Error", + "An error occurred while signing up: $error Please try again later.", + [ + MihButton( + onPressed: () { + Navigator.of(context).pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 200, + child: Text( + "Dismiss", style: TextStyle( - color: MihColors.getSecondaryColor( + color: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), fontSize: 18, + fontWeight: FontWeight.bold, ), ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + ), + ], + context, ); } @@ -200,7 +199,7 @@ class _MihRegisterState extends State { if (_formKey.currentState!.validate()) { submitFormInput(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } }, @@ -302,7 +301,7 @@ class _MihRegisterState extends State { if (_formKey.currentState!.validate()) { submitFormInput(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_reset_password.dart b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_reset_password.dart index a87ed353..a96d14f3 100644 --- a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_reset_password.dart +++ b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_reset_password.dart @@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; @@ -32,7 +31,7 @@ class _MihResetPasswordState extends State { void submitFormInput() async { if (passwordController.text != confirmPasswordController.text) { - MihAlertServices().passwordMatchError(context); + MihAlertServices().passwordMatchAlert(context); } else { showDialog( context: context, @@ -46,65 +45,39 @@ class _MihResetPasswordState extends State { if (successfulResetPassword) { resetSuccessfully(); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } } void resetSuccessfully() { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Reset Password", - alertBody: Column( - children: [ - Text( - "Great news! Your password reset is complete. You can now log in to Mzansi Innovation Hub using your new password.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: true, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Reset Password", + "Great news! Your password reset is complete. You can now log in to Mzansi Innovation Hub using your new password.", + [ + MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: true, + ); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -127,7 +100,7 @@ class _MihResetPasswordState extends State { if (_formKey.currentState!.validate()) { submitFormInput(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } }, @@ -212,7 +185,7 @@ class _MihResetPasswordState extends State { if (_formKey.currentState!.validate()) { submitFormInput(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_sign_in.dart b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_sign_in.dart index e48d3369..7de9afe2 100644 --- a/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_sign_in.dart +++ b/Frontend/lib/mih_packages/mih_authentication/package_tools/mih_sign_in.dart @@ -47,12 +47,12 @@ class _MihSignInState extends State { context, ); if (!successfulSignIn) { - MihAlertServices().loginErrorMessage(context); + MihAlertServices().loginErrorAlert(context); passwordController.clear(); } } on Exception { Navigator.of(context).pop(); - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); passwordController.clear(); } } @@ -77,7 +77,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, appName: "Patient", @@ -100,7 +100,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, appName: "Doctor", @@ -124,7 +124,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, appName: "Business", @@ -147,7 +147,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, appName: "Test", @@ -201,7 +201,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } }, @@ -359,7 +359,7 @@ class _MihSignInState extends State { if (_formKey.currentState!.validate()) { submitSignInForm(); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mih_home/mih_home.dart b/Frontend/lib/mih_packages/mih_home/mih_home.dart index a4ce1881..554224f8 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_home.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_home.dart @@ -7,7 +7,6 @@ import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; @@ -129,38 +128,8 @@ class _MihHomeState extends State { children: [ MihPackageWindow( fullscreen: false, - windowTitle: "Privacy Policy & Terms Of Service Alert!", - onWindowTapClose: () { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark", - ), - ), - alertTitle: "Oops, Looks like you missed a step!", - alertBody: Text( - "We're excited for you to keep using the MIH app! Before you do, please take a moment to accept our Privacy Policy and Terms of Service. Thanks for helping us keep your experience great!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark", - ), - fontSize: 15, - fontWeight: FontWeight.normal, - ), - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark", - ), - ); - }); - }, + windowTitle: null, + onWindowTapClose: null, windowBody: Column( children: [ Icon( @@ -190,7 +159,7 @@ class _MihHomeState extends State { color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark", ), - fontSize: 15, + fontSize: 18, fontWeight: FontWeight.normal, ), ), diff --git a/Frontend/lib/mih_packages/mine_sweeper/package_tools/mih_mine_sweeper_leader_board.dart b/Frontend/lib/mih_packages/mine_sweeper/package_tools/mih_mine_sweeper_leader_board.dart index d6e74e12..0293fd0a 100644 --- a/Frontend/lib/mih_packages/mine_sweeper/package_tools/mih_mine_sweeper_leader_board.dart +++ b/Frontend/lib/mih_packages/mine_sweeper/package_tools/mih_mine_sweeper_leader_board.dart @@ -24,7 +24,7 @@ class MihMineSweeperLeaderBoard extends StatefulWidget { class _MihMineSweeperLeaderBoardState extends State { TextEditingController filterController = TextEditingController(); - + bool isLoading = true; Future initialiseLeaderboard() async { MihMineSweeperProvider mineSweeperProvider = context.read(); @@ -39,10 +39,16 @@ class _MihMineSweeperLeaderBoardState extends State { } mineSweeperProvider.setLeaderboardUserPictures( leaderboardUserPictures: userPictures); + setState(() { + isLoading = false; + }); } void refreshLeaderBoard( MihMineSweeperProvider mineSweeperProvider, String difficulty) { + setState(() { + isLoading = true; + }); mineSweeperProvider.setDifficulty(difficulty); mineSweeperProvider.setLeaderboard(leaderboard: null); mineSweeperProvider.setMyScoreboard(myScoreboard: null); @@ -80,7 +86,7 @@ class _MihMineSweeperLeaderBoardState extends State { return Consumer( builder: (BuildContext context, MihMineSweeperProvider mineSweeperProvider, Widget? child) { - if (mineSweeperProvider.leaderboard == null) { + if (isLoading) { return Center( child: Mihloadingcircle(), ); @@ -121,7 +127,7 @@ class _MihMineSweeperLeaderBoardState extends State { ), ), const SizedBox(height: 10), - mineSweeperProvider.leaderboard!.isEmpty + !isLoading && mineSweeperProvider.leaderboard!.isEmpty ? Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: Column( diff --git a/Frontend/lib/mih_packages/mine_sweeper/package_tools/mine_sweeper_game.dart b/Frontend/lib/mih_packages/mine_sweeper/package_tools/mine_sweeper_game.dart index 2d9baab8..e8d04dcc 100644 --- a/Frontend/lib/mih_packages/mine_sweeper/package_tools/mine_sweeper_game.dart +++ b/Frontend/lib/mih_packages/mine_sweeper/package_tools/mine_sweeper_game.dart @@ -9,8 +9,8 @@ import 'package:mzansi_innovation_hub/mih_package_components/mih_banner_ad.dart' import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart'; @@ -130,6 +130,7 @@ class _MineSweeperGameState extends State { // Intermediate - 10 * 15 & 23 bombs // Hard - 10 * 20 & 30 bombs showDialog( + barrierDismissible: false, context: context, builder: (context) { return MihMineSweeperStartGameWindow( @@ -252,99 +253,7 @@ class _MineSweeperGameState extends State { board[r][c].isOpened = true; isGameOver = true; // lose alert - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Padding( - padding: const EdgeInsets.all(8.0), - child: Icon( - FontAwesomeIcons.bomb, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, - ), - ), - alertTitle: "Better Luck Next Time", - alertBody: Column( - children: [ - Text( - "Your lost this game of MIH Minesweeper!!!", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - ), - const SizedBox(height: 10), - Text( - "Please feel free to start a New Game or check out the Leader Board to find out who's the best in Mzansi.", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 18, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - ), - const SizedBox(height: 20), - Wrap( - runAlignment: WrapAlignment.center, - crossAxisAlignment: WrapCrossAlignment.center, - spacing: 10, - runSpacing: 10, - children: [ - MihButton( - onPressed: () { - context.pop(); - showStartGameWindow(mihMineSweeperProvider); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "New Game", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - onPressed: () { - context.pop(); - mihMineSweeperProvider.setToolIndex(1); - }, - buttonColor: MihColors.getOrangeColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "Leader Board", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, - ); + loseAlert(mihMineSweeperProvider); }); return; } @@ -384,111 +293,7 @@ class _MineSweeperGameState extends State { isGameWon = true; isGameOver = true; // win alert - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.celebration, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, - ), - alertTitle: "Congratulations", - alertBody: Column( - children: [ - Text( - "Your won this game of MIH Minesweeper!!!", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox(height: 10), - // Text( - // "You took ${_formatTime()} to complete the game on ${mihMineSweeperProvider.difficulty} mode.", - // style: TextStyle( - // fontSize: 15, - // color: MihColors.getSecondaryColor( - // MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - // ), - // ), - // const SizedBox(height: 10), - Text( - "Time Taken: ${_formatTime().replaceAll("00:", "")}", - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox(height: 10), - Text( - "Score: ${calculateGameScore(mihMineSweeperProvider)}", - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox(height: 20), - Wrap( - runAlignment: WrapAlignment.center, - crossAxisAlignment: WrapCrossAlignment.center, - spacing: 10, - runSpacing: 10, - children: [ - MihButton( - onPressed: () { - context.pop(); - showStartGameWindow(mihMineSweeperProvider); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "New Game", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - onPressed: () { - context.pop(); - mihMineSweeperProvider.setToolIndex(1); - }, - buttonColor: MihColors.getOrangeColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "Leader Board", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, - ); + winAlert(mihMineSweeperProvider); showDialog( context: context, builder: (context) { @@ -530,6 +335,264 @@ class _MineSweeperGameState extends State { } } + void loseAlert(MihMineSweeperProvider mihMineSweeperProvider) { + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: Column( + children: [ + const SizedBox(height: 10), + Icon( + FontAwesomeIcons.bomb, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + size: 125, + ), + const SizedBox(height: 10), + Text( + "Better Luck Next Time", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Center( + child: Text( + "Your lost this game of MIH Minesweeper!!!", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "Please feel free to start a New Game or check out the Leader Board to find out who's the best in Mzansi.", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 18, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + ), + const SizedBox(height: 20), + Wrap( + runAlignment: WrapAlignment.center, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 10, + runSpacing: 10, + children: [ + MihButton( + onPressed: () { + context.pop(); + mihMineSweeperProvider.setToolIndex(1); + }, + buttonColor: MihColors.getGoldColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Leader Board", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "View Board", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + showStartGameWindow(mihMineSweeperProvider); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "New Game", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ], + ), + ); + }, + ); + } + + void winAlert(MihMineSweeperProvider mihMineSweeperProvider) { + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + windowBody: Column( + children: [ + const SizedBox(height: 10), + Icon( + Icons.celebration, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + size: 150, + ), + const SizedBox(height: 10), + Text( + "Congratulations", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Text( + "Your won this game of MIH Minesweeper!!!", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + ), + const SizedBox(height: 10), + Text( + "Time Taken: ${_formatTime().replaceAll("00:", "")}", + style: TextStyle( + fontSize: 20, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + ), + const SizedBox(height: 10), + Text( + "Score: ${calculateGameScore(mihMineSweeperProvider)}", + style: TextStyle( + fontSize: 20, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + ), + const SizedBox(height: 20), + Wrap( + runAlignment: WrapAlignment.center, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 10, + runSpacing: 10, + children: [ + MihButton( + onPressed: () { + mihMineSweeperProvider.setLeaderboard(leaderboard: null); + context.pop(); + mihMineSweeperProvider.setToolIndex(1); + }, + buttonColor: MihColors.getGoldColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Leader Board", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "View Board", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + showStartGameWindow(mihMineSweeperProvider); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "New Game", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ], + ), + ); + }, + ); + } + @override void dispose() { _timer?.cancel(); diff --git a/Frontend/lib/mih_packages/mzansi_ai/package_tools/ai_chat.dart b/Frontend/lib/mih_packages/mzansi_ai/package_tools/ai_chat.dart deleted file mode 100644 index ae91dda3..00000000 --- a/Frontend/lib/mih_packages/mzansi_ai/package_tools/ai_chat.dart +++ /dev/null @@ -1,896 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'package:flutter_speed_dial/flutter_speed_dial.dart'; -import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_providers/mzansi_ai_provider.dart'; -import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; -import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_numeric_stepper.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_radio_options.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_chat_ui/flutter_chat_ui.dart'; -import 'package:flutter_chat_types/flutter_chat_types.dart' as types; -import 'package:flutter/services.dart' show rootBundle; -import 'package:flutter_tts/flutter_tts.dart'; -import 'package:ollama_dart/ollama_dart.dart' as ollama; -import 'package:provider/provider.dart'; -import 'package:uuid/uuid.dart'; - -class AiChat extends StatefulWidget { - const AiChat({ - super.key, - }); - - @override - State createState() => _AiChatState(); -} - -class _AiChatState extends State { - final TextEditingController _modelController = TextEditingController(); - final TextEditingController _fontSizeController = TextEditingController(); - final TextEditingController _ttsVoiceController = TextEditingController(); - final ValueNotifier _showModelOptions = ValueNotifier(false); - FlutterTts _flutterTts = FlutterTts(); - final ValueNotifier _ttsVoiceName = ValueNotifier(""); - // bool _ttsOn = false; - String? textStream; - List _voices = []; - List _voicesString = []; - List _messages = []; - late types.User _user; - late types.User _mihAI; - String systemPromt = "0"; - bool _aiThinking = false; - final client = ollama.OllamaClient( - baseUrl: "${AppEnviroment.baseAiUrl}/api", - ); - List _chatHistory = []; - double _chatFrontSize = 15; - - String getModel() { - return AppEnviroment.getEnv() == "Prod" ? 'gemma3n:e4b' : "gemma3:1b"; - } - - String setSystemPromt() { - String temp = ""; - temp += - "You are Mzansi AI, a helpful and friendly AI assistant running on the 'MIH App'.\n"; - temp += - "The MIH App was created by 'Mzansi Innovation Hub', a South African-based startup company."; - temp += - "Your primary purpose is to assist users by answering general questions and helping with creative writing tasks or any other task a user might have for you.\n"; - temp += - "Maintain a casual and friendly tone, but always remain professional.\n"; - temp += - "Strive for a balance between being empathetic and delivering factual information accurately.\n"; - temp += - "You may use lighthearted or playful language if the context is appropriate and enhances the user experience.\n"; - temp += "You operate within the knowledge domain of the 'MIH App'.\n"; - temp += "Here is a description of the MIH App and its features:\n"; - temp += - "MIH App Description: MIH is the first super app of Mzansi, designed to streamline both personal and business life. It's an all-in-one platform for managing professional profiles, teams, appointments, and quick calculations. \n"; - temp += "Key Features:\n"; - temp += - "- Mzansi Profile: Central hub for managing personal and business information, including business team details."; - temp += "- Mzansi Wallet: Digitally store loyalty cards.\n"; - temp += - "- Patient Manager (For Medical Practices): Seamless patient appointment scheduling and data management.\n"; - temp += - "- Mzansi AI: Your friendly AI assistant for quick answers and support (that's you!).\n"; - temp += - "- Mzansi Directory: A place to search and find out more about the people and businesses across Mzansi.\n"; - temp += - "- Calendar: Integrated calendar for managing personal and business appointments.\n"; - temp += - "- Calculator: Simple calculator with tip and forex calculation functionality.\n"; - temp += "- MIH Access: Manage and view profile access security.\n"; - temp += - "- MIH Minesweeper: The first game from MIH! It's the classic brain-teaser ready to entertain you no matter where you are.\n"; - temp += "**Core Rules and Guidelines:**\n"; - temp += - "- **Accuracy First:** Always prioritize providing correct information.\n"; - temp += - "- **Uncertainty Handling:** If you are unsure about an answer, politely respond with: 'Please bear with us as we are still learning and do not have all the answers.'\n"; - temp += - "- **Response Length:** Aim to keep responses under 250 words. If a more comprehensive answer is required, exceed this limit but offer to elaborate further (e.g., 'Would you like me to elaborate on this topic?').\n"; - temp += - "- **Language & Safety:** Never use offensive language or generate harmful content. If a user presses for information that is inappropriate or out of bounds, clearly state why you cannot provide it (e.g., 'I cannot assist with that request as it goes against my safety guidelines.').\n"; - temp += - "- **Out-of-Scope Questions:** - If a question is unclear, ask the user to rephrase or clarify it. - If a question is entirely out of your scope and you cannot provide a useful answer, admit you don't know. - If a user is unhappy with your response or needs further assistance beyond your capabilities, suggest they visit the 'Mzansi Innovation Hub Social Media Pages' for more direct support. Do not provide specific links, just refer to the pages generally.\n"; - temp += - "- **Target Audience:** Adapt your explanations to beginners and intermediate users, but be prepared for more complex questions from expert users. Ensure your language is clear and easy to understand.\n"; - return temp; - } - - void _addMessage(types.Message message) { - setState(() { - _messages.insert(0, message); - }); - } - - void _loadMessages() async { - final response = await rootBundle.loadString('assets/messages.json'); - final messages = (jsonDecode(response) as List) - .map((e) => types.Message.fromJson(e as Map)) - .toList(); - - setState(() { - _messages = messages; - }); - } - - void _handleSendPressed(types.PartialText message) { - FocusScope.of(context).unfocus(); - final textMessage = types.TextMessage( - author: _user, - createdAt: DateTime.now().millisecondsSinceEpoch, - id: const Uuid().v4(), - text: message.text, - ); - //Add user prompt to history - setState(() { - _chatHistory.add( - ollama.Message( - role: ollama.MessageRole.user, - content: message.text, - ), - ); - }); - - _addMessage(textMessage); - - _handleMessageBack(message.text); - } - - void _handleMessageBack(String userMessage) async { - showDialog( - context: context, - builder: (context) { - return const Mihloadingcircle(); - }, - ); - Stream aiChatStream = - _generateChatCompletionWithHistoryStream(userMessage, client); - - Navigator.of(context).pop(); - showDialog( - context: context, - barrierDismissible: false, - builder: (context) { - return responseWindow(aiChatStream); - }, - ); - } - - Widget responseWindow( - Stream aiChatStream, - ) { - return StreamBuilder( - stream: aiChatStream, - builder: (context, snapshot) { - if (snapshot.hasData) { - textStream = snapshot.requireData; - // print("Text: $textStream"); - // _speakText(textStream!); - return MihPackageWindow( - fullscreen: false, - windowTitle: 'Mzansi AI Thoughts', - menuOptions: _aiThinking == true - ? null - : [ - SpeedDialChild( - child: Icon( - Icons.volume_up, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - label: "Read Aloud", - labelBackgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - labelStyle: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontWeight: FontWeight.bold, - ), - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - onTap: () { - _speakText(snapshot.requireData); - }, - ) - ], - onWindowTapClose: () { - _captureAIResponse(snapshot.requireData); - _flutterTts.stop(); - Navigator.of(context).pop(); - }, - windowBody: SizedBox( - width: double.infinity, - // color: Colors.black, - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - // SelectionArea( - // child: GptMarkdown( - // snapshot.requireData, - // textAlign: TextAlign.left, - // style: TextStyle( - // color: MihColors.getSecondaryColor( - // MzansiInnovationHub.of(context)!.theme.mode == - // "Dark"), - // fontSize: _chatFrontSize, - // fontWeight: FontWeight.bold, - // ), - // ), - // ), - SelectionArea( - child: Text( - snapshot.requireData, - textAlign: TextAlign.left, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: _chatFrontSize, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - ); - } else { - return MihPackageWindow( - fullscreen: false, - windowTitle: 'Mzansi AI Thoughts', - // windowTools: [], - onWindowTapClose: () { - Navigator.of(context).pop(); - }, - windowBody: Mihloadingcircle(), - ); - } - }, - ); - } - - void _captureAIResponse(String responseMessage) { - types.TextMessage textMessage; - setState(() { - _chatHistory.add( - ollama.Message( - role: ollama.MessageRole.assistant, - content: responseMessage, - ), - ); - }); - textMessage = types.TextMessage( - author: _mihAI, - createdAt: DateTime.now().millisecondsSinceEpoch, - id: const Uuid().v4(), - - text: responseMessage - .replaceAll("\n\n", "**Thinking:**\n") - .replaceAll("\n", "**Thinking:**\n") - .replaceAll("\n\n", "\n**Answer:**\n"), //message.text, - ); - - _addMessage(textMessage); - } - - Stream _generateChatCompletionWithHistoryStream( - String userMessage, - final ollama.OllamaClient client, - ) async* { - final aiStream = client.generateChatCompletionStream( - request: ollama.GenerateChatCompletionRequest( - model: _modelController.text, - messages: _chatHistory, - ), - ); - String text = ''; - setState(() { - _aiThinking = true; - }); - await for (final res in aiStream) { - text += (res.message.content); - yield text; - } - setState(() { - _aiThinking = false; - }); - } - - void _resetChat() { - setState(() { - _messages = []; - _chatHistory = []; - _loadMessages(); - }); - } - - ChatTheme getChatTheme() { - return DarkChatTheme( - backgroundColor: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - inputBackgroundColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - inputTextColor: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - inputTextCursorColor: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - primaryColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - secondaryColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - errorColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - sentMessageBodyTextStyle: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: _chatFrontSize, - fontWeight: FontWeight.w500, - fontFamily: 'Segoe UI', - ), - receivedMessageBodyTextStyle: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: _chatFrontSize, - fontWeight: FontWeight.w500, - fontFamily: 'Segoe UI', - ), - emptyChatPlaceholderTextStyle: TextStyle( - color: MihColors.getGreyColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: _chatFrontSize, - fontWeight: FontWeight.w500, - fontFamily: 'Segoe UI', - ), - ); - } - - Widget _getSettings() { - return ValueListenableBuilder( - valueListenable: _showModelOptions, - builder: (BuildContext context, bool value, Widget? child) { - return Visibility( - visible: value, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Align( - alignment: Alignment.centerLeft, - child: FittedBox( - child: Container( - padding: const EdgeInsets.all(10.0), - decoration: BoxDecoration( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - borderRadius: BorderRadius.circular(25.0), - border: Border.all( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 3.0), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Settings", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - ), - ], - ), - const SizedBox(height: 15), - Row( - children: [ - SizedBox( - width: 300, - child: MihRadioOptions( - controller: _modelController, - hintText: "AI Model", - fillColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - secondaryFillColor: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - requiredText: true, - radioOptions: [getModel()], - ), - ), - ], - ), - const SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - SizedBox( - width: 230, - child: MihDropdownField( - controller: _ttsVoiceController, - hintText: "AI Voice", - dropdownOptions: _voicesString, - editable: true, - enableSearch: true, - requiredText: true, - validator: (value) { - return MihValidationServices().isEmpty(value); - }, - ), - ), - const SizedBox(width: 10), - Container( - // color: Colors.white, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 25), // Optional: rounds the corners - boxShadow: const [ - BoxShadow( - color: Color.fromARGB(60, 0, 0, - 0), // 0.2 opacity = 51 in alpha (255 * 0.2) - spreadRadius: -2, - blurRadius: 10, - offset: Offset(0, 5), - ), - ], - ), - child: Padding( - padding: const EdgeInsets.only( - top: 2.0, - left: 5.0, - ), - child: SizedBox( - width: 50, - height: 50, - child: IconButton.filled( - style: ButtonStyle( - backgroundColor: - WidgetStateProperty.all( - MihColors.getGreenColor( - MzansiInnovationHub.of(context)! - .theme - .mode == - "Dark")), - ), - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)! - .theme - .mode == - "Dark"), - iconSize: 25, - onPressed: () { - print("Start TTS now"); - _speakText( - "This is the sample of the Mzansi A.I Voice."); - }, - icon: const Icon( - Icons.volume_up, - ), - ), - ), - ), - ), - ], - ), - const SizedBox(height: 10), - Row( - children: [ - SizedBox( - width: 300, - child: MihNumericStepper( - controller: _fontSizeController, - fillColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - inputColor: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - hintText: "Font Size", - requiredText: true, - minValue: 1, - // maxValue: 5, - validationOn: true, - ), - ), - ], - ), - const SizedBox(height: 15), - ], - ), - ), - ), - ), - ), - ); - }, - ); - } - - static void loadingPopUp(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return const Mihloadingcircle(); - }, - ); - } - - void _speakText(String text) async { - try { - loadingPopUp(context); - await _flutterTts.stop(); // Stop any ongoing speech - await _flutterTts.speak(text).then((value) { - Navigator.of(context).pop(); - }); // Speak the new text - } catch (e) { - Navigator.of(context).pop(); - print("TTS Error: $e"); - } - } - - void setTtsVoice(String voiceName) { - _flutterTts.setVoice( - { - "name": voiceName, - "locale": _voices - .where((_voice) => _voice["name"].contains(voiceName)) - .first["locale"] - }, - ); - _ttsVoiceController.text = voiceName; - } - - void voiceSelected() { - if (_ttsVoiceController.text.isNotEmpty) { - _ttsVoiceName.value = _ttsVoiceController.text; - // print( - // "======================================== Voice Set ========================================"); - setTtsVoice(_ttsVoiceController.text); - } else { - _ttsVoiceName.value = ""; - } - } - - void fontSizeChanged() { - setState(() { - _chatFrontSize = double.parse(_fontSizeController.text); - }); - } - - @override - void dispose() { - super.dispose(); - _modelController.dispose(); - _fontSizeController.dispose(); - _ttsVoiceController.dispose(); - _ttsVoiceController.removeListener(voiceSelected); - _fontSizeController.removeListener(fontSizeChanged); - client.endSession(); - _flutterTts.stop(); - } - - void initTTS() { - _flutterTts.setVolume(1); - _fontSizeController.addListener(fontSizeChanged); - // _flutterTts.setSpeechRate(0.6); - // _flutterTts.setPitch(1.0); - _flutterTts.getVoices.then( - (data) { - try { - _voices = List.from(data); - - setState(() { - _voices = _voices - .where( - (_voice) => _voice["name"].toLowerCase().contains("en-us")) - .toList(); - _voicesString = - _voices.map((_voice) => _voice["name"] as String).toList(); - _voicesString.sort(); - setTtsVoice(_voicesString.first); - }); - } catch (e) { - print(e); - } - }, - ); - } - - @override - void initState() { - super.initState(); - MzansiAiProvider mzansiAiProvider = context.read(); - MzansiProfileProvider mzansiProfileProvider = - context.read(); - _user = types.User( - firstName: mzansiProfileProvider.user!.fname, - id: mzansiProfileProvider - .user!.app_id, //'82091008-a484-4a89-ae75-a22bf8d6f3ac', - ); - _mihAI = types.User( - firstName: "Mzansi AI", - id: const Uuid().v4(), - ); - _modelController.text = getModel(); - _fontSizeController.text = _chatFrontSize.ceil().toString(); - systemPromt = setSystemPromt(); - _chatHistory.add( - ollama.Message( - role: ollama.MessageRole.system, - content: systemPromt, - ), - ); - initTTS(); - _ttsVoiceController.addListener(voiceSelected); - if (mzansiAiProvider.startUpQuestion != null && - mzansiAiProvider.startUpQuestion!.isNotEmpty) { - final partialText = - types.PartialText(text: mzansiAiProvider.startUpQuestion!); - WidgetsBinding.instance.addPostFrameCallback((_) { - _handleSendPressed(partialText); - }); - } - } - - @override - Widget build(BuildContext context) { - return MihPackageToolBody( - borderOn: false, - bodyItem: getBody(), - ); - } - - Widget getBody() { - return Stack( - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - children: [ - _getSettings(), - Expanded( - child: GestureDetector( - onTap: () { - if (_showModelOptions.value == true) { - setState(() { - _showModelOptions.value = false; - }); - } - }, - child: Chat( - messages: _messages, - emptyState: noMessagescDisplay(), - // onAttachmentPressed: _handleAttachmentPressed, - // onMessageTap: _handleMessageTap, - // onPreviewDataFetched: _handlePreviewDataFetched, - onSendPressed: _handleSendPressed, - showUserAvatars: false, - showUserNames: false, - user: _user, - theme: getChatTheme(), - ), - ), - ) - ], - ), - Positioned( - left: 15, - top: 15, - child: Visibility( - visible: _showModelOptions.value == true, - child: Container( - // color: Colors.white, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(25), // Optional: rounds the corners - boxShadow: const [ - BoxShadow( - color: Color.fromARGB( - 60, 0, 0, 0), // 0.2 opacity = 51 in alpha (255 * 0.2) - spreadRadius: -2, - blurRadius: 10, - offset: Offset(0, 5), - ), - ], - ), - child: Padding( - padding: const EdgeInsets.only( - top: 2.0, - left: 5.0, - ), - child: SizedBox( - width: 40, - child: IconButton.filled( - style: ButtonStyle( - backgroundColor: WidgetStateProperty.all( - MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark")), - ), - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - iconSize: 20, - onPressed: () { - if (_showModelOptions.value == true) { - setState(() { - _showModelOptions.value = false; - }); - } else { - setState(() { - _showModelOptions.value = true; - }); - } - }, - icon: const Icon( - Icons.close, - ), - ), - ), - ), - ), - // IconButton.filled( - // iconSize: 20, - // onPressed: () { - // if (_showModelOptions.value == true) { - // setState(() { - // _showModelOptions.value = false; - // }); - // } else { - // setState(() { - // _showModelOptions.value = true; - // }); - // } - // }, - // icon: const Icon( - // Icons.settings, - // ), - // ), - ), - ), - Positioned( - right: 10, - bottom: 80, - child: MihFloatingMenu( - animatedIcon: AnimatedIcons.menu_close, - children: [ - SpeedDialChild( - child: Icon( - Icons.refresh, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - label: "New Chat", - labelBackgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - labelStyle: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontWeight: FontWeight.bold, - ), - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - onTap: () { - _resetChat(); - }, - ), - SpeedDialChild( - child: Icon( - Icons.settings, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - label: "Settings", - labelBackgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - labelStyle: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontWeight: FontWeight.bold, - ), - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - onTap: () { - if (_showModelOptions.value == true) { - setState(() { - _showModelOptions.value = false; - }); - } else { - setState(() { - _showModelOptions.value = true; - }); - } - }, - ), - ], - ), - ), - ], - ); - } - - Widget? noMessagescDisplay() { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // const SizedBox(height: 50), - Icon( - MihIcons.mzansiAi, - size: 165, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - const SizedBox(height: 10), - Text( - "Mzansi AI is here to help", - textAlign: TextAlign.center, - overflow: TextOverflow.visible, - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox(height: 25), - Center( - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.normal, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - children: [ - TextSpan( - text: - "Send us a message and we'll try our best to assist you"), - // WidgetSpan( - // alignment: PlaceholderAlignment.middle, - // child: Icon( - // Icons.menu, - // size: 20, - // color: MzansiInnovationHub.of(context)! - // .theme - // .secondaryColor(), - // ), - // ), - // TextSpan(text: " to add your first loyalty card."), - ], - ), - ), - ), - ], - ), - ); - } -} diff --git a/Frontend/lib/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart b/Frontend/lib/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart index e43b6d8b..b4cd3caa 100644 --- a/Frontend/lib/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart +++ b/Frontend/lib/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart @@ -240,7 +240,7 @@ class _MihSearchMzansiState extends State { searchPressed( profileProvider, directoryProvider); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Business Type Not Selected", "Please ensure you have selected a Business Type before seareching for Businesses of Mzansi", context, diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart index 37d752c2..e7173d62 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart @@ -3,11 +3,13 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; +import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart'; import 'package:provider/provider.dart'; @@ -25,6 +27,26 @@ class MihAddBookmarkAlert extends StatefulWidget { } class _MihAddBookmarkAlertState extends State { + Future getFavouriteBusinesses() async { + MzansiDirectoryProvider directoryProvider = + context.read(); + MzansiProfileProvider profileProvider = + context.read(); + await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness( + profileProvider.user!.app_id, + directoryProvider, + ); + List favBus = []; + for (var bus in directoryProvider.bookmarkedBusinesses) { + await MihBusinessDetailsServices() + .getBusinessDetailsByBusinessId(bus.business_id) + .then((business) { + favBus.add(business!); + }); + } + directoryProvider.setFavouriteBusinesses(businesses: favBus); + } + Future addBookmark( MzansiProfileProvider profileProvider, String business_id) async { showDialog( @@ -43,7 +65,7 @@ class _MihAddBookmarkAlertState extends State { "${widget.business.Name} has successfully been added to favourite businessess in the Mzansi Directory.", ); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Error Adding Bookmark", "An error occured while add ${widget.business.Name} to you Mzansi Directory, Please try again later.", context, @@ -53,58 +75,33 @@ class _MihAddBookmarkAlertState extends State { } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - widget.onSuccessDismissPressed!.call(); - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () async { + await getFavouriteBusinesses(); + widget.onSuccessDismissPressed!.call(); + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -113,24 +110,35 @@ class _MihAddBookmarkAlertState extends State { return Consumer( builder: (BuildContext context, MzansiProfileProvider profileProvider, Widget? child) { - return MihPackageAlert( - alertColour: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Bookmark Business", - alertBody: Column( + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + windowBody: Column( children: [ + Icon( + Icons.warning_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + "Bookmark Business", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), Text( "Are you sure you want to save ${widget.business.Name} to your Mzansi Directory?", style: TextStyle( color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, + fontSize: 18, ), ), const SizedBox(height: 25), diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_employee_window.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_employee_window.dart index ea2b8dfe..b0f7e02d 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_employee_window.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_add_employee_window.dart @@ -5,7 +5,6 @@ import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -45,62 +44,36 @@ class _MihAddEmployeeWindowState extends State { "${widget.user.username} is now apart of your team with ${accessController.text} access to ${mzansiProfileProvider.business!.Name}"; successPopUp(message, false); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void successPopUp(String message, bool stayOnPersonalSide) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Added Employee", + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ) + ], + context, ); } @@ -193,10 +166,10 @@ class _MihAddEmployeeWindowState extends State { if (isRequiredFieldsCaptured()) { createBusinessUserAPICall(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart index a2e719f9..fa5b1440 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart @@ -6,12 +6,14 @@ import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_objects/business_review.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart'; +import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart'; import 'package:provider/provider.dart'; @@ -58,34 +60,11 @@ class _MihBusinessCardState extends State { if (await canLaunchUrl(url)) { await launchUrl(url); } else { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Making Call", - alertBody: Column( - children: [ - Text( - "We couldn't open your phone app to call ${widget.business.contact_no}. To fix this, make sure you have a phone application installed and it's set as your default dialer.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Making Call", + "We couldn't open your phone app to call $formattedNumber. To fix this, make sure you have a phone application installed and it's set as your default dialer.", + context, + ); } } @@ -110,34 +89,11 @@ class _MihBusinessCardState extends State { if (await canLaunchUrl(emailLaunchUri)) { await launchUrl(emailLaunchUri); } else { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Creating Email", - alertBody: Column( - children: [ - Text( - "We couldn't launch your email app to send a message to ${widget.business.bus_email}. To fix this, please confirm that you have an email application installed and that it's set as your default.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Creating Email", + "We couldn't launch your email app to send a message to $recipient. To fix this, please confirm that you have an email application installed and that it's set as your default.", + context, + ); } } @@ -153,64 +109,18 @@ class _MihBusinessCardState extends State { if (await canLaunchUrl(googleMapsUrl)) { await launchUrl(googleMapsUrl); } else { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Creating Maps", - alertBody: Column( - children: [ - Text( - "There was an issue opening maps for ${widget.business.Name}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Opening Maps", + "There was an issue opening maps for ${widget.business.Name}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.", + context, + ); } } catch (e) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Creating Maps", - alertBody: Column( - children: [ - Text( - "There was an issue opening maps for ${widget.business.Name}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Opening Maps", + "There was an issue opening maps for ${widget.business.Name}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.", + context, + ); } } @@ -224,65 +134,18 @@ class _MihBusinessCardState extends State { if (await canLaunchUrl(url)) { await launchUrl(url); } else { - print('Could not launch $urlString'); - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Opening Website", - alertBody: Column( - children: [ - Text( - "We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Opening Website", + "We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.", + context, + ); } } catch (e) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Opening Website", - alertBody: Column( - children: [ - Text( - "We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }); + MihAlertServices().errorBasicAlert( + "Error Opening Website", + "We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.", + context, + ); } } @@ -410,9 +273,9 @@ class _MihBusinessCardState extends State { @override Widget build(BuildContext context) { // double screenWidth = MediaQuery.of(context).size.width; - return Consumer( - builder: (BuildContext context, MzansiDirectoryProvider directoryProvider, - Widget? child) { + return Consumer2( + builder: (BuildContext context, MzansiProfileProvider profileProvider, + MzansiDirectoryProvider directoryProvider, Widget? child) { return Material( color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark") @@ -698,6 +561,7 @@ class _MihBusinessCardState extends State { double width) async { if (_isUserSignedIn) { showDialog( + barrierDismissible: false, context: context, builder: (context) => MihReviewBusinessWindow( business: widget.business, @@ -725,13 +589,12 @@ class _MihBusinessCardState extends State { void showAddBookmarkAlert() { if (_isUserSignedIn) { showDialog( + barrierDismissible: false, context: context, builder: (context) => MihAddBookmarkAlert( business: widget.business, - onSuccessDismissPressed: () { - setState(() { - _bookmarkedBusinessFuture = getUserBookmark(); - }); + onSuccessDismissPressed: () async { + _bookmarkedBusinessFuture = getUserBookmark(); }, ), ); @@ -743,14 +606,13 @@ class _MihBusinessCardState extends State { void showDeleteBookmarkAlert(BookmarkedBusiness? bookmarkBusiness) { if (_isUserSignedIn) { showDialog( + barrierDismissible: false, context: context, builder: (context) => MihDeleteBookmarkAlert( business: widget.business, bookmarkBusiness: bookmarkBusiness, onSuccessDismissPressed: () { - setState(() { - _bookmarkedBusinessFuture = getUserBookmark(); - }); + _bookmarkedBusinessFuture = getUserBookmark(); }, // startUpSearch: widget.startUpSearch, )); @@ -761,59 +623,72 @@ class _MihBusinessCardState extends State { void showSignInRequiredAlert() { showDialog( + barrierDismissible: false, context: context, - builder: (context) => MihPackageAlert( - alertIcon: Column( - children: [ - Icon( - MihIcons.mihLogo, - size: 125, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - const SizedBox(height: 10), - ], - ), - alertTitle: "Let's Get Started", - alertBody: Column( - children: [ - Text( - "Ready to dive in to the world of MIH?\nSign in or create a free MIH account to unlock all the powerful features of the MIH app. It's quick and easy!", - style: TextStyle( + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: () { + context.pop(); + }, + windowBody: Column( + children: [ + Icon( + MihIcons.mihLogo, + size: 125, color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: true, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Sign In/ Create Account", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, + const SizedBox(height: 10), + Text( + "Let's Get Started", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Text( + "Ready to dive in to the world of MIH?\nSign in or create a free MIH account to unlock all the powerful features of the MIH app. It's quick and easy!", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 15, + ), + ), + const SizedBox(height: 25), + Center( + child: MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: true, + ); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + elevation: 10, + width: 300, + child: Text( + "Sign In/ Create Account", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), ), ), - ) - ], - ), - alertColour: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), + ], + ), + ); + }, ); } } diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart index 730e1a01..df496d72 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart @@ -4,11 +4,15 @@ import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/bookmarked_business.dart'; import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; +import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart'; +import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart'; +import 'package:provider/provider.dart'; class MihDeleteBookmarkAlert extends StatefulWidget { final Business business; @@ -28,6 +32,26 @@ class MihDeleteBookmarkAlert extends StatefulWidget { } class _MihDeleteBookmarkAlertState extends State { + Future getFavouriteBusinesses() async { + MzansiDirectoryProvider directoryProvider = + context.read(); + MzansiProfileProvider profileProvider = + context.read(); + await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness( + profileProvider.user!.app_id, + directoryProvider, + ); + List favBus = []; + for (var bus in directoryProvider.bookmarkedBusinesses) { + await MihBusinessDetailsServices() + .getBusinessDetailsByBusinessId(bus.business_id) + .then((business) { + favBus.add(business!); + }); + } + directoryProvider.setFavouriteBusinesses(businesses: favBus); + } + Future deleteBookmark(int idbookmarked_businesses) async { showDialog( context: context, @@ -45,7 +69,7 @@ class _MihDeleteBookmarkAlertState extends State { "${widget.business.Name} has successfully been removed your favourite businessess in the Mzansi Directory.", ); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Error Adding Bookmark", "An error occured while add ${widget.business.Name} to you Mzansi Directory, Please try again later.", context, @@ -55,89 +79,67 @@ class _MihDeleteBookmarkAlertState extends State { } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - // context.goNamed( - // "mzansiDirectory", - // extra: MzansiDirectoryArguments( - // personalSearch: false, - // startSearchText: widget.business.Name, - // packageIndex: 1, - // ), - // ); - widget.onSuccessDismissPressed!.call(); - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () async { + await getFavouriteBusinesses(); + widget.onSuccessDismissPressed!.call(); + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ) + ], + context, ); } @override Widget build(BuildContext context) { - return MihPackageAlert( - alertColour: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Remove Bookmark", - alertBody: Column( + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + windowBody: Column( children: [ + Icon( + Icons.warning_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + "Remove Bookmark", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), Text( "Are you sure you want to remove ${widget.business.Name} from your Mzansi Directory?", style: TextStyle( color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, + fontSize: 18, ), ), const SizedBox(height: 25), diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_edit_employee_details_window.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_edit_employee_details_window.dart index 129bbfc8..fe454a62 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_edit_employee_details_window.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_edit_employee_details_window.dart @@ -6,7 +6,6 @@ import 'package:mzansi_innovation_hub/mih_objects/business_employee.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -48,7 +47,7 @@ class _MihEditEmployeeDetailsWindowState String message = "Your employees details have been updated."; successPopUp(message, false); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -61,14 +60,15 @@ class _MihEditEmployeeDetailsWindowState if (statusCode == 200) { String message = "The employee has been deleted successfully. This means they will no longer have access to your business profile"; + context.pop(); successPopUp(message, false); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void showDeleteWarning() { - MihAlertServices().deleteConfirmationMessage( + MihAlertServices().deleteConfirmationAlert( "This team member will be deleted permanently from the business profile. Are you certain you want to delete it?", () { deleteEmployeeApiCall(); @@ -78,57 +78,31 @@ class _MihEditEmployeeDetailsWindowState } void successPopUp(String message, bool stayOnPersonalSide) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Updated Employee Details", + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -263,10 +237,10 @@ class _MihEditEmployeeDetailsWindowState if (isRequiredFieldsCaptured()) { updateEmployeeAPICall(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart index d5be0f06..539c4f52 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart @@ -7,7 +7,6 @@ import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_objects/business_review.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; @@ -53,104 +52,75 @@ class _MihReviewBusinessWindowState extends State { final ValueNotifier _counter = ValueNotifier(0); void showDeleteReviewAlert(MzansiDirectoryProvider directoryProvider) { - showDialog( - context: context, - builder: (context) => MihPackageAlert( - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - alertIcon: Icon( - Icons.warning_rounded, - size: 100, - color: MihColors.getRedColor( + MihAlertServices().errorAdvancedAlert( + "Delete Review", + "Are you sure you want to delete this review? This action cannot be undone.", + [ + MihButton( + width: 300, + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return const Mihloadingcircle(); + }, + ); + await MihMzansiDirectoryServices() + .deleteBusinessReview( + widget.businessReview!.idbusiness_ratings, + widget.businessReview!.business_id, + widget.businessReview!.rating_score, + widget.business.rating, + ) + .then((statusCode) async { + context.pop(); //Remove loading dialog + context.pop(); //Remove delete dialog + if (statusCode == 200) { + await refreshBusiness(directoryProvider); + successPopUp( + "Successfully Deleted Review!", + "Your review has successfully been delete and will no longer appear under the business.", + ); + } else { + MihAlertServices().errorBasicAlert( + "Error Deleting Review", + "There was an error deleting your review. Please try again later.", + context, + ); + } + }); + }, + buttonColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Delete Review", - alertBody: Column( - children: [ - Text( - "Are you sure you want to delete this review? This action cannot be undone.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - ), + child: Text( + "Delete", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, ), - const SizedBox(height: 25), - Wrap( - spacing: 10, - runSpacing: 10, - children: [ - MihButton( - width: 300, - onPressed: () async { - showDialog( - context: context, - builder: (context) { - return const Mihloadingcircle(); - }, - ); - await MihMzansiDirectoryServices() - .deleteBusinessReview( - widget.businessReview!.idbusiness_ratings, - widget.businessReview!.business_id, - widget.businessReview!.rating_score, - widget.business.rating, - ) - .then((statusCode) async { - context.pop(); //Remove loading dialog - context.pop(); //Remove delete dialog - if (statusCode == 200) { - await refreshBusiness(directoryProvider); - context.pop(); //Remove window - successPopUp( - "Successfully Deleted Review!", - "Your review has successfully been delete and will no longer appear under the business.", - ); - } else { - MihAlertServices().errorAlert( - "Error Deleting Review", - "There was an error deleting your review. Please try again later.", - context, - ); - } - }); - }, - buttonColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - child: Text( - "Delete", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - width: 300, - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - child: Text( - "Cancel", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ], + ), ), - ), + MihButton( + width: 300, + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + child: Text( + "Cancel", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -198,13 +168,12 @@ class _MihReviewBusinessWindowState extends State { context.pop(); //Remove loading dialog if (statusCode == 200) { await refreshBusiness(directoryProvider); - context.pop(); successPopUp( "Successfully Updated Review!", "Your review has successfully been updated and will now appear under the business.", ); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Error Updating Review", "There was an error updating your review. Please try again later.", context, @@ -225,13 +194,12 @@ class _MihReviewBusinessWindowState extends State { context.pop(); //Remove loading dialog if (statusCode == 201) { await refreshBusiness(directoryProvider); - context.pop(); successPopUp( "Successfully Added Review!", "Your review has successfully been added and will now appear under the business.", ); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Error Adding Review", "There was an error adding your review. Please try again later.", context, @@ -242,64 +210,32 @@ class _MihReviewBusinessWindowState extends State { } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - // context.goNamed( - // "mzansiDirectory", - // extra: MzansiDirectoryArguments( - // personalSearch: false, - // startSearchText: widget.business.Name, - // ), - // ); - widget.onSuccessDismissPressed!.call(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + widget.onSuccessDismissPressed!.call(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -577,7 +513,7 @@ class _MihReviewBusinessWindowState extends State { directoryProvider, ); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_update_business_details_window.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_update_business_details_window.dart index cae226a2..67b1c937 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_update_business_details_window.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/components/mih_update_business_details_window.dart @@ -7,7 +7,6 @@ import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; @@ -134,56 +133,10 @@ class _MihUpdateBusinessDetailsWindowState } void successPopUp(String message, bool stayOnPersonalSide) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().successBasicAlert( + "Success!", + message, + context, ); } @@ -263,41 +216,19 @@ class _MihUpdateBusinessDetailsWindowState } else { context.pop(); // File upload failed - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Updating Business Details", - alertBody: Column( - children: [ - Text( - "An error occurred while updating the business details. Please check internet connection and try again.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().errorBasicAlert( + "Error Updating Business Details", + "An error occurred while updating the business details. Please try again.", + context, ); } } else { context.pop(); if (!mounted) return; - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } @@ -656,7 +587,7 @@ class _MihUpdateBusinessDetailsWindowState if (_formKey.currentState!.validate()) { submitForm(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart index 2ec28813..09586742 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart @@ -27,6 +27,7 @@ class _MihBusinessDetailsState extends State { void editBizProfileWindow( MzansiProfileProvider mzansiProfileProvider, double width) { showDialog( + barrierDismissible: false, context: context, builder: (context) => MihUpdateBusinessDetailsWindow(width: width), ); diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_set_up.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_set_up.dart index b49abaab..a02ef2e7 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_set_up.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_set_up.dart @@ -9,7 +9,6 @@ import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; @@ -64,7 +63,7 @@ class _MihBusinessDetailsSetUpState extends State { if (isFieldsFilled()) { createBusinessProfileAPICall(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } @@ -97,7 +96,7 @@ class _MihBusinessDetailsSetUpState extends State { } await createBusinessUserAPICall(mzansiProfileProvider); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -123,10 +122,10 @@ class _MihBusinessDetailsSetUpState extends State { "Your business profile is now live! You can now start connecting with customers and growing your business."; successPopUp(message, false); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -192,59 +191,33 @@ class _MihBusinessDetailsSetUpState extends State { } void successPopUp(String message, bool stayOnPersonalSide) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: stayOnPersonalSide, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Updated Profile", + message, + [ + MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: stayOnPersonalSide, + ); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -324,7 +297,7 @@ class _MihBusinessDetailsSetUpState extends State { if (_formKey.currentState!.validate()) { submitForm(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } }, @@ -784,7 +757,7 @@ class _MihBusinessDetailsSetUpState extends State { if (_formKey.currentState!.validate()) { submitForm(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart index 257e8284..795ed2f1 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart @@ -11,7 +11,7 @@ import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -111,59 +111,69 @@ class _MihBusinessQrCodeState extends State { void showSignInRequiredAlert() { showDialog( + barrierDismissible: false, context: context, - builder: (context) => MihPackageAlert( - alertIcon: Column( - children: [ - Icon( - MihIcons.mihLogo, - size: 125, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - const SizedBox(height: 10), - ], - ), - alertTitle: "Let's Get Started", - alertBody: Column( - children: [ - Text( - "Ready to dive in to the world of MIH?\nSign in or create a free MIH account to unlock all the powerful features of the MIH app. It's quick and easy!", - style: TextStyle( + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + windowBody: Column( + children: [ + Icon( + MihIcons.mihLogo, + size: 100, color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: true, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Sign In/ Create Account", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), + Text( + "Let's Get Started", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, ), ), - ) - ], - ), - alertColour: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), + const SizedBox(height: 15), + Text( + "Ready to dive in to the world of MIH?\nSign in or create a free MIH account to unlock all the powerful features of the MIH app. It's quick and easy!", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 15, + ), + ), + const SizedBox(height: 25), + Center( + child: MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: true, + ); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + elevation: 10, + width: 300, + child: Text( + "Sign In/ Create Account", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ) + ], + ), + ); + }, ); } diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart index fd9dd147..66be859f 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart @@ -41,6 +41,7 @@ class _MihBusinessReviewsState extends State { // showDialog(context: context, builder: (context)=> ) showDialog( context: context, + barrierDismissible: false, builder: (context) { return MihReviewBusinessWindow( business: business, diff --git a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart index c49f6bd1..6ebf2110 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart @@ -1,6 +1,5 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -13,7 +12,6 @@ import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_sc import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; @@ -110,93 +108,25 @@ class _MihMyBusinessUserState extends State { String message = "Business details updated successfully"; successPopUp(message, false); } else { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_rounded, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Error Updating Business User Details", - alertBody: Column( - children: [ - Text( - "An error occurred while updating the business User details. Please check internet connection and try again.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - ), - ), - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().errorBasicAlert( + "Error Updating Business User Details", + "An error occurred while updating the business User details. Please check internet connection and try again.", + context, ); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } void successPopUp(String message, bool stayOnPersonalSide) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().successBasicAlert( + "Success!", + message, + context, ); } @@ -418,7 +348,7 @@ class _MihMyBusinessUserState extends State { if (_formKey.currentState!.validate()) { submitForm(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/components/mih_edit_personal_profile_window.dart b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/components/mih_edit_personal_profile_window.dart index e31c1011..c0ad5736 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/components/mih_edit_personal_profile_window.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/components/mih_edit_personal_profile_window.dart @@ -7,7 +7,6 @@ import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_toggle.dart'; @@ -105,7 +104,7 @@ class _MihEditPersonalProfileWindowState message, ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -121,7 +120,7 @@ class _MihEditPersonalProfileWindowState if (response == 200) { deleteFileApiCall(mzansiProfileProvider, oldProPicName); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -137,7 +136,7 @@ class _MihEditPersonalProfileWindowState if (response == 200) { //SQL delete } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -163,63 +162,36 @@ class _MihEditPersonalProfileWindowState MzansiProfileProvider profileProvider, String message, ) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Successfully Updated Profile", - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - if (profileProvider.user!.type.toLowerCase() == - "business" && - profileProvider.business == null) { - setupBusinessPopUp(profileProvider); - } else { - context.pop(); - context.pop(); - } - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + "Successfully Updated Profile", + message, + [ + MihButton( + onPressed: () { + if (profileProvider.user!.type.toLowerCase() == "business" && + profileProvider.business == null) { + setupBusinessPopUp(profileProvider); + } else { + context.pop(); + context.pop(); + } + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -228,17 +200,31 @@ class _MihEditPersonalProfileWindowState ) { showDialog( context: context, + barrierDismissible: false, builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - MihIcons.businessSetup, - size: 150, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Setup Business Profile?", - alertBody: Column( + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + windowBody: Column( children: [ + Icon( + MihIcons.businessSetup, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + "Setup Business Profile?", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), Text( "It looks like this is the first time activating your business account. Would you like to set up your business now or would you like to do it later?", style: TextStyle( @@ -307,35 +293,16 @@ class _MihEditPersonalProfileWindowState ) ], ), - alertColour: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), ); }, ); } void notUniqueAlert() { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Too Slow, That Username is Taken", - alertBody: const Text( - "The username you have entered is already taken by another member of Mzansi. Please choose a different username and try again.", - style: TextStyle( - fontSize: 15, - ), - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().errorBasicAlert( + "Too Slow, That Username is Taken", + "The username you have entered is already taken by another member of Mzansi. Please choose a different username and try again.", + context, ); } @@ -528,7 +495,7 @@ class _MihEditPersonalProfileWindowState if (_formKey.currentState!.validate()) { submitForm(mzansiProfileProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart index 2ba0cfae..e21ec303 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart @@ -1,6 +1,5 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart'; @@ -26,17 +25,10 @@ class _MihPersonalProfileState extends State { void editProfileWindow(double width) { showDialog( context: context, + barrierDismissible: false, builder: (context) => Consumer( builder: (BuildContext context, MzansiProfileProvider mzansiProfileProvider, Widget? child) { - // usernameController.text = mzansiProfileProvider.user!.username; - // fnameController.text = mzansiProfileProvider.user!.fname; - // lnameController.text = mzansiProfileProvider.user!.lname; - // purposeController.text = mzansiProfileProvider.user!.purpose; - // proPicController.text = - // mzansiProfileProvider.user!.pro_pic_path.isNotEmpty - // ? mzansiProfileProvider.user!.pro_pic_path.split("/").last - // : ""; return MihEditPersonalProfileWindow(); }, ), @@ -62,13 +54,7 @@ class _MihPersonalProfileState extends State { return Center( child: Mihloadingcircle(), ); - } - // else if (mzansiProfileProvider.user!.username.isEmpty) { - // editProfileWindow(width); - // } - else { - KenLogger.success( - mzansiProfileProvider.userProfilePicture.toString()); + } else { return MihSingleChildScroll( child: Padding( padding: diff --git a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart index 465868d8..a12f410b 100644 --- a/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart +++ b/Frontend/lib/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart @@ -1,11 +1,11 @@ import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -22,101 +22,64 @@ class MihPersonalSettings extends StatefulWidget { class _MihPersonalSettingsState extends State { @override Widget build(BuildContext context) { - return MihPackageToolBody( - borderOn: false, - innerHorizontalPadding: 10, - bodyItem: getBody(), - ); - } - - void deleteAccountPopUp(BuildContext ctxtd) { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) { - return Consumer( - builder: (BuildContext context, - MzansiProfileProvider mzansiProfileProvider, Widget? child) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: - "Are you sure you want to permanently delete your MIH account?", - alertBody: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "This action will remove all of your data, and it cannot be recovered. We understand this is a big decision, so please take a moment to double-check.\n\nIf you're certain, please confirm below. If you've changed your mind, you can simply close this window.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Wrap( - spacing: 10, - runSpacing: 10, - children: [ - MihButton( - onPressed: () { - MihUserServices.deleteAccount( - mzansiProfileProvider, context); - }, - buttonColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "Delete", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - MihButton( - onPressed: () { - Navigator.pop(context); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - width: 300, - child: Text( - "Cancel", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ) - ], - ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + return Consumer( + builder: (BuildContext context, + MzansiProfileProvider mzansiProfileProvider, Widget? child) { + return MihPackageToolBody( + borderOn: false, + innerHorizontalPadding: 10, + bodyItem: getBody(mzansiProfileProvider), ); }, ); } - Widget getBody() { + void deleteAccountPopUp( + MzansiProfileProvider mzansiProfileProvider, BuildContext ctxtd) { + MihAlertServices().errorAdvancedAlert( + "Are you sure you want to permanently delete your MIH account?", + "This action will remove all of your data, and it cannot be recovered. We understand this is a big decision, so please take a moment to double-check.\n\nIf you're certain, please confirm below. If you've changed your mind, you can simply close this window.", + [ + MihButton( + onPressed: () { + MihUserServices.deleteAccount(mzansiProfileProvider, context); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Delete", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + Navigator.pop(context); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Cancel", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ctxtd, + ); + } + + Widget getBody(MzansiProfileProvider mzansiProfileProvider) { return MihSingleChildScroll( child: Column( children: [ @@ -142,7 +105,7 @@ class _MihPersonalSettingsState extends State { const SizedBox(height: 10.0), MihButton( onPressed: () { - deleteAccountPopUp(context); + deleteAccountPopUp(mzansiProfileProvider, context); }, buttonColor: MihColors.getRedColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), diff --git a/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart b/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart index 801d2e84..19d90e77 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart @@ -13,7 +13,6 @@ import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_wallet_services.da import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart'; @@ -158,11 +157,16 @@ class _BuildLoyaltyCardListState extends State { if (statusCode == 200) { context.pop(); context.pop(); + MihAlertServices().successBasicAlert( + "Success!", + "You have successfully updated the loyalty card details.", + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -192,7 +196,7 @@ class _BuildLoyaltyCardListState extends State { void deleteCardWindow(MzansiProfileProvider mzansiProfileProvider, MzansiWalletProvider walletProvider, BuildContext ctxt, int index) { - MihAlertServices().deleteConfirmationMessage( + MihAlertServices().deleteConfirmationAlert( "This Card will be deleted permanently from your Mzansi Wallet. Are you certain you want to delete it?", () async { int statusCode = await MIHMzansiWalletApis.deleteLoyaltyCardAPICall( @@ -204,9 +208,14 @@ class _BuildLoyaltyCardListState extends State { if (statusCode == 200) { context.pop(); context.pop(); + MihAlertServices().successBasicAlert( + "Success!", + "You have successfully deleted the loyalty card from your Mzansi Wallet.", + context, + ); } else { context.pop(); - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } }, context, @@ -215,153 +224,147 @@ class _BuildLoyaltyCardListState extends State { void addToFavCardWindow(MzansiProfileProvider mzansiProfileProvider, MzansiWalletProvider walletProvider, BuildContext ctxt, int index) { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) { - return MihPackageAlert( - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + // "Card Added to Favourites", + "Add Card to Favourites?", + "Would you like to add this card to your favourites for quick access?", + // "You have successfully added the loyalty card to your favourites.", + [ + MihButton( + onPressed: () async { + context.pop(); + }, + buttonColor: MihColors.getRedColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - alertIcon: Icon( - Icons.favorite, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, + width: 300, + child: Text( + "Cancel", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), - alertTitle: "Add to Favourites", - alertBody: Column( - children: [ - Text( - "Are you sure you want to add this card to your favourites?", - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox( - height: 15, - ), - MihButton( - onPressed: () async { - int statusCode = - await MIHMzansiWalletApis.updateLoyaltyCardAPICall( - walletProvider, - mzansiProfileProvider.user!, - widget.cardList[index].idloyalty_cards, - widget.cardList[index].shop_name, - "Yes", - _noFavourites, - widget.cardList[index].nickname, - widget.cardList[index].card_number, - ctxt, - ); - if (statusCode == 200) { - context.pop(); - context.pop(); - await MIHMzansiWalletApis.getFavouriteLoyaltyCards( - walletProvider, - mzansiProfileProvider.user!.app_id, - context, - ); - context.read().setToolIndex(1); - } else { - MihAlertServices().internetConnectionLost(context); - } - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Add", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], + ), + MihButton( + onPressed: () async { + int statusCode = await MIHMzansiWalletApis.updateLoyaltyCardAPICall( + walletProvider, + mzansiProfileProvider.user!, + widget.cardList[index].idloyalty_cards, + widget.cardList[index].shop_name, + "Yes", + _noFavourites, + widget.cardList[index].nickname, + widget.cardList[index].card_number, + ctxt, + ); + if (statusCode == 200) { + context.pop(); + context.pop(); + await MIHMzansiWalletApis.getFavouriteLoyaltyCards( + walletProvider, + mzansiProfileProvider.user!.app_id, + context, + ); + context.read().setToolIndex(1); + MihAlertServices().successBasicAlert( + "Success!", + "You have successfully added the loyalty card to your favourites.", + context, + ); + } else { + MihAlertServices().internetConnectionAlert(context); + } + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Add", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), - ); - }, + ), + ], + context, ); } void removeFromFavCardWindow(MzansiProfileProvider mzansiProfileProvider, MzansiWalletProvider walletProvider, BuildContext ctxt, int index) { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) { - return MihPackageAlert( - alertColour: MihColors.getRedColor( + MihAlertServices().errorAdvancedAlert( + "Remove From Favourites?", + "Are you sure you want to remove this card from your favourites?", + [ + MihButton( + onPressed: () async { + int statusCode = await MIHMzansiWalletApis.updateLoyaltyCardAPICall( + walletProvider, + mzansiProfileProvider.user!, + widget.cardList[index].idloyalty_cards, + widget.cardList[index].shop_name, + "", + 0, + widget.cardList[index].nickname, + widget.cardList[index].card_number, + ctxt, + ); + if (statusCode == 200) { + context.pop(); + context.pop(); + await MIHMzansiWalletApis.getFavouriteLoyaltyCards( + walletProvider, + mzansiProfileProvider.user!.app_id, + context, + ); + context.read().setToolIndex(0); + MihAlertServices().successBasicAlert( + "Success!", + "You have successfully removed the loyalty card to your favourites.", + context, + ); + } else { + MihAlertServices().internetConnectionAlert(context); + } + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - alertIcon: Icon( - Icons.favorite_border, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - size: 100, + width: 300, + child: Text( + "Remove", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), - alertTitle: "Remove From Favourites", - alertBody: Column( - children: [ - Text( - "Are you sure you want to remove this card from your favourites?", - style: TextStyle( - fontSize: 20, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - ), - const SizedBox( - height: 15, - ), - MihButton( - onPressed: () async { - int statusCode = - await MIHMzansiWalletApis.updateLoyaltyCardAPICall( - walletProvider, - mzansiProfileProvider.user!, - widget.cardList[index].idloyalty_cards, - widget.cardList[index].shop_name, - "", - 0, - widget.cardList[index].nickname, - widget.cardList[index].card_number, - ctxt, - ); - if (statusCode == 200) { - context.pop(); - context.pop(); - await MIHMzansiWalletApis.getFavouriteLoyaltyCards( - walletProvider, - mzansiProfileProvider.user!.app_id, - context, - ); - context.read().setToolIndex(0); - } else { - MihAlertServices().internetConnectionLost(context); - } - }, - buttonColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Remove", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], + ), + MihButton( + onPressed: () async { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + child: Text( + "Cancel", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), ), - ); - }, + ), + ], + ctxt, ); } @@ -587,56 +590,31 @@ class _BuildLoyaltyCardListState extends State { KenLogger.success("Brightness set to: $newBrightness"); } else { context.pop(); - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.brightness_7_rounded, - size: 150, - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: "Permission Required", - alertBody: Column( - children: [ - Text( - "Sometimes it can be tough to scan your loyalty card if your phone screen is dim. To make sure your scan is successful every time, we need your permission to temporarily increase your screen brightness.\n\nWould you mind enabling this in your device settings?", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - MihButton( - onPressed: () async { - context.pop(); - await ScreenBrightness.instance - .setSystemScreenBrightness(newBrightness); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - child: Text( - "Grant Permission", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - alertColour: MihColors.getSecondaryColor( + MihAlertServices().errorAdvancedAlert( + "Permission Required", + "Sometimes it can be tough to scan your loyalty card if your phone screen is dim. To make sure your scan is successful every time, we need your permission to temporarily increase your screen brightness.\n\nWould you mind enabling this in your device settings?", + [ + MihButton( + onPressed: () async { + context.pop(); + await ScreenBrightness.instance + .setSystemScreenBrightness(newBrightness); + }, + buttonColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + width: 300, + child: Text( + "Grant Permission", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } } else { diff --git a/Frontend/lib/mih_packages/mzansi_wallet/components/mih_add_card_window.dart b/Frontend/lib/mih_packages/mzansi_wallet/components/mih_add_card_window.dart index b98574bc..d006947a 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/components/mih_add_card_window.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/components/mih_add_card_window.dart @@ -5,7 +5,6 @@ import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -34,56 +33,10 @@ class _MihAddCardWindowState extends State { final ValueNotifier _shopName = ValueNotifier(""); void successPopUp(String title, String message, int packageIndex) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().successBasicAlert( + title, + message, + context, ); } @@ -282,7 +235,7 @@ class _MihAddCardWindowState extends State { onPressed: () async { if (_formKey.currentState!.validate()) { if (_shopController.text == "") { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } else { int statusCode = await MIHMzansiWalletApis .addLoyaltyCardAPICall( @@ -306,11 +259,11 @@ class _MihAddCardWindowState extends State { ); } else { MihAlertServices() - .internetConnectionLost(context); + .internetConnectionAlert(context); } } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart b/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart index c827b917..98f5b828 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart @@ -1,12 +1,9 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart'; -import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_wallet_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_add_card_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart'; @@ -14,6 +11,7 @@ import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart'; import 'package:flutter/material.dart'; import 'package:mobile_scanner/mobile_scanner.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:provider/provider.dart'; class MihCards extends StatefulWidget { @@ -56,56 +54,10 @@ class _MihCardsState extends State { } void successPopUp(String title, String message, int packageIndex) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + MihAlertServices().successBasicAlert( + title, + message, + context, ); } diff --git a/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_mih_patient_search_list.dart b/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_mih_patient_search_list.dart index bf84743f..fbaf353a 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_mih_patient_search_list.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_mih_patient_search_list.dart @@ -78,6 +78,12 @@ class _BuildPatientsListState extends State { return accessStatus; } + Future refreshMyPatientList(MzansiProfileProvider mzansiProfileProvider, + PatientManagerProvider patientManagerProvider) async { + await MihPatientServices().getPatientAccessListOfBusiness( + patientManagerProvider, mzansiProfileProvider.business!.business_id); + } + void patientProfileChoicePopUp( MzansiProfileProvider profileProvider, PatientManagerProvider patientManagerProvider, @@ -300,7 +306,7 @@ class _BuildPatientsListState extends State { // "business", // )); } else { - MihAlertServices().warningMessage( + MihAlertServices().warningAlert( "Access Pending", "Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.", context, @@ -344,6 +350,8 @@ class _BuildPatientsListState extends State { ), context, ); + refreshMyPatientList( + profileProvider, patientManagerProvider); }, buttonColor: MihColors.getGreenColor( MzansiInnovationHub.of(context)!.theme.mode == @@ -380,6 +388,8 @@ class _BuildPatientsListState extends State { ), context, ); + refreshMyPatientList( + profileProvider, patientManagerProvider); }, buttonColor: MihColors.getGreenColor( MzansiInnovationHub.of(context)!.theme.mode == diff --git a/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_my_patient_list_list.dart b/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_my_patient_list_list.dart index ee348ee6..692f13bd 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_my_patient_list_list.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_manager/list_builders/build_my_patient_list_list.dart @@ -1,6 +1,5 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; @@ -64,69 +63,43 @@ class _BuildPatientsListState extends State { successPopUp("Successfully Added Appointment", "You appointment has been successfully added to your calendar."); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.pop(); - setState(() { - dateController.clear(); - timeController.clear(); - idController.clear(); - fnameController.clear(); - lnameController.clear(); - }); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + setState(() { + dateController.clear(); + timeController.clear(); + idController.clear(); + fnameController.clear(); + lnameController.clear(); + }); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -242,10 +215,10 @@ class _BuildPatientsListState extends State { submitApointment( profileProvider, patientManagerProvider, index); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -276,13 +249,13 @@ class _BuildPatientsListState extends State { void noAccessWarning( PatientManagerProvider patientManagerProvider, int index) { if (patientManagerProvider.myPaitentList![index].status == "pending") { - MihAlertServices().warningMessage( + MihAlertServices().warningAlert( "Access Pending", "Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.", context, ); } else { - MihAlertServices().warningMessage( + MihAlertServices().errorBasicAlert( "Access Declined", "Your request to access the patient's profile has been denied. Please contact the patient directly to inquire about the reason for this restriction.", context, diff --git a/Frontend/lib/mih_packages/patient_manager/pat_manager/package_tools/waiting_room.dart b/Frontend/lib/mih_packages/patient_manager/pat_manager/package_tools/waiting_room.dart index 0a38e0d8..dfcae152 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_manager/package_tools/waiting_room.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_manager/package_tools/waiting_room.dart @@ -2,7 +2,6 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart'; @@ -266,7 +265,7 @@ class _WaitingRoomState extends State { patientManagerProvider.setPatientManagerIndex(1); context.pop(); }, - buttonColor: MihColors.getGreenColor( + buttonColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), width: 300, child: Text( @@ -285,7 +284,7 @@ class _WaitingRoomState extends State { patientManagerProvider.setPatientManagerIndex(2); context.pop(); }, - buttonColor: MihColors.getGreenColor( + buttonColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), width: 300, child: Text( @@ -305,7 +304,7 @@ class _WaitingRoomState extends State { addAppointmentWindow( profileProvider, mihCalendarProvider, width); }, - buttonColor: MihColors.getGreenColor( + buttonColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), width: 300, child: Text( @@ -410,7 +409,7 @@ class _WaitingRoomState extends State { addAppointmentCall( profileProvider, mihCalendarProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -462,71 +461,45 @@ class _WaitingRoomState extends State { "You appointment has been successfully added to your calendar."); _loadInitialAppointments(); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } checkforchange(); } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - setState(() { - _appointmentDateController.clear(); - _appointmentTimeController.clear(); - _appointmentTitleController.clear(); - _appointmentDescriptionIDController.clear(); - }); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + setState(() { + _appointmentDateController.clear(); + _appointmentTimeController.clear(); + _appointmentTitleController.clear(); + _appointmentDescriptionIDController.clear(); + }); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/claim_statement_window.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/claim_statement_window.dart index c92a3aed..b70857df 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/claim_statement_window.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/claim_statement_window.dart @@ -388,10 +388,10 @@ class _ClaimStatementWindowState extends State { AppEnviroment.getEnv(), context); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/medicine_search.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/medicine_search.dart index 9b02a2a7..ab3a5d0d 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/medicine_search.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/medicine_search.dart @@ -38,7 +38,7 @@ class _MedicineSearchState extends State { // medicines.forEach((element) => meds.add(element.name)); return medicines; } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); throw Exception('failed to load medicine'); } } diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart index 491b64c6..afbada89 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart @@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_toggle.dart'; @@ -67,7 +66,7 @@ class _MihEditPatientDetailsWindowState "${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.", ); } else { - MihAlertServices().errorAlert( + MihAlertServices().errorBasicAlert( "Error Updating Profile", "There was an error updating your profile. Please try again later.", context, @@ -76,67 +75,31 @@ class _MihEditPatientDetailsWindowState } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - // context.goNamed( - // "patientProfile", - // extra: PatientViewArguments( - // widget.signedInUser, - // widget.selectedPatient, - // null, - // null, - // "personal", - // ), - // ); - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -422,7 +385,7 @@ class _MihEditPatientDetailsWindowState if (_formKey.currentState!.validate()) { updatePatientApiCall(patientManagerProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -543,7 +506,7 @@ class _MihEditPatientDetailsWindowState if (_formKey.currentState!.validate()) { updatePatientApiCall(patientManagerProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } }, diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/prescip_input.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/prescip_input.dart index cdd1a8f0..cde00c8e 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/components/prescip_input.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/components/prescip_input.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; @@ -17,6 +17,8 @@ import 'package:mzansi_innovation_hub/mih_objects/business_user.dart'; import 'package:mzansi_innovation_hub/mih_objects/patients.dart'; import 'package:mzansi_innovation_hub/mih_objects/perscription.dart'; import 'package:flutter/material.dart'; +import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart'; +import 'package:provider/provider.dart'; import 'package:supertokens_flutter/http.dart' as http; class PrescripInput extends StatefulWidget { @@ -94,7 +96,9 @@ class _PrescripInputState extends State { "30" ]; - Future generatePerscription() async { + Future generatePerscription( + PatientManagerProvider patManProvider, + ) async { //start loading circle showDialog( context: context, @@ -161,84 +165,25 @@ class _PrescripInputState extends State { context.pop(); String message = "The perscription $fileName has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use."; - successPopUp(message); + + await MihPatientServices().getPatientDocuments(patManProvider); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - void getMedsPopUp(TextEditingController medSearch) { showDialog( context: context, + barrierDismissible: false, builder: (context) { return MedicineSearch( searchVlaue: medSearch, @@ -485,10 +430,10 @@ class _PrescripInputState extends State { widget.noRepeatsController.text = "0"; }); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getSecondaryColor( @@ -511,7 +456,7 @@ class _PrescripInputState extends State { ); } - Widget displayPerscList() { + Widget displayPerscList(PatientManagerProvider patManProvider) { return Column( children: [ Container( @@ -573,9 +518,9 @@ class _PrescripInputState extends State { onPressed: () async { if (perscriptionObjOutput.isNotEmpty) { //print(jsonEncode(perscriptionObjOutput)); - await generatePerscription(); + await generatePerscription(patManProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -613,18 +558,23 @@ class _PrescripInputState extends State { var size = MediaQuery.of(context).size; width = size.width; height = size.height; - return Wrap( - direction: Axis.horizontal, - alignment: WrapAlignment.center, - spacing: 10, - runSpacing: 10, - // mainAxisAlignment: MainAxisAlignment.center, - // mainAxisSize: MainAxisSize.max, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(width: 500, child: displayMedInput()), - displayPerscList(), - ], + return Consumer( + builder: (BuildContext context, PatientManagerProvider patManProvider, + Widget? child) { + return Wrap( + direction: Axis.horizontal, + alignment: WrapAlignment.center, + spacing: 10, + runSpacing: 10, + // mainAxisAlignment: MainAxisAlignment.center, + // mainAxisSize: MainAxisSize.max, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 500, child: displayMedInput()), + displayPerscList(patManProvider), + ], + ); + }, ); } } diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_claim_statement_files_list.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_claim_statement_files_list.dart index fc29a05c..026900ca 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_claim_statement_files_list.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_claim_statement_files_list.dart @@ -4,7 +4,6 @@ import 'package:fl_downloader/fl_downloader.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_file_viewer_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -51,70 +50,6 @@ class _BuildClaimStatementFileListState return teporaryFileUrl; } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - String getFileName(String path) { //print(pdfLink.split(".")[1]); return path.split("/").last; diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart index a6ffd6f1..49748219 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart @@ -6,7 +6,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_file_viewer_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -51,72 +50,6 @@ class _BuildFilesListState extends State { return teporaryFileUrl; } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - String getFileName(String path) { //print(pdfLink.split(".")[1]); return path.split("/").last; diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart index 6ac295a0..6bbc2b10 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart @@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -45,68 +44,42 @@ class _BuildNotesListState extends State { "The note has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments."; successPopUp("Successfuly Deleted", message); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } void deletePatientPopUp( PatientManagerProvider patientManagerProvider, int NoteId) { - MihAlertServices().deleteConfirmationMessage( + MihAlertServices().deleteConfirmationAlert( "This note will be deleted permanently. Are you certain you want to delete it?", () { deleteNoteApiCall(patientManagerProvider, NoteId); diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart index eafbafda..02858370 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart @@ -51,14 +51,18 @@ class _PatientConsultationState extends State { ); if (statuscode == 201) { context.pop(); - successPopUp("Note added successfully."); + MihAlertServices().successBasicAlert( + "Success!", + "Note added successfully.", + context, + ); titleController.clear(); noteTextController.clear(); officeController.clear(); dateController.clear(); doctorController.clear(); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -203,7 +207,7 @@ class _PatientConsultationState extends State { addPatientNoteAPICall( profileProvider, patManProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -251,72 +255,6 @@ class _PatientConsultationState extends State { } } - void successPopUp(String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - @override void dispose() { titleController.dispose(); diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart index f87cf693..9354feb0 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart @@ -1,7 +1,6 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; @@ -56,7 +55,7 @@ class _PatientDocumentsState extends State { if (isFileFieldsFilled()) { await uploadSelectedFile(patientManagerProvider, selected); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } } @@ -81,7 +80,7 @@ class _PatientDocumentsState extends State { "The file $fname has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use."; successPopUp("Successfully Uplouded File", message); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -97,7 +96,7 @@ class _PatientDocumentsState extends State { if (response == 200) { await addPatientFileLocationToDB(patientManagerProvider, file); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -126,9 +125,10 @@ class _PatientDocumentsState extends State { context.pop(); //Loading removal String message = "The medical certificate $fileName has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use."; + await MihPatientServices().getPatientDocuments(patientManagerProvider); successPopUp("Successfully Generated Certificate", message); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -217,7 +217,7 @@ class _PatientDocumentsState extends State { submitDocUploadForm(patientManagerProvider); // uploadSelectedFile(selected); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -303,7 +303,7 @@ class _PatientDocumentsState extends State { profileProvider, patientManagerProvider); //Navigator.pop(context); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( @@ -496,57 +496,31 @@ class _PatientDocumentsState extends State { } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.pop(); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart index ec5bc678..1bbb95a1 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart @@ -271,6 +271,7 @@ class _PatientInfoState extends State { void showEditPatientWindow() { showDialog( context: context, + barrierDismissible: false, builder: (context) { return MihEditPatientDetailsWindow(); }); diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart index 025159e9..5dda6ece 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart @@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_toggle.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; @@ -65,64 +64,38 @@ class _PatientSetupFormState extends State { "${fnameController.text} ${lnameController.text} patient profile has been successfully added!\n"; successPopUp("Successfully created Patient Profile", message); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } void successPopUp(String title, String message) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.pop(); - context.goNamed( - 'patientProfile', - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.pop(); + context.goNamed( + 'patientProfile', + ); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); } @@ -458,7 +431,7 @@ class _PatientSetupFormState extends State { addPatientService( profileProvider, patientManagerProvider); } else { - MihAlertServices().inputErrorMessage(context); + MihAlertServices().inputErrorAlert(context); } }, buttonColor: MihColors.getGreenColor( diff --git a/Frontend/lib/mih_packages/patient_manager/pat_profile/patient_profile.dart b/Frontend/lib/mih_packages/patient_manager/pat_profile/patient_profile.dart index 9926f643..8016a307 100644 --- a/Frontend/lib/mih_packages/patient_manager/pat_profile/patient_profile.dart +++ b/Frontend/lib/mih_packages/patient_manager/pat_profile/patient_profile.dart @@ -103,7 +103,6 @@ class _PatientProfileState extends State { icon: const Icon(Icons.arrow_back), iconSize: 35, onTap: () { - patientManagerProvider.setPatientProfileIndex(0); if (!patientManagerProvider.personalMode) { context.pop(); } else { @@ -111,6 +110,8 @@ class _PatientProfileState extends State { 'mihHome', ); } + patientManagerProvider.setPatientProfileIndex(0); + patientManagerProvider.setHidePatientDetails(true); FocusScope.of(context).unfocus(); }, ); diff --git a/Frontend/lib/mih_services/mih_access_controls_services.dart b/Frontend/lib/mih_services/mih_access_controls_services.dart index 41bd7b14..ba2ad08f 100644 --- a/Frontend/lib/mih_services/mih_access_controls_services.dart +++ b/Frontend/lib/mih_services/mih_access_controls_services.dart @@ -97,7 +97,7 @@ class MihAccessControlsServices { await MihNotificationApis.addAccessRequestNotificationAPICall( app_id, requested_by, personalSelected, args, context); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -135,7 +135,7 @@ class MihAccessControlsServices { app_id, personalSelected, args, context); //notification here } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } diff --git a/Frontend/lib/mih_services/mih_alert_services.dart b/Frontend/lib/mih_services/mih_alert_services.dart index 774353c0..46785027 100644 --- a/Frontend/lib/mih_services/mih_alert_services.dart +++ b/Frontend/lib/mih_services/mih_alert_services.dart @@ -2,750 +2,12 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; +import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart'; class MihAlertServices { - void internetConnectionLost(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Internet Connection Lost!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "We seem to be having some trouble connecting you to the internet. This could be due to a temporary outage or an issue with your device's connection.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void locationPermissionError(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Location Services Not Enabled", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "To get the most out of MIH, we need your location. Please go to the site settings of the app and enable location services. Once you do that, we can start showing you relevant information based on your location.", - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void inputErrorMessage(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Oops! Looks like some fields are missing.", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "We noticed that some required fields are still empty. To ensure your request is processed smoothly, please fill out all the highlighted fields before submitting the form again.", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - RichText( - text: TextSpan( - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - children: [ - TextSpan( - text: "Here's a quick tip: ", - style: TextStyle( - fontStyle: FontStyle.italic, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"))), - const TextSpan(text: "Look for fields with an asterisk ("), - TextSpan( - text: "*", - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"))), - const TextSpan( - text: ") next to them, as these are mandatory."), - ], - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void passwordRequiredError(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Password Doesn't Meet Requirements", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "Oops! Your password doesn't quite meet our standards. To keep your account secure, please make sure your password meets the following requirements", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - RichText( - text: TextSpan( - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - children: [ - TextSpan( - text: "Requirements:\n", - style: TextStyle( - fontStyle: FontStyle.italic, - fontSize: 20, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"))), - const TextSpan( - text: "1) Contailes at least 8 characters\n", - ), - const TextSpan( - text: "2) Contains at least 1 uppercase letter (A-Z)\n", - ), - const TextSpan( - text: "3) Contains at least 1 lowercase letter (a-z)\n", - ), - const TextSpan( - text: "4) Contains at least 1 number (0-9)\n", - ), - const TextSpan( - text: - "5) Contains at least 1 special character (!@#\$%^&*)\n", - ), - ], - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void passwordMatchError(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Passwords Don't Match", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "The password and confirm password fields do not match. Please make sure they are identical.", - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - Text( - "Here are some things to keep in mind:", - textAlign: TextAlign.left, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20.0, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void loginErrorMessage(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Uh oh! Login attempt unsuccessful.", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "The email address or password you entered doesn't seem to match our records. Please double-check your information and try again.", - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - Text( - "Here are some things to keep in mind:", - textAlign: TextAlign.left, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20.0, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - Text( - "1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.", - textAlign: TextAlign.left, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20.0, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void emailExistsError(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Email Already Exists", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "Here are some things to keep in mind:", - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - Text( - "1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.", - textAlign: TextAlign.left, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void invalidEmailError(BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Oops! Invalid Email", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - "Looks like there's a little hiccup with that email address. Please double-check that you've entered it correctly, including the \"@\" symbol and a domain (like example@email.com).", - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void successAlert(String title, String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - ], - ), - alertColour: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, - ); - } - - void warningMessage(String title, String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - title, - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - Text( - message, - style: TextStyle( - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - - void deleteConfirmationMessage( - String message, void Function()? onpressed, BuildContext context) { + void internetConnectionAlert(BuildContext context) { showDialog( context: context, barrierDismissible: false, @@ -755,18 +17,852 @@ class MihAlertServices { windowTitle: null, onWindowTapClose: null, backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Internet Connection Lost!", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "We seem to be having some trouble connecting you to the internet. This could be due to a temporary outage or an issue with your device's connection.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void locationPermissionAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Location Services Not Enabled", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "To get the most out of MIH, we need your location. Please go to the site settings of the app and enable location services. Once you do that, we can start showing you relevant information based on your location.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void inputErrorAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Oops! Looks like some fields are missing.", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "We noticed that some required fields are still empty. To ensure your request is processed smoothly, please fill out all the highlighted fields before submitting the form again.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + RichText( + text: TextSpan( + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 15, + fontWeight: FontWeight.bold, + ), + children: [ + TextSpan( + text: "Here's a quick tip: ", + style: TextStyle( + fontStyle: FontStyle.italic, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"))), + const TextSpan( + text: "Look for fields with an asterisk ("), + TextSpan( + text: "*", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"))), + const TextSpan( + text: ") next to them, as these are mandatory."), + ], + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void passwordRequirementAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Password Doesn't Meet Requirements", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "Oops! Your password doesn't quite meet our standards. To keep your account secure, please make sure your password meets the following requirements", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + RichText( + text: TextSpan( + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + children: [ + TextSpan( + text: "Requirements:\n", + style: TextStyle( + fontStyle: FontStyle.italic, + fontSize: 20, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"))), + const TextSpan( + text: "1) Contailes at least 8 characters\n", + ), + const TextSpan( + text: "2) Contains at least 1 uppercase letter (A-Z)\n", + ), + const TextSpan( + text: "3) Contains at least 1 lowercase letter (a-z)\n", + ), + const TextSpan( + text: "4) Contains at least 1 number (0-9)\n", + ), + const TextSpan( + text: + "5) Contains at least 1 special character (!@#\$%^&*)\n", + ), + ], + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void passwordMatchAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Passwords Don't Match", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "The password and confirm password fields do not match. Please make sure they are identical.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void loginErrorAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Uh oh! Login attempt unsuccessful.", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "The email address or password you entered doesn't seem to match our records. Please double-check your information and try again.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), + Text( + "Here are some things to keep in mind:", + textAlign: TextAlign.left, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18.0, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), + Text( + "1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.", + textAlign: TextAlign.left, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void emailExistsAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Email Already Exists", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "It looks like that email is already registered. Please sign in or try a different email.", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void invalidEmailAlert(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Oops! Invalid Email", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + "Looks like there's a little hiccup with that email address. Please double-check that you've entered it correctly, including the \"@\" symbol and a domain (like example@email.com).", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void warningAlert(String title, String message, BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.warning_amber_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Center( - child: Text( - "Are You Sure?", + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + title, + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + message, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + void deleteConfirmationAlert( + String message, + void Function()? onpressed, + BuildContext context, + ) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Center( + child: Text( + "Are You Sure?", + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Text( + message, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Wrap( + spacing: 10.0, + runSpacing: 10.0, + alignment: WrapAlignment.center, + children: [ + MihButton( + onPressed: onpressed, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + width: 300, + elevation: 10, + child: Text( + "Delete", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + width: 300, + elevation: 10, + child: Text( + "Cancel", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } + + void successBasicAlert( + String title, + String message, + BuildContext context, + ) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.check_circle_outline_rounded, + size: 150, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + title, textAlign: TextAlign.center, style: TextStyle( color: MihColors.getPrimaryColor( @@ -775,69 +871,249 @@ class MihAlertServices { fontWeight: FontWeight.bold, ), ), - ), - const SizedBox(height: 15), - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: onpressed, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Delete", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, + const SizedBox(height: 15), + Center( + child: Text( + message, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], + const SizedBox(height: 15), + MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), ), ); }, ); } - void errorAlert(String title, String message, BuildContext context) { + void successAdvancedAlert( + String title, + String message, + List actions, + BuildContext context, + ) { showDialog( context: context, + barrierDismissible: false, builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.warning_amber_rounded, - size: 150, - color: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getGreenColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.check_circle_outline_rounded, + size: 150, + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + title, + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Center( + child: Text( + message, + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Center( + child: Wrap( + spacing: 10.0, + runSpacing: 10.0, + alignment: WrapAlignment.center, + children: actions, + ), + ) + ], + ), ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( + ); + }, + ); + } + + void errorBasicAlert( + String title, + String message, + BuildContext context, + ) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, color: MihColors.getSecondaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, ), - ), - const SizedBox(height: 25), - ], + Text( + title, + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Center( + child: Text( + message, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Center( + child: MihButton( + onPressed: () { + context.pop(); + }, + buttonColor: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + width: 300, + elevation: 10, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ) + ], + ), + ), + ); + }, + ); + } + + void errorAdvancedAlert( + String title, + String message, + List actions, + BuildContext context, + ) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return MihPackageWindow( + fullscreen: false, + windowTitle: null, + onWindowTapClose: null, + backgroundColor: MihColors.getRedColor( + MzansiInnovationHub.of(context)!.theme.mode != "Dark"), + windowBody: MihSingleChildScroll( + child: Column( + children: [ + Icon( + Icons.warning_amber_rounded, + size: 150, + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + ), + Text( + title, + textAlign: TextAlign.center, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 25, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 15), + Center( + child: Text( + message, + style: TextStyle( + color: MihColors.getSecondaryColor( + MzansiInnovationHub.of(context)!.theme.mode == + "Dark"), + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 15), + Center( + child: Wrap( + spacing: 10.0, + runSpacing: 10.0, + alignment: WrapAlignment.center, + children: actions, + ), + ) + ], + ), ), - alertColour: MihColors.getRedColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), ); }, ); diff --git a/Frontend/lib/mih_services/mih_authentication_services.dart b/Frontend/lib/mih_services/mih_authentication_services.dart index 0f608602..3b1f6cd7 100644 --- a/Frontend/lib/mih_services/mih_authentication_services.dart +++ b/Frontend/lib/mih_services/mih_authentication_services.dart @@ -100,6 +100,7 @@ class MihAuthenticationServices { void loginError(String error, BuildContext context) { showDialog( context: context, + barrierDismissible: false, builder: (context) { return AlertDialog( title: Text(error), @@ -111,6 +112,7 @@ class MihAuthenticationServices { void signUpError(BuildContext context) { showDialog( context: context, + barrierDismissible: false, builder: (context) { return MihPackageWindow( fullscreen: false, diff --git a/Frontend/lib/mih_services/mih_claim_statement_generation_services.dart b/Frontend/lib/mih_services/mih_claim_statement_generation_services.dart index 668b81de..9b705d35 100644 --- a/Frontend/lib/mih_services/mih_claim_statement_generation_services.dart +++ b/Frontend/lib/mih_services/mih_claim_statement_generation_services.dart @@ -1,16 +1,12 @@ import 'dart:convert'; import 'package:go_router/go_router.dart'; -import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_objects/claim_statement_file.dart'; import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:supertokens_flutter/http.dart' as http; @@ -98,12 +94,16 @@ class MIHClaimStatementGenerationApi { getClaimStatementFilesByPatient(patientManagerProvider); String message = "The ${data.document_type}: $fileName has been successfully generated and added to ${data.patient_full_name}'s record. You can now access and download it for their use."; - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -230,80 +230,17 @@ class MIHClaimStatementGenerationApi { // setState(() {}); String message = "The File has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments."; - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } - - //================== POP UPS ========================================================================== - - static void successPopUp(String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } } +//================== POP UPS ========================================================================== diff --git a/Frontend/lib/mih_services/mih_file_services.dart b/Frontend/lib/mih_services/mih_file_services.dart index 8e42b069..e19fa3d1 100644 --- a/Frontend/lib/mih_services/mih_file_services.dart +++ b/Frontend/lib/mih_services/mih_file_services.dart @@ -3,11 +3,7 @@ import 'dart:convert'; import 'package:file_picker/file_picker.dart'; import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; -import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:flutter/material.dart'; import 'package:supertokens_flutter/http.dart' as http; @@ -107,87 +103,8 @@ class MihFileApi { return response.statusCode; } - // Future signOut() async { - // await SuperTokens.signOut(completionHandler: (error) { - // print(error); - // }); - // if (await SuperTokens.doesSessionExist() == false) { - // Navigator.of(context).pop(); - // Navigator.of(context).popAndPushNamed( - // '/', - // arguments: AuthArguments(true, false), - // ); - // } - // } - //================== POP UPS ========================================================================== - static void successPopUp(String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - static void loadingPopUp(BuildContext context) { showDialog( context: context, diff --git a/Frontend/lib/mih_services/mih_location_services.dart b/Frontend/lib/mih_services/mih_location_services.dart index 92534da7..a27c6e61 100644 --- a/Frontend/lib/mih_services/mih_location_services.dart +++ b/Frontend/lib/mih_services/mih_location_services.dart @@ -19,10 +19,10 @@ class MIHLocationAPI { if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); if (permission == LocationPermission.denied) { - MihAlertServices().locationPermissionError(context); + MihAlertServices().locationPermissionAlert(context); return null; } else if (permission == LocationPermission.deniedForever) { - MihAlertServices().locationPermissionError(context); + MihAlertServices().locationPermissionAlert(context); return null; } else { Position location = await Geolocator.getCurrentPosition( @@ -30,7 +30,7 @@ class MIHLocationAPI { return location; } } else if (permission == LocationPermission.deniedForever) { - MihAlertServices().locationPermissionError(context); + MihAlertServices().locationPermissionAlert(context); return null; } else { Position location = await Geolocator.getCurrentPosition( diff --git a/Frontend/lib/mih_services/mih_my_business_user_services.dart b/Frontend/lib/mih_services/mih_my_business_user_services.dart index d453b1da..286de533 100644 --- a/Frontend/lib/mih_services/mih_my_business_user_services.dart +++ b/Frontend/lib/mih_services/mih_my_business_user_services.dart @@ -70,7 +70,7 @@ class MihMyBusinessUserServices { ); return 201; } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); return 500; } } @@ -123,7 +123,7 @@ class MihMyBusinessUserServices { provider.setBusinessUserSignatureUrl(newProPicUrl); return 200; } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); return 500; } } diff --git a/Frontend/lib/mih_services/mih_mzansi_calendar_services.dart b/Frontend/lib/mih_services/mih_mzansi_calendar_services.dart index 2dd01f3e..255ee4c0 100644 --- a/Frontend/lib/mih_services/mih_mzansi_calendar_services.dart +++ b/Frontend/lib/mih_services/mih_mzansi_calendar_services.dart @@ -1,9 +1,6 @@ import 'dart:convert'; import 'package:go_router/go_router.dart'; -import 'package:mzansi_innovation_hub/main.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; import 'package:mzansi_innovation_hub/mih_objects/appointment.dart'; @@ -11,7 +8,6 @@ import 'package:mzansi_innovation_hub/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_objects/business_user.dart'; import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:supertokens_flutter/http.dart' as http; @@ -539,72 +535,6 @@ class MihMzansiCalendarApis { //================== POP UPS ========================================================================== - static void successPopUp(String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - static void loadingPopUp(BuildContext context) { showDialog( context: context, diff --git a/Frontend/lib/mih_services/mih_mzansi_wallet_services.dart b/Frontend/lib/mih_services/mih_mzansi_wallet_services.dart index 3141f7f6..39013ba7 100644 --- a/Frontend/lib/mih_services/mih_mzansi_wallet_services.dart +++ b/Frontend/lib/mih_services/mih_mzansi_wallet_services.dart @@ -2,15 +2,11 @@ import 'dart:convert'; import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; -import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_wallet_provider.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:supertokens_flutter/http.dart' as http; @@ -215,72 +211,6 @@ class MIHMzansiWalletApis { //================== POP UPS ========================================================================== - static void successPopUp(String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } - static void loadingPopUp(BuildContext context) { showDialog( context: context, diff --git a/Frontend/lib/mih_services/mih_notification_services.dart b/Frontend/lib/mih_services/mih_notification_services.dart index 9285f1c4..b651112d 100644 --- a/Frontend/lib/mih_services/mih_notification_services.dart +++ b/Frontend/lib/mih_services/mih_notification_services.dart @@ -1,12 +1,8 @@ import 'dart:convert'; import 'package:go_router/go_router.dart'; -import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_objects/notification.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart'; -import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; @@ -74,9 +70,13 @@ class MihNotificationApis { args.businessUser, ), ); - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -130,9 +130,13 @@ class MihNotificationApis { // args.businessUser, // ), // ); - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -186,9 +190,13 @@ class MihNotificationApis { ); String message = "The appointment has been successfully rescheduled."; - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -239,9 +247,13 @@ class MihNotificationApis { ); String message = "The appointment has been cancelled successfully. This means it will no longer be visible in your waiting room and calender."; - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -294,76 +306,14 @@ class MihNotificationApis { ); String message = "The appointment was been created successfully. This means it will now be visible in your waiting room and calender."; - successPopUp(message, context); + MihAlertServices().successBasicAlert( + "Success!", + message, + context, + ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } -//================== POP UPS ========================================================================== - - static void successPopUp(String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageWindow( - fullscreen: false, - windowTitle: null, - onWindowTapClose: null, - backgroundColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - windowBody: Column( - children: [ - Icon( - Icons.check_circle_outline_rounded, - size: 100, - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - Text( - "Success!", - textAlign: TextAlign.center, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 25, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 15), - Center( - child: Text( - message, - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - context.pop(); - }, - buttonColor: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - width: 300, - elevation: 10, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ); - }, - ); - } } +//================== POP UPS ========================================================================== diff --git a/Frontend/lib/mih_services/mih_user_services.dart b/Frontend/lib/mih_services/mih_user_services.dart index 034fcbc1..d92c8295 100644 --- a/Frontend/lib/mih_services/mih_user_services.dart +++ b/Frontend/lib/mih_services/mih_user_services.dart @@ -1,11 +1,9 @@ import 'dart:convert'; - import 'package:go_router/go_router.dart'; import 'package:ken_logger/ken_logger.dart'; import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/mih_objects/app_user.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart'; -import 'package:mzansi_innovation_hub/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; @@ -73,7 +71,7 @@ class MihUserServices { extra: true, ); } else { - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } @@ -265,66 +263,40 @@ class MihUserServices { } } else { Navigator.of(context).pop(); // Pop loading dialog - MihAlertServices().internetConnectionLost(context); + MihAlertServices().internetConnectionAlert(context); } } //================== POP UPS ========================================================================== static void successPopUp(String title, String message, BuildContext context) { - showDialog( - context: context, - builder: (context) { - return MihPackageAlert( - alertIcon: Icon( - Icons.check_circle_outline_rounded, - size: 150, - color: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ), - alertTitle: title, - alertBody: Column( - children: [ - Text( - message, - style: TextStyle( - color: MihColors.getSecondaryColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 25), - Center( - child: MihButton( - onPressed: () { - context.goNamed( - 'mihHome', - extra: true, - ); - }, - buttonColor: MihColors.getGreenColor( - MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - elevation: 10, - width: 300, - child: Text( - "Dismiss", - style: TextStyle( - color: MihColors.getPrimaryColor( - MzansiInnovationHub.of(context)!.theme.mode == - "Dark"), - fontSize: 20, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - ], - ), - alertColour: MihColors.getGreenColor( + MihAlertServices().successAdvancedAlert( + title, + message, + [ + MihButton( + onPressed: () { + context.goNamed( + 'mihHome', + extra: true, + ); + }, + buttonColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!.theme.mode == "Dark"), - ); - }, + elevation: 10, + width: 300, + child: Text( + "Dismiss", + style: TextStyle( + color: MihColors.getPrimaryColor( + MzansiInnovationHub.of(context)!.theme.mode == "Dark"), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + context, ); }