This commit is contained in:
Hamza-Ayed
2024-09-19 07:05:19 +03:00
parent a65e7e5562
commit 2e3ce78fe8
12 changed files with 393 additions and 223 deletions

View File

@@ -8,6 +8,7 @@ import 'package:SEFER/controller/payment/payment_controller.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import '../../../main.dart';
import '../../widgets/my_textField.dart';
class PassengerWalletDialog extends StatelessWidget {
const PassengerWalletDialog({
@@ -163,92 +164,137 @@ class PassengerWalletDialog extends StatelessWidget {
},
),
box.read(BoxName.countryCode) == 'Egypt'
? Column(
children: [
MyElevatedButton(
title: '💳 Pay with Credit Card'.tr,
? box.read(BoxName.phoneWallet) != null
? Column(
children: [
MyElevatedButton(
title: '💳 Pay with Credit Card'.tr,
onPressed: () {
if (controller.selectedAmount != 0) {
controller.payWithPayMob(
context,
controller.selectedAmount
.toString(), // Convert int to double
box.read(BoxName.countryCode) ==
'Egypt'
? 'EGP'
: 'JOD',
() async {
await controller
.addPassengerWallet();
controller
.changePromoSheetDialogue();
await controller
.getPassengerWallet();
},
);
} else {
Toast.show(
context,
'⚠️ You need to choose an amount!'
.tr,
AppColor.redColor,
);
}
},
),
// Add some spacing between buttons
MyElevatedButton(
kolor: AppColor.yellowColor,
title: '💰 Pay with Wallet'.tr,
onPressed: () {
if (controller.selectedAmount != 0) {
controller.payWithPayMobWallet(
context,
controller.selectedAmount
.toString(), // Convert int to double
box.read(BoxName.countryCode) ==
'Egypt'
? 'EGP'
: 'JOD',
() async {
await controller
.addPassengerWallet();
controller
.changePromoSheetDialogue();
await controller
.getPassengerWallet();
},
);
} else {
Toast.show(
context,
'⚠️ You need to choose an amount!'
.tr,
AppColor.redColor,
);
}
},
),
],
)
: MyElevatedButton(
title: 'Pay with Credit Card'.tr,
onPressed: () {
if (controller.selectedAmount != 0) {
controller.payWithPayMob(
context,
controller.selectedAmount
.toString(), // Convert int to double
box.read(BoxName.countryCode) ==
'Egypt'
? 'EGP'
: 'JOD',
() async {
await controller
.addPassengerWallet();
controller
.changePromoSheetDialogue();
await controller
.getPassengerWallet();
},
);
controller.makePaymentStripe(
controller.selectedAmount!
.toDouble(), // Convert int to double
box.read(BoxName.countryCode) !=
'Egypt'
? 'usd'
: 'jod', () {
controller.addPassengerWallet();
controller.changePromoSheetDialogue();
controller.getPassengerWallet();
});
} else {
Toast.show(
context,
'⚠️ You need to choose an amount!'.tr,
AppColor.redColor,
);
context,
'You will choose one of above !'.tr,
AppColor.redColor);
}
},
),
// Add some spacing between buttons
MyElevatedButton(
kolor: AppColor.yellowColor,
title: '💰 Pay with Wallet'.tr,
onPressed: () {
if (controller.selectedAmount != 0) {
controller.payWithPayMobWallet(
context,
controller.selectedAmount
.toString(), // Convert int to double
box.read(BoxName.countryCode) ==
'Egypt'
? 'EGP'
: 'JOD',
() async {
await controller
.addPassengerWallet();
controller
.changePromoSheetDialogue();
await controller
.getPassengerWallet();
},
);
} else {
Toast.show(
context,
'⚠️ You need to choose an amount!'.tr,
AppColor.redColor,
);
}
},
),
],
)
})
: MyElevatedButton(
title: 'Pay with Credit Card'.tr,
kolor: AppColor.deepPurpleAccent,
title: "Add wallet phone you use".tr,
onPressed: () {
if (controller.selectedAmount != 0) {
controller.makePaymentStripe(
controller.selectedAmount!
.toDouble(), // Convert int to double
box.read(BoxName.countryCode) != 'Egypt'
? 'usd'
: 'jod', () {
controller.addPassengerWallet();
controller.changePromoSheetDialogue();
controller.getPassengerWallet();
});
} else {
Toast.show(
context,
'You will choose one of above !'.tr,
AppColor.redColor);
}
Get.defaultDialog(
barrierDismissible: false,
title: 'Insert Wallet phone number'.tr,
content: Form(
key: controller.formKey,
child: MyTextForm(
controller: controller
.walletphoneController,
label:
'Insert Wallet phone number'
.tr,
hint: 'Insert Wallet phone number'
.tr,
type: TextInputType.phone)),
confirm: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'OK'.tr,
onPressed: () async {
Get.back();
box.write(
BoxName.phoneWallet,
controller
.walletphoneController.text);
Toast.show(
context,
'Phone Wallet Saved Successfully'
.tr,
AppColor.greenColor);
},
),
cancel: MyElevatedButton(
title: 'Cancel'.tr,
kolor: AppColor.redColor,
onPressed: () {
Get.back();
}));
}),
MyElevatedButton(
title: 'Cancel'.tr,