This commit is contained in:
Hamza-Ayed
2024-12-01 10:17:23 +02:00
parent 5aeb3cf685
commit 0129162309
34 changed files with 1317 additions and 875 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/controller/firebase/local_notification.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart';
import 'package:SEFER/views/widgets/mydialoug.dart';
@@ -159,21 +160,32 @@ Download the SEFER app now and enjoy your ride!
//claim your gift
if (driverInvitationData[index]['isGiftToken'].toString() == '0') {
Get.back();
await Get.find<CaptainWalletController>()
.addDriverWallet('paymentMethod', '500');
// add for invitor too
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
'paymentMethod',
driverInvitationData[index]['driverInviterId'],
'500');
await CRUD().post(
link: AppLink.updateInviteDriver,
payload: {'id': driverInvitationData[index]['id']});
await Get.find<CaptainWalletController>().addDriverPayment(
'paymentMethod',
'500',
'',
);
// add for invitor too
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
'paymentMethod',
driverInvitationData[index]['driverInviterId'],
'500',
);
await Get.find<CaptainWalletController>()
.addSeferWallet('giftInvitation', '-1000');
NotificationCaptainController().addNotificationCaptain(
driverInvitationData[index]['driverInviterId'].toString(),
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
false);
NotificationController().showNotification(
"You have got a gift for invitation".tr,
'${"You have 500".tr} ${'LE'}',
'tone1',
'');
} else {
Get.back();
MyDialog().getDialog("You have got a gift".tr,
@@ -188,12 +200,12 @@ Download the SEFER app now and enjoy your ride!
void onSelectPassengerInvitation(int index) async {
MyDialog().getDialog(
driverInvitationDataToPassengers[index]['countOfInvitDriver'] < 6
driverInvitationDataToPassengers[index]['countOfInvitDriver'] < 3
? '${'When'.tr} ${driverInvitationDataToPassengers[index]['passengerName']} ${"complete, you can claim your gift".tr} '
: 'You deserve the gift'.tr,
'${driverInvitationDataToPassengers[index]['passengerName']} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 6 ${'Trip'.tr}',
() async {
if (driverInvitationDataToPassengers[index]['countOfInvitDriver'] < 6) {
if (driverInvitationDataToPassengers[index]['countOfInvitDriver'] < 3) {
Get.back();
} else {
// Claim the gift if 100 trips are completed
@@ -203,7 +215,7 @@ Download the SEFER app now and enjoy your ride!
Get.back();
// Add wallet to the inviter
await Get.find<CaptainWalletController>()
.addDriverWallet('paymentMethod', '50');
.addDriverWallet('paymentMethod', '50', '50');
// add for invitor too
await Get.find<CaptainWalletController>().addDriverWalletToInvitor(
'paymentMethod',

View File

@@ -145,7 +145,9 @@ class LoginDriverController extends GetxController {
box.write(BoxName.phoneVerified,
jsonDecoeded['data'][0]['is_verified'].toString());
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
box.write(BoxName.is_claimed, jsonDecoeded['data'][0]['is_claimed']);
box.write(BoxName.nameArabic, jsonDecoeded['data'][0]['name_arabic']);
box.write(BoxName.carYear, jsonDecoeded['data'][0]['year']);
box.write(
BoxName.bankCodeDriver, jsonDecoeded['data'][0]['bankCode']);
box.write(BoxName.accountBankNumberDriver,

View File

@@ -269,12 +269,8 @@ class RegisterCaptainController extends GetxController {
update();
}
// Show error message in case of invalid phone number
void _showErrorMessage(String message) {
mySnackeBarError(message);
}
verifySMSCode() async {
// var loginDriverController = Get.put(LoginDriverController());
if (formKey3.currentState!.validate()) {
var res = await CRUD().post(link: AppLink.verifyOtpDriver, payload: {
'phone_number': '+2${phoneController.text}',
@@ -285,24 +281,16 @@ class RegisterCaptainController extends GetxController {
box.write(BoxName.phoneDriver, '+2${phoneController.text}');
box.write(BoxName.phoneVerified, '1');
// var res1 = await CRUD().post(
// link: AppLink.updateAccountBank,
// payload: {'phone': '+2${phoneController.text}'});
// if (res1 != 'failure') {
Get.find<LoginDriverController>().isGoogleLogin == true
? await Get.put(LoginDriverController())
.loginUsingCredentialsWithoutGoogle(
Get.find<LoginDriverController>()
.passwordController
.text
.toString(),
box.read(BoxName.emailDriver).toString(),
)
: await Get.put(LoginDriverController()).loginUsingCredentials(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver).toString(),
);
// Get.to(EgyptCardAI());
// loginDriverController.isGoogleLogin == true
// ? await loginDriverController.loginUsingCredentialsWithoutGoogle(
// loginDriverController.passwordController.text.toString(),
// box.read(BoxName.emailDriver).toString(),
// )
// : await loginDriverController.loginUsingCredentials(
// box.read(BoxName.driverID).toString(),
// box.read(BoxName.emailDriver).toString(),
// );
Get.to(EgyptCardAI());
// } else {
// Get.snackbar('title', 'message');
// }

View File

@@ -383,6 +383,70 @@ class NotificationController extends GetxController {
print('Notifications scheduled every 5 seconds');
}
void showTimerNotification(String title, String message, String tone) async {
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
// Setup Android notification
final AndroidNotificationDetails android = AndroidNotificationDetails(
'high_importance_channel',
'High Importance Notifications',
importance: Importance.max,
priority: Priority.high,
showWhen: false,
sound: RawResourceAndroidNotificationSound(
tone), // tone without the file extension
);
// Setup iOS notification
const DarwinNotificationDetails ios = DarwinNotificationDetails(
sound: 'default',
presentAlert: true,
presentBadge: true,
presentSound: true,
);
final NotificationDetails details =
NotificationDetails(android: android, iOS: ios);
// Request permission on Android
if (Platform.isAndroid) {
if (await Permission.scheduleExactAlarm.isDenied) {
if (await Permission.scheduleExactAlarm.request().isGranted) {
print('SCHEDULE_EXACT_ALARM permission granted');
} else {
print('SCHEDULE_EXACT_ALARM permission denied');
return;
}
}
}
// Timer duration (e.g., 120 seconds countdown)
int countdown = 12;
// Display the notification initially with the full countdown time
// Timer to update the notification every second
Timer.periodic(const Duration(seconds: 1), (timer) async {
// if (countdown > 0) {
// Update the existing notification with the updated countdown
// Decrease the countdown by 1
countdown--;
// } else {
// // Cancel the timer when the countdown reaches zero
// timer.cancel();
// }
});
await flutterLocalNotificationsPlugin.show(
0,
title,
'$message Remaining: $countdown seconds', // Initial message
details,
);
print('Notification will update every second');
}
// Callback when the notification is tapped
void onDidReceiveNotificationResponse(NotificationResponse response) {
handleNotificationResponse(response);
@@ -448,7 +512,7 @@ class NotificationController extends GetxController {
if (orderData is List && orderData.length == 34) {
closeOverLay();
Get.put(HomeCaptainController()).changeRideId();
Get.to(() => OrderSpeedRequest(), arguments: {'myListString': data});
Get.to(() => OrderRequestPage(), arguments: {'myListString': data});
} else {
Log.print('Invalid order data');
}

View File

@@ -233,7 +233,7 @@ class CRUD {
Log.print('response: ${response.body}');
// Log.print('response: ${response.statusCode}');
// Log.print('response: ${response.reasonPhrase}');
// Log.print('response: ${payload}');
Log.print('response: ${payload}');
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {

View File

@@ -258,7 +258,7 @@ class AI extends GetxController {
await addRegistrationCarEgypt();
if (isCarSaved && isDriverSaved) {
DeviceController().getDeviceSerialNumber();
// DeviceController().getDeviceSerialNumber();
box.write(BoxName.phoneVerified, '1');
Get.offAll(() => HomeCaptain());
// Get.offAll(() => HomeCaptain());
@@ -312,7 +312,7 @@ class AI extends GetxController {
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
'password':
Get.find<LoginDriverController>().passwordController.text.isEmpty
Get.put(LoginDriverController()).passwordController.text.isEmpty
? box.read(BoxName.emailDriver).toString()
: Get.find<LoginDriverController>()
.passwordController

View File

@@ -75,16 +75,41 @@ class LocationController extends GetxController {
isActive = Get.find<HomeCaptainController>().isActive;
if (isActive) {
if (double.parse(totalPoints) > -3000) {
if (double.parse(totalPoints) > -300) {
await getLocation();
print(
'Latitude: ${myLocation.latitude}, Longitude: ${myLocation.longitude}');
// Determine the area based on current location
// Determine the area
String area =
getLocationArea(myLocation.latitude, myLocation.longitude);
print('Determined Area: $area');
String endpoint;
switch (area) {
case 'Cairo':
print('Area matched: Cairo');
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
endpoint = AppLink.addCarsLocationCairoEndpoint;
break;
case 'Giza':
print('Area matched: Giza');
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
endpoint = AppLink.addCarsLocationGizaEndpoint;
break;
case 'Alexandria':
print('Area matched: Alexandria');
box.write(
BoxName.serverChosen, AppLink.seferAlexandriaServer);
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
break;
default:
print('Unknown location area. Fallback to Cairo');
endpoint = AppLink.addCarsLocationCairoEndpoint;
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
}
Log.print('Final Endpoint: $endpoint');
switch (area) {
case 'Cairo':
box.write(BoxName.serverChosen, AppLink.seferCairoServer);

View File

@@ -1,15 +1,18 @@
import 'dart:io';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:flutter_confetti/flutter_confetti.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
import 'package:get/get.dart';
import 'package:location/location.dart';
// import 'package:permission_handler/permission_handler.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../../print.dart';
import '../auth/captin/login_captin_controller.dart';
import '../home/payment/captain_wallet_controller.dart';
Future<void> getPermissionOverlay() async {
if (Platform.isAndroid) {
@@ -28,6 +31,27 @@ Future<void> getPermissionOverlay() async {
}
}
Future<void> showDriverGiftClaim(BuildContext context) async {
if (box.read(BoxName.is_claimed).toString() == '0' ||
box.read(BoxName.is_claimed) == null) {
MyDialog().getDialog('You have gift 300 L.E'.tr, 'text', () async {
var res = await CRUD().post(link: AppLink.updateDriverClaim, payload: {
'driverId': box.read(BoxName.driverID),
});
if (res != 'failure') {
Get.find<CaptainWalletController>()
.addDriverWallet('new driver', '300', '300');
Confetti.launch(
context,
options:
const ConfettiOptions(particleCount: 100, spread: 70, y: 0.6),
);
}
Get.back();
});
}
}
Future<void> closeOverlayIfFound() async {
if (Platform.isAndroid) {
bool isOverlayActive = await FlutterOverlayWindow.isActive();

View File

@@ -89,7 +89,7 @@ class HomeCaptainController extends GetxController {
isActive = !isActive;
if (isActive) {
if (double.parse(totalPoints) > -3000) {
if (double.parse(totalPoints) > -300) {
locationController.startLocationUpdates();
// locationBackController.startBackLocation();
activeStartTime = DateTime.now();

View File

@@ -173,19 +173,20 @@ class MapDriverController extends GetxController {
cancelTripFromDriverAfterApplied() async {
if (formKeyCancel.currentState!.validate()) {
FirebaseMessagesController().sendNotificationToDriverMAP(
"Cancel Trip from driver",
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
.tr,
tokenPassenger,
[],
'cancel.wav',
);
await CRUD().post(
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD()
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
}
await CRUD().post(
link:
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
@@ -196,6 +197,11 @@ class MapDriverController extends GetxController {
"notes": cancelTripCotroller.text.toString()
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD()
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
CRUD().post(
link:
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
@@ -206,14 +212,6 @@ class MapDriverController extends GetxController {
"notes": cancelTripCotroller.text.toString()
});
}
FirebaseMessagesController().sendNotificationToDriverMAP(
"Cancel Trip from driver".tr,
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
.tr,
tokenPassenger,
[],
'cancel.wav',
);
sql.insertData({
'order_id': rideId,
@@ -221,7 +219,7 @@ class MapDriverController extends GetxController {
'driver_id': box.read(BoxName.driverID).toString(),
}, TableName.driverOrdersRefuse);
Get.find<HomeCaptainController>().getRefusedOrderByCaptain();
Get.offAll(HomeCaptain());
Get.offAll(() => HomeCaptain());
}
}
@@ -550,21 +548,21 @@ class MapDriverController extends GetxController {
Get.find<LocationController>().myLocation.longitude,
);
MyDialog().getDialog('Are you sure to exit ride ?'.tr, '', () {
if (distanceToDestination > 900 ||
(double.parse(distance.toString()) < 1000 &&
distanceToDestination > 150)) {
Get.back();
finishRideFromDriver1();
} else {
Get.back();
if (distanceToDestination <= 150) {
// todo add scam from start point and dont move
// finishRideFromDriver1();
}
MyDialog().getDialog('you are not moved yet !'.tr, '', () {
Get.back();
});
}
// if (distanceToDestination > 900 ||
// (double.parse(distance.toString()) < 1000 &&
// distanceToDestination > 150)) {
Get.back();
finishRideFromDriver1();
// } else {
// Get.back();
// if (distanceToDestination <= 150) {
// // todo add scam from start point and dont move
// // finishRideFromDriver1();
// }
// MyDialog().getDialog('you are not moved yet !'.tr, '', () {
// Get.back();
// });
// }
});
}
@@ -598,7 +596,7 @@ class MapDriverController extends GetxController {
box.write(BoxName.rideStatus, 'Finished');
// Get.find<HomeCaptainController>().changeToAppliedRide('Finished');
// Get.find<HomeCaptainController>().update();
totalCost = price < 30
totalCost = price < 20
? carType != 'Comfort' && carType != 'Mishwar Vip' && carType != 'Lady'
? '20'
: '30'
@@ -662,7 +660,8 @@ class MapDriverController extends GetxController {
}
double pointsSubtraction = 0;
pointsSubtraction = double.parse(paymentAmount) * (-1);
pointsSubtraction =
double.parse(paymentAmount) * (-1) * .08; //for 300 from 3000
var paymentToken2 =
await generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {

View File

@@ -1,12 +1,14 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/main.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'dart:math' as math;
import '../../../constant/box_name.dart';
import '../../../print.dart';
import '../../functions/audio_controller.dart';
import '../../functions/crud.dart';
import '../../functions/location_controller.dart';
@@ -15,7 +17,7 @@ import 'home_captain_controller.dart';
class OrderRequestController extends GetxController {
double progress = 0;
double progressSpeed = 0;
int duration = 11;
int duration = 15;
int durationSpeed = 20;
int remainingTime = 0;
int remainingTimeSpeed = 0;
@@ -30,12 +32,17 @@ class OrderRequestController extends GetxController {
late int minutes;
@override
void onInit() {
Future<void> onInit() async {
// AudioController audioController = Get.put(AudioController());
print('onInit called');
await initilizeOrderPage();
bool isOverlayActive = await FlutterOverlayWindow.isActive();
if (isOverlayActive) {
await FlutterOverlayWindow.closeOverlay();
}
// audioController.playAudio();
// getRefusedOrderByCaptain();
initilizeOrderPage();
addCustomStartIcon();
addCustomEndIcon();
@@ -51,34 +58,41 @@ class OrderRequestController extends GetxController {
late double lngPassengerLocation;
late double lngPassengerDestination;
late double latPassengerDestination;
initilizeOrderPage() {
final myListString = arguments['myListString'];
// final myList = arguments['DriverList'];
if (arguments['DriverList'] == null || arguments['DriverList'].isEmpty) {
Future<void> initilizeOrderPage() async {
final myListString = Get.arguments['myListString'];
if (Get.arguments['DriverList'] == null ||
Get.arguments['DriverList'].isEmpty) {
myList = jsonDecode(myListString);
Log.print('myList: ${myList}');
} else {
myList = arguments['DriverList'];
myList = Get.arguments['DriverList'];
Log.print('myList1: ${myList}');
}
body = arguments['body'];
Duration durationToAdd = Duration(seconds: int.parse(myList[4]));
body = Get.arguments['body'];
Duration durationToAdd =
Duration(seconds: (double.tryParse(myList[4]) ?? 0).toInt());
hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round();
startTimerSpeed(myList[6].toString(), body.toString());
var coords = myList[0].split(',');
var coordDestination = myList[1].split(',');
// Parse to double
latPassengerLocation = double.parse(coords[0]);
lngPassengerLocation = double.parse(coords[1]);
latPassengerDestination = double.parse(coordDestination[0]);
lngPassengerDestination = double.parse(coordDestination[1]);
// Instead of splitting, directly use the values from the list
// First coordinate pair is at index 0 and 1
latPassengerLocation = double.tryParse(myList[0]) ?? 0.0;
lngPassengerLocation = double.tryParse(myList[1]) ?? 0.0;
// Second coordinate pair is at index 2 and 3
latPassengerDestination = double.tryParse(myList[2]) ?? 0.0;
lngPassengerDestination = double.tryParse(myList[3]) ?? 0.0;
pointsDirection = [
LatLng(latPassengerLocation, lngPassengerLocation),
LatLng(latPassengerDestination, lngPassengerDestination)
]; // Calculate the midpoint between the two points
// Calculate the minimum and maximum latitude and longitude values
];
// Calculate bounds
double minLatitude =
math.min(pointsDirection[0].latitude, pointsDirection[1].latitude);
double maxLatitude =
@@ -87,17 +101,18 @@ class OrderRequestController extends GetxController {
math.min(pointsDirection[0].longitude, pointsDirection[1].longitude);
double maxLongitude =
math.max(pointsDirection[0].longitude, pointsDirection[1].longitude);
// Create a bounding box using the calculated values
bounds = LatLngBounds(
southwest: LatLng(minLatitude, minLongitude),
northeast: LatLng(maxLatitude, maxLongitude),
);
update();
}
getRideDEtailsForBackgroundOrder() async {
getRideDEtailsForBackgroundOrder(String rideId) async {
await CRUD().get(link: AppLink.getRidesDetails, payload: {
'id': box.read(BoxName.myList)[2].toString(),
'id': rideId,
});
}
@@ -193,20 +208,14 @@ class OrderRequestController extends GetxController {
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
CRUD().post(
link: '${AppLink.seferAlexandriaServer}/rides/update.php',
payload: {
'id': orderID,
// 'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
CRUD().post(link: '${AppLink.seferGizaServer}/rides/update.php', payload: {
'id': orderID,
// 'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: '${AppLink.endPoint}/rides/update.php', payload: {
'id': orderID,
// 'rideTimeStart': DateTime.now().toString(),
'status': 'Refused',
'driver_id': box.read(BoxName.driverID),
});
}
// applied = true;
// if (box.read(BoxName.gender).toString() != 'Female') {
@@ -252,41 +261,24 @@ class OrderRequestController extends GetxController {
'distance': distance,
'duration': duration,
});
CRUD().post(
link:
'${AppLink.seferAlexandriaServer}/notificationCaptain/addWaitingRide.php',
payload: {
'id': orderID,
'start_location': startLocation,
'end_location': endLocation,
'date': date,
'time': time,
'price': price,
'passenger_id': passengerId,
'status': status,
'carType': carType,
'passengerRate': passengerRate,
'price_for_passenger': priceForPassenger,
'distance': distance,
'duration': duration,
});
CRUD().post(
link:
'${AppLink.seferGizaServer}/notificationCaptain/addWaitingRide.php',
payload: {
'id': orderID,
'start_location': startLocation,
'end_location': endLocation,
'date': date,
'time': time,
'price': price,
'passenger_id': passengerId,
'status': status,
'carType': carType,
'passengerRate': passengerRate,
'price_for_passenger': priceForPassenger,
'distance': distance,
'duration': duration,
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(
link: '${AppLink.endPoint}/notificationCaptain/addWaitingRide.php',
payload: {
'id': orderID,
'start_location': startLocation,
'end_location': endLocation,
'date': date,
'time': time,
'price': price,
'passenger_id': passengerId,
'status': status,
'carType': carType,
'passengerRate': passengerRate,
'price_for_passenger': priceForPassenger,
'distance': distance,
'duration': duration,
});
}
}
}

View File

@@ -1,8 +1,8 @@
import 'dart:convert';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart';
import 'package:SEFER/controller/firebase/local_notification.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/error_snakbar.dart';
import 'package:flutter/material.dart';
@@ -32,27 +32,34 @@ class CaptainWalletController extends GetxController {
payFromBudget() async {
if (formKey.currentState!.validate()) {
var pointFromBudget = box.read(BoxName.countryCode) == 'Jordan'
? int.parse((amountFromBudgetController.text)) * 100
: int.parse((amountFromBudgetController.text));
var pointFromBudget = int.parse((amountFromBudgetController.text));
await addDriverPaymentPoints('fromBudgetToPoints',
int.parse((amountFromBudgetController.text)) * -1);
var paymentToken3 = await generateToken(
(int.parse(amountFromBudgetController.text) * -1).toString());
// await getPaymentId('fromBudgetToPoints',
// int.parse((amountFromBudgetController.text)) * -1);
var paymentToken3 =
await generateToken((pointFromBudget * -1).toString());
var paymentID = await getPaymentId(
'fromBudgetToPoints', (pointFromBudget * -1).toString());
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'amount': (int.parse(amountFromBudgetController.text) * -1).toString(),
'amount': (pointFromBudget * -1).toString(),
'rideId': paymentID.toString(),
'payment_method': 'myBudget',
'passengerID': 'myBudgetToPoint',
'token': paymentToken3,
'driverID': box.read(BoxName.driverID).toString(),
});
Future.delayed(const Duration(seconds: 2));
await addDriverWallet('fromBudget', pointFromBudget.toString());
Future.delayed(const Duration(seconds: 1));
await addDriverWallet(
'fromBudget', pointFromBudget.toString(), pointFromBudget.toString());
update();
Get.back();
await refreshCaptainWallet();
NotificationController().showNotification(
'You have successfully charged your account'.tr,
'$pointFromBudget ${'has been added to your budget'.tr}',
'tone1',
'',
);
}
}
@@ -148,8 +155,8 @@ class CaptainWalletController extends GetxController {
return d['message'];
}
late String paymentID;
Future<String> addDriverPaymentPoints(String paymentMethod, amount) async {
// late String paymentID;
Future<String> getPaymentId(String paymentMethod, amount) async {
// paymentToken = await generateToken(amount);
var res = await CRUD().post(link: AppLink.addDriverPaymentPoints, payload: {
'driverID': box.read(BoxName.driverID).toString(),
@@ -157,12 +164,13 @@ class CaptainWalletController extends GetxController {
'payment_method': paymentMethod.toString(),
});
var d = jsonDecode(res);
paymentID = d['message'].toString();
return paymentID;
// paymentID = d['message'].toString();
return d['message'];
}
Future addDriverWallet(String paymentMethod, point) async {
paymentToken = await generateToken(point);
Future addDriverWallet(String paymentMethod, point, count) async {
paymentToken = await generateToken(count);
var paymentID = await getPaymentId(paymentMethod, point);
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'driverID': box.read(BoxName.driverID).toString(),
'paymentID': paymentID.toString(),
@@ -172,15 +180,66 @@ class CaptainWalletController extends GetxController {
});
}
Future addDriverPayment(String paymentMethod, point, wayPay) async {
paymentToken = await generateToken(point);
var paymentID = await getPaymentId(paymentMethod, point.toString());
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'amount': point.toString(),
'rideId': paymentID.toString(),
'payment_method': paymentMethod,
'passengerID': wayPay,
'token': paymentToken,
'driverID': box.read(BoxName.driverID).toString(),
});
}
Future addDriverWalletFromPromo(String paymentMethod, point) async {
var resPromotion =
await CRUD().post(link: AppLink.addpromotionDriver, payload: {
'driver_id': box.read(BoxName.driverID).toString(),
'payment_amount': point,
'timePromo': paymentMethod,
});
if (resPromotion != 'failure') {
paymentToken = await generateToken(point);
var paymentID = await getPaymentId(paymentMethod, point.toString());
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
'amount': point,
'rideId': paymentID.toString(),
'payment_method': paymentMethod.toString(),
'passengerID': paymentMethod,
'token': paymentToken,
'driverID': box.read(BoxName.driverID).toString(),
});
if (res != 'failure') {
String title = 'wallet_updated'.tr; // Notification title
String message = '${'wallet_credited_message'.tr} $point';
String tone = 'default_tone'.tr; // Notification tone or sound
String payLoad =
'wallet_updated'; // Additional data payload for the notification
Get.find<NotificationController>()
.showNotification(title, message, tone, payLoad);
}
} else {
Get.back();
mySnackeBarError(
"A promotion record for this driver already exists for today.".tr);
}
}
Future addDriverWalletToInvitor(String paymentMethod, driverID, point) async {
paymentToken = await generateToken(point);
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
var paymentID = await getPaymentId(paymentMethod, point.toString());
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'driverID': driverID,
'paymentID': paymentID.toString(),
'amount': point,
'token': paymentToken,
'paymentMethod': paymentMethod.toString(),
'rideId': paymentID.toString(),
'payment_method': paymentMethod.toString(),
'passengerID': paymentMethod,
});
await addSeferWallet(paymentMethod, (double.parse(point) * -1).toString());
}
Future addSeferWallet(String paymentMethod, String point) async {
@@ -195,10 +254,11 @@ class CaptainWalletController extends GetxController {
}
Future addTransferDriversWallet(String paymentMethod1, paymentMethod2) async {
paymentID = await addDriverPaymentPoints(
paymentMethod1, amountFromBudgetController.text);
var paymentID =
await getPaymentId(paymentMethod1, amountFromBudgetController.text);
paymentToken = await generateToken(
(int.parse(amountFromBudgetController.text) * -1).toString());
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'amount': (int.parse(amountFromBudgetController.text) * -1).toString(),
'rideId': paymentID.toString(),
@@ -208,15 +268,15 @@ class CaptainWalletController extends GetxController {
'driverID': box.read(BoxName.driverID).toString(),
});
paymentID = await addDriverPaymentPoints(paymentMethod2,
paymentID = await getPaymentId(paymentMethod2,
(int.parse(amountFromBudgetController.text) - 5).toString());
paymentToken = await generateToken(amountFromBudgetController.text);
var res1 =
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'driverID': amountToNewDriverMap[0]['id'].toString(),
'paymentID': paymentID.toString(),
'amount': ((int.parse(amountFromBudgetController.text) - 5) /
kazan) // double.parse(kazan) .08 for egypt
'amount': ((int.parse(amountFromBudgetController.text) - 5))
// kazan) // double.parse(kazan) .08 for egypt
.toStringAsFixed(
0), // this will convert buddget to poitns by kazan .08

View File

@@ -4,6 +4,18 @@ class MyTranslation extends Translations {
@override
Map<String, Map<String, String>> get keys => {
"ar": {
'Passenger Information': 'معلومات الراكب',
'Name': 'الاسم',
"wallet_updated": "تم تحديث المحفظة",
"wallet_credited_message": "تم إضافة",
"default_tone": "النغمة الافتراضية",
"No orders available": "لا توجد طلبات متوفرة",
'Phone': 'رقم الهاتف',
"A promotion record for this driver already exists for today.":
"يوجد بالفعل سجل ترويج لهذا السائق لهذا اليوم.",
'Gender': 'الجنس',
'time Selected': 'الوقت المختار',
'Ride Status': 'حالة الرحلة',
'If you need any help or have questions, this is the right place to do that. You are welcome!':
'إذا كنت بحاجة إلى أي مساعدة أو لديك أي أسئلة، فهذا هو المكان المناسب لذلك. أهلاً وسهلاً بك!',
'ID Mismatch': "عدم تطابق الرقم التعريفي",
@@ -52,7 +64,10 @@ class MyTranslation extends Translations {
"incorrect_document_title": "وثيقة غير صحيحة",
"incorrect_document_message":
"الرجاء تحميل {expected} الصحيحة. تم الكشف عن {detected}.",
"driver_license": "رخصة_القيادة",
"driver_license": "رخصة_القيادة", "minute": "دقيقة",
"kilometer": "كم",
"You have successfully charged your account": "تم شحن حسابك بنجاح",
"has been added to your budget": "تمت إضافته إلى ميزانيتك",
"id_front": "هوية_أمامية",
"id_back": "هوية_خلفية",
"car_back": "سيارة_خلفية",
@@ -139,6 +154,7 @@ class MyTranslation extends Translations {
"Central Bank Of Egypt": "البنك المركزي المصري",
"ATTIJARIWAFA BANK Egypt": "البنك التجاري وفا مصر",
"Morning Promo": "بونص الصباح",
'You have gift 300 L.E': "لديك هدية بقيمة 300 جنيه.",
"VIP Order": "طلب VIP", "VIP Order Accepted": "تم قبول طلب VIP.",
"The driver accepted your trip": "السائق قبل رحلتك.",
"this is count of your all trips in the morning promo today from 7:00am-10:00am":
@@ -156,8 +172,8 @@ class MyTranslation extends Translations {
"Please enter a health insurance status.":
"يرجى إدخال حالة التأمين الصحي",
"Sefer Driver": "سفر السائق",
"The 3000 points equal 3000 L.E for you \nSo go and gain your money":
"3000 نقطة تساوي 3000 جنيه لك \nلذا اذهب واحصل على أموالك",
"The 300 points equal 300 L.E for you \nSo go and gain your money":
"300 نقطة تساوي 300 جنيه لك \nلذا اذهب واحصل على أموالك",
"Info": "معلومات",
"You dont have money in your Wallet": "ليس لديك أموال في محفظتك",
"You dont have money in your Wallet or you should less transfer 5 LE to activate":
@@ -564,7 +580,7 @@ Store your money with us and receive it in your bank as a monthly salary.''':
"before": "قبل",
'SEFER': 'سفر',
"Code not approved": "الرمز غير موافق عليه",
"3000 LE": "3000 جنيه مصري",
"300 LE": "300 جنيه مصري",
"Do you have an invitation code from another driver?":
"هل لديك كود دعوة من سائق آخر؟",
"Paste the code here": "الصق الكود هنا",
@@ -1118,11 +1134,10 @@ Store your money with us and receive it in your bank as a monthly salary.''':
"Share Trip Details": "شارك تفاصيل الرحلة",
"Car Plate is": "لوحة السيارة",
'L.E': 'ج.م',
"the 3000 points equal 3000 L.E for you":
"الـ 3000 نقطة تعادل 3000 جنيه مصري بالنسبة لك",
"the 300 points equal 300 L.E for you":
"الـ 300 نقطة تعادل 300 جنيه مصري بالنسبة لك",
"So go and gain your money": "انطلق واكسب مالك",
"the 3000 points equal 3000 L.E":
"الـ 3000 نقطة تساوي 3000 جنيه مصري",
"the 300 points equal 300 L.E": "الـ 300 نقطة تساوي 300 جنيه مصري",
"The payment was not approved. Please try again.":
"لم يتم الموافقة على الدفع. يرجى المحاولة مرة أخرى.",
"Payment Failed": "تعذرت عملية الدفع",
@@ -1146,8 +1161,8 @@ Store your money with us and receive it in your bank as a monthly salary.''':
' is ON for this month': ' لهذا الشهر ',
"Origin": "الأصل",
"Destination": "مكان الوصول",
'the 3000 points equal 3000 L.E for you \nSo go and gain your money':
"ال3000 نقطة تعادل 3000 ج.م لك، فاذهب واكسب مالك.",
'the 300 points equal 300 L.E for you \nSo go and gain your money':
"ال300 نقطة تعادل 300 ج.م لك، فاذهب واكسب مالك.",
"Driver Name": "اسم السائق",
"Driver Car Plate": "لوحة سيارة السائق",
"Available for rides": "‏الرحلات المتوفرة",

View File

@@ -2,9 +2,7 @@ import 'dart:convert';
import 'dart:math';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/functions/location_controller.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
@@ -18,21 +16,55 @@ class RideAvailableController extends GetxController {
Map rideAvailableMap = {};
late LatLng southwest;
late LatLng northeast;
LatLngBounds calculateBounds(
double centerLat, double centerLng, double radius) {
// double radius = 4000; // 10 km in meters
// LatLngBounds calculateBounds(
// double centerLat, double centerLng, double radius) {
// // double radius = 4000; // 10 km in meters
southwest = LatLng(
centerLat - (radius / 111000),
centerLng - (radius / (111000 * cos(centerLat))),
// southwest = LatLng(
// centerLat - (radius / 111000),
// centerLng - (radius / (111000 * cos(centerLat))),
// );
// northeast = LatLng(
// centerLat + (radius / 111000),
// centerLng + (radius / (111000 * cos(centerLat))),
// );
// return LatLngBounds(southwest: southwest, northeast: northeast);
// }
LatLngBounds calculateBounds(double lat, double lng, double radiusInMeters) {
const double earthRadius = 6378137.0; // Earth's radius in meters
double latDelta = (radiusInMeters / earthRadius) * (180 / pi);
double lngDelta =
(radiusInMeters / (earthRadius * cos(pi * lat / 180))) * (180 / pi);
double minLat = lat - latDelta;
double maxLat = lat + latDelta;
double minLng = lng - lngDelta;
double maxLng = lng + lngDelta;
// Ensure the latitude is between -90 and 90
minLat = max(-90.0, minLat);
maxLat = min(90.0, maxLat);
// Ensure the longitude is between -180 and 180
minLng = (minLng + 180) % 360 - 180;
maxLng = (maxLng + 180) % 360 - 180;
// Ensure the bounds are in the correct order
if (minLng > maxLng) {
double temp = minLng;
minLng = maxLng;
maxLng = temp;
}
return LatLngBounds(
southwest: LatLng(minLat, minLng),
northeast: LatLng(maxLat, maxLng),
);
northeast = LatLng(
centerLat + (radius / 111000),
centerLng + (radius / (111000 * cos(centerLat))),
);
return LatLngBounds(southwest: southwest, northeast: northeast);
}
getRideAvailable() async {

View File

@@ -591,12 +591,12 @@ class PaymentController extends GetxController {
billingData: PaymobBillingDataWallet(),
onPayment: (PaymobResponseWallet response) {},
);
Log.print('message: ${response!.message}');
Log.print('responseCode: ${response.responseCode}');
Log.print('success: ${response.success}');
Log.print('transactionID: ${response.transactionID}');
if (response.responseCode.toString() == '200' &&
response.success == true) {
// Log.print('message: ${response!.message}');
// Log.print('responseCode: ${response.responseCode}');
// Log.print('success: ${response.success}');
// Log.print('transactionID: ${response.transactionID}');
if (response!.success == true &&
response.message.toString() == 'Approved') {
// Log.print('transactionID wewer: ${response.transactionID}');
Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
method();

View File

@@ -128,31 +128,26 @@ class RateController extends GetxController {
middleText: '',
confirm: MyElevatedButton(title: 'Ok', onPressed: () => Get.back()));
} else {
await CRUD()
.post(link: "${AppLink.seferCairoServer}/rate/add.php", payload: {
'passenger_id': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
'rideId': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rate/add.php",
await CRUD().post(
link: "${AppLink.seferCairoServer}/ride/rate/add.php",
payload: {
'passenger_id': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
'rideId': rideId,
'rideId': rideId.toString(),
'rating': selectedRateItemId.toString(),
'comment': comment.text,
'comment': comment.text ?? 'none',
});
CRUD().post(link: AppLink.seferGizaServer, payload: {
'passenger_id': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
'rideId': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
});
await CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: "${AppLink.endPoint}/ride/rate/add.php", payload: {
'passenger_id': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
'rideId': rideId.toString(),
'rating': selectedRateItemId.toString(),
'comment': comment.text ?? 'none',
});
}
CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
'startLocation':
Get.find<MapDriverController>().passengerLocation.toString(),
'endLocation':