import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sefer_driver/constant/colors.dart'; import 'package:sefer_driver/constant/style.dart'; import 'package:sefer_driver/controller/home/payment/captain_wallet_controller.dart'; import 'package:sefer_driver/controller/payment/payment_controller.dart'; import '../../../constant/box_name.dart'; import '../../../main.dart'; import '../../widgets/elevated_btn.dart'; import '../../widgets/my_textField.dart'; class PointsCaptain extends StatelessWidget { PaymentController paymentController = Get.put(PaymentController()); CaptainWalletController captainWalletController = Get.put(CaptainWalletController()); PointsCaptain({ super.key, required this.kolor, required this.countPoint, required this.pricePoint, }); final Color kolor; final String countPoint; double pricePoint; @override Widget build(BuildContext context) { return InkWell( onTap: () async { box.read(BoxName.countryCode) == 'Egypt' ? Get.defaultDialog( title: 'Which method you will pay'.tr, titleStyle: AppStyle.title, content: Column( children: [ Text( '${'you can buy '.tr}$countPoint ${'LE'.tr}${'by '.tr}${'$pricePoint'.tr}', style: AppStyle.title, ), MyElevatedButton( title: 'Pay with Credit Card'.tr, onPressed: () async { Get.back(); await paymentController.payWithPayMob( context, pricePoint.toStringAsFixed(2), box.read(BoxName.countryCode) == 'Egypt' ? 'EGP' : 'JOD', () async { // await captainWalletController.getPaymentId( // 'visa-in', pricePoint); await captainWalletController.addDriverWallet( 'visa-in', countPoint, pricePoint); await captainWalletController.addSeferWallet( 'visa-in', pricePoint.toString()); await captainWalletController .getCaptainWalletFromBuyPoints(); }); }, //51524 ), // Add some spacing between buttons MyElevatedButton( kolor: AppColor.redColor, title: 'Pay with Wallet'.tr, onPressed: () async { Get.back(); Get.defaultDialog( barrierDismissible: false, title: 'Insert Wallet phone number'.tr, content: Form( key: paymentController.formKey, child: MyTextForm( controller: paymentController.walletphoneController, label: 'Insert Wallet phone number'.tr, hint: 'Insert Wallet phone number'.tr, type: TextInputType.phone)), confirm: MyElevatedButton( title: 'OK'.tr, onPressed: () async { Get.back(); if (paymentController.formKey.currentState! .validate()) { box.write( BoxName.phoneWallet, paymentController .walletphoneController.text); await paymentController.payWithPayMobWallet( context, pricePoint.toStringAsFixed(2), box.read(BoxName.countryCode) == 'Egypt' ? 'EGP' : 'JOD', () async { // await captainWalletController // .getPaymentId('visa-in', pricePoint); await captainWalletController .addDriverWallet('visa-in', countPoint, pricePoint); await captainWalletController .addSeferWallet( 'visa-in', pricePoint.toString()); await captainWalletController .getCaptainWalletFromBuyPoints(); }); } // Get.back(); })); }, ), ], )) : await paymentController.makePaymentStripe(pricePoint, box.read(BoxName.countryCode) == 'Jordan' ? 'jod' : 'egp', () async { // await captainWalletController.getPaymentId( // 'visa-in', pricePoint); await captainWalletController.addDriverWallet( 'visa-in', countPoint, pricePoint); await captainWalletController.getCaptainWalletFromBuyPoints(); }); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 3, vertical: 8), child: Container( width: Get.width * .22, height: Get.width * .22, margin: const EdgeInsets.all(4), decoration: BoxDecoration( gradient: LinearGradient( colors: [ kolor.withOpacity(0.3), kolor, kolor.withOpacity(0.7), kolor, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), border: Border.all(color: AppColor.accentColor), borderRadius: BorderRadius.circular(12), shape: BoxShape.rectangle, ), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( '$countPoint ${box.read(BoxName.countryCode) == 'Jordan' ? 'JOD'.tr : 'L.E'.tr}', style: AppStyle.subtitle .copyWith(color: AppColor.secondaryColor), ), Text( '$pricePoint ${box.read(BoxName.countryCode) == 'Jordan' ? 'JOD'.tr : 'L.E'.tr}', style: AppStyle.title.copyWith(color: AppColor.secondaryColor), textAlign: TextAlign.center, ), ], ), ), ), ), ); } }