353 lines
17 KiB
Dart
353 lines
17 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
import 'package:ride/constant/links.dart';
|
|
import 'package:ride/constant/style.dart';
|
|
import 'package:ride/controller/functions/crud.dart';
|
|
import 'package:ride/controller/functions/toast.dart';
|
|
import 'package:ride/controller/payment/payment_controller.dart';
|
|
import 'package:ride/views/widgets/my_scafold.dart';
|
|
import 'package:flutter_paypal/flutter_paypal.dart';
|
|
import '../../../constant/box_name.dart';
|
|
import '../../../constant/colors.dart';
|
|
import '../../../constant/info.dart';
|
|
import '../../../controller/functions/secure_storage.dart';
|
|
import '../../../controller/home/payment/credit_card_controller.dart';
|
|
import '../../../main.dart';
|
|
import '../../widgets/elevated_btn.dart';
|
|
import '../map_widget.dart/payment_method.page.dart';
|
|
|
|
class PassengerWallet extends StatelessWidget {
|
|
const PassengerWallet({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Get.put(PaymentController());
|
|
Get.put(CreditCardController());
|
|
return MyScafolld(
|
|
title: 'My Wallet',
|
|
isleading: true,
|
|
body: [
|
|
GetBuilder<PaymentController>(
|
|
builder: (controller) => Column(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
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(10),
|
|
child:
|
|
box.read(BoxName.passengerWalletTotal) == null
|
|
? Text(
|
|
'You Dont Have Any amount in'.tr +
|
|
' ${AppInformation.appName}' +
|
|
'Wallet!'.tr,
|
|
style: AppStyle.title,
|
|
)
|
|
: Text(
|
|
'You Have'.tr +
|
|
' ${box.read(BoxName.passengerWalletTotal).toString()} JD in ${AppInformation.appName} Wallet',
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 30,
|
|
),
|
|
const CreditCardWidget(),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
GetBuilder<CreditCardController>(
|
|
builder: (creditCardController) => Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
MyElevatedButton(
|
|
title: 'Save Credit Card'.tr,
|
|
onPressed: () async {
|
|
if (controller.formKey.currentState!
|
|
.validate()) {
|
|
SecureStorage().saveData(
|
|
BoxName.cardNumber,
|
|
creditCardController
|
|
.cardNumberController.text);
|
|
SecureStorage().saveData(
|
|
BoxName.cardHolderName,
|
|
creditCardController
|
|
.cardHolderNameController.text);
|
|
SecureStorage().saveData(
|
|
BoxName.cvvCode,
|
|
creditCardController
|
|
.cvvCodeController.text);
|
|
SecureStorage().saveData(
|
|
BoxName.expiryDate,
|
|
creditCardController
|
|
.expiryDateController.text);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
)),
|
|
// MyElevatedButton(
|
|
// title: 'Charge your Wallet',
|
|
// onPressed: () {
|
|
// Get.defaultDialog(
|
|
// title: 'Choose amount you will Charge?'.tr,
|
|
// content: Column(
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
// children: [
|
|
// Row(
|
|
// children: [
|
|
// Radio(
|
|
// value: 10,
|
|
// groupValue: controller.selectedAmount,
|
|
// onChanged: (value) {
|
|
// controller.selectedAmount =
|
|
// value as String?;
|
|
// },
|
|
// ),
|
|
// Text('10 and get 4% discount'.tr),
|
|
// ],
|
|
// ),
|
|
// Row(
|
|
// children: [
|
|
// Radio(
|
|
// value: 20,
|
|
// groupValue: controller.selectedAmount,
|
|
// onChanged: (value) {
|
|
// controller.selectedAmount =
|
|
// value as String?;
|
|
// },
|
|
// ),
|
|
// Text('20 and get 6% discount'.tr),
|
|
// ],
|
|
// ),
|
|
// Row(
|
|
// children: [
|
|
// Radio(
|
|
// value: 40,
|
|
// groupValue: controller.selectedAmount,
|
|
// onChanged: (value) {
|
|
// controller.selectedAmount =
|
|
// value as String?;
|
|
// },
|
|
// ),
|
|
// Text('40 and get 8% discount'.tr),
|
|
// ],
|
|
// ),
|
|
// Row(
|
|
// children: [
|
|
// Radio(
|
|
// value: 100,
|
|
// groupValue: controller.selectedAmount,
|
|
// onChanged: (value) {
|
|
// controller.selectedAmount =
|
|
// value as String?;
|
|
// },
|
|
// ),
|
|
// Text('100 and get 11% discount'.tr),
|
|
// ],
|
|
// ),
|
|
// ],
|
|
// ));
|
|
// },
|
|
// )
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GetBuilder<PaymentController>(
|
|
builder: (controller) => controller.isPromoSheetDialogue
|
|
? Container(
|
|
color: AppColor.accentColor.withOpacity(.91),
|
|
)
|
|
: const SizedBox()),
|
|
GetBuilder<PaymentController>(
|
|
builder: (controller) => Positioned(
|
|
bottom: Get.height * .3,
|
|
left: Get.width * .3,
|
|
right: Get.width * .3,
|
|
child: MyElevatedButton(
|
|
title: 'Show Promos'.tr,
|
|
onPressed: () {
|
|
controller.changePromoSheetDialogue();
|
|
},
|
|
),
|
|
)),
|
|
GetBuilder<PaymentController>(
|
|
builder: (controller) => Positioned(
|
|
top: Get.height * .2,
|
|
right: Get.width * .15,
|
|
left: Get.width * .15,
|
|
bottom: Get.height * .2,
|
|
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: 10,
|
|
groupValue: controller.selectedAmount,
|
|
onChanged: (value) {
|
|
controller
|
|
.updateSelectedAmount(value as int);
|
|
},
|
|
),
|
|
Text(
|
|
'10 and get 4% discount'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
controller.updateSelectedAmount(20);
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Radio(
|
|
value: 20,
|
|
groupValue: controller.selectedAmount,
|
|
onChanged: (value) {
|
|
controller
|
|
.updateSelectedAmount(value as int);
|
|
},
|
|
),
|
|
Text(
|
|
'20 and get 6% discount'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
)),
|
|
GestureDetector(
|
|
onTap: () {
|
|
controller.updateSelectedAmount(40);
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Radio(
|
|
value: 40,
|
|
groupValue: controller.selectedAmount,
|
|
onChanged: (value) {
|
|
controller
|
|
.updateSelectedAmount(value as int);
|
|
},
|
|
),
|
|
Text(
|
|
'40 and get 8% discount'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
)),
|
|
GestureDetector(
|
|
onTap: () {
|
|
controller.updateSelectedAmount(100);
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Radio(
|
|
value: 100,
|
|
groupValue: controller.selectedAmount,
|
|
onChanged: (value) {
|
|
controller
|
|
.updateSelectedAmount(value as int);
|
|
},
|
|
),
|
|
Text(
|
|
'100 and get 11% discount'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
)),
|
|
const Spacer(),
|
|
MyElevatedButton(
|
|
title: 'Pay with Your PayPal'.tr,
|
|
onPressed: () {
|
|
if (controller.selectedAmount != 0) {
|
|
controller.makePaymentPayPal(context);
|
|
} else {
|
|
Toast.show(
|
|
context,
|
|
'You will choose one of above !'.tr,
|
|
AppColor.redColor);
|
|
}
|
|
},
|
|
),
|
|
MyElevatedButton(
|
|
title: 'Pay with Credit Card'.tr,
|
|
onPressed: () => controller.makePaymentStripe(
|
|
controller.selectedAmount as int,
|
|
'USD',
|
|
() => Get.snackbar('Hi', '')),
|
|
),
|
|
MyElevatedButton(
|
|
title: 'Cancel'.tr,
|
|
kolor: AppColor.redColor,
|
|
onPressed: () {
|
|
controller.changePromoSheetDialogue();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
))
|
|
: const SizedBox()),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|