Initial commit
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/toast.dart';
|
||||
@@ -8,7 +8,6 @@ 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({
|
||||
@@ -19,294 +18,198 @@ class PassengerWalletDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<PaymentController>(
|
||||
builder: (controller) => Positioned(
|
||||
top: Get.height * .1,
|
||||
right: Get.width * .15,
|
||||
left: Get.width * .15,
|
||||
bottom: Get.height * .1,
|
||||
child: controller.isPromoSheetDialogue
|
||||
? Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
color: AppColor.secondaryColor,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.accentColor,
|
||||
offset: Offset(-1, -1),
|
||||
blurRadius: 0,
|
||||
spreadRadius: 0,
|
||||
blurStyle: BlurStyle.normal),
|
||||
BoxShadow(
|
||||
color: AppColor.accentColor,
|
||||
offset: Offset(3, 3),
|
||||
blurRadius: 1,
|
||||
spreadRadius: 0,
|
||||
blurStyle: BlurStyle.normal)
|
||||
]),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
controller.updateSelectedAmount(10);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value: box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 100
|
||||
: 10,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller.updateSelectedAmount(value as int);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '100 ${'LE'.tr}'.tr
|
||||
: '10 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
top: Get.height * .1,
|
||||
right: Get.width * .15,
|
||||
left: Get.width * .15,
|
||||
bottom: Get.height * .1,
|
||||
child: controller.isPromoSheetDialogue
|
||||
? CupertinoActionSheet(
|
||||
title: Text('Select Payment Amount'.tr),
|
||||
actions: [
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Egypt' ? 100 : 10,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '100 ${'LE'.tr}'
|
||||
: '10 ${'JOD'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Egypt' ? 200 : 20,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '200 ${'LE'.tr} = 205 ${'LE'.tr}'
|
||||
: '20 ${'JOD'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Egypt' ? 400 : 40,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '400 ${'LE'.tr} = 415 ${'LE'.tr}'
|
||||
: '40 ${'JOD'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Egypt' ? 1000 : 50,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '1000 ${'LE'.tr} = 1100 ${'LE'.tr}'
|
||||
: '50 ${'JOD'.tr}',
|
||||
),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.changePromoSheetDialogue();
|
||||
},
|
||||
child: Text('Cancel'.tr),
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void showPaymentOptions(BuildContext context, PaymentController controller) {
|
||||
showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: Text('Payment Options'.tr),
|
||||
actions: [
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? CupertinoActionSheetAction(
|
||||
child: Text('💳 Pay with Credit Card'.tr),
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.payWithPayMob(
|
||||
context,
|
||||
controller.selectedAmount.toString(),
|
||||
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);
|
||||
}
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
box.read(BoxName.countryCode) != 'Egypt'
|
||||
? CupertinoActionSheetAction(
|
||||
child: Text('Pay with PayPal'.tr),
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.makePaymentPayPal(context);
|
||||
} else {
|
||||
Toast.show(context, 'You will choose one of above!'.tr,
|
||||
AppColor.redColor);
|
||||
}
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
box.read(BoxName.phoneWallet) != null
|
||||
? CupertinoActionSheetAction(
|
||||
child: Text('💰 Pay with Wallet'.tr),
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.payWithPayMobWallet(
|
||||
context,
|
||||
controller.selectedAmount.toString(),
|
||||
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);
|
||||
}
|
||||
},
|
||||
)
|
||||
: CupertinoActionSheetAction(
|
||||
child: Text('Add wallet phone you use'.tr),
|
||||
onPressed: () {
|
||||
Get.dialog(
|
||||
CupertinoAlertDialog(
|
||||
title: Text('Insert Wallet phone number'.tr),
|
||||
content: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
CupertinoTextField(
|
||||
controller: controller.walletphoneController,
|
||||
placeholder: 'Insert Wallet phone number'.tr,
|
||||
keyboardType: TextInputType.phone,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
horizontal: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
controller.updateSelectedAmount(20);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 210
|
||||
: 20,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
.updateSelectedAmount(value as int);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '${'200 ${'LE'.tr} '.tr} = 205 ${'LE'.tr}'
|
||||
: '20 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
controller.updateSelectedAmount(40);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 415
|
||||
: 40,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
.updateSelectedAmount(value as int);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '${'400 ${'LE'.tr} '.tr} = 415 ${'LE'.tr}'
|
||||
: '40 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
controller.updateSelectedAmount(100);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 1100
|
||||
: 50,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
.updateSelectedAmount(value as int);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '${'1000 ${'LE'.tr} '.tr} = 1100 ${'LE'.tr}'
|
||||
: '50 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
)),
|
||||
const Spacer(),
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? const SizedBox()
|
||||
: MyElevatedButton(
|
||||
kolor: AppColor.blueColor,
|
||||
title: '${'Pay with Your'.tr} PayPal',
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.makePaymentPayPal(context);
|
||||
} else {
|
||||
Toast.show(
|
||||
context,
|
||||
'You will choose one of above !'.tr,
|
||||
AppColor.redColor);
|
||||
}
|
||||
},
|
||||
),
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 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.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);
|
||||
}
|
||||
})
|
||||
: MyElevatedButton(
|
||||
kolor: AppColor.deepPurpleAccent,
|
||||
title: "Add wallet phone you use".tr,
|
||||
onPressed: () {
|
||||
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,
|
||||
kolor: AppColor.redColor,
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text('Cancel'.tr,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.destructiveRed)),
|
||||
onPressed: () {
|
||||
controller.changePromoSheetDialogue();
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text('OK'.tr,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.activeGreen)),
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
box.write(BoxName.phoneWallet,
|
||||
controller.walletphoneController.text);
|
||||
Toast.show(
|
||||
context,
|
||||
'Phone Wallet Saved Successfully'.tr,
|
||||
AppColor.greenColor);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
))
|
||||
: const SizedBox()),
|
||||
);
|
||||
}
|
||||
barrierDismissible: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: Text('Cancel'.tr),
|
||||
onPressed: () {
|
||||
controller.changePromoSheetDialogue();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user