Merge branch 'wala_plus_with_dialog_removal' of http://34.17.182.140/Haroon6138/mohemm-flutter-app into wala_plus_with_dialog_removal

* 'wala_plus_with_dialog_removal' of http://34.17.182.140/Haroon6138/mohemm-flutter-app:
  Toast fixed
wala_plus_with_dialog_removal
Sultan khan 2 weeks ago
commit c957d547a8

@ -33,10 +33,20 @@ class Utils {
// longDuration is accepted but no longer varies the duration - every caller already used the
// default (true), so AppToast.plainSeconds covers both cases with one fixed value.
// Soft red bg + red text - same combo already used elsewhere in the app for
// expired/inactive-style chips (e.g. dependent_details_screen.dart's "Access Off" badge).
static void showToast(String message, {bool longDuration = true}) {
AppToast.show( message, seconds: AppToast.plainSeconds, showIcon: false, showCountdownText: true, bgColor: const Color(0xFFF1CECE), textColor: const Color(0xFFC53030));
// isSuccess: true -> soft green/green (same combo as dependent_details_screen.dart's "Active"
// badge); false (default) -> soft red/red (same combo as that screen's "Access Off" badge).
// Callers showing a value straight from an API response should pass isSuccess: response's
// MessageStatus == 1; everywhere else (validation messages, caught errors) just defaults to
// red, and the handful of hardcoded success confirmations pass isSuccess: true explicitly.
static void showToast(String message, {bool longDuration = true, bool isSuccess = false}) {
AppToast.show(
message,
seconds: AppToast.plainSeconds,
showIcon: false,
showCountdownText: true,
bgColor: isSuccess ? const Color(0xFFECFDF5) : const Color(0xFFF1CECE),
textColor: isSuccess ? const Color(0xFF059669) : const Color(0xFFC53030),
);
}
static dynamic getNotNullValue(List<dynamic> list, int index) {

@ -216,7 +216,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
CreateVacationRuleList? createVacationRuleList = await VacationRuleApiClient().createVacationRule(DateUtil.convertDateToStringLocation(startTime), DateUtil.convertDateToStringLocation(endTime!),
selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!, message, getPAction(), selectedReplacementEmployee!.userName!, respondAttributeList);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.vacationRuleAdded.tr());
Utils.showToast(LocaleKeys.vacationRuleAdded.tr(), isSuccess: true);
Navigator.popUntil(context, ModalRoute.withName(AppRoutes.dashboard));
} catch (ex) {
Utils.hideLoading(context);

@ -306,10 +306,12 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
sortBy: _filterSortBy,
radius: radiusParam,
minDiscount: minDiscountParam,
// Same as getWalaPlusRetailerById: always pass context whenever we have one so
// WP_Geo_Location is attempted - don't gate it on wantsNearest, that only matters for
// whether we block the fetch to prompt for permission first (see the gate above).
context: context,
// _getCurrentPositionSilently (triggered whenever context is non-null) isn't actually
// silent - it calls Geolocator.requestPermission() if permission hasn't been
// granted/denied yet, which pops the real OS permission dialog. Only pass context when
// Nearest is actually selected, otherwise every fetch (including the default newest-sort
// load on app start) would trigger that prompt for no reason.
context: wantsNearest ? context : null,
);
retailersList = response?.retailers ?? <WalaPlusRetailerModel>[];
@ -366,7 +368,7 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
sortBy: _filterSortBy,
radius: radiusParam,
minDiscount: minDiscountParam,
context: context,
context: wantsNearest ? context : null,
);
List<WalaPlusRetailerModel> newRetailers = response?.retailers ?? [];

@ -41,7 +41,7 @@ class _ChangeItgAdPasswordScreenState extends State<ChangeItgAdPasswordScreen> {
GenericResponseModel response = await LoginApiClient().changePasswordFromActiveDirectorySession(password.text, AppState().memberInformationList!.eMPLOYEEEMAILADDRESS!);
Utils.hideLoading(context);
if ((response.messageStatus ?? 0) == 1) {
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr());
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr(), isSuccess: true);
Navigator.pop(context);
}
} catch (ex) {

@ -222,7 +222,7 @@ class _SurveyScreenState extends State<SurveyScreen> {
Utils.hideLoading(context);
if (res!.mohemmItgResponseItem!.statusCode == 200) {
Utils.showToast("Survey has been submitted successfully");
Utils.showToast("Survey has been submitted successfully", isSuccess: true);
Navigator.pop(context);
} else {
Utils.showToast(res.mohemmItgResponseItem!.message.toString());

@ -112,11 +112,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
try {
debugPrint("WalaPlusRetailerDetailsScreen: fetching details for retailer ID: $_effectiveRetailerId");
WalaPlusRetailerModel? result = await OffersAndDiscountsApiClient().getWalaPlusRetailerById(
retailerId: _effectiveRetailerId!,
context: context,
userReference: _effectiveUserReference,
);
WalaPlusRetailerModel? result = await OffersAndDiscountsApiClient().getWalaPlusRetailerById(retailerId: _effectiveRetailerId!, context: context, userReference: _effectiveUserReference);
if (result != null && mounted) {
if ((result.image == null || result.image!.isEmpty || result.image == "null") && _retailer?.image != null) {
result.image = _retailer!.image;
@ -230,17 +226,9 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
bool targetFavorite = !_isFavorite;
GenericResponseModel? response;
if (targetFavorite) {
response = await OffersAndDiscountsApiClient().addWalaPlusFavorite(
retailerId: retailerId,
context: context,
userReference: _effectiveUserReference,
);
response = await OffersAndDiscountsApiClient().addWalaPlusFavorite(retailerId: retailerId, context: context, userReference: _effectiveUserReference);
} else {
response = await OffersAndDiscountsApiClient().removeWalaPlusFavorite(
retailerId: retailerId,
context: context,
userReference: _effectiveUserReference,
);
response = await OffersAndDiscountsApiClient().removeWalaPlusFavorite(retailerId: retailerId, context: context, userReference: _effectiveUserReference);
}
Utils.hideLoading(context);
@ -262,7 +250,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
msg = targetFavorite ? LocaleKeys.favoriteAddedSuccess.tr() : LocaleKeys.favoriteRemovedSuccess.tr();
}
}
Utils.showToast(msg);
Utils.showToast(msg, isSuccess: true);
} else {
String error = response?.errorEndUserMessage ?? response?.errorMessage ?? LocaleKeys.favoriteError.tr();
Utils.showToast(error);
@ -684,11 +672,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
child: IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: Icon(
_isFavorite ? Icons.favorite_rounded : Icons.favorite_border_rounded,
size: 22,
color: _isFavorite ? Colors.black : const Color(0xFF1E293B),
),
icon: Icon(_isFavorite ? Icons.favorite_rounded : Icons.favorite_border_rounded, size: 22, color: _isFavorite ? Colors.black : const Color(0xFF1E293B)),
tooltip: LocaleKeys.favorite.tr(),
onPressed: _isTogglingFavorite ? null : _toggleFavorite,
),
@ -705,7 +689,7 @@ class _WalaPlusRetailerDetailsScreenState extends State<WalaPlusRetailerDetailsS
14.height,
InkWell(
onTap: _openMerchantWebsite,
child: LocaleKeys.visitMerchantWebsite.tr().toText14(color: const Color(0xFF0D9488), isUnderLine: true, weight: FontWeight.w600),
child: LocaleKeys.visitMerchantWebsite.tr().toText14(color: const Color(0xFF0D9488), isUnderLine: true, weight: FontWeight.w600),
),
],
10.height,

@ -39,7 +39,7 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
try {
var genericResponseModel = await LoginApiClient().changePasswordFromActiveSession(oldPassword.text, password.text, confirmPassword.text);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr());
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr(), isSuccess: true);
Navigator.pop(context);
} catch (ex) {
Utils.hideLoading(context);

@ -791,7 +791,7 @@ class _LoginScreenState extends State<LoginScreen> {
try {
await LoginApiClient().mohemmSendOTPDependent(nationalId: nationalId.text.trim(), mobileNumber: mobileNumber, logInTokenID: logInTokenID, context: context);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.verificationCodeResent.tr());
Utils.showToast(LocaleKeys.verificationCodeResent.tr(), isSuccess: true);
_showDependentOtpDialog(logInTokenID, mobileNumber);
} catch (ex) {
Utils.hideLoading(context);

@ -41,7 +41,7 @@ class _NewPasswordScreenState extends State<NewPasswordScreen> {
try {
var genericResponseModel = await LoginApiClient().changePasswordForget(AppState().getForgetPasswordTokenID ?? "", password.text, confirmPassword.text, userName);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr());
Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr(), isSuccess: true);
Navigator.pop(context);
} catch (ex) {
print(ex);

@ -145,7 +145,7 @@ class _RequestSubmitScreenState extends State<RequestSubmitScreen> {
);
} else {}
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourRequestHasBeenSubmittedForApprovals.tr(), longDuration: true);
Utils.showToast(LocaleKeys.yourRequestHasBeenSubmittedForApprovals.tr(), longDuration: true, isSuccess: true);
AppState().cancelRequestTrancsection = false;
if (params?.popNavigateToSpecificRoute == null) {

@ -1827,7 +1827,7 @@ class _AddDependentVerifyScreenState extends State<AddDependentVerifyScreen> {
Utils.hideLoading(context);
Navigator.pop(context);
} else {
Utils.showToast(LocaleKeys.dependentAddedSuccessfully.tr());
Utils.showToast(LocaleKeys.dependentAddedSuccessfully.tr(), isSuccess: true);
Navigator.pop(context);
}
} catch (ex) {

@ -529,7 +529,7 @@ class MazayaAccessResultScreen extends StatelessWidget {
LocaleKeys.copyLink.tr(),
() {
Clipboard.setData(ClipboardData(text: _buildMazayaInviteMessage(linkToShare, nationalId, dateOfBirth)));
Utils.showToast(LocaleKeys.linkCopied.tr());
Utils.showToast(LocaleKeys.linkCopied.tr(), isSuccess: true);
},
colors: const <Color>[Colors.white, Colors.white],
border: Border.all(color: const Color(0xFFCBD5E1)),

@ -146,7 +146,7 @@ class _ItemReviewFragmentState extends State<ItemReviewFragment> {
Utils.showLoading(context);
String message = await ItemsForSaleApiClient().addItemForSale(itemReviewModel!, imagesList);
Utils.hideLoading(context);
Utils.showToast(message);
Utils.showToast(message, isSuccess: true);
Navigator.of(context).pop();
setState(() {});
} catch (ex) {

@ -382,7 +382,7 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
}
int? messageStatus = await MowadhafhiApiClient().submitRequest(selectedDepartment?.projectDepartmentId, description, projectID, selectedSection?.departmentSectionId.toString(),
selectedTopic?.sectionTopicId.toString(), selectedServiceType!.ticketTypeId, list);
Utils.showToast(LocaleKeys.requestCreatedSuccessfully.tr());
Utils.showToast(LocaleKeys.requestCreatedSuccessfully.tr(), isSuccess: true);
Utils.hideLoading(context);
Navigator.pop(context);
} catch (ex) {

@ -480,7 +480,7 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
AppState().memberInformationList?.eMPLOYEEEMAILADDRESS ?? "",
);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
// Navigator.pop(context, "delegate_reload");
AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!);
if (AppState().requestAllList!.isEmpty) {
@ -504,7 +504,7 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
Utils.showLoading(context);
ITGRequest? itgRequest = await WorkListApiClient().answerITGRequest(requestType, taskId, itemId, employeeNumber, "", comments);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
// Navigator.pop(context, "delegate_reload");
AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!);
if (AppState().requestAllList!.isEmpty) {
@ -528,7 +528,7 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
Utils.showLoading(context);
ITGRequest? itgRequest = await WorkListApiClient().rejectITGRequest(requestType, taskId, itemId, employeeNumber, comments);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
// Navigator.pop(context, "delegate_reload");
AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!);
if (AppState().requestAllList!.isEmpty) {
@ -552,7 +552,7 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
Utils.showLoading(context);
ITGRequest? itgRequest = await WorkListApiClient().approveITGRequest(requestType, taskId, itemId, employeeNumber, comments);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
// Navigator.pop(context, "delegate_reload");
animationIndex = animationIndex + 1;
AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!);
@ -578,7 +578,7 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
animationIndex = animationIndex + 1;
ITGRequest? itgRequest = await WorkListApiClient().grantITGRequest(requestType, taskId, itemId, employeeNumber, "", "");
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!);
if (AppState().requestAllList!.isEmpty) {

@ -742,7 +742,7 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
Utils.showLoading(context);
GenericResponseModel model = await WorkListApiClient().postNotificationActions(payload);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr(), isSuccess: true);
animationIndex = animationIndex + 1;
AppState().workList!.removeAt(AppState().workListIndex!);
if (AppState().workList!.isEmpty) {

Loading…
Cancel
Save