This commit is contained in:
Hamza-Ayed
2024-02-10 00:27:19 +03:00
parent 835be01923
commit 8c99fc94e2
15 changed files with 158 additions and 127 deletions

View File

@@ -55,8 +55,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 26
targetSdkVersion flutter.targetSdkVersion
versionCode 17
versionName '1.4.1'
versionCode 18
versionName '1.4.2'
// manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml']
}

View File

@@ -8,7 +8,7 @@ class BoxName {
static const String agreeTerms = "agreeTerms";
static const String addWork = 'addWork';
static const String addHome = 'addHome';
static const String tipAmount = 'tipAmount';
static const String tipPercentage = 'tipPercentage';
static const String accountIdStripeConnect = "accountIdStripeConnect";
static const String faceDetectTimes = "faceDetectTimes";
static const String sosPhonePassenger = "sosPhonePassenger";

View File

@@ -28,7 +28,7 @@ class AppLink {
static String getWalletByDriver = "$walletDriver/getWalletByDriver.php";
static String getDriversWallet = "$walletDriver/get.php";
static String addDriversWallet = "$walletDriver/add.php";
static String addDriversWalletPoints = "$walletDriver/add.php";
static String deleteDriversWallet = "$walletDriver/delete.php";
static String updateDriversWallet = "$walletDriver/update.php";

View File

@@ -21,6 +21,7 @@ import '../../views/home/profile/promos_passenger_page.dart';
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
import '../home/map_passenger_controller.dart';
import '../home/payment/captain_wallet_controller.dart';
import '../payment/payment_controller.dart';
class FirebaseMessagesController extends GetxController {
final fcmToken = FirebaseMessaging.instance;
@@ -204,56 +205,66 @@ class FirebaseMessagesController extends GetxController {
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
Get.defaultDialog(
title: 'Driver Finish Trip'.tr,
content: DriverTipWidget(),
confirm: MyElevatedButton(
title: 'Yes'.tr,
onPressed: () async {
var tip = (Get.find<MapPassengerController>().totalPassenger) *
(double.parse(box.read(BoxName.tipAmount.toString())));
var res = await CRUD().post(link: AppLink.addTips, payload: {
'passengerID': box.read(BoxName.passengerID),
'driverID': driverList[0].toString(),
'rideID': driverList[1].toString(),
'tipAmount': tip.toString(),
});
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * tip).toString()
});
if (Get.find<PaymentController>().isCashChecked == false &&
Get.find<PaymentController>().isWalletChecked == true) {
Get.defaultDialog(
title: 'Driver Finish Trip'.tr,
content: DriverTipWidget(),
confirm: MyElevatedButton(
title: 'Yes'.tr,
onPressed: () async {
var tip = (Get.find<MapPassengerController>().totalPassenger) *
(double.parse(box.read(BoxName.tipPercentage.toString())));
var res = await CRUD().post(link: AppLink.addTips, payload: {
'passengerID': box.read(BoxName.passengerID),
'driverID': driverList[0].toString(),
'rideID': driverList[1].toString(),
'tipAmount': tip.toString(),
});
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * tip).toString()
});
await CRUD().post(link: AppLink.addDriversWallet, payload: {
'driverID': driverList[0].toString(),
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
'amount': (tip * 100).toString(),
'paymentMethod': 'visa-tip',
});
await CRUD()
.post(link: AppLink.addDriversWalletPoints, payload: {
'driverID': driverList[0].toString(),
'paymentID':
'${Get.find<MapPassengerController>().rideId}tip',
'amount': (tip * 100).toString(),
'paymentMethod': 'visa-tip',
});
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'You Have Tips',
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
driverList[2].toString(),
);
}
Get.to(() => RateCaptainFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
},
kolor: AppColor.greenColor,
),
cancel: MyElevatedButton(
title: 'No,I want'.tr,
onPressed: () {
Get.to(() => RateCaptainFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
},
kolor: AppColor.redColor,
));
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'You Have Tips',
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
driverList[2].toString(),
);
}
Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
},
kolor: AppColor.greenColor,
),
cancel: MyElevatedButton(
title: 'No,I want'.tr,
onPressed: () {
Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
},
kolor: AppColor.redColor,
));
} else {
Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(),
});
}
}
}
@@ -457,10 +468,10 @@ class DriverTipWidget extends StatelessWidget {
children: [
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.05');
box.write(BoxName.tipPercentage, '0.05');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
AppColor.blueColor);
},
child: Container(
@@ -475,10 +486,10 @@ class DriverTipWidget extends StatelessWidget {
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.10');
box.write(BoxName.tipPercentage, '0.10');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
AppColor.blueColor);
},
child: Container(
@@ -493,10 +504,10 @@ class DriverTipWidget extends StatelessWidget {
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.15');
box.write(BoxName.tipPercentage, '0.15');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
AppColor.blueColor);
},
child: Container(
@@ -511,10 +522,10 @@ class DriverTipWidget extends StatelessWidget {
),
InkWell(
onTap: () {
box.write(BoxName.tipAmount, '0.20');
box.write(BoxName.tipPercentage, '0.20');
Toast.show(
context,
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipAmount.toString())))}',
'Tip is ${(Get.find<MapPassengerController>().totalPassenger) * (double.parse(box.read(BoxName.tipPercentage.toString())))}',
AppColor.blueColor);
},
child: Container(

View File

@@ -16,8 +16,10 @@ import '../../constant/style.dart';
class LogOutController extends GetxController {
TextEditingController checkTxtController = TextEditingController();
final formKey = GlobalKey<FormState>();
final formKey1 = GlobalKey<FormState>();
final emailTextController = TextEditingController();
Future deleteMyAccount(String id) async {
Future deleteMyAccountDriver(String id) async {
await CRUD().post(link: AppLink.removeUser, payload: {'id': id}).then(
(value) => Get.snackbar('Deleted', 'Your Account is Deleted',
backgroundColor: AppColor.redColor));
@@ -156,4 +158,18 @@ class LogOutController extends GetxController {
],
));
}
deletePassengerAccount() async {
if (formKey1.currentState!.validate()) {
if (box.read(BoxName.email).toString() == emailTextController.text) {
await CRUD().post(link: AppLink.passengerRemovedAccountEmail, payload: {
'email': box.read(BoxName.email),
});
} else {
Get.snackbar('Email Wrong'.tr, 'Email you inserted is Wrong.'.tr,
snackPosition: SnackPosition.BOTTOM,
backgroundColor: AppColor.redColor);
}
}
}
}

View File

@@ -265,7 +265,7 @@ class MapDriverController extends GetxController {
rideIsBeginPassengerTimer();
double pointsSubstraction = 0;
pointsSubstraction = double.parse(paymentAmount) * -100;
var res = await CRUD().post(link: AppLink.addDriversWallet, payload: {
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(),
'paymentMethod': paymentMethod,
@@ -563,6 +563,9 @@ class MapDriverController extends GetxController {
update();
}
late Duration durationToAdd;
int hours = 0;
int minutes = 0;
@override
void onInit() async {
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
@@ -621,6 +624,9 @@ class MapDriverController extends GetxController {
addCustomEndIcon();
// updateMarker();
startTimerToShowPassengerInfoWindowFromDriver();
durationToAdd = Duration(seconds: int.parse(duration));
hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round();
// cancelCheckRidefromPassenger();
// checkIsDriverNearPassenger();
super.onInit();

View File

@@ -520,14 +520,13 @@ class MapPassengerController extends GetxController {
update();
//print('rideTimerBegin: $rideTimerBegin');
//print('isRideFinished: $isRideFinished');
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * totalPassenger).toString()
});
// Get.to(() => RateCaptainFromPassenger(), arguments: {
// 'driverId': driverId.toString(),
// 'rideId': rideId.toString(),
// });
if (Get.find<PaymentController>().isWalletChecked == true &&
Get.find<PaymentController>().isCashChecked == false) {
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': ((-1) * totalPassenger).toString()
});
}
}
void getBeginRideFromDriver() async {

View File

@@ -93,7 +93,7 @@ class CaptainWalletController extends GetxController {
}
Future addDriverWallet(String paymentMethod, point) async {
await CRUD().post(link: AppLink.addDriversWallet, payload: {
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'driverID': box.read(BoxName.driverID).toString(),
'paymentID': paymentID.toString(),
'amount': point,

View File

@@ -8,8 +8,8 @@ import '../../controller/rate/rate_conroller.dart';
import '../widgets/elevated_btn.dart';
import '../widgets/my_scafold.dart';
class RateCaptainFromPassenger extends StatelessWidget {
RateCaptainFromPassenger({super.key});
class RateDriverFromPassenger extends StatelessWidget {
RateDriverFromPassenger({super.key});
final RateController controller = Get.put(RateController());
@override
Widget build(BuildContext context) {

View File

@@ -37,7 +37,9 @@ GetBuilder<MapDriverController> driverEndRideBar() {
children: [
const Icon(Icons.timelapse),
Text(
'${mapDriverController.duration} ${'Minute'.tr}',
mapDriverController.hours > 1
? '${'Your Ride Duration is '.tr}${mapDriverController.hours} H and ${mapDriverController.minutes} m'
: '${'Your Ride Duration is '.tr} ${mapDriverController.minutes} m',
style: AppStyle.title),
],
),

View File

@@ -108,22 +108,19 @@ class PointsPageForRider extends StatelessWidget {
border: Border.all(),
color:
AppColor.accentColor.withOpacity(.5)),
child: GetBuilder<MapPassengerController>(
builder: (mapPassengerController) {
return Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(mapPassengerController
.currentLocationStringAll[index]
.toString()),
const Icon(
Icons.reorder,
size: 20,
),
],
);
}),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(mapPassengerController
.currentLocationStringAll[index]
.toString()),
const Icon(
Icons.reorder,
size: 20,
),
],
),
),
),
trailing: index > 0

View File

@@ -143,8 +143,9 @@ class PassengerWalletDialoge extends StatelessWidget {
onPressed: () {
if (controller.selectedAmount != 0) {
controller.makePaymentStripe(
controller.selectedAmount as double, 'USD',
() {
controller.selectedAmount!
.toDouble(), // Convert int to double
'USD', () {
controller.addPassengerWallet();
controller.changePromoSheetDialogue();
controller.getPassengerWallet();

View File

@@ -63,7 +63,7 @@ class WaletCaptain extends StatelessWidget {
const SizedBox(
height: 10,
),
CardSeferWalletDriver(),
const CardSeferWalletDriver(),
Card(
elevation: 4,
child: Padding(

View File

@@ -203,44 +203,36 @@ class PassengerProfilePage extends StatelessWidget {
left: 70,
bottom: 10,
right: 70,
child: MyElevatedButton(
title: 'Delete My Account'.tr,
onPressed: () {
Get.defaultDialog(
title: 'Are you sure to delete your account?'.tr,
content: GetBuilder<LogOutController>(
builder: (logOutController) {
return Form(
child: GetBuilder<LogOutController>(builder: (logOutController) {
return MyElevatedButton(
title: 'Delete My Account'.tr,
onPressed: () {
Get.defaultDialog(
title: 'Are you sure to delete your account?'.tr,
content: Form(
key: logOutController.formKey1,
child: MyTextForm(
controller: logOutController.emailTextController,
label: 'Type your Email'.tr,
hint: 'Type your Email'.tr,
type: TextInputType.emailAddress,
),
);
}),
confirm: MyElevatedButton(
title: 'Delete My Account'.tr,
onPressed: () async {
if (logOutController.formKey.currentState!
.validate()) {
LogOutController().deleteMyAccount(
box.read(BoxName.passengerID).toString());
await CRUD().post(
link: AppLink.passengerRemovedAccountEmail,
payload: {
'email': box.read(BoxName.email).text,
});
}
}),
cancel: MyElevatedButton(
title: 'No I want'.tr,
onPressed: () {
logOutController.emailTextController.clear();
logOutController.update();
Get.back();
}));
}),
),
confirm: MyElevatedButton(
title: 'Delete My Account'.tr,
kolor: AppColor.redColor,
onPressed: () async {
await logOutController.deletePassengerAccount();
}),
cancel: MyElevatedButton(
title: 'No I want'.tr,
onPressed: () {
logOutController.emailTextController.clear();
logOutController.update();
Get.back();
}));
});
}),
)
],
);

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import '../../constant/colors.dart';
@@ -44,11 +45,17 @@ class MyTextForm extends StatelessWidget {
if (value!.isEmpty) {
return 'Please enter $label.'.tr;
}
if (type == TextInputType.emailAddress) {
return 'Please enter Valid email.'.tr;
if (!value.contains('@')) {
return 'Please enter a valid email.'.tr;
}
} else if (type == TextInputType.phone) {
return 'Please enter Valid Phone.'.tr;
if (value.length != 10) {
return 'Please enter a valid phone number.'.tr;
}
}
return null;
},
),