This commit is contained in:
Hamza-Ayed
2024-06-15 12:47:08 +03:00
parent a13f9254ae
commit 4eb0d46402
59 changed files with 413 additions and 743 deletions

View File

@@ -29,118 +29,123 @@ class CardSeferWalletDriver extends StatelessWidget {
DateTime? lastRequestTime =
box.read(BoxName.lastTimeCaptainWalletCashOut);
if (lastRequestTime == null ||
now.difference(lastRequestTime).inHours >= 24) {
// Update the last request time to now
lastRequestTime = now;
await box.write(
BoxName.lastTimeCaptainWalletCashOut, lastRequestTime);
box.write(BoxName.cvvCode, 1111);
if (double.parse(
Get.find<CaptainWalletController>().totalAmountVisa) >
100) {
Get.defaultDialog(
barrierDismissible: false,
title: 'Do you want to collect your earnings?'.tr,
titleStyle: AppStyle.title,
content: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Total wallet is '.tr,
style: AppStyle.title,
),
const SizedBox(
width: 5,
),
Text(
Get.find<CaptainWalletController>()
.totalAmountVisa,
style: AppStyle.number,
),
],
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Wallet Type'.tr,
style: AppStyle.title,
),
const SizedBox(
width: 5,
),
MyDropDown(),
],
),
Form(
key: captainWalletController.formKey,
child: MyTextForm(
controller: captainWalletController.issurWallet,
label: "Enter your wallet number".tr,
hint: "Enter your wallet number".tr,
type: TextInputType.phone,
// if (lastRequestTime == null ||
// now.difference(lastRequestTime).inHours >= 24) {
// // Update the last request time to now
// lastRequestTime = now;
// await box.write(
// BoxName.lastTimeCaptainWalletCashOut, lastRequestTime);
// box.write(BoxName.cvvCode, 1111);
if (double.parse(
Get.find<CaptainWalletController>().totalAmountVisa) >
100) {
Get.defaultDialog(
barrierDismissible: false,
title: 'Do you want to collect your earnings?'.tr,
titleStyle: AppStyle.title,
content: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Total wallet is '.tr,
style: AppStyle.title,
),
)
],
),
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () async {
if (captainWalletController.formKey.currentState!
.validate()) {
if (double.parse(Get.find<CaptainWalletController>()
.totalAmountVisa) >
100) {
Get.back();
String amountAfter5LE = (double.parse(
Get.find<CaptainWalletController>()
.totalAmountVisa) -
5)
.toStringAsFixed(0);
await Get.put(PaymobPayout())
.payToWalletDriverAll(
amountAfter5LE,
captainWalletController.issurWallet.toString(),
captainWalletController.issurWallet.toString(),
);
} else {
Get.snackbar(
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
'',
backgroundColor: AppColor.yellowColor);
}
const SizedBox(
width: 5,
),
Text(
Get.find<CaptainWalletController>()
.totalAmountVisa,
style: AppStyle.number,
),
],
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Wallet Type'.tr,
style: AppStyle.title,
),
const SizedBox(
width: 5,
),
MyDropDown1(),
],
),
Form(
key: captainWalletController.formKey,
child: MyTextForm(
controller: captainWalletController.phoneWallet,
label: "Enter your wallet number".tr,
hint: "Enter your wallet number".tr,
type: TextInputType.phone,
),
)
],
),
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () async {
if (captainWalletController.formKey.currentState!
.validate()) {
if (double.parse(Get.find<CaptainWalletController>()
.totalAmountVisa) >
100) {
Get.back();
String amountAfter5LE = (double.parse(
Get.find<CaptainWalletController>()
.totalAmountVisa) -
5)
.toStringAsFixed(0);
print(Get.find<PaymobPayout>()
.dropdownValue
.toString());
print(captainWalletController.phoneWallet.text
.toString());
await Get.put(PaymobPayout()).payToWalletDriverAll(
amountAfter5LE,
Get.find<PaymobPayout>().dropdownValue.toString(),
captainWalletController.phoneWallet.text
.toString(),
);
} else {
Get.snackbar(
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
'',
backgroundColor: AppColor.yellowColor);
}
},
kolor: AppColor.greenColor,
),
cancel: MyElevatedButton(
title: 'cancel'.tr,
onPressed: () {
Get.back();
},
kolor: AppColor.redColor,
));
} else {
{
Get.snackbar(
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
'',
backgroundColor: AppColor.yellowColor);
}
}
}
},
kolor: AppColor.greenColor,
),
cancel: MyElevatedButton(
title: 'cancel'.tr,
onPressed: () {
Get.back();
},
kolor: AppColor.redColor,
));
} else {
// Optionally show a message or handle the throttling case
final hoursLeft = 24 - now.difference(lastRequestTime).inHours;
Get.snackbar(
'${'Please wait'.tr} $hoursLeft ${"hours before trying again.".tr}',
'');
{
Get.snackbar(
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
'',
backgroundColor: AppColor.yellowColor);
}
}
// } else {
// // Optionally show a message or handle the throttling case
// final hoursLeft = 24 - now.difference(lastRequestTime).inHours;
// Get.snackbar(
// '${'Please wait'.tr} $hoursLeft ${"hours before trying again.".tr}',
// '');
// }
},
child: Container(
width: Get.width * .85,