This commit is contained in:
Hamza-Ayed
2024-12-08 18:16:31 +03:00
parent 630d0c4afb
commit e0c242bd77
34 changed files with 1876 additions and 1345 deletions

View File

@@ -1,4 +1,6 @@
import 'package:SEFER/constant/style.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/colors.dart';
@@ -89,6 +91,147 @@ class PassengerWalletDialog extends StatelessWidget {
);
}
}
// 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: box.read(BoxName.countryCode) == 'Egypt' ? 100 : 10,
bonusAmount: 0,
currency: box.read(BoxName.countryCode) == 'Egypt'
? 'LE'.tr
: 'JOD'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: box.read(BoxName.countryCode) == 'Egypt' ? 200 : 20,
bonusAmount: box.read(BoxName.countryCode) == 'Egypt' ? 5 : 1,
currency: box.read(BoxName.countryCode) == 'Egypt'
? 'LE'.tr
: 'JOD'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: box.read(BoxName.countryCode) == 'Egypt' ? 400 : 40,
bonusAmount:
box.read(BoxName.countryCode) == 'Egypt' ? 15 : 2.5,
currency: box.read(BoxName.countryCode) == 'Egypt'
? 'LE'.tr
: 'JOD'.tr,
),
const SizedBox(height: 8.0),
_buildPaymentOption(
context: context,
controller: controller,
amount: box.read(BoxName.countryCode) == 'Egypt' ? 1000 : 50,
bonusAmount: box.read(BoxName.countryCode) == 'Egypt' ? 100 : 6,
currency: box.read(BoxName.countryCode) == 'Egypt'
? 'LE'.tr
: 'JOD'.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(
@@ -209,7 +352,8 @@ void showPaymentOptions(BuildContext context, PaymentController controller) {
cancelButton: CupertinoActionSheetAction(
child: Text('Cancel'.tr),
onPressed: () {
controller.changePromoSheetDialogue();
// controller.changePromoSheetDialogue();
Get.back();
},
),
),