542 lines
22 KiB
Dart
542 lines
22 KiB
Dart
import 'package:SEFER/constant/links.dart';
|
|
import 'package:SEFER/controller/functions/crud.dart';
|
|
import 'package:SEFER/controller/functions/tts.dart';
|
|
import 'package:SEFER/controller/home/payment/paymob_payout.dart';
|
|
import 'package:SEFER/views/home/my_wallet/bank_account_egypt.dart';
|
|
import 'package:SEFER/views/home/my_wallet/payment_history_driver_page.dart';
|
|
import 'package:SEFER/views/widgets/error_snakbar.dart';
|
|
import 'package:SEFER/views/widgets/mydialoug.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';
|
|
import 'package:SEFER/constant/info.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart';
|
|
import 'package:SEFER/main.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
import 'package:SEFER/views/widgets/my_textField.dart';
|
|
import 'package:SEFER/views/widgets/mycircular.dart';
|
|
|
|
import '../../../controller/payment/driver_payment_controller.dart';
|
|
import '../../widgets/my_scafold.dart';
|
|
import 'card_wallet_widget.dart';
|
|
import 'points_captain.dart';
|
|
import 'transfer_budget_page.dart';
|
|
import 'weekly_payment_page.dart';
|
|
|
|
class WalletCaptain extends StatelessWidget {
|
|
WalletCaptain({super.key});
|
|
CaptainWalletController captainWalletController =
|
|
Get.put(CaptainWalletController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Get.put(MapDriverController()).totalPricePassenger = '0';
|
|
captainWalletController.refreshCaptainWallet();
|
|
return MyScafolld(
|
|
title: 'Driver Wallet'.tr,
|
|
body: [
|
|
GetBuilder<CaptainWalletController>(
|
|
builder: (captainWalletController) => captainWalletController
|
|
.isLoading
|
|
? const MyCircularProgressIndicator()
|
|
: Padding(
|
|
padding: const EdgeInsets.all(10),
|
|
child: ListView(
|
|
children: [
|
|
const SizedBox(),
|
|
Container(
|
|
color: double.parse(captainWalletController
|
|
.totalPoints
|
|
.toString()) <
|
|
0 &&
|
|
double.parse(captainWalletController
|
|
.totalPoints
|
|
.toString()) >
|
|
-3000
|
|
? AppColor.yellowColor
|
|
: double.parse(captainWalletController.totalPoints
|
|
.toString()) <
|
|
-3000
|
|
? AppColor.redColor
|
|
: AppColor.greenColor,
|
|
child: InkWell(
|
|
onTap: () {
|
|
showCupertinoDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return CupertinoAlertDialog(
|
|
title: Text('Info'.tr),
|
|
content: Text(
|
|
'The 3000 points equal 3000 L.E for you \nSo go and gain your money'
|
|
.tr,
|
|
),
|
|
actions: <Widget>[
|
|
CupertinoDialogAction(
|
|
child: Text("OK".tr),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 4),
|
|
child: Text(
|
|
'${'Total Points is'.tr} ${captainWalletController.totalPoints.toString()} 💎',
|
|
style: AppStyle.headTitle2,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
if (double.parse(captainWalletController.totalPoints
|
|
.toString()) <
|
|
-3000)
|
|
CupertinoButton.filled(
|
|
child: Text('Charge your Account'.tr),
|
|
onPressed: () {
|
|
// Add your charge account logic here
|
|
},
|
|
),
|
|
const SizedBox(height: 10),
|
|
const CardSeferWalletDriver(),
|
|
Card(
|
|
elevation: 8,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildBudgetRow(
|
|
title: 'Total Budget from trips is '.tr,
|
|
amount: captainWalletController.totalAmount,
|
|
onTap: () {
|
|
Get.snackbar(
|
|
icon: InkWell(
|
|
onTap: () async {
|
|
await Get.put(
|
|
TextToSpeechController())
|
|
.speakText(
|
|
'This amount for all trip I get from Passengers'
|
|
.tr);
|
|
},
|
|
child: const Icon(Icons.headphones)),
|
|
'${'Total Amount:'.tr} ${captainWalletController.totalAmount} ${'L.E'.tr}',
|
|
'This amount for all trip I get from Passengers'
|
|
.tr,
|
|
duration: const Duration(seconds: 6),
|
|
backgroundColor: AppColor.yellowColor,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
);
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
_buildBudgetRow(
|
|
title:
|
|
'Total Budget from trips by\nCredit card is '
|
|
.tr,
|
|
amount:
|
|
captainWalletController.totalAmountVisa,
|
|
onTap: () {
|
|
Get.snackbar(
|
|
icon: InkWell(
|
|
onTap: () async {
|
|
await Get.find<
|
|
TextToSpeechController>()
|
|
.speakText(
|
|
'This amount for all trip I get from Passengers and Collected For me in'
|
|
.tr +
|
|
' SAFAR Wallet'.tr,
|
|
);
|
|
},
|
|
child: const Icon(Icons.headphones),
|
|
),
|
|
'${'Total Amount:'.tr} ${captainWalletController.totalAmountVisa} ${'L.E'.tr}',
|
|
'This amount for all trip I get from Passengers and Collected For me in'
|
|
.tr +
|
|
' ${AppInformation.appName} Wallet'
|
|
.tr,
|
|
duration: const Duration(seconds: 6),
|
|
backgroundColor: AppColor.redColor,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
);
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
_buildBuyPointsButton(captainWalletController),
|
|
const SizedBox(height: 16),
|
|
_buildTransferBudgetButton(
|
|
captainWalletController),
|
|
const SizedBox(height: 16),
|
|
_buildPurchaseInstructions(),
|
|
const SizedBox(height: 8),
|
|
_buildPointsOptions(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
GetBuilder<CaptainWalletController>(
|
|
builder: (captainWalletController) {
|
|
return Column(
|
|
children: [
|
|
_buildPromoCard(
|
|
title: 'Morning Promo'.tr,
|
|
count: captainWalletController
|
|
.walletDate['message'][0]
|
|
['morning_count'],
|
|
maxCount: 5,
|
|
description:
|
|
"this is count of your all trips in the morning promo today from 7:00am-10:00am"
|
|
.tr,
|
|
),
|
|
const SizedBox(
|
|
height: 16), // Add space between the cards
|
|
_buildPromoCard(
|
|
title: 'Afternoon Promo'.tr,
|
|
count: captainWalletController
|
|
.walletDate['message'][0]
|
|
['afternoon_count'],
|
|
maxCount: 5,
|
|
description:
|
|
"this is count of your all trips in the Afternoon promo today from 3:00pm-6:00 pm"
|
|
.tr,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
MyElevatedButton(
|
|
kolor: AppColor.blueColor,
|
|
title: 'Payment History'.tr,
|
|
onPressed: () async {
|
|
await Get.put(DriverWalletHistoryController())
|
|
.getArchivePayment();
|
|
Get.to(() => const PaymentHistoryDriverPage(),
|
|
transition: Transition.size);
|
|
},
|
|
),
|
|
MyElevatedButton(
|
|
kolor: AppColor.blueColor,
|
|
title: 'Weekly Budget'.tr,
|
|
onPressed: () async {
|
|
await Get.put(DriverWalletHistoryController())
|
|
.getWeekllyArchivePayment();
|
|
Get.to(() => const WeeklyPaymentPage(),
|
|
transition: Transition.size);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// TextButton(
|
|
// onPressed: () async {
|
|
// PaymentController paymentController =
|
|
// Get.put(PaymentController());
|
|
// await paymentController.createTransactionToCaptain(
|
|
// '1000',
|
|
// box.read(BoxName.accountIdStripeConnect));
|
|
// },
|
|
// child: const Text(
|
|
// "Pay to Captain",
|
|
// ),
|
|
// )
|
|
],
|
|
),
|
|
))
|
|
],
|
|
isleading: true,
|
|
action: InkWell(
|
|
onTap: () async {
|
|
captainWalletController.refreshCaptainWallet();
|
|
},
|
|
child: const Icon(Icons.refresh)),
|
|
);
|
|
}
|
|
|
|
// Helper methods for better structure
|
|
Widget _buildBudgetRow(
|
|
{required String title,
|
|
required String amount,
|
|
required VoidCallback onTap}) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: AppStyle.title,
|
|
),
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(width: 2, color: AppColor.writeColor),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: GestureDetector(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8),
|
|
child: Text(
|
|
'$amount ${'L.E'.tr}',
|
|
style:
|
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildPromoCard(
|
|
{required String title,
|
|
required int count,
|
|
required int maxCount,
|
|
required String description}) {
|
|
return InkWell(
|
|
onTap: () {
|
|
MyDialog().getDialog(title, description, () {
|
|
Get.back();
|
|
});
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
width: Get.width * .9,
|
|
child: Stack(
|
|
children: [
|
|
LinearProgressIndicator(
|
|
minHeight: 35,
|
|
color: AppColor.blueColor,
|
|
borderRadius: BorderRadius.circular(12),
|
|
backgroundColor: AppColor.accentColor.withOpacity(.5),
|
|
value: count / maxCount,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Text(
|
|
title,
|
|
style: AppStyle.title,
|
|
),
|
|
const SizedBox(width: 20),
|
|
Text(
|
|
'$count / $maxCount',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildBuyPointsButton(CaptainWalletController controller) {
|
|
return MyElevatedButton(
|
|
title: 'You can buy points from your budget'.tr,
|
|
onPressed: () {
|
|
Get.defaultDialog(
|
|
title: 'Pay from my budget'.tr,
|
|
content: Form(
|
|
key: controller.formKey,
|
|
child: MyTextForm(
|
|
controller: controller.amountFromBudgetController,
|
|
label:
|
|
'${'You have in account'.tr} ${controller.totalAmountVisa}',
|
|
hint: '${'You have in account'.tr} ${controller.totalAmountVisa}',
|
|
type: TextInputType.number,
|
|
),
|
|
),
|
|
confirm: MyElevatedButton(
|
|
title: 'Pay'.tr,
|
|
onPressed: () async {
|
|
if (double.parse(controller.amountFromBudgetController.text) <
|
|
double.parse(controller.totalAmountVisa)) {
|
|
await controller.payFromBudget();
|
|
} else {
|
|
Get.back();
|
|
|
|
mySnackeBarError('Your Budget less than needed'.tr);
|
|
}
|
|
},
|
|
),
|
|
cancel: MyElevatedButton(
|
|
title: 'Cancel'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
},
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildTransferBudgetButton(CaptainWalletController controller) {
|
|
return MyElevatedButton(
|
|
title: 'Transfer budget'.tr,
|
|
onPressed: () {
|
|
if (double.parse(controller.totalAmountVisa) > 15) {
|
|
Get.to(() => const TransferBudgetPage());
|
|
} else {
|
|
mySnackeBarError(
|
|
"You don't have enough money in your SEFER wallet".tr);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildPurchaseInstructions() {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Container(
|
|
decoration: AppStyle.boxDecoration,
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
"You can purchase a budget to enable online access through the options listed below."
|
|
.tr,
|
|
textAlign: TextAlign.center,
|
|
style: AppStyle.title,
|
|
),
|
|
const Divider(
|
|
indent: 30,
|
|
endIndent: 30,
|
|
color: AppColor.accentColor,
|
|
thickness: 3),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildPointsOptions() {
|
|
return Container(
|
|
height: Get.height * 0.19,
|
|
child: ListView(
|
|
scrollDirection: Axis.horizontal,
|
|
children: [
|
|
PointsCaptain(
|
|
kolor: AppColor.greyColor,
|
|
pricePoint: box.read(BoxName.countryCode) == 'Jordan' ? 5 : 80,
|
|
countPoint:
|
|
box.read(BoxName.countryCode) == 'Jordan' ? '3000' : '1000',
|
|
),
|
|
PointsCaptain(
|
|
kolor: AppColor.bronze,
|
|
pricePoint: box.read(BoxName.countryCode) == 'Jordan' ? 10 : 200,
|
|
countPoint:
|
|
box.read(BoxName.countryCode) == 'Jordan' ? '1040' : '2500',
|
|
),
|
|
PointsCaptain(
|
|
kolor: AppColor.goldenBronze,
|
|
pricePoint: box.read(BoxName.countryCode) == 'Jordan' ? 22 : 400,
|
|
countPoint:
|
|
box.read(BoxName.countryCode) == 'Jordan' ? '23000' : '5100',
|
|
),
|
|
PointsCaptain(
|
|
kolor: AppColor.gold,
|
|
pricePoint: box.read(BoxName.countryCode) == 'Jordan' ? 50 : 1000,
|
|
countPoint:
|
|
box.read(BoxName.countryCode) == 'Jordan' ? '55000' : '130000',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<dynamic> addBankCodeEgypt(
|
|
CaptainWalletController captainWalletController) {
|
|
return Get.defaultDialog(
|
|
title: "Insert Account Bank".tr,
|
|
content: Form(
|
|
key: captainWalletController.formKeyAccount,
|
|
child: Column(
|
|
children: [
|
|
Text("Insert Card Bank Details to Receive Your Visa Money Weekly"
|
|
.tr),
|
|
MyTextForm(
|
|
controller: captainWalletController.cardBank,
|
|
label: "Insert card number".tr,
|
|
hint: '4123 4567 8910 1235',
|
|
type: TextInputType.number),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
BankDropdown()
|
|
],
|
|
)),
|
|
confirm: MyElevatedButton(
|
|
title: 'Ok'.tr,
|
|
onPressed: () async {
|
|
if (captainWalletController.formKeyAccount.currentState!
|
|
.validate()) {
|
|
Get.back();
|
|
var res =
|
|
await CRUD().post(link: AppLink.updateAccountBank, payload: {
|
|
"bankCode": Get.find<BankController>().selectedBank.toString(),
|
|
"accountBank": captainWalletController.cardBank.text.toString(),
|
|
"id": box.read(BoxName.driverID).toString()
|
|
});
|
|
print('res: ${res}');
|
|
if (res != 'failure') {
|
|
mySnackbarSuccess('bank account added succesfly'.tr);
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
class MyDropDown1 extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Get.put(PaymobPayout());
|
|
return GetBuilder<PaymobPayout>(builder: (controller) {
|
|
return DropdownButton<String>(
|
|
value: controller.dropdownValue,
|
|
icon: const Icon(Icons.arrow_drop_down),
|
|
elevation: 16,
|
|
style: const TextStyle(color: Colors.deepPurple),
|
|
underline: Container(
|
|
height: 2,
|
|
color: Colors.deepPurpleAccent,
|
|
),
|
|
onChanged: (String? newValue) {
|
|
controller.dropdownValue = newValue!;
|
|
controller.update();
|
|
},
|
|
items: <String>['etisalat', 'aman', 'orange', 'vodafone']
|
|
.map<DropdownMenuItem<String>>((String value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value,
|
|
child: Text(value),
|
|
);
|
|
}).toList(),
|
|
);
|
|
});
|
|
}
|
|
}
|