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

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