BASE: Initialize Localization.

This commit is contained in:
2025-12-03 18:21:19 +05:00
parent cf58d069ab
commit b04050384d
141 changed files with 1577 additions and 1419 deletions

View File

@@ -5,6 +5,7 @@ import 'dart:math' as maths;
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:customer/models/coupon_model.dart';
import 'package:customer/models/wallet_transaction_model.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_paypal/flutter_paypal.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
@@ -135,7 +136,7 @@ class ParcelOrderConfirmationController extends GetxController {
}
Future<void> placeOrder() async {
ShowToastDialog.showLoader("Please wait...".tr);
ShowToastDialog.showLoader("Please wait...".tr());
try {
List<String> parcelImages = [];
@@ -206,7 +207,7 @@ class ParcelOrderConfirmationController extends GetxController {
value,
) async {
ShowToastDialog.closeLoader();
ShowToastDialog.showToast("Order placed successfully".tr);
ShowToastDialog.showToast("Order placed successfully".tr());
Get.offAll(
() => OrderSuccessfullyPlaced(),
arguments: {'parcelOrder': parcelOrder.value},
@@ -215,7 +216,7 @@ class ParcelOrderConfirmationController extends GetxController {
});
} catch (e) {
ShowToastDialog.closeLoader();
ShowToastDialog.showToast("Something went wrong. Please try again.".tr);
ShowToastDialog.showToast("Something went wrong. Please try again.".tr());
}
}
@@ -323,7 +324,7 @@ class ParcelOrderConfirmationController extends GetxController {
if (paymentIntentData!.containsKey("error")) {
Get.back();
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr,
"Something went wrong, please contact admin.".tr(),
);
} else {
await Stripe.instance.initPaymentSheet(
@@ -356,7 +357,7 @@ class ParcelOrderConfirmationController extends GetxController {
Future<void> displayStripePaymentSheet({required String amount}) async {
try {
await Stripe.instance.presentPaymentSheet().then((value) {
ShowToastDialog.showToast("Payment successfully".tr);
ShowToastDialog.showToast("Payment successfully".tr());
placeOrder();
});
} on StripeException catch (e) {
@@ -439,10 +440,10 @@ class ParcelOrderConfirmationController extends GetxController {
final data = jsonDecode(response.body);
Get.to(MercadoPagoScreen(initialURl: data['init_point']))!.then((value) {
if (value) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
} else {
ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
}
});
} else {
@@ -479,17 +480,17 @@ class ParcelOrderConfirmationController extends GetxController {
onSuccess: (Map params) async {
debugPrint("✅ PayPal Payment Success: $params");
placeOrder();
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
},
onError: (error) {
debugPrint("❌ PayPal Payment Error: $error");
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
},
onCancel: (params) {
debugPrint("⚠️ PayPal Payment Canceled: $params");
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
},
),
),
@@ -520,15 +521,15 @@ class ParcelOrderConfirmationController extends GetxController {
// note: "Contact us for any questions on your order.",
// onSuccess: (Map params) async {
// placeOrder();
// ShowToastDialog.showToast("Payment Successful!!".tr);
// ShowToastDialog.showToast("Payment Successful!!".tr());
// },
// onError: (error) {
// Get.back();
// ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
// ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
// },
// onCancel: (params) {
// Get.back();
// ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
// ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
// },
// ),
// ),
@@ -558,15 +559,15 @@ class ParcelOrderConfirmationController extends GetxController {
),
)!.then((value) {
if (value) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
} else {
ShowToastDialog.showToast("Payment UnSuccessful!!".tr);
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
}
});
} else {
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr,
"Something went wrong, please contact admin.".tr(),
);
}
});
@@ -613,10 +614,10 @@ class ParcelOrderConfirmationController extends GetxController {
bool isVerified = await verifyFlutterWavePayment(_ref!);
if (isVerified) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
} else {
ShowToastDialog.showToast("Payment Unsuccessful!!".tr);
ShowToastDialog.showToast("Payment Unsuccessful!!".tr());
Get.back();
}
});
@@ -675,11 +676,11 @@ class ParcelOrderConfirmationController extends GetxController {
);
if (isDone) {
Get.back();
ShowToastDialog.showToast("Payment successfully".tr);
ShowToastDialog.showToast("Payment successfully".tr());
placeOrder();
} else {
Get.back();
ShowToastDialog.showToast("Payment Failed".tr);
ShowToastDialog.showToast("Payment Failed".tr());
}
});
}
@@ -832,7 +833,7 @@ class ParcelOrderConfirmationController extends GetxController {
data["body"]["txnToken"].toString().isEmpty) {
Get.back();
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr,
"Something went wrong, please contact admin.".tr(),
);
}
@@ -865,7 +866,7 @@ class ParcelOrderConfirmationController extends GetxController {
// final data = jsonDecode(response.body);
// if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) {
// Get.back();
// ShowToastDialog.showToast("something went wrong, please contact admin.".tr);
// ShowToastDialog.showToast("something went wrong, please contact admin.".tr());
// }
// return GetPaymentTxtTokenModel.fromJson(data);
// }
@@ -901,18 +902,18 @@ class ParcelOrderConfirmationController extends GetxController {
void handlePaymentSuccess(PaymentSuccessResponse response) {
Get.back();
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
}
void handleExternalWaller(ExternalWalletResponse response) {
Get.back();
ShowToastDialog.showToast("Payment Processing!! via".tr);
ShowToastDialog.showToast("Payment Processing!! via".tr());
}
void handlePaymentError(PaymentFailureResponse response) {
Get.back();
ShowToastDialog.showToast("Payment Failed!!".tr);
ShowToastDialog.showToast("Payment Failed!!".tr());
}
bool isCurrentDateInRange(DateTime startDate, DateTime endDate) {
@@ -930,10 +931,10 @@ class ParcelOrderConfirmationController extends GetxController {
if (url != '') {
Get.to(() => MidtransScreen(initialURl: url))!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
} else {
ShowToastDialog.showToast("Payment Unsuccessful!!".tr);
ShowToastDialog.showToast("Payment Unsuccessful!!".tr());
}
});
}
@@ -974,7 +975,7 @@ class ParcelOrderConfirmationController extends GetxController {
return responseData['payment_url'];
} else {
ShowToastDialog.showToast(
"something went wrong, please contact admin.".tr,
"something went wrong, please contact admin.".tr(),
);
return '';
}
@@ -1001,7 +1002,7 @@ class ParcelOrderConfirmationController extends GetxController {
debugPrint('🟩 Starting OrangePay Payment...');
debugPrint('💰 Amount: $amount | 🆔 Order ID: $id');
ShowToastDialog.showLoader("Initializing payment...".tr);
ShowToastDialog.showLoader("Initializing payment...".tr());
var paymentURL = await fetchToken(
context: context,
@@ -1026,20 +1027,20 @@ class ParcelOrderConfirmationController extends GetxController {
),
)?.then((value) async {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
debugPrint('🎉 Payment Successful for Order ID: $orderId');
if (Get.isBottomSheetOpen ?? false) Get.back();
await placeOrder();
} else {
ShowToastDialog.showToast("Payment Unsuccessful!!".tr);
ShowToastDialog.showToast("Payment Unsuccessful!!".tr());
debugPrint('⚠️ Payment flow closed without success.');
if (Get.isBottomSheetOpen ?? false) Get.back();
}
});
} else {
ShowToastDialog.showToast("Payment Unsuccessful!!".tr);
ShowToastDialog.showToast("Payment Unsuccessful!!".tr());
if (Get.isBottomSheetOpen ?? false) Get.back();
}
}
@@ -1085,7 +1086,7 @@ class ParcelOrderConfirmationController extends GetxController {
} else {
debugPrint('❌ Failed to fetch access token.');
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr,
"Something went wrong, please contact admin.".tr(),
);
return '';
}
@@ -1151,7 +1152,7 @@ class ParcelOrderConfirmationController extends GetxController {
} else {
debugPrint('❌ Payment request failed.');
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr,
"Something went wrong, please contact admin.".tr(),
);
return '';
}
@@ -1178,11 +1179,11 @@ class ParcelOrderConfirmationController extends GetxController {
),
)!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr);
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
();
} else {
ShowToastDialog.showToast("Payment Unsuccessful!!".tr);
ShowToastDialog.showToast("Payment Unsuccessful!!".tr());
}
});
}