NEW: MIh Alerts

This commit is contained in:
2025-11-20 10:56:15 +02:00
parent b69a52a5a8
commit 00cd5488e3
66 changed files with 3188 additions and 5130 deletions

View File

@@ -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<PackageTest> {
MihPackageTools getTools() {
Map<Widget, void Function()?> 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<PackageTest> {
}
void showAlert() {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
List<Widget> getToolBody() {
MzansiProfileProvider profileProvider =
context.read<MzansiProfileProvider>();
List<Widget> toolBodies = [
const PackageToolZero(),
PackageToolOne(
user: profileProvider.user!,
business: profileProvider.business,
@@ -94,6 +101,7 @@ class _PackageTestState extends State<PackageTest> {
List<String> getToolTitle() {
List<String> toolTitles = [
"Tool Zero",
"Tool One",
"Tool Two",
];

View File

@@ -645,7 +645,7 @@ class _PackageToolOneState extends State<PackageToolOne> {
const SnackBar(content: Text("Input Valid")),
);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getSecondaryColor(

View File

@@ -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<PackageToolZero> createState() => _PackageToolZeroState();
}
class _PackageToolZeroState extends State<PackageToolZero> {
@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),
],
),
);
}
}

View File

@@ -43,7 +43,7 @@ class _MIHNotificationDrawerState extends State<MIHNotificationDrawer> {
arguments: widget.signedInUser,
);
} else {
MihAlertServices().internetConnectionLost(context);
MihAlertServices().internetConnectionAlert(context);
}
}

View File

@@ -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<MihPackageAlert> createState() => _MihPackageAlertState();
}
class _MihPackageAlertState extends State<MihPackageAlert> {
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,
),
),
),
],
),
);
}
}

View File

@@ -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<MihPackageTile> {
void displayHint() {
if (widget.ytVideoID != null) {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return MihPackageWindow(
@@ -89,82 +90,67 @@ class _MihPackageTileState extends State<MihPackageTile> {
}
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,
);
}

View File

@@ -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<BuildAccessRequestList> {
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<BuildAccessRequestList> {
// ),
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,

View File

@@ -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<BuildBusinessAccessList> {
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<BuildBusinessAccessList> {
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<BuildBusinessAccessList> {
}
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,
);
}

View File

@@ -169,6 +169,7 @@ class _CurrencyExchangeRateState extends State<CurrencyExchangeRate> {
final String companyName = 'Mzansi Innovation Hub';
showDialog(
barrierDismissible: false,
context: context,
builder: (context) => MihPackageWindow(
fullscreen: false,
@@ -383,7 +384,7 @@ class _CurrencyExchangeRateState extends State<CurrencyExchangeRate> {
FocusScope.of(context)
.requestFocus(FocusNode());
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -392,7 +392,7 @@ class _TipCalcState extends State<TipCalc> {
if (_formKey.currentState!.validate()) {
validateInput();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<BuildAccessRequestList> {
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<BuildAccessRequestList> {
// ),
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,

View File

@@ -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<BuildAppointmentList> {
updateAppointmentCall(mzansiProfileProvider,
mihCalendarProvider, index);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -569,7 +568,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
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<BuildAppointmentList> {
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<BuildAppointmentList> {
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,
);
}

View File

@@ -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<Appointments> {
addAppointmentCall(
mzansiProfileProvider, mihCalendarProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -301,71 +300,45 @@ class _PatientAccessRequestState extends State<Appointments> {
);
}
} 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,
);
}

View File

@@ -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<MihForgotPassword> {
}
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<MihForgotPassword> {
if (_formKey.currentState!.validate()) {
prePassResteWarning();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihRegister> {
Future<void> signUserUp() async {
context.read<MzansiProfileProvider>().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<MihRegister> {
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<MihRegister> {
//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<MihRegister> {
}
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<MihRegister> {
if (_formKey.currentState!.validate()) {
submitFormInput();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
},
@@ -302,7 +301,7 @@ class _MihRegisterState extends State<MihRegister> {
if (_formKey.currentState!.validate()) {
submitFormInput();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihResetPassword> {
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<MihResetPassword> {
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<MihResetPassword> {
if (_formKey.currentState!.validate()) {
submitFormInput();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
},
@@ -212,7 +185,7 @@ class _MihResetPasswordState extends State<MihResetPassword> {
if (_formKey.currentState!.validate()) {
submitFormInput();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -47,12 +47,12 @@ class _MihSignInState extends State<MihSignIn> {
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<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
appName: "Patient",
@@ -100,7 +100,7 @@ class _MihSignInState extends State<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
appName: "Doctor",
@@ -124,7 +124,7 @@ class _MihSignInState extends State<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
appName: "Business",
@@ -147,7 +147,7 @@ class _MihSignInState extends State<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
appName: "Test",
@@ -201,7 +201,7 @@ class _MihSignInState extends State<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
},
@@ -359,7 +359,7 @@ class _MihSignInState extends State<MihSignIn> {
if (_formKey.currentState!.validate()) {
submitSignInForm();
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihHome> {
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<MihHome> {
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark",
),
fontSize: 15,
fontSize: 18,
fontWeight: FontWeight.normal,
),
),

View File

@@ -24,7 +24,7 @@ class MihMineSweeperLeaderBoard extends StatefulWidget {
class _MihMineSweeperLeaderBoardState extends State<MihMineSweeperLeaderBoard> {
TextEditingController filterController = TextEditingController();
bool isLoading = true;
Future<void> initialiseLeaderboard() async {
MihMineSweeperProvider mineSweeperProvider =
context.read<MihMineSweeperProvider>();
@@ -39,10 +39,16 @@ class _MihMineSweeperLeaderBoardState extends State<MihMineSweeperLeaderBoard> {
}
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<MihMineSweeperLeaderBoard> {
return Consumer<MihMineSweeperProvider>(
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<MihMineSweeperLeaderBoard> {
),
),
const SizedBox(height: 10),
mineSweeperProvider.leaderboard!.isEmpty
!isLoading && mineSweeperProvider.leaderboard!.isEmpty
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(

View File

@@ -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<MineSweeperGame> {
// 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<MineSweeperGame> {
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<MineSweeperGame> {
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<MineSweeperGame> {
}
}
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();

View File

@@ -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<AiChat> createState() => _AiChatState();
}
class _AiChatState extends State<AiChat> {
final TextEditingController _modelController = TextEditingController();
final TextEditingController _fontSizeController = TextEditingController();
final TextEditingController _ttsVoiceController = TextEditingController();
final ValueNotifier<bool> _showModelOptions = ValueNotifier(false);
FlutterTts _flutterTts = FlutterTts();
final ValueNotifier<String> _ttsVoiceName = ValueNotifier("");
// bool _ttsOn = false;
String? textStream;
List<Map> _voices = [];
List<String> _voicesString = [];
List<types.Message> _messages = [];
late types.User _user;
late types.User _mihAI;
String systemPromt = "0";
bool _aiThinking = false;
final client = ollama.OllamaClient(
baseUrl: "${AppEnviroment.baseAiUrl}/api",
);
List<ollama.Message> _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<String, dynamic>))
.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<String> aiChatStream =
_generateChatCompletionWithHistoryStream(userMessage, client);
Navigator.of(context).pop();
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return responseWindow(aiChatStream);
},
);
}
Widget responseWindow(
Stream<String> 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("<think>\n\n", "**Thinking:**\n")
.replaceAll("<think>\n", "**Thinking:**\n")
.replaceAll("</think>\n\n", "\n**Answer:**\n"), //message.text,
);
_addMessage(textMessage);
}
Stream<String> _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<Color>(
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<Map>.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<MzansiAiProvider>();
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
_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<Color>(
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."),
],
),
),
),
],
),
);
}
}

View File

@@ -240,7 +240,7 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
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,

View File

@@ -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<MihAddBookmarkAlert> {
Future<void> getFavouriteBusinesses() async {
MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>();
MzansiProfileProvider profileProvider =
context.read<MzansiProfileProvider>();
await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
profileProvider.user!.app_id,
directoryProvider,
);
List<Business> favBus = [];
for (var bus in directoryProvider.bookmarkedBusinesses) {
await MihBusinessDetailsServices()
.getBusinessDetailsByBusinessId(bus.business_id)
.then((business) {
favBus.add(business!);
});
}
directoryProvider.setFavouriteBusinesses(businesses: favBus);
}
Future<void> addBookmark(
MzansiProfileProvider profileProvider, String business_id) async {
showDialog(
@@ -43,7 +65,7 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
"${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<MihAddBookmarkAlert> {
}
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<MihAddBookmarkAlert> {
return Consumer<MzansiProfileProvider>(
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),

View File

@@ -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<MihAddEmployeeWindow> {
"${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<MihAddEmployeeWindow> {
if (isRequiredFieldsCaptured()) {
createBusinessUserAPICall(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihBusinessCard> {
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<MihBusinessCard> {
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<MihBusinessCard> {
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<MihBusinessCard> {
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<MihBusinessCard> {
@override
Widget build(BuildContext context) {
// double screenWidth = MediaQuery.of(context).size.width;
return Consumer<MzansiDirectoryProvider>(
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
Widget? child) {
return Consumer2<MzansiProfileProvider, MzansiDirectoryProvider>(
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<MihBusinessCard> {
double width) async {
if (_isUserSignedIn) {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) => MihReviewBusinessWindow(
business: widget.business,
@@ -725,13 +589,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
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<MihBusinessCard> {
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<MihBusinessCard> {
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"),
),
],
),
);
},
);
}
}

View File

@@ -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<MihDeleteBookmarkAlert> {
Future<void> getFavouriteBusinesses() async {
MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>();
MzansiProfileProvider profileProvider =
context.read<MzansiProfileProvider>();
await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
profileProvider.user!.app_id,
directoryProvider,
);
List<Business> favBus = [];
for (var bus in directoryProvider.bookmarkedBusinesses) {
await MihBusinessDetailsServices()
.getBusinessDetailsByBusinessId(bus.business_id)
.then((business) {
favBus.add(business!);
});
}
directoryProvider.setFavouriteBusinesses(businesses: favBus);
}
Future<void> deleteBookmark(int idbookmarked_businesses) async {
showDialog(
context: context,
@@ -45,7 +69,7 @@ class _MihDeleteBookmarkAlertState extends State<MihDeleteBookmarkAlert> {
"${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<MihDeleteBookmarkAlert> {
}
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),

View File

@@ -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(

View File

@@ -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<MihReviewBusinessWindow> {
final ValueNotifier<int> _counter = ValueNotifier<int>(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<MihReviewBusinessWindow> {
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<MihReviewBusinessWindow> {
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<MihReviewBusinessWindow> {
}
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<MihReviewBusinessWindow> {
directoryProvider,
);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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(

View File

@@ -27,6 +27,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
void editBizProfileWindow(
MzansiProfileProvider mzansiProfileProvider, double width) {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) => MihUpdateBusinessDetailsWindow(width: width),
);

View File

@@ -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<MihBusinessDetailsSetUp> {
if (isFieldsFilled()) {
createBusinessProfileAPICall(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
@@ -97,7 +96,7 @@ class _MihBusinessDetailsSetUpState extends State<MihBusinessDetailsSetUp> {
}
await createBusinessUserAPICall(mzansiProfileProvider);
} else {
MihAlertServices().internetConnectionLost(context);
MihAlertServices().internetConnectionAlert(context);
}
}
@@ -123,10 +122,10 @@ class _MihBusinessDetailsSetUpState extends State<MihBusinessDetailsSetUp> {
"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<MihBusinessDetailsSetUp> {
}
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<MihBusinessDetailsSetUp> {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
},
@@ -784,7 +757,7 @@ class _MihBusinessDetailsSetUpState extends State<MihBusinessDetailsSetUp> {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihBusinessQrCode> {
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,
),
),
),
)
],
),
);
},
);
}

View File

@@ -41,6 +41,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
// showDialog(context: context, builder: (context)=> )
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return MihReviewBusinessWindow(
business: business,

View File

@@ -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<MihMyBusinessUser> {
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<MihMyBusinessUser> {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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(

View File

@@ -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<MihPersonalProfile> {
void editProfileWindow(double width) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Consumer<MzansiProfileProvider>(
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<MihPersonalProfile> {
return Center(
child: Mihloadingcircle(),
);
}
// else if (mzansiProfileProvider.user!.username.isEmpty) {
// editProfileWindow(width);
// }
else {
KenLogger.success(
mzansiProfileProvider.userProfilePicture.toString());
} else {
return MihSingleChildScroll(
child: Padding(
padding:

View File

@@ -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<MihPersonalSettings> {
@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<MzansiProfileProvider>(
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<MzansiProfileProvider>(
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<MihPersonalSettings> {
const SizedBox(height: 10.0),
MihButton(
onPressed: () {
deleteAccountPopUp(context);
deleteAccountPopUp(mzansiProfileProvider, context);
},
buttonColor: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),

View File

@@ -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<BuildLoyaltyCardList> {
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<BuildLoyaltyCardList> {
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<BuildLoyaltyCardList> {
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<BuildLoyaltyCardList> {
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<MzansiWalletProvider>().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<MzansiWalletProvider>().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<MzansiWalletProvider>().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<MzansiWalletProvider>().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<BuildLoyaltyCardList> {
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 {

View File

@@ -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<MihAddCardWindow> {
final ValueNotifier<String> _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<MihAddCardWindow> {
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<MihAddCardWindow> {
);
} else {
MihAlertServices()
.internetConnectionLost(context);
.internetConnectionAlert(context);
}
}
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -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<MihCards> {
}
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,
);
}

View File

@@ -78,6 +78,12 @@ class _BuildPatientsListState extends State<BuildMihPatientSearchList> {
return accessStatus;
}
Future<void> 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<BuildMihPatientSearchList> {
// "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<BuildMihPatientSearchList> {
),
context,
);
refreshMyPatientList(
profileProvider, patientManagerProvider);
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
@@ -380,6 +388,8 @@ class _BuildPatientsListState extends State<BuildMihPatientSearchList> {
),
context,
);
refreshMyPatientList(
profileProvider, patientManagerProvider);
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==

View File

@@ -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<BuildMyPatientListList> {
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<BuildMyPatientListList> {
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<BuildMyPatientListList> {
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,

View File

@@ -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<WaitingRoom> {
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<WaitingRoom> {
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<WaitingRoom> {
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<WaitingRoom> {
addAppointmentCall(
profileProvider, mihCalendarProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -462,71 +461,45 @@ class _WaitingRoomState extends State<WaitingRoom> {
"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,
);
}

View File

@@ -388,10 +388,10 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
AppEnviroment.getEnv(),
context);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -38,7 +38,7 @@ class _MedicineSearchState extends State<MedicineSearch> {
// medicines.forEach((element) => meds.add(element.name));
return medicines;
} else {
MihAlertServices().internetConnectionLost(context);
MihAlertServices().internetConnectionAlert(context);
throw Exception('failed to load medicine');
}
}

View File

@@ -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);
}
}
},

View File

@@ -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<PrescripInput> {
"30"
];
Future<void> generatePerscription() async {
Future<void> generatePerscription(
PatientManagerProvider patManProvider,
) async {
//start loading circle
showDialog(
context: context,
@@ -161,84 +165,25 @@ class _PrescripInputState extends State<PrescripInput> {
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<PrescripInput> {
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<PrescripInput> {
);
}
Widget displayPerscList() {
Widget displayPerscList(PatientManagerProvider patManProvider) {
return Column(
children: [
Container(
@@ -573,9 +518,9 @@ class _PrescripInputState extends State<PrescripInput> {
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<PrescripInput> {
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<PatientManagerProvider>(
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),
],
);
},
);
}
}

View File

@@ -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;

View File

@@ -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<BuildFilesList> {
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;

View File

@@ -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<BuildNotesList> {
"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);

View File

@@ -51,14 +51,18 @@ class _PatientConsultationState extends State<PatientConsultation> {
);
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<PatientConsultation> {
addPatientNoteAPICall(
profileProvider, patManProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -251,72 +255,6 @@ class _PatientConsultationState extends State<PatientConsultation> {
}
}
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();

View File

@@ -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<PatientDocuments> {
if (isFileFieldsFilled()) {
await uploadSelectedFile(patientManagerProvider, selected);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
}
@@ -81,7 +80,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
"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<PatientDocuments> {
if (response == 200) {
await addPatientFileLocationToDB(patientManagerProvider, file);
} else {
MihAlertServices().internetConnectionLost(context);
MihAlertServices().internetConnectionAlert(context);
}
}
@@ -126,9 +125,10 @@ class _PatientDocumentsState extends State<PatientDocuments> {
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<PatientDocuments> {
submitDocUploadForm(patientManagerProvider);
// uploadSelectedFile(selected);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -303,7 +303,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
profileProvider, patientManagerProvider);
//Navigator.pop(context);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(
@@ -496,57 +496,31 @@ class _PatientDocumentsState extends State<PatientDocuments> {
}
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,
);
}

View File

@@ -271,6 +271,7 @@ class _PatientInfoState extends State<PatientInfo> {
void showEditPatientWindow() {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return MihEditPatientDetailsWindow();
});

View File

@@ -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<PatientSetupForm> {
"${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<PatientSetupForm> {
addPatientService(
profileProvider, patientManagerProvider);
} else {
MihAlertServices().inputErrorMessage(context);
MihAlertServices().inputErrorAlert(context);
}
},
buttonColor: MihColors.getGreenColor(

View File

@@ -103,7 +103,6 @@ class _PatientProfileState extends State<PatientProfile> {
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<PatientProfile> {
'mihHome',
);
}
patientManagerProvider.setPatientProfileIndex(0);
patientManagerProvider.setHidePatientDetails(true);
FocusScope.of(context).unfocus();
},
);

View File

@@ -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);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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,

View File

@@ -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 ==========================================================================

View File

@@ -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<void> 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,

View File

@@ -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(

View File

@@ -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;
}
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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 ==========================================================================

View File

@@ -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,
);
}