first commit
This commit is contained in:
260
siro_rider/lib/views/home/my_wallet/passenger_wallet.dart
Normal file
260
siro_rider/lib/views/home/my_wallet/passenger_wallet.dart
Normal file
@@ -0,0 +1,260 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_rider/views/home/my_wallet/payment_history_passenger_page.dart';
|
||||
import 'dart:ui'; // لاستخدام تأثيرات متقدمة
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/info.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/functions/toast.dart';
|
||||
import '../../../controller/home/payment/credit_card_controller.dart';
|
||||
import '../../../controller/payment/payment_controller.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import 'passenger_wallet_dialoge.dart';
|
||||
|
||||
// --- الويدجت الرئيسية بالتصميم الجديد ---
|
||||
class PassengerWallet extends StatelessWidget {
|
||||
const PassengerWallet({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// نفس منطق استدعاء الكنترولرز
|
||||
Get.put(PaymentController());
|
||||
Get.put(CreditCardController());
|
||||
|
||||
return MyScafolld(
|
||||
title: 'My Balance'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
// استخدام Stack فقط لعرض الـ Dialog فوق المحتوى عند الحاجة
|
||||
Stack(
|
||||
children: [
|
||||
// استخدام Column لتنظيم المحتوى بشكل أفضل
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// --- 1. بطاقة المحفظة العصرية ---
|
||||
_buildModernWalletCard(),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
Text("Actions".tr,
|
||||
style: AppStyle.title.copyWith(
|
||||
color: AppColor.writeColor.withOpacity(0.6))),
|
||||
const Divider(height: 24),
|
||||
|
||||
// --- 2. قائمة الخيارات المنظمة ---
|
||||
_buildActionTile(
|
||||
icon: Icons.add_card_rounded,
|
||||
title: 'Top up Balance'.tr,
|
||||
subtitle: 'Add funds using our secure methods'.tr,
|
||||
onTap: () =>
|
||||
showPaymentBottomSheet(context), // نفس دالتك القديمة
|
||||
),
|
||||
_buildActionTile(
|
||||
icon: Icons.history_rounded,
|
||||
title: 'Payment History'.tr,
|
||||
subtitle: 'View your past transactions'.tr,
|
||||
onTap: () => Get.to(
|
||||
() => const PaymentHistoryPassengerPage(),
|
||||
transition: Transition.rightToLeftWithFade),
|
||||
),
|
||||
_buildActionTile(
|
||||
icon: Icons.phone_iphone_rounded,
|
||||
title: 'Set Phone Number'.tr,
|
||||
subtitle: 'Link a phone number for transfers'.tr,
|
||||
onTap: () => _showWalletPhoneDialog(context,
|
||||
Get.find<PaymentController>()), // نفس دالتك القديمة
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// --- عرض الـ Dialog بنفس طريقتك القديمة ---
|
||||
const PassengerWalletDialog(),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// --- ويدجت مساعدة لبناء بطاقة المحفظة ---
|
||||
Widget _buildModernWalletCard() {
|
||||
return GetBuilder<PaymentController>(
|
||||
builder: (paymentController) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: Get.height * 0.25,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
gradient: const LinearGradient(
|
||||
colors: [
|
||||
AppColor.primaryColor,
|
||||
Color(0xFF1E3A8A)
|
||||
], // تدرج لوني أنيق
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primaryColor.withOpacity(0.3),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
// --- عنصر تزييني (شكل موجة) ---
|
||||
Positioned(
|
||||
right: -100,
|
||||
bottom: -100,
|
||||
child: Icon(
|
||||
Icons.waves,
|
||||
size: 250,
|
||||
color: Colors.white.withOpacity(0.05),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${AppInformation.appName} ${'Balance'.tr}',
|
||||
style: AppStyle.headTitle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Icon(Icons.memory_rounded,
|
||||
color: Colors.white.withOpacity(0.7),
|
||||
size: 30), // أيقونة الشريحة
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Current Balance".tr,
|
||||
style: AppStyle.subtitle
|
||||
.copyWith(color: Colors.white.withOpacity(0.7)),
|
||||
),
|
||||
Text(
|
||||
'${box.read(BoxName.passengerWalletTotal) ?? '0.0'} ${'SYP'.tr}',
|
||||
style: AppStyle.headTitle2.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
(box.read(BoxName.name) ?? "User Name").toString(),
|
||||
style: AppStyle.title.copyWith(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// --- ويدجت مساعدة لبناء عناصر القائمة ---
|
||||
Widget _buildActionTile({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
onTap: onTap,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primaryColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(icon, color: AppColor.primaryColor, size: 24),
|
||||
),
|
||||
title: Text(title.tr, style: AppStyle.title),
|
||||
subtitle: Text(subtitle.tr,
|
||||
style: AppStyle.subtitle
|
||||
.copyWith(color: AppColor.writeColor.withOpacity(0.6))),
|
||||
trailing: Icon(Icons.arrow_forward_ios_rounded,
|
||||
size: 16, color: AppColor.writeColor),
|
||||
);
|
||||
}
|
||||
|
||||
// --- نفس دالة الـ Dialog الخاصة بك ---
|
||||
void _showWalletPhoneDialog(
|
||||
BuildContext context, PaymentController controller) {
|
||||
Get.dialog(
|
||||
CupertinoAlertDialog(
|
||||
title: Text('Insert Wallet phone number'.tr),
|
||||
content: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Form(
|
||||
key: controller.formKey,
|
||||
child: CupertinoTextField(
|
||||
controller: controller.walletphoneController,
|
||||
placeholder: 'Insert Wallet phone number'.tr,
|
||||
keyboardType: TextInputType.phone,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 10),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text('Cancel'.tr,
|
||||
style: const TextStyle(color: CupertinoColors.destructiveRed)),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text('OK'.tr,
|
||||
style: const TextStyle(color: CupertinoColors.activeGreen)),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
box.write(
|
||||
BoxName.phoneWallet, (controller.walletphoneController.text));
|
||||
Toast.show(context, 'Phone Wallet Saved Successfully'.tr,
|
||||
AppColor.greenColor);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// الكلاس القديم CardIntaleqWallet لم نعد بحاجة إليه لأنه تم دمجه وتطويره
|
||||
@@ -0,0 +1,486 @@
|
||||
import 'package:siro_rider/print.dart';
|
||||
import 'package:siro_rider/constant/style.dart';
|
||||
import 'package:siro_rider/controller/functions/encrypt_decrypt.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_rider/constant/box_name.dart';
|
||||
import 'package:siro_rider/constant/colors.dart';
|
||||
import 'package:siro_rider/controller/functions/toast.dart';
|
||||
import 'package:siro_rider/controller/payment/payment_controller.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
|
||||
import '../../../main.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
import 'payment_screen_sham.dart';
|
||||
|
||||
class PassengerWalletDialog extends StatelessWidget {
|
||||
const PassengerWalletDialog({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
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
|
||||
? CupertinoActionSheet(
|
||||
title: Text('Select Payment Amount'.tr),
|
||||
actions: [
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Syria' ? 10000 : 10,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Syria'
|
||||
? '10000 ${'LE'.tr}'
|
||||
: '10 ${'SYP'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Syria' ? 20000 : 20,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Syria'
|
||||
? '20000 ${'LE'.tr} = 2050 ${'LE'.tr}'
|
||||
: '20 ${'SYP'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Syria' ? 40000 : 40,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Syria'
|
||||
? '40000 ${'LE'.tr} = 4150 ${'LE'.tr}'
|
||||
: '40 ${'SYP'.tr}',
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.updateSelectedAmount(
|
||||
box.read(BoxName.countryCode) == 'Syria' ? 100000 : 50,
|
||||
);
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Text(
|
||||
box.read(BoxName.countryCode) == 'Syria'
|
||||
? '100000 ${'LE'.tr} = 11000 ${'LE'.tr}'
|
||||
: '50 ${'SYP'.tr}',
|
||||
),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
controller.changePromoSheetDialogue();
|
||||
},
|
||||
child: Text('Cancel'.tr),
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// class PassengerWalletDialog extends StatelessWidget {
|
||||
// const PassengerWalletDialog({
|
||||
// super.key,
|
||||
// });
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return GetBuilder<PaymentController>(
|
||||
// builder: (controller) {
|
||||
// return Positioned(
|
||||
// top: Get.height * .1,
|
||||
// right: Get.width * .15,
|
||||
// left: Get.width * .15,
|
||||
// bottom: Get.height * .1,
|
||||
// child: controller.isPromoSheetDialogue
|
||||
// ? Container()
|
||||
// : SizedBox
|
||||
// .shrink(), // If condition is false, return an empty widget
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
void showPaymentBottomSheet(BuildContext context) {
|
||||
final controller = Get.find<PaymentController>();
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(15.0)),
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Get.back();
|
||||
return false;
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'Select Payment Amount'.tr,
|
||||
style: AppStyle.headTitle2,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
|
||||
// Payment Options List
|
||||
_buildPaymentOption(
|
||||
context: context,
|
||||
controller: controller,
|
||||
amount: 500,
|
||||
bonusAmount: 30,
|
||||
currency: 'SYP'.tr,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8.0),
|
||||
_buildPaymentOption(
|
||||
context: context,
|
||||
controller: controller,
|
||||
amount: 1000,
|
||||
bonusAmount: 70,
|
||||
currency: 'SYP'.tr,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8.0),
|
||||
_buildPaymentOption(
|
||||
context: context,
|
||||
controller: controller,
|
||||
amount: 2000,
|
||||
bonusAmount: 180,
|
||||
currency: 'SYP'.tr,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8.0),
|
||||
_buildPaymentOption(
|
||||
context: context,
|
||||
controller: controller,
|
||||
amount: 5000,
|
||||
bonusAmount: 700,
|
||||
currency: 'SYP'.tr,
|
||||
),
|
||||
|
||||
const SizedBox(height: 16.0),
|
||||
TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text('Cancel'.tr),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaymentOption({
|
||||
required BuildContext context,
|
||||
required PaymentController controller,
|
||||
required int amount,
|
||||
required double bonusAmount,
|
||||
required String currency,
|
||||
}) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.updateSelectedAmount(amount);
|
||||
Get.back();
|
||||
showPaymentOptions(context, controller);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey[300]!),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Text(
|
||||
bonusAmount > 0
|
||||
? '${'Pay'.tr} $amount $currency, ${'Get'.tr} ${amount + bonusAmount} $currency'
|
||||
: '$amount $currency',
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showPaymentOptions(BuildContext context, PaymentController controller) {
|
||||
showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: Text('Payment Options'.tr),
|
||||
actions: [
|
||||
box.read(BoxName.countryCode) == 'Syria'
|
||||
? CupertinoActionSheetAction(
|
||||
child: Text('💳 Pay with Credit Card'.tr),
|
||||
onPressed: () async {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.payWithEcash(
|
||||
context,
|
||||
controller.selectedAmount.toString(),
|
||||
// () 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.phoneWallet) != null
|
||||
// ? CupertinoActionSheetAction(
|
||||
// child: Text('💰 Pay with Wallet'.tr),
|
||||
// onPressed: () async {
|
||||
// if (controller.selectedAmount != 0) {
|
||||
// controller.isLoading = true;
|
||||
// controller.update();
|
||||
// controller.payWithMTNWallet(
|
||||
// context,
|
||||
// controller.selectedAmount.toString(),
|
||||
// 'SYP',
|
||||
// );
|
||||
// await controller.getPassengerWallet();
|
||||
// controller.isLoading = false;
|
||||
// controller.update();
|
||||
// } 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,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// actions: [
|
||||
// CupertinoDialogAction(
|
||||
// child: Text('Cancel'.tr,
|
||||
// style: const TextStyle(
|
||||
// color: CupertinoColors.destructiveRed)),
|
||||
// onPressed: () {
|
||||
// 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);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// barrierDismissible: false,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// GestureDetector(
|
||||
// onTap: () async {
|
||||
// Get.back();
|
||||
// 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: '963941234567',
|
||||
// type: TextInputType.phone)),
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'OK'.tr,
|
||||
// onPressed: () async {
|
||||
// Get.back();
|
||||
// if (controller.formKey.currentState!.validate()) {
|
||||
// if (controller.selectedAmount != 0) {
|
||||
// controller.isLoading = true;
|
||||
// controller.update();
|
||||
// box.write(BoxName.phoneWallet,
|
||||
// (controller.walletphoneController.text));
|
||||
// Get.back();
|
||||
// await controller.payWithMTNWallet(
|
||||
// context,
|
||||
// controller.selectedAmount.toString(),
|
||||
// 'SYP',
|
||||
// );
|
||||
// await controller.getPassengerWallet();
|
||||
|
||||
// controller.isLoading = false;
|
||||
// controller.update();
|
||||
// } else {
|
||||
// Toast.show(
|
||||
// context,
|
||||
// '⚠️ You need to choose an amount!'.tr,
|
||||
// AppColor.redColor,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }));
|
||||
// },
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// 'Pay by MTN Wallet'.tr,
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// const SizedBox(width: 10),
|
||||
// Image.asset(
|
||||
// 'assets/images/cashMTN.png',
|
||||
// width: 70,
|
||||
// height: 70,
|
||||
// fit: BoxFit.contain,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// )),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
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: '963941234567',
|
||||
type: TextInputType.phone)),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'OK'.tr,
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
if (controller.formKey.currentState!.validate()) {
|
||||
box.write(BoxName.phoneWallet,
|
||||
controller.walletphoneController.text);
|
||||
await controller.payWithSyriaTelWallet(
|
||||
controller.selectedAmount.toString(), 'SYP');
|
||||
}
|
||||
}));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Pay by Syriatel Wallet'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Image.asset(
|
||||
'assets/images/syriatel.png',
|
||||
width: 70,
|
||||
height: 70,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
// التحقق بالبصمة قبل أي شيء
|
||||
bool isAuthSupported =
|
||||
await LocalAuthentication().isDeviceSupported();
|
||||
|
||||
if (isAuthSupported) {
|
||||
bool didAuthenticate = await LocalAuthentication().authenticate(
|
||||
localizedReason: 'استخدم بصمة الإصبع أو الوجه لتأكيد الدفع',
|
||||
);
|
||||
|
||||
if (!didAuthenticate) {
|
||||
Log.print("❌ User did not authenticate with biometrics");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// الانتقال مباشرة لإنشاء الفاتورة بعد النجاح بالبصمة
|
||||
Get.to(() => PaymentScreenSmsProvider(
|
||||
amount: double.parse(controller.selectedAmount.toString())));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Pay by Sham Cash'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Image.asset(
|
||||
'assets/images/shamCash.png',
|
||||
width: 70,
|
||||
height: 70,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: Text('Cancel'.tr),
|
||||
onPressed: () {
|
||||
// controller.changePromoSheetDialogue();
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_rider/constant/colors.dart';
|
||||
import 'package:siro_rider/constant/style.dart';
|
||||
import 'package:siro_rider/views/widgets/my_scafold.dart';
|
||||
import 'package:siro_rider/views/widgets/mycircular.dart';
|
||||
|
||||
import '../../../controller/payment/driver_payment_controller.dart';
|
||||
|
||||
class PaymentHistoryDriverPage extends StatelessWidget {
|
||||
const PaymentHistoryDriverPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(DriverWalletHistoryController());
|
||||
return MyScafolld(
|
||||
title: 'Payment History'.tr,
|
||||
body: [
|
||||
GetBuilder<DriverWalletHistoryController>(
|
||||
builder: (controller) => controller.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: ListView.builder(
|
||||
itemCount: controller.archive.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var list = controller.archive[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: double.parse(list['amount']) < 0
|
||||
? AppColor.redColor.withOpacity(.4)
|
||||
: AppColor.greenColor.withOpacity(.4)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
list['amount'],
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
list['created_at'],
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
isleading: true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_rider/constant/colors.dart';
|
||||
import 'package:siro_rider/constant/style.dart';
|
||||
import 'package:siro_rider/controller/payment/passenger_wallet_history_controller.dart';
|
||||
import 'package:siro_rider/views/widgets/my_scafold.dart';
|
||||
import 'package:siro_rider/views/widgets/mycircular.dart';
|
||||
|
||||
class PaymentHistoryPassengerPage extends StatelessWidget {
|
||||
const PaymentHistoryPassengerPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(PassengerWalletHistoryController());
|
||||
return MyScafolld(
|
||||
title: 'Payment History'.tr,
|
||||
body: [
|
||||
GetBuilder<PassengerWalletHistoryController>(
|
||||
builder: (controller) => controller.isLoading
|
||||
? const MyCircularProgressIndicator() // iOS-style loading indicator
|
||||
: controller.archive.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No wallet record found'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
)
|
||||
: CupertinoListSection.insetGrouped(
|
||||
children: List.generate(
|
||||
controller.archive.length,
|
||||
(index) {
|
||||
var list = controller.archive[index];
|
||||
return CupertinoListTile(
|
||||
backgroundColor: double.parse(list['balance']) < 0
|
||||
? AppColor.redColor.withOpacity(.2)
|
||||
: AppColor.greenColor.withOpacity(.2),
|
||||
title: Text(
|
||||
list['balance'],
|
||||
style: AppStyle.title.copyWith(
|
||||
color: CupertinoColors.black,
|
||||
),
|
||||
),
|
||||
additionalInfo: Text(
|
||||
list['created_at'],
|
||||
style: AppStyle.title.copyWith(
|
||||
fontSize: 12,
|
||||
color: CupertinoColors.systemGrey,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 16),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
isleading: true);
|
||||
}
|
||||
}
|
||||
515
siro_rider/lib/views/home/my_wallet/payment_screen_sham.dart
Normal file
515
siro_rider/lib/views/home/my_wallet/payment_screen_sham.dart
Normal file
@@ -0,0 +1,515 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../controller/functions/crud.dart';
|
||||
import '../../../main.dart';
|
||||
|
||||
// --- خدمة الدفع (نفس المنطق السابق) ---
|
||||
class PaymentService {
|
||||
final String _baseUrl = "${AppLink.paymentServer}/ride/shamcash/passenger";
|
||||
|
||||
Future<String?> createInvoice({required double amount}) async {
|
||||
final url = "$_baseUrl/create_invoice.php";
|
||||
try {
|
||||
final response = await CRUD().postWallet(
|
||||
link: url,
|
||||
payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'amount': amount.toString(),
|
||||
},
|
||||
).timeout(const Duration(seconds: 15));
|
||||
|
||||
if (response != 'failure') {
|
||||
final data = response;
|
||||
if (data['status'] == 'success' && data['invoice_number'] != null) {
|
||||
return data['invoice_number'].toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
debugPrint("Create Invoice Error: $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> checkInvoiceStatus(String invoiceNumber) async {
|
||||
final url = "$_baseUrl/check_status.php";
|
||||
try {
|
||||
final response = await CRUD().postWallet(link: url, payload: {
|
||||
'invoice_number': invoiceNumber,
|
||||
}).timeout(const Duration(seconds: 10));
|
||||
|
||||
if (response != 'failure') {
|
||||
final data = response;
|
||||
return data['status'] == 'success' &&
|
||||
data['invoice_status'] == 'completed';
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum PaymentStatus {
|
||||
creatingInvoice,
|
||||
waitingForPayment,
|
||||
paymentSuccess,
|
||||
paymentTimeout,
|
||||
paymentError
|
||||
}
|
||||
|
||||
class PaymentScreenSmsProvider extends StatefulWidget {
|
||||
final double amount;
|
||||
final String providerName;
|
||||
final String providerLogo;
|
||||
final String qrImagePath;
|
||||
|
||||
const PaymentScreenSmsProvider({
|
||||
super.key,
|
||||
required this.amount,
|
||||
this.providerName = 'شام كاش',
|
||||
this.providerLogo = 'assets/images/shamCash.png',
|
||||
this.qrImagePath = 'assets/images/shamcashsend.png',
|
||||
});
|
||||
|
||||
@override
|
||||
_PaymentScreenSmsProviderState createState() =>
|
||||
_PaymentScreenSmsProviderState();
|
||||
}
|
||||
|
||||
class _PaymentScreenSmsProviderState extends State<PaymentScreenSmsProvider>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final PaymentService _paymentService = PaymentService();
|
||||
Timer? _pollingTimer;
|
||||
PaymentStatus _status = PaymentStatus.creatingInvoice;
|
||||
String? _invoiceNumber;
|
||||
|
||||
// العنوان الثابت للدفع (المستخرج من الصورة)
|
||||
final String _paymentAddress = "80f23afe40499b02f49966c3340ae0fc";
|
||||
|
||||
// متحكم الأنيميشن للوميض
|
||||
late AnimationController _blinkController;
|
||||
late Animation<Color?> _colorAnimation;
|
||||
late Animation<double> _shadowAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// إعداد الأنيميشن (وميض أحمر)
|
||||
_blinkController = AnimationController(
|
||||
duration: const Duration(milliseconds: 800),
|
||||
vsync: this,
|
||||
)..repeat(reverse: true); // يكرر الحركة ذهاباً وإياباً
|
||||
|
||||
_colorAnimation = ColorTween(
|
||||
begin: Colors.red.shade700,
|
||||
end: Colors.red.shade100,
|
||||
).animate(_blinkController);
|
||||
|
||||
_shadowAnimation = Tween<double>(begin: 2.0, end: 15.0).animate(
|
||||
CurvedAnimation(parent: _blinkController, curve: Curves.easeInOut),
|
||||
);
|
||||
|
||||
_createAndPollInvoice();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pollingTimer?.cancel();
|
||||
_blinkController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _createAndPollInvoice() async {
|
||||
setState(() => _status = PaymentStatus.creatingInvoice);
|
||||
final invoiceNumber =
|
||||
await _paymentService.createInvoice(amount: widget.amount);
|
||||
|
||||
if (invoiceNumber != null && mounted) {
|
||||
setState(() {
|
||||
_invoiceNumber = invoiceNumber;
|
||||
_status = PaymentStatus.waitingForPayment;
|
||||
});
|
||||
_startPolling(invoiceNumber);
|
||||
} else if (mounted) {
|
||||
setState(() => _status = PaymentStatus.paymentError);
|
||||
}
|
||||
}
|
||||
|
||||
void _startPolling(String invoiceNumber) {
|
||||
const timeoutDuration = Duration(minutes: 5);
|
||||
var elapsed = Duration.zero;
|
||||
|
||||
_pollingTimer = Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
elapsed += const Duration(seconds: 5);
|
||||
if (elapsed >= timeoutDuration) {
|
||||
timer.cancel();
|
||||
if (mounted) setState(() => _status = PaymentStatus.paymentTimeout);
|
||||
return;
|
||||
}
|
||||
final isCompleted =
|
||||
await _paymentService.checkInvoiceStatus(invoiceNumber);
|
||||
if (isCompleted && mounted) {
|
||||
timer.cancel();
|
||||
setState(() => _status = PaymentStatus.paymentSuccess);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> _onPopInvoked() async {
|
||||
if (_status == PaymentStatus.waitingForPayment) {
|
||||
final shouldPop = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('إلغاء العملية؟', textAlign: TextAlign.right),
|
||||
content: const Text('الخروج الآن سيؤدي لإلغاء متابعة عملية الدفع.',
|
||||
textAlign: TextAlign.right),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('البقاء')),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text('خروج', style: TextStyle(color: Colors.red))),
|
||||
],
|
||||
),
|
||||
);
|
||||
return shouldPop ?? false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: _onPopInvoked,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[50],
|
||||
appBar: AppBar(
|
||||
title: Text("دفع عبر ${widget.providerName}"),
|
||||
centerTitle: true,
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.black,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Center(child: _buildContentByStatus()),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContentByStatus() {
|
||||
switch (_status) {
|
||||
case PaymentStatus.creatingInvoice:
|
||||
return const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 20),
|
||||
Text("جاري إنشاء رقم البيان...", style: TextStyle(fontSize: 16)),
|
||||
],
|
||||
);
|
||||
case PaymentStatus.waitingForPayment:
|
||||
return _buildWaitingForPaymentUI();
|
||||
case PaymentStatus.paymentSuccess:
|
||||
return _buildSuccessUI();
|
||||
case PaymentStatus.paymentTimeout:
|
||||
case PaymentStatus.paymentError:
|
||||
return _buildErrorUI();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildWaitingForPaymentUI() {
|
||||
final currencyFormat = NumberFormat.decimalPattern('ar_SY');
|
||||
final invoiceText = _invoiceNumber ?? '---';
|
||||
|
||||
return SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// 1. المبلغ
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue.shade800, Colors.blue.shade600]),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blue.withOpacity(0.25),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 5))
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const Text("المبلغ المطلوب",
|
||||
style: TextStyle(color: Colors.white70, fontSize: 14)),
|
||||
const SizedBox(height: 5),
|
||||
Text("${currencyFormat.format(widget.amount)} ل.س",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
|
||||
// 2. رقم البيان (هام جداً - وميض أحمر)
|
||||
AnimatedBuilder(
|
||||
animation: _blinkController,
|
||||
builder: (context, child) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: _colorAnimation.value ?? Colors.red,
|
||||
width: 3.0, // إطار سميك
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: (_colorAnimation.value ?? Colors.red)
|
||||
.withOpacity(0.4),
|
||||
blurRadius: _shadowAnimation.value,
|
||||
spreadRadius: 2,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.warning_rounded,
|
||||
color: Colors.red.shade800, size: 28),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
"هام جداً: لا تنسَ!",
|
||||
style: TextStyle(
|
||||
color: Colors.red.shade900,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
"يجب نسخ (رقم البيان) هذا ووضعه في تطبيق شام كاش لضمان نجاح العملية.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: invoiceText));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: const Text("تم نسخ رقم البيان ✅",
|
||||
textAlign: TextAlign.center),
|
||||
backgroundColor: Colors.red.shade700));
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.shade50,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.red.shade200, width: 1)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("رقم البيان (Invoice No)",
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: Colors.grey)),
|
||||
Text(invoiceText,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 2.0,
|
||||
color: Colors.red.shade900)),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.shade100,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(Icons.copy_rounded,
|
||||
color: Colors.red.shade900, size: 24),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
|
||||
// 3. عنوان الدفع (اختياري / عادي)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("عنوان الدفع (Payment Address)",
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
const SizedBox(height: 8),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: _paymentAddress));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: const Text("تم نسخ عنوان الدفع ✅",
|
||||
textAlign: TextAlign.center),
|
||||
backgroundColor: Colors.green.shade600));
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(_paymentAddress,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Courier',
|
||||
color: Colors.black87,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.copy, size: 18, color: Colors.grey),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// 4. QR Code
|
||||
const Text("أو امسح الرمز للدفع",
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: InteractiveViewer(
|
||||
child: Image.asset(widget.qrImagePath))));
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(color: Colors.grey.shade300)),
|
||||
child: Image.asset(widget.qrImagePath,
|
||||
width: 150,
|
||||
height: 150,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (c, o, s) => const Icon(Icons.qr_code_2,
|
||||
size: 100, color: Colors.grey)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const LinearProgressIndicator(backgroundColor: Colors.white),
|
||||
const SizedBox(height: 10),
|
||||
const Text("جاري التحقق من الدفع تلقائياً...",
|
||||
style: TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSuccessUI() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.verified_rounded, color: Colors.green, size: 100),
|
||||
const SizedBox(height: 20),
|
||||
const Text("تم الدفع بنجاح!",
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 40),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text("متابعة", style: TextStyle(fontSize: 18)),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorUI() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error_outline_rounded, color: Colors.red.shade400, size: 80),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
_status == PaymentStatus.paymentTimeout
|
||||
? "انتهى الوقت"
|
||||
: "لم يتم التحقق",
|
||||
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 15),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30),
|
||||
child: Text("لم يصلنا إشعار الدفع خلال الوقت المحدد.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey))),
|
||||
const SizedBox(height: 40),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15)),
|
||||
onPressed: _createAndPollInvoice,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text("حاول مرة أخرى"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text("إلغاء", style: TextStyle(color: Colors.grey)))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user