201 lines
8.1 KiB
Dart
201 lines
8.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../constant/box_name.dart';
|
|
import '../../../constant/colors.dart';
|
|
import '../../../constant/info.dart';
|
|
import '../../../constant/style.dart';
|
|
import '../../../controller/home/payment/captain_wallet_controller.dart';
|
|
import '../../../controller/home/payment/paymob_payout.dart';
|
|
import '../../../main.dart';
|
|
import '../../widgets/elevated_btn.dart';
|
|
import '../../widgets/my_textField.dart';
|
|
import 'walet_captain.dart';
|
|
|
|
class CardSeferWalletDriver extends StatelessWidget {
|
|
const CardSeferWalletDriver({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
GetBuilder<CaptainWalletController>(builder: (captainWalletController) {
|
|
return InkWell(
|
|
onTap: () async {
|
|
final now = DateTime.now();
|
|
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,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
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);
|
|
}
|
|
}
|
|
},
|
|
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);
|
|
}
|
|
}
|
|
} 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,
|
|
height: Get.height * .25,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.deepPurpleAccent,
|
|
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
|
gradient: const LinearGradient(
|
|
colors: [AppColor.blueColor, AppColor.primaryColor]),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text(
|
|
'${AppInformation.appName} Wallet',
|
|
style: AppStyle.headTitle
|
|
.copyWith(color: AppColor.primaryColor),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'${Get.find<CaptainWalletController>().totalAmountVisa}\$' ??
|
|
'0.0 \$',
|
|
style: AppStyle.headTitle2,
|
|
)
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
box.read(BoxName.nameDriver),
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
"Cash Out".tr,
|
|
style: AppStyle.title,
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
],
|
|
);
|
|
}
|
|
}
|