This commit is contained in:
Hamza-Ayed
2024-08-17 22:15:26 +03:00
parent 46f11d5991
commit b93ddc3945
14 changed files with 358 additions and 203 deletions

7
.env
View File

@@ -14,7 +14,12 @@ chatGPTkeySeferNew=zg-Z4AJcAROgNXjgrEIU8fKC9XrxgUE4Qtrrlq1yiux0jL3dITSXrXlBl
secretKey=zg_ropj_57Iiv6MFCBFq3C2n6IXlmjykpxDmW93SW3vvXh68UA9T5FORTWgWsT37StKsOPdwDdsy8qR9srMUluahs3nPHvgBa33tGk90vV5XrXlBl secretKey=zg_ropj_57Iiv6MFCBFq3C2n6IXlmjykpxDmW93SW3vvXh68UA9T5FORTWgWsT37StKsOPdwDdsy8qR9srMUluahs3nPHvgBa33tGk90vV5XrXlBl
stripe_publishableKe=vg_ropj_57Iiv6MFCBFq3C2n6kNJnZByV6nuDtXe9IjEPOfhmpDtWmt3MLR0gQpiHcQmAFMUPrZc3QiCDjxBZLbxDC3efxWxz33bWH1ZgrsXrXlBl stripe_publishableKe=vg_ropj_57Iiv6MFCBFq3C2n6kNJnZByV6nuDtXe9IjEPOfhmpDtWmt3MLR0gQpiHcQmAFMUPrZc3QiCDjxBZLbxDC3efxWxz33bWH1ZgrsXrXlBl
llamaKey=RR-EuyoFDUvfRDBj46fZKAtKJ3voM8Mt768cPeJV7GNdAkPTKdY8Odm9n4ggGqI5GyoXrXlBl llamaKey=RR-EuyoFDUvfRDBj46fZKAtKJ3voM8Mt768cPeJV7GNdAkPTKdY8Odm9n4ggGqI5GyoXrXlBl
serverPHP=https://api.sefer.live/sefer serverPHP=https://sefer.click/sefer
seferAlexandriaServer=https://seferalexandria.site/sefer
seferPaymentServer=https://seferpayment.shop/sefer/ride
seferCairoServer=https://sefer.click/sefer
seferGizaServer=https://sefergiza.site/sefer
# serverPHP=https://api.sefer.live/sefer
cohere=Aulwd8y5SPWos0hJhG0toUf8gOhUUrpf5Q2TPmVGXrXlBl cohere=Aulwd8y5SPWos0hJhG0toUf8gOhUUrpf5Q2TPmVGXrXlBl
claudeAiAPI=zg-qbc-qvo39-xWOxIGwWTOzCFBnIYSKKhfyz_KVAvrH-6_4ZEJL68G_QBH26oeTOMMoQug9KuOjjKSP_A4S3SUDlbxR9duVzoQ-MkX_UQQQXrXlBl claudeAiAPI=zg-qbc-qvo39-xWOxIGwWTOzCFBnIYSKKhfyz_KVAvrH-6_4ZEJL68G_QBH26oeTOMMoQug9KuOjjKSP_A4S3SUDlbxR9duVzoQ-MkX_UQQQXrXlBl
payPalClientId=QALymfNI5Tzt4s-ysoz6vD4_nqX0SUtkC_qYV-Ugk5gaM_8Z-kg4L53k8Uux_4jEWXDkNpXGSWPpIzDFXrXlBl payPalClientId=QALymfNI5Tzt4s-ysoz6vD4_nqX0SUtkC_qYV-Ugk5gaM_8Z-kg4L53k8Uux_4jEWXDkNpXGSWPpIzDFXrXlBl

View File

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

View File

@@ -37,11 +37,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>45</string> <string>47</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>4.3.45</string> <string>4.3.47</string>
<key>FirebaseAppDelegateProxyEnabled</key> <key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string> <string>NO</string>
<key>GMSApiKey</key> <key>GMSApiKey</key>

View File

@@ -5,6 +5,7 @@ class BoxName {
static const String tokenParent = "tokenParent"; static const String tokenParent = "tokenParent";
static const String lang = "lang"; static const String lang = "lang";
static const String serverChosen = "serverChosen";
static const String gender = "gender"; static const String gender = "gender";
static const String carType = "carType"; static const String carType = "carType";
static const String carPlate = "carPlate"; static const String carPlate = "carPlate";

View File

@@ -1,7 +1,17 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/env/env.dart'; import 'package:SEFER/env/env.dart';
import 'package:SEFER/main.dart';
class AppLink { class AppLink {
static final String server = Env.serverPHP; // static final String seferPaymentServer = Env.seferPaymentServer;
static final String seferPaymentServer = '${Env.seferCairoServer}/ride';
static final String seferAlexandriaServer = Env.seferAlexandriaServer;
static final String seferCairoServer = Env.seferCairoServer;
static final String seferGizaServer = Env.seferGizaServer;
static final String endPoint = box.read(BoxName.serverChosen);
static final String server = endPoint;
static String googleMapsLink = 'https://maps.googleapis.com/maps/api/'; static String googleMapsLink = 'https://maps.googleapis.com/maps/api/';
static String llama = 'https://api.llama-api.com/chat/completions'; static String llama = 'https://api.llama-api.com/chat/completions';
static String gemini = static String gemini =
@@ -16,8 +26,8 @@ class AppLink {
static String packageInfo = "$server/auth/packageInfo.php"; static String packageInfo = "$server/auth/packageInfo.php";
//=======================Wallet=================== //=======================Wallet===================
static String wallet = '$server/ride/passengerWallet'; static String wallet = '$seferPaymentServer/passengerWallet';
static String walletDriver = '$server/ride/driverWallet'; static String walletDriver = '$seferPaymentServer/driverWallet';
static String getAllPassengerTransaction = static String getAllPassengerTransaction =
"$wallet/getAllPassengerTransaction.php"; "$wallet/getAllPassengerTransaction.php";
static String getWalletByPassenger = "$wallet/getWalletByPassenger.php"; static String getWalletByPassenger = "$wallet/getWalletByPassenger.php";
@@ -25,8 +35,8 @@ class AppLink {
static String getPassengerWalletArchive = static String getPassengerWalletArchive =
"$wallet/getPassengerWalletArchive.php"; "$wallet/getPassengerWalletArchive.php";
static String addDrivePayment = "$ride/payment/add.php"; static String addDrivePayment = "$seferPaymentServer/payment/add.php";
static String addSeferWallet = "$ride/seferWallet/add.php"; static String addSeferWallet = "$seferPaymentServer/seferWallet/add.php";
static String addPassengersWallet = "$wallet/add.php"; static String addPassengersWallet = "$wallet/add.php";
static String deletePassengersWallet = "$wallet/delete.php"; static String deletePassengersWallet = "$wallet/delete.php";
static String updatePassengersWallet = "$wallet/update.php"; static String updatePassengersWallet = "$wallet/update.php";
@@ -47,19 +57,22 @@ class AppLink {
////=======================cancelRide=================== ////=======================cancelRide===================
static String ride = '$server/ride'; static String ride = '$server/ride';
static String addCancelRideFromPassenger = "$server/ride/cancelRide/add.php"; static String addCancelRideFromPassenger =
static String cancelRide = "$server/ride/cancelRide/get.php"; "$endPoint/ride/cancelRide/add.php";
static String cancelRide = "$endPoint/ride/cancelRide/get.php";
//-----------------ridessss------------------ //-----------------ridessss------------------
static String addRides = "$ride/rides/add.php"; static String addRides = "$ride/rides/add.php";
static String getRides = "$ride/rides/get.php"; static String getRides = "$endPoint/ride/rides/get.php";
static String getRideOrderID = "$ride/rides/getRideOrderID.php"; static String getRideOrderID = "$endPoint/ride/rides/getRideOrderID.php";
static String getRideStatus = "$ride/rides/getRideStatus.php"; static String getRideStatus = "$endPoint/ride/rides/getRideStatus.php";
static String getRideStatusBegin = "$ride/rides/getRideStatusBegin.php"; static String getRideStatusBegin =
"$endPoint/ride/rides/getRideStatusBegin.php";
static String getRideStatusFromStartApp = static String getRideStatusFromStartApp =
"$ride/rides/getRideStatusFromStartApp.php"; "$ride/rides/getRideStatusFromStartApp.php";
static String updateRides = "$ride/rides/update.php"; static String updateRides = "$endPoint/ride/rides/update.php";
static String updateStausFromSpeed = "$ride/rides/updateStausFromSpeed.php"; static String updateStausFromSpeed =
static String deleteRides = "$ride/rides/delete.php"; "$endPoint/ride/rides/updateStausFromSpeed.php";
static String deleteRides = "$endPoint/ride/rides/delete.php";
//-----------------DriverPayment------------------ //-----------------DriverPayment------------------
static String adddriverScam = "$ride/driver_scam/add.php"; static String adddriverScam = "$ride/driver_scam/add.php";
@@ -128,7 +141,7 @@ class AppLink {
static String updateLicense = "$ride/license/updateFeedBack.php"; static String updateLicense = "$ride/license/updateFeedBack.php";
//-----------------RegisrationCar------------------ //-----------------RegisrationCar------------------
static String addRegisrationCar = "$ride/RegisrationCar/add.php"; static String addRegisrationCar = "$ride/RegisrationCar/add.php";
static String getRegisrationCar = "$ride/RegisrationCar/get.php"; static String getRegisrationCar = "$endPoint/ride/RegisrationCar/get.php";
static String selectDriverAndCarForMishwariTrip = static String selectDriverAndCarForMishwariTrip =
"$ride/RegisrationCar/selectDriverAndCarForMishwariTrip.php"; "$ride/RegisrationCar/selectDriverAndCarForMishwariTrip.php";
static String updateRegisrationCar = "$ride/RegisrationCar/update.php"; static String updateRegisrationCar = "$ride/RegisrationCar/update.php";
@@ -169,7 +182,7 @@ class AppLink {
static String uploadEgypt = "$server/uploadEgypt.php"; static String uploadEgypt = "$server/uploadEgypt.php";
//==================certifcate========== //==================certifcate==========
static String location = '$server/ride/location'; static String location = '$endPoint/ride/location';
static String getCarsLocationByPassenger = "$location/get.php"; static String getCarsLocationByPassenger = "$location/get.php";
static String addpassengerLocation = "$location/addpassengerLocation.php"; static String addpassengerLocation = "$location/addpassengerLocation.php";
static String getCarsLocationByPassengerSpeed = "$location/getSpeed.php"; static String getCarsLocationByPassengerSpeed = "$location/getSpeed.php";

View File

@@ -181,6 +181,14 @@ class RegisterController extends GetxController {
payload: payload, payload: payload,
); );
if (res1 != 'failure') { if (res1 != 'failure') {
CRUD().post(
link: '${AppLink.seferAlexandriaServer}/auth/signup.php',
payload: payload,
);
CRUD().post(
link: '${AppLink.seferGizaServer}/auth/signup.php',
payload: payload,
);
box.write(BoxName.isVerified, '1'); box.write(BoxName.isVerified, '1');
box.write(BoxName.phone, '+2${phoneController.text}'); box.write(BoxName.phone, '+2${phoneController.text}');
Get.offAll(const MapPagePassenger()); Get.offAll(const MapPagePassenger());

View File

@@ -195,11 +195,7 @@ class FirebaseMessagesController extends GetxController {
onPressed: () async { onPressed: () async {
Get.back(); Get.back();
await Get.find<MapPassengerController>() await Get.find<MapPassengerController>()
.getCarsLocationByPassengerAndReloadMarker( .reSearchAfterCanceledFromDriver();
box.read(BoxName.carType), 7000);
Get.find<MapPassengerController>()
.confirmRideForAllDriverAvailable();
}, },
), ),
cancel: MyElevatedButton( cancel: MyElevatedButton(

View File

@@ -28,9 +28,11 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}', 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
}, },
); );
print(response.request);
Log.print('payload: ${payload}'); Log.print('payload: ${payload}');
print(response.body); Log.print('response.request: ${response.request}');
Log.print('response.reasonPhrase: ${response.reasonPhrase}');
Log.print('response.body: ${response.body}');
// print(payload); // print(payload);
// if (response.statusCode == 200) { // if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body); var jsonData = jsonDecode(response.body);
@@ -231,8 +233,10 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}', 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
}, },
); );
print(response.request); Log.print('payload: ${payload}');
print(response.body); // print(response.request);
Log.print('response.request: ${response.request}');
Log.print('response.body: ${response.body}');
var jsonData = jsonDecode(response.body); var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) { if (response.statusCode == 200) {
if (jsonData['status'] == 'success') { if (jsonData['status'] == 'success') {

View File

@@ -218,7 +218,7 @@ class MapPassengerController extends GetxController {
bool currentLocationToFormPlaces3 = false; bool currentLocationToFormPlaces3 = false;
bool currentLocationToFormPlaces4 = false; bool currentLocationToFormPlaces4 = false;
List currentLocationToFormPlacesAll = []; List currentLocationToFormPlacesAll = [];
late String driverToken; late String driverToken = '';
int carsOrder = 0; int carsOrder = 0;
int wayPointIndex = 0; int wayPointIndex = 0;
late double kazan; late double kazan;
@@ -559,7 +559,7 @@ class MapPassengerController extends GetxController {
remainingTimeToPassengerFromDriverAfterApplied = remainingTimeToPassengerFromDriverAfterApplied =
timeToPassengerFromDriverAfterApplied - secondsElapsed; timeToPassengerFromDriverAfterApplied - secondsElapsed;
if (remainingTimeToPassengerFromDriverAfterApplied < 69) { if (remainingTimeToPassengerFromDriverAfterApplied < 59) {
if (rideTimerBegin == false) { if (rideTimerBegin == false) {
rideTimerBegin = true; rideTimerBegin = true;
} }
@@ -1016,11 +1016,13 @@ class MapPassengerController extends GetxController {
late String make = ''; late String make = '';
late String licensePlate = ''; late String licensePlate = '';
confirmRideForFirstDriver() async { confirmRideForFirstDriver() async {
startCarLocationSearch(box.read(BoxName.carType)); // startCarLocationSearch(box.read(BoxName.carType));
// await getCarsLocationByPassengerAndReloadMarker(); await getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 7000);
await getNearestDriverByPassengerLocationAPIGOOGLE(); await getNearestDriverByPassengerLocationAPIGOOGLE();
if (dataCarsLocationByPassenger != 'failure') { if (dataCarsLocationByPassenger != 'failure' ||
dataCarsLocationByPassenger != null) {
driverToken = driverToken =
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(); dataCarsLocationByPassenger['message'][carsOrder]['token'].toString();
driverPhone = driverPhone =
@@ -1050,7 +1052,6 @@ class MapPassengerController extends GetxController {
isDriversTokensSend = false; isDriversTokensSend = false;
update(); update();
await CRUD().post(link: AppLink.addRides, payload: { await CRUD().post(link: AppLink.addRides, payload: {
"start_location": //'${data[0]['start_address']}', "start_location": //'${data[0]['start_address']}',
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}', '${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
@@ -1131,6 +1132,51 @@ class MapPassengerController extends GetxController {
Log.print( Log.print(
'body: ${dataCarsLocationByPassenger['message'][carsOrder]['token']}'); 'body: ${dataCarsLocationByPassenger['message'][carsOrder]['token']}');
}); });
CRUD().post(
link: '${AppLink.seferAlexandriaServer}/ride/rides/add.php',
payload: {
"start_location": //'${data[0]['start_address']}',
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
"end_location": //'${data[0]['end_address']}',
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
"date": DateTime.now().toString(),
"time": DateTime.now().toString(),
"endtime": durationToAdd.toString(),
"price": totalPassenger.toStringAsFixed(2),
"passenger_id": box.read(BoxName.passengerID).toString(),
"driver_id": dataCarsLocationByPassenger['message'][carsOrder]
['driver_id']
.toString(),
"status": "waiting",
'carType': box.read(BoxName.carType),
"price_for_driver": totalPassenger.toString(),
"price_for_passenger": totalME.toString(),
"distance": distance.toString(),
"paymentMethod": paymentController.isWalletChecked.toString(),
});
CRUD().post(
link: '${AppLink.seferGizaServer}/ride/rides/add.php',
payload: {
"start_location": //'${data[0]['start_address']}',
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
"end_location": //'${data[0]['end_address']}',
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
"date": DateTime.now().toString(),
"time": DateTime.now().toString(),
"endtime": durationToAdd.toString(),
"price": totalPassenger.toStringAsFixed(2),
"passenger_id": box.read(BoxName.passengerID).toString(),
"driver_id": dataCarsLocationByPassenger['message'][carsOrder]
['driver_id']
.toString(),
"status": "waiting",
'carType': box.read(BoxName.carType),
"price_for_driver": totalPassenger.toString(),
"price_for_passenger": totalME.toString(),
"distance": distance.toString(),
"paymentMethod": paymentController.isWalletChecked.toString(),
});
delayAndFetchRideStatus(rideId); delayAndFetchRideStatus(rideId);
if (shouldFetch == false) { if (shouldFetch == false) {
startTimer(); startTimer();
@@ -1156,8 +1202,6 @@ class MapPassengerController extends GetxController {
bool isDriversTokensSend = false; bool isDriversTokensSend = false;
confirmRideForAllDriverAvailable() async { confirmRideForAllDriverAvailable() async {
// isDriversTokensSend = true;
driversToken.remove(driverToken); driversToken.remove(driverToken);
PaymentController paymentController = Get.find<PaymentController>(); PaymentController paymentController = Get.find<PaymentController>();
rideConfirm = true; rideConfirm = true;
@@ -1206,6 +1250,7 @@ class MapPassengerController extends GetxController {
kazan.toStringAsFixed(0), kazan.toStringAsFixed(0),
passengerRate.toStringAsFixed(2), passengerRate.toStringAsFixed(2),
]; ];
Log.print('body: ${body}');
for (var i = 1; i < driversToken.length; i++) { for (var i = 1; i < driversToken.length; i++) {
FirebaseMessagesController().sendNotificationToDriverMapPolyline( FirebaseMessagesController().sendNotificationToDriverMapPolyline(
'OrderSpeed', 'OrderSpeed',
@@ -1255,8 +1300,8 @@ class MapPassengerController extends GetxController {
// } // }
tick++; tick++;
} else { } else {
timer timer.cancel();
.cancel(); // Stop the timer if remainingTimeToPassengerFromDriverAfterApplied <= 0 // Stop the timer if remainingTimeToPassengerFromDriverAfterApplied <= 0
} }
} else { } else {
timer.cancel(); // Stop the timer if shouldFetch is false timer.cancel(); // Stop the timer if shouldFetch is false
@@ -1269,124 +1314,132 @@ class MapPassengerController extends GetxController {
"No Captain Accepted Your Order".tr, "No Captain Accepted Your Order".tr,
"We are looking for a captain but the price may increase to let a captain accept" "We are looking for a captain but the price may increase to let a captain accept"
.tr, .tr,
backgroundColor: AppColor.bronze, backgroundColor: AppColor.yellowColor,
); );
} }
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) async { void delayAndFetchRideStatusForAllDriverAvailable(String rideId) async {
startCarLocationSearch(box.read(BoxName.carType));
int attemptCounter = 0;
const int maxAttempts = 15; const int maxAttempts = 15;
int attemptCounter = 0;
bool isApplied = false;
tick = 0; tick = 0;
Log.print('tick delayAndFetchRideStatusForAllDriverAvailable: ${tick}'); Log.print('tick delayAndFetchRideStatusForAllDriverAvailable: ${tick}');
void fetchRideStatus() async { void fetchRideStatus() async {
if (shouldFetch && attemptCounter < maxAttempts) { if (attemptCounter < maxAttempts && !isApplied) {
attemptCounter++; attemptCounter++;
tick++; tick++;
var res = await getRideStatus(rideId); var res = await getRideStatus(rideId);
if (res.toString() == 'Apply') { if (res.toString() == 'Apply') {
getUpdatedRideForDriverApply(rideId); getUpdatedRideForDriverApply(rideId);
isApplied = true;
shouldFetch = false; // Stop further fetches shouldFetch = false;
statusRide = 'Apply'; statusRide = 'Apply';
rideConfirm = false; rideConfirm = false;
isSearchingWindow = false; isSearchingWindow = false;
update(); update();
startTimerFromDriverToPassengerAfterApplied(); startTimerFromDriverToPassengerAfterApplied();
} else { } else if (attemptCounter >= maxAttempts) {
Timer(const Duration(seconds: 2), shouldFetch = false;
fetchRideStatus); // Continue fetching for other statuses // If the status is still not "Apply" after 15 attempts
} MyDialog().getDialog('upgrade price'.tr,
} else { 'You can upgrade price to may driver accept your order'.tr, () {
// Stop fetching after maxAttempts or if shouldFetch is false Get.back();
shouldFetch = false; Get.defaultDialog(
MyDialog().getDialog('upgrade price'.tr, barrierDismissible: false,
'You can upgrade price to may driver accept your order'.tr, () { title: "Increase Your Trip Fee (Optional)".tr,
Get.back(); titleStyle: AppStyle.title,
Get.defaultDialog( content: Column(
barrierDismissible: false, children: [
title: "Increase Your Trip Fee (Optional)".tr, Text(
titleStyle: AppStyle.title, "We haven't found any drivers yet. Consider increasing your trip fee to make your offer more attractive to drivers."
content: Column( .tr,
children: [ style: AppStyle.title,
Text( textAlign: TextAlign.center,
"We haven't found any drivers yet. Consider increasing your trip fee to make your offer more attractive to drivers." ),
.tr, Row(
style: AppStyle.title, mainAxisAlignment: MainAxisAlignment.center,
textAlign: TextAlign.center, children: [
), IconButton(
Row( onPressed: () {
mainAxisAlignment: MainAxisAlignment.center, increasFeeFromPassenger.text =
children: [ (totalPassenger + 6).toStringAsFixed(1);
IconButton( update();
onPressed: () { },
increasFeeFromPassenger.text = icon: Column(
(totalPassenger + 6).toStringAsFixed(1); children: [
// mapPassengerController.increasFeeFromPassenger.text = Text(
// mapPassengerController.totalPassenger '6',
// .toStringAsFixed(1); style: AppStyle.number,
update();
},
icon: Column(
children: [
Text(
'6',
style: AppStyle.number,
),
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: AppColor.greenColor),
child: const Icon(
Icons.arrow_circle_up,
size: 30,
color: AppColor.secondaryColor,
), ),
), Container(
], decoration: const BoxDecoration(
shape: BoxShape.circle,
color: AppColor.greenColor),
child: const Icon(
Icons.arrow_circle_up,
size: 30,
color: AppColor.secondaryColor,
),
),
],
),
), ),
), SizedBox(
SizedBox( width: 100,
width: 100, child: Form(
child: Form( key: increaseFeeFormKey,
key: increaseFeeFormKey, child: MyTextForm(
child: MyTextForm( controller: increasFeeFromPassenger,
controller: increasFeeFromPassenger, label: totalPassenger.toStringAsFixed(2),
label: totalPassenger.toStringAsFixed(2), hint: totalPassenger.toStringAsFixed(2),
hint: totalPassenger.toStringAsFixed(2), type: TextInputType.number),
type: TextInputType.number), ),
), ),
), ],
], )
) ],
),
actions: [
MyElevatedButton(
title: "No, thanks",
onPressed: () {
Get.back();
cancelRide();
}),
MyElevatedButton(
title: "Increase Fee".tr,
kolor: AppColor.greenColor,
onPressed: () {
increaseFeeByPassengerAndReOrder();
})
], ],
), );
actions: [ });
MyElevatedButton( update();
title: "No, thanks", print('Stopped fetching ride status after 15 attempts.');
onPressed: () { } else {
Get.back(); Timer(const Duration(seconds: 2), fetchRideStatus);
cancelRide(); }
}),
MyElevatedButton(
title: "Increase Fee".tr,
kolor: AppColor.greenColor,
onPressed: () {
increaseFeeByPassengerAndReOrder();
})
],
);
});
update();
print('Stopped fetching ride status after 30 seconds.');
} }
} }
fetchRideStatus(); // Initial call to start the process fetchRideStatus(); // Initial call to start the process
} }
reSearchAfterCanceledFromDriver() async {
await getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 7000);
confirmRideForAllDriverAvailable();
shouldFetch = true; // Stop further fetches
statusRide = 'wait';
rideConfirm = true;
isSearchingWindow = true;
update();
}
void start15SecondTimer(String rideId) { void start15SecondTimer(String rideId) {
Timer(const Duration(seconds: 15), () { Timer(const Duration(seconds: 15), () {
delayAndFetchRideStatusForAllDriverAvailable(rideId); delayAndFetchRideStatusForAllDriverAvailable(rideId);
@@ -1581,7 +1634,7 @@ class MapPassengerController extends GetxController {
Log.print('searchInterval: ${searchInterval}'); Log.print('searchInterval: ${searchInterval}');
int boundIncreaseStep = 2500; // Initial bounds in meters int boundIncreaseStep = 2500; // Initial bounds in meters
Log.print('boundIncreaseStep: ${boundIncreaseStep}'); Log.print('boundIncreaseStep: ${boundIncreaseStep}');
int maxAttempts = 6; // Maximum attempts to increase bounds int maxAttempts = 3; // Maximum attempts to increase bounds
int maxBoundIncreaseStep = 6000; // Maximum bounds increase step int maxBoundIncreaseStep = 6000; // Maximum bounds increase step
int attempt = 0; // Current attempt int attempt = 0; // Current attempt
Log.print('initial attempt: ${attempt}'); Log.print('initial attempt: ${attempt}');
@@ -1598,7 +1651,8 @@ class MapPassengerController extends GetxController {
} }
return; return;
} else { } else if (reloadStartApp == true) {
Log.print('reloadStartApp: ${reloadStartApp}');
foundCars = await getCarsLocationByPassengerAndReloadMarker( foundCars = await getCarsLocationByPassengerAndReloadMarker(
carType, boundIncreaseStep); carType, boundIncreaseStep);
Log.print('foundCars: ${foundCars}'); Log.print('foundCars: ${foundCars}');
@@ -1624,6 +1678,36 @@ class MapPassengerController extends GetxController {
}); });
} }
String getLocationArea(double latitude, double longitude) {
// Giza Boundary Check
if (latitude >= 29.904975 &&
latitude <= 30.143372 &&
longitude >= 30.787030 &&
longitude <= 31.238843) {
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
return 'Giza';
}
// Cairo Boundary Check
else if (latitude >= 29.918901 &&
latitude <= 30.198857 &&
longitude >= 31.215009 &&
longitude <= 31.532186) {
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
return 'Cairo';
}
// Alexandria Boundary Check
else if (latitude >= 30.396286 &&
latitude <= 31.654458 &&
longitude >= 29.041139 &&
longitude <= 32.626259) {
box.write(BoxName.serverChosen, AppLink.seferAlexandriaServer);
return 'Alexandria';
}
// Return 'Unknown' if outside defined areas
return 'Unknown';
}
Future<bool> getCarsLocationByPassengerAndReloadMarker( Future<bool> getCarsLocationByPassengerAndReloadMarker(
String carType, int boundIncreaseStep) async { String carType, int boundIncreaseStep) async {
if (statusRide == 'wait') { if (statusRide == 'wait') {
@@ -1631,6 +1715,7 @@ class MapPassengerController extends GetxController {
LatLngBounds bounds = calculateBounds(passengerLocation.latitude, LatLngBounds bounds = calculateBounds(passengerLocation.latitude,
passengerLocation.longitude, boundIncreaseStep.toDouble()); passengerLocation.longitude, boundIncreaseStep.toDouble());
var res; var res;
// await getLocation();
switch (carType) { switch (carType) {
case 'Lady': case 'Lady':
@@ -1680,6 +1765,9 @@ class MapPassengerController extends GetxController {
} }
if (res == 'failure') { if (res == 'failure') {
noCarString = true;
dataCarsLocationByPassenger = 'failure';
update();
return false; return false;
} else { } else {
noCarString = false; noCarString = false;
@@ -1930,6 +2018,8 @@ class MapPassengerController extends GetxController {
})); }));
} else if (res1['status'] == 'success') { } else if (res1['status'] == 'success') {
var tokenParent = res1['data'][0]['token']; var tokenParent = res1['data'][0]['token'];
Get.snackbar("The invitation was sent successfully".tr, '',
backgroundColor: AppColor.greenColor);
FirebaseMessagesController().sendNotificationToPassengerToken( FirebaseMessagesController().sendNotificationToPassengerToken(
"Trip Monitoring".tr, "Trip Monitoring".tr,
"Trip Monitoring".tr, "Trip Monitoring".tr,
@@ -2029,9 +2119,14 @@ class MapPassengerController extends GetxController {
.toString()); .toString());
BitmapDescriptor icon = BitmapDescriptor icon =
datadriverCarsLocationToPassengerAfterApplied['message'][0]['model'] datadriverCarsLocationToPassengerAfterApplied['message'][0]
.toString() ['model']
.contains('دراجة') .toString()
.contains('دراجة') ||
datadriverCarsLocationToPassengerAfterApplied['message'][0]
['make']
.toString()
.contains('دراجة')
? motoIcon ? motoIcon
: datadriverCarsLocationToPassengerAfterApplied['message'][0] : datadriverCarsLocationToPassengerAfterApplied['message'][0]
['gender'] == ['gender'] ==
@@ -2155,14 +2250,14 @@ class MapPassengerController extends GetxController {
clearPlacesDestination(); clearPlacesDestination();
clearPolyline(); clearPolyline();
data = []; data = [];
await CRUD().post(link: AppLink.updateDriverOrder, payload: { // await CRUD().post(link: AppLink.updateDriverOrder, payload: {
"order_id": rideId.toString(), // Convert to String // "order_id": rideId.toString(), // Convert to String
"status": 'Cancel' // "status": 'Cancel'
}); // });
await CRUD().post(link: AppLink.updateRides, payload: { // await CRUD().post(link: AppLink.updateRides, payload: {
"id": rideId.toString(), // Convert to String // "id": rideId.toString(), // Convert to String
"status": 'Cancel' // "status": 'Cancel'
}); // });
Get.offAll(const MapPagePassenger()); Get.offAll(const MapPagePassenger());
} }
} }
@@ -2516,6 +2611,7 @@ class MapPassengerController extends GetxController {
(_locationData.latitude != null && _locationData.longitude != null (_locationData.latitude != null && _locationData.longitude != null
? LatLng(_locationData.latitude!, _locationData.longitude!) ? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!; : null)!;
getLocationArea(passengerLocation.latitude, passengerLocation.longitude);
newStartPointLocation = passengerLocation; newStartPointLocation = passengerLocation;
speed = _locationData.speed!; speed = _locationData.speed!;
// //print location details // //print location details
@@ -2563,30 +2659,34 @@ class MapPassengerController extends GetxController {
// } // }
// }); // });
// } // }
bool reloadStartApp = false;
startMarkerReloading() async { startMarkerReloading() async {
Log.print('AppLink.endPoint: ${AppLink.endPoint}');
int reloadCount = 0; int reloadCount = 0;
if (reloadStartApp == false) {
Timer.periodic(const Duration(seconds: 5), (timer) async {
reloadCount++;
Log.print('reloadCount: ${reloadCount}');
Timer.periodic(const Duration(seconds: 5), (timer) async { if (!rideConfirm) {
reloadCount++; clearMarkersExceptStartEnd();
Log.print('reloadCount: ${reloadCount}'); // _smoothlyUpdateMarker();
// startCarLocationSearch(box.read(BoxName.carType));
await getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 6000);
await getNearestDriverByPassengerLocation();
Log.print('reloadMarkers: from startMarkerReloading');
} else {
// runWhenRideIsBegin();
}
if (!rideConfirm) { if (reloadCount >= 6) {
clearMarkersExceptStartEnd(); reloadStartApp = true;
// _smoothlyUpdateMarker(); timer.cancel(); // Stop the timer after 5 reloads
// startCarLocationSearch(box.read(BoxName.carType)); }
await getCarsLocationByPassengerAndReloadMarker( });
box.read(BoxName.carType), 6000); }
await getNearestDriverByPassengerLocation();
Log.print('reloadMarkers: from startMarkerReloadin');
} else {
// runWhenRideIsBegin();
}
if (reloadCount >= 10) {
timer.cancel(); // Stop the timer after 5 reloads
}
});
} }
String durationByPassenger = ''; String durationByPassenger = '';
@@ -2602,39 +2702,41 @@ class MapPassengerController extends GetxController {
} }
if (!rideConfirm) { if (!rideConfirm) {
if (dataCarsLocationByPassenger != 'failure') { if (dataCarsLocationByPassenger != 'failure') {
if (dataCarsLocationByPassenger['message'].length > 0) { if (dataCarsLocationByPassenger != null) {
for (var i = 0; if (dataCarsLocationByPassenger['message'].length > 0) {
i < dataCarsLocationByPassenger['message'].length; for (var i = 0;
i++) { i < dataCarsLocationByPassenger['message'].length;
var carLocation = dataCarsLocationByPassenger['message'][i]; i++) {
var carLocation = dataCarsLocationByPassenger['message'][i];
// Calculate the distance between the passenger's location and the current driver's location // Calculate the distance between the passenger's location and the current driver's location
final distance = Geolocator.distanceBetween( final distance = Geolocator.distanceBetween(
passengerLocation.latitude, passengerLocation.latitude,
passengerLocation.longitude, passengerLocation.longitude,
double.parse(carLocation['latitude']), double.parse(carLocation['latitude']),
double.parse(carLocation['longitude']), double.parse(carLocation['longitude']),
);
durationToPassenger = (distance * 25 * (1000 / 3600))
.round(); //////35 is avg of speed in city
// Update the UI with the distance and duration
update();
// If the distance is less than the nearest distance, update the nearest driver
if (distance < nearestDistance) {
nearestDistance = distance;
nearestCar = CarLocation(
distance: distance,
duration:
0, // We don't have duration information from Geolocator
id: carLocation['driver_id'],
latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']),
); );
durationToPassenger = (distance * 25 * (1000 / 3600))
// Update the UI with the nearest driver .round(); //////35 is avg of speed in city
// Update the UI with the distance and duration
update(); update();
// If the distance is less than the nearest distance, update the nearest driver
if (distance < nearestDistance) {
nearestDistance = distance;
nearestCar = CarLocation(
distance: distance,
duration:
0, // We don't have duration information from Geolocator
id: carLocation['driver_id'],
latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']),
);
// Update the UI with the nearest driver
update();
}
} }
} }
} }
@@ -2665,7 +2767,7 @@ class MapPassengerController extends GetxController {
String apiUrl = String apiUrl =
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${passengerLocation.latitude},${passengerLocation.longitude}&units=metric&key=${AK.mapAPIKEY}'; '${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${passengerLocation.latitude},${passengerLocation.longitude}&units=metric&key=${AK.mapAPIKEY}';
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {}); var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
if (response['status'] == "OK") { if (response != null && response['status'] == "OK") {
var data = response; var data = response;
// Extract distance and duration from the response and handle accordingly // Extract distance and duration from the response and handle accordingly
int distance1 = int distance1 =
@@ -2701,6 +2803,7 @@ class MapPassengerController extends GetxController {
// Handle the distance and duration as needed // Handle the distance and duration as needed
else { else {
// 'Failed to retrieve distance and duration: ${response['status']}'); // 'Failed to retrieve distance and duration: ${response['status']}');
Log.print('${response['status']}: ${response['status']}}');
// Handle the failure case // Handle the failure case
} }
} }
@@ -2788,7 +2891,8 @@ class MapPassengerController extends GetxController {
isLoading = true; isLoading = true;
update(); update();
remainingTime = 25; //to make cancel every call remainingTime = 25; //to make cancel every call
startCarLocationSearch(box.read(BoxName.carType)); // startCarLocationSearch(box.read(BoxName.carType));
getCarsLocationByPassengerAndReloadMarker(box.read(BoxName.carType), 7000);
// await getCarsLocationByPassengerAndReloadMarker(); // await getCarsLocationByPassengerAndReloadMarker();
var coordDestination = destination.split(','); var coordDestination = destination.split(',');
double latPassengerDestination = double.parse(coordDestination[0]); double latPassengerDestination = double.parse(coordDestination[0]);
@@ -2992,7 +3096,9 @@ class MapPassengerController extends GetxController {
getMapPoints(String originSteps, String destinationSteps, int index) async { getMapPoints(String originSteps, String destinationSteps, int index) async {
isWayPointStopsSheetUtilGetMap = false; isWayPointStopsSheetUtilGetMap = false;
// haveSteps = true; // haveSteps = true;
startCarLocationSearch(box.read(BoxName.carType)); // startCarLocationSearch(box.read(BoxName.carType));
await getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 7000);
// await getCarsLocationByPassengerAndReloadMarker(); // await getCarsLocationByPassengerAndReloadMarker();
// isLoading = true; // isLoading = true;
update(); update();
@@ -3439,6 +3545,12 @@ class MapPassengerController extends GetxController {
} }
} }
void startFetchingData() {
Timer.periodic(Duration(milliseconds: 50), (Timer timer) async {
await getKazanPercent();
});
}
getPassengerRate() async { getPassengerRate() async {
var res = await CRUD().get( var res = await CRUD().get(
link: AppLink.getPassengerRate, link: AppLink.getPassengerRate,
@@ -3467,10 +3579,12 @@ class MapPassengerController extends GetxController {
addCustomStartIcon(); addCustomStartIcon();
addCustomEndIcon(); addCustomEndIcon();
await getLocation(); await getLocation();
// await addToken(); // await addToken();
await getKazanPercent(); getKazanPercent();
await getPassengerRate(); getPassengerRate();
await getRideStatusFromStartApp(); getRideStatusFromStartApp();
reloadStartApp = false;
startMarkerReloading(); startMarkerReloading();
Get.put(TextToSpeechController()); Get.put(TextToSpeechController());
box.write(BoxName.carType, 'yet'); box.write(BoxName.carType, 'yet');

View File

@@ -22,8 +22,8 @@ class ComplaintController extends GetxController {
'passengerId': box.read(BoxName.passengerID).toString(), 'passengerId': box.read(BoxName.passengerID).toString(),
'feedBack': complaintController.text 'feedBack': complaintController.text
}); });
var d = jsonDecode(res); // var d = jsonDecode(res);
if (d['status'].toString() == 'success') { if (res != 'failure') {
Get.defaultDialog( Get.defaultDialog(
title: 'Success'.tr, title: 'Success'.tr,
titleStyle: AppStyle.title, titleStyle: AppStyle.title,

View File

@@ -154,7 +154,9 @@ iOS [https://getapp.cc/app/6458734951]
"You have call from driver": " لديك مكالمة من السائق", "You have call from driver": " لديك مكالمة من السائق",
"Comfort": "كمفورت", "Comfort": "كمفورت",
"Speed": "سبيد", "Speed": "سبيد",
"The invitation was sent successfully": "تم إرسال الدعوة بنجاح",
"Lady": "ليدي", "Lady": "ليدي",
"You should select your country": "يجب عليك اختيار بلدك",
"Delivery": "توصيل", "Delivery": "توصيل",
"Mashwari": "‏مشواري", "Mashwari": "‏مشواري",
'The driver waiting you in picked location .': 'The driver waiting you in picked location .':

View File

@@ -49,6 +49,11 @@ List<CarType> carTypes = [
carDetail: 'Mashwari without end point'.tr, carDetail: 'Mashwari without end point'.tr,
image: 'assets/images/freeRide.png', image: 'assets/images/freeRide.png',
), ),
// CarType(
// carType: 'Family',
// carDetail: 'Family for 7 passenger'.tr,
// image: 'assets/images/Family.png',
// ),
]; ];
class CarDetailsTypeToChoose extends StatelessWidget { class CarDetailsTypeToChoose extends StatelessWidget {

View File

@@ -1,3 +1,4 @@
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart'; import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/home/map_passenger_controller.dart'; import 'package:SEFER/controller/home/map_passenger_controller.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart';
@@ -84,8 +85,9 @@ class CupertinoDriverListWidget extends StatelessWidget {
width: 20, width: 20,
height: 20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: hexToColor(
hexToColor(driver['color_hex'].toString()), driver['color_hex'].toString()) ??
Colors.amber,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
border: Border.all(), border: Border.all(),
), ),
@@ -119,7 +121,8 @@ class CupertinoDriverListWidget extends StatelessWidget {
height: 20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: hexToColor( color: hexToColor(
driver['color_hex'].toString()), driver['color_hex'].toString()) ??
AppColor.bronze,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
border: Border.all(), border: Border.all(),
), ),

View File

@@ -378,8 +378,12 @@ class CountryPicker extends StatelessWidget {
box.write( box.write(
BoxName.countryCode, // BoxName.countryCode, //
controller.selectedCountry); // Already saved in English controller.selectedCountry); // Already saved in English
Get.snackbar(controller.selectedCountry.toString().tr, ''); if (controller.selectedCountry == null) {
Get.off(LoginPage()); Get.snackbar("You should select your country".tr, '');
} else {
Get.snackbar(controller.selectedCountry.toString().tr, '');
Get.off(LoginPage());
}
}, },
) )
], ],