25-7-26-1

This commit is contained in:
Hamza-Ayed
2025-07-26 10:30:10 +03:00
parent 83fa8c776c
commit 3742d5b417
645 changed files with 134317 additions and 0 deletions

View File

@@ -0,0 +1,260 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/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 Wallet'.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 Wallet'.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 Wallet 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} Wallet'.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: const 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 لم نعد بحاجة إليه لأنه تم دمجه وتطويره

View File

@@ -0,0 +1,347 @@
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/controller/functions/encrypt_decrypt.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/box_name.dart';
import 'package:Intaleq/constant/colors.dart';
import 'package:Intaleq/controller/functions/toast.dart';
import 'package:Intaleq/controller/payment/payment_controller.dart';
import '../../../main.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' ? 1000 : 10,
);
showPaymentOptions(context, controller);
},
child: Text(
box.read(BoxName.countryCode) == 'Syria'
? '1000 ${'LE'.tr}'
: '10 ${'SYP'.tr}',
),
),
CupertinoActionSheetAction(
onPressed: () {
controller.updateSelectedAmount(
box.read(BoxName.countryCode) == 'Syria' ? 2000 : 20,
);
showPaymentOptions(context, controller);
},
child: Text(
box.read(BoxName.countryCode) == 'Syria'
? '2000 ${'LE'.tr} = 2050 ${'LE'.tr}'
: '20 ${'SYP'.tr}',
),
),
CupertinoActionSheetAction(
onPressed: () {
controller.updateSelectedAmount(
box.read(BoxName.countryCode) == 'Syria' ? 4000 : 40,
);
showPaymentOptions(context, controller);
},
child: Text(
box.read(BoxName.countryCode) == 'Syria'
? '4000 ${'LE'.tr} = 4150 ${'LE'.tr}'
: '40 ${'SYP'.tr}',
),
),
CupertinoActionSheetAction(
onPressed: () {
controller.updateSelectedAmount(
box.read(BoxName.countryCode) == 'Syria' ? 1000 : 50,
);
showPaymentOptions(context, controller);
},
child: Text(
box.read(BoxName.countryCode) == 'Syria'
? '10000 ${'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: 100000,
bonusAmount: 0,
currency: 'SYP'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: 200000,
bonusAmount: 5000,
currency: 'SYP'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: 400000,
bonusAmount: 25000,
currency: 'SYP'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: 1000000,
bonusAmount: 40000,
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.countryCode) != 'Syria'
? 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: () 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,
);
},
),
],
cancelButton: CupertinoActionSheetAction(
child: Text('Cancel'.tr),
onPressed: () {
// controller.changePromoSheetDialogue();
Get.back();
},
),
),
);
}

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/colors.dart';
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
import 'package:Intaleq/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);
}
}

View File

@@ -0,0 +1,61 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/colors.dart';
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/controller/payment/passenger_wallet_history_controller.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
import 'package:Intaleq/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);
}
}