6/15/1
This commit is contained in:
@@ -29,118 +29,123 @@ class CardSeferWalletDriver extends StatelessWidget {
|
||||
DateTime? lastRequestTime =
|
||||
box.read(BoxName.lastTimeCaptainWalletCashOut);
|
||||
|
||||
if (lastRequestTime == null ||
|
||||
now.difference(lastRequestTime).inHours >= 24) {
|
||||
// Update the last request time to now
|
||||
lastRequestTime = now;
|
||||
await box.write(
|
||||
BoxName.lastTimeCaptainWalletCashOut, lastRequestTime);
|
||||
box.write(BoxName.cvvCode, 1111);
|
||||
if (double.parse(
|
||||
Get.find<CaptainWalletController>().totalAmountVisa) >
|
||||
100) {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Do you want to collect your earnings?'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Total wallet is '.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa,
|
||||
style: AppStyle.number,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Wallet Type'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
MyDropDown(),
|
||||
],
|
||||
),
|
||||
Form(
|
||||
key: captainWalletController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: captainWalletController.issurWallet,
|
||||
label: "Enter your wallet number".tr,
|
||||
hint: "Enter your wallet number".tr,
|
||||
type: TextInputType.phone,
|
||||
// if (lastRequestTime == null ||
|
||||
// now.difference(lastRequestTime).inHours >= 24) {
|
||||
// // Update the last request time to now
|
||||
// lastRequestTime = now;
|
||||
// await box.write(
|
||||
// BoxName.lastTimeCaptainWalletCashOut, lastRequestTime);
|
||||
// box.write(BoxName.cvvCode, 1111);
|
||||
if (double.parse(
|
||||
Get.find<CaptainWalletController>().totalAmountVisa) >
|
||||
100) {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Do you want to collect your earnings?'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Total wallet is '.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () async {
|
||||
if (captainWalletController.formKey.currentState!
|
||||
.validate()) {
|
||||
if (double.parse(Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa) >
|
||||
100) {
|
||||
Get.back();
|
||||
String amountAfter5LE = (double.parse(
|
||||
Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa) -
|
||||
5)
|
||||
.toStringAsFixed(0);
|
||||
await Get.put(PaymobPayout())
|
||||
.payToWalletDriverAll(
|
||||
amountAfter5LE,
|
||||
captainWalletController.issurWallet.toString(),
|
||||
captainWalletController.issurWallet.toString(),
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
|
||||
'',
|
||||
backgroundColor: AppColor.yellowColor);
|
||||
}
|
||||
const SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa,
|
||||
style: AppStyle.number,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Wallet Type'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
MyDropDown1(),
|
||||
],
|
||||
),
|
||||
Form(
|
||||
key: captainWalletController.formKey,
|
||||
child: MyTextForm(
|
||||
controller: captainWalletController.phoneWallet,
|
||||
label: "Enter your wallet number".tr,
|
||||
hint: "Enter your wallet number".tr,
|
||||
type: TextInputType.phone,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () async {
|
||||
if (captainWalletController.formKey.currentState!
|
||||
.validate()) {
|
||||
if (double.parse(Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa) >
|
||||
100) {
|
||||
Get.back();
|
||||
String amountAfter5LE = (double.parse(
|
||||
Get.find<CaptainWalletController>()
|
||||
.totalAmountVisa) -
|
||||
5)
|
||||
.toStringAsFixed(0);
|
||||
print(Get.find<PaymobPayout>()
|
||||
.dropdownValue
|
||||
.toString());
|
||||
print(captainWalletController.phoneWallet.text
|
||||
.toString());
|
||||
await Get.put(PaymobPayout()).payToWalletDriverAll(
|
||||
amountAfter5LE,
|
||||
Get.find<PaymobPayout>().dropdownValue.toString(),
|
||||
captainWalletController.phoneWallet.text
|
||||
.toString(),
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
|
||||
'',
|
||||
backgroundColor: AppColor.yellowColor);
|
||||
}
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'cancel'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
} else {
|
||||
{
|
||||
Get.snackbar(
|
||||
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
|
||||
'',
|
||||
backgroundColor: AppColor.yellowColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'cancel'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
} else {
|
||||
// Optionally show a message or handle the throttling case
|
||||
final hoursLeft = 24 - now.difference(lastRequestTime).inHours;
|
||||
Get.snackbar(
|
||||
'${'Please wait'.tr} $hoursLeft ${"hours before trying again.".tr}',
|
||||
'');
|
||||
{
|
||||
Get.snackbar(
|
||||
'${'The Amount is less than'.tr}${box.read(BoxName.countryCode) == 'Egypt' ? '100' : '20'}',
|
||||
'',
|
||||
backgroundColor: AppColor.yellowColor);
|
||||
}
|
||||
}
|
||||
// } else {
|
||||
// // Optionally show a message or handle the throttling case
|
||||
// final hoursLeft = 24 - now.difference(lastRequestTime).inHours;
|
||||
// Get.snackbar(
|
||||
// '${'Please wait'.tr} $hoursLeft ${"hours before trying again.".tr}',
|
||||
// '');
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
width: Get.width * .85,
|
||||
|
||||
128
lib/views/home/my_wallet/transfer_budget_page.dart
Normal file
128
lib/views/home/my_wallet/transfer_budget_page.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:SEFER/views/widgets/my_textField.dart';
|
||||
import 'package:SEFER/views/widgets/mycircular.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../controller/home/payment/captain_wallet_controller.dart';
|
||||
|
||||
class TransferBudgetPage extends StatelessWidget {
|
||||
const TransferBudgetPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(CaptainWalletController());
|
||||
return MyScafolld(
|
||||
title: "Transfer budget".tr,
|
||||
body: [
|
||||
GetBuilder<CaptainWalletController>(
|
||||
builder: (captainWalletController) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
height: Get.height * .7,
|
||||
width: double.infinity,
|
||||
child: Form(
|
||||
key: captainWalletController.formKeyTransfer,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyTextForm(
|
||||
controller: captainWalletController
|
||||
.newDriverPhoneController,
|
||||
label: 'phone number of driver'.tr,
|
||||
hint: 'phone number of driver',
|
||||
type: TextInputType.phone),
|
||||
MyTextForm(
|
||||
controller: captainWalletController
|
||||
.amountFromBudgetController,
|
||||
label: 'insert amount'.tr,
|
||||
hint:
|
||||
'${'You have in account'.tr} ${captainWalletController.totalAmountVisa}',
|
||||
type: TextInputType.number),
|
||||
captainWalletController.isNewTransfer
|
||||
? const MyCircularProgressIndicator()
|
||||
: captainWalletController
|
||||
.amountToNewDriverMap.isEmpty
|
||||
? MyElevatedButton(
|
||||
title: 'Next'.tr,
|
||||
onPressed: () async {
|
||||
await captainWalletController
|
||||
.detectNewDriverFromMyBudget();
|
||||
})
|
||||
: const SizedBox(),
|
||||
captainWalletController.amountToNewDriverMap.isNotEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Text(
|
||||
'Name :'.tr +
|
||||
captainWalletController
|
||||
.amountToNewDriverMap[0]['name']
|
||||
.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Text(
|
||||
"${"NationalID".tr} ${captainWalletController.amountToNewDriverMap[0]['national_number']}",
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Text(
|
||||
"${"amount".tr} ${captainWalletController.amountFromBudgetController.text} ${'LE'.tr}",
|
||||
style: AppStyle.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
captainWalletController
|
||||
.amountToNewDriverMap.isNotEmpty
|
||||
? MyElevatedButton(
|
||||
title: 'Transfer'.tr,
|
||||
onPressed: () async {
|
||||
await captainWalletController
|
||||
.addtransferDriversWallet(
|
||||
'Transfer');
|
||||
})
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox()
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
isleading: true);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ 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 {
|
||||
@@ -254,6 +255,11 @@ class WalletCaptain extends StatelessWidget {
|
||||
}));
|
||||
},
|
||||
),
|
||||
MyElevatedButton(
|
||||
title: 'Transfer budget'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => const TransferBudgetPage());
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -370,6 +376,7 @@ class WalletCaptain extends StatelessWidget {
|
||||
: const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
@@ -425,37 +432,32 @@ class WalletCaptain extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyDropDown extends StatefulWidget {
|
||||
@override
|
||||
_MyDropDownState createState() => _MyDropDownState();
|
||||
}
|
||||
|
||||
class _MyDropDownState extends State<MyDropDown> {
|
||||
String dropdownValue = 'Itsalate';
|
||||
|
||||
class MyDropDown1 extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DropdownButton<String>(
|
||||
value: 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) {
|
||||
setState(() {
|
||||
dropdownValue = newValue!;
|
||||
});
|
||||
},
|
||||
items: <String>['Itsalate', 'We', 'Orange', 'Vodafone']
|
||||
.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
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(),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user