This commit is contained in:
Hamza-Ayed
2024-11-12 00:45:23 +02:00
parent 213c2724aa
commit bf8a29b814
8 changed files with 156 additions and 81 deletions

View File

@@ -148,8 +148,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.
minSdk = 23 minSdk = 23
targetSdk = flutter.targetSdkVersion targetSdk = flutter.targetSdkVersion
versionCode = 93 versionCode = 94
versionName = '1.5.93' versionName = '1.5.94'
multiDexEnabled =true multiDexEnabled =true
// manifestPlaceholders can be specified here if needed // manifestPlaceholders can be specified here if needed

View File

@@ -67,7 +67,7 @@ class FirebaseMessagesController extends GetxController {
} }
NotificationController notificationController = NotificationController notificationController =
Get.find<NotificationController>(); Get.put(NotificationController());
Future getTokens() async { Future getTokens() async {
String? basicAuthCredentials = String? basicAuthCredentials =
@@ -126,7 +126,11 @@ class FirebaseMessagesController extends GetxController {
notificationController.showNotification( notificationController.showNotification(
'Order', message.notification!.body!, 'Order'); 'Order', message.notification!.body!, 'Order');
} }
} else if (message.notification!.title! == 'Apply Ride'.tr) { } else if (message.notification!.title! == 'Accepted Ride') {
if (Platform.isAndroid) {
notificationController.showNotification(
'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'ding');
}
var passengerList = message.data['passengerList']; var passengerList = message.data['passengerList'];
var myList = jsonDecode(passengerList) as List<dynamic>; var myList = jsonDecode(passengerList) as List<dynamic>;
@@ -135,12 +139,7 @@ class FirebaseMessagesController extends GetxController {
Get.find<MapPassengerController>().statusRide == 'Apply'; Get.find<MapPassengerController>().statusRide == 'Apply';
Get.find<MapPassengerController>().isSearchingWindow == false; Get.find<MapPassengerController>().isSearchingWindow == false;
Get.find<MapPassengerController>().update(); Get.find<MapPassengerController>().update();
if (Platform.isAndroid) {
notificationController.showNotification(
'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'order1');
//notificationController.showNotification(
// 'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'order1');
}
// driverAppliedTripSnakBar(); // driverAppliedTripSnakBar();
} else if (message.notification!.title! == 'Promo'.tr) { } else if (message.notification!.title! == 'Promo'.tr) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
@@ -177,7 +176,7 @@ class FirebaseMessagesController extends GetxController {
} else if (message.notification!.title! == 'message From passenger') { } else if (message.notification!.title! == 'message From passenger') {
if (Platform.isAndroid) { if (Platform.isAndroid) {
notificationController.showNotification( notificationController.showNotification(
'message From passenger'.tr, ''.tr, 'tone2'); 'message From passenger'.tr, ''.tr, 'ding');
} }
passengerDialog(message.notification!.body!); passengerDialog(message.notification!.body!);
@@ -185,7 +184,7 @@ class FirebaseMessagesController extends GetxController {
} else if (message.notification!.title! == 'message From Driver') { } else if (message.notification!.title! == 'message From Driver') {
if (Platform.isAndroid) { if (Platform.isAndroid) {
notificationController.showNotification( notificationController.showNotification(
'message From passenger'.tr, ''.tr, 'tone2'); 'message From Driver'.tr, ''.tr, 'ding');
} }
passengerDialog(message.notification!.body!); passengerDialog(message.notification!.body!);
@@ -204,19 +203,23 @@ class FirebaseMessagesController extends GetxController {
// backgroundColor: AppColor.greenColor); // backgroundColor: AppColor.greenColor);
if (Platform.isAndroid) { if (Platform.isAndroid) {
notificationController.showNotification( notificationController.showNotification(
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2'); 'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'ding');
} }
update(); update();
} else if (message.notification!.title! == 'Hi ,I Arrive your site'.tr) { } else if (message.notification!.title! == 'Hi ,I Arrive your site') {
driverArrivePassengerDialoge();
if (Platform.isAndroid) { if (Platform.isAndroid) {
notificationController.showNotification( notificationController.showNotification(
'Hi ,I Arrive your site'.tr, ''.tr, 'tone2'); 'Hi ,I Arrive your site'.tr, ''.tr, 'ding');
} }
driverArrivePassengerDialoge();
update(); update();
} else if (message.notification!.title! == "Cancel Trip from driver".tr) { } else if (message.notification!.title! == "Cancel Trip from driver".tr) {
Get.back(); Get.back();
if (Platform.isAndroid) {
notificationController.showNotification("Cancel Trip from driver".tr,
"We will look for a new driver.\nPlease wait.".tr, 'cancel');
}
Get.defaultDialog( Get.defaultDialog(
title: "The driver canceled your ride.".tr, title: "The driver canceled your ride.".tr,
middleText: "We will look for a new driver.\nPlease wait.".tr, middleText: "We will look for a new driver.\nPlease wait.".tr,
@@ -321,13 +324,13 @@ class FirebaseMessagesController extends GetxController {
notificationController.showNotification( notificationController.showNotification(
'Call End'.tr, 'Call End'.tr,
message.notification!.body!, message.notification!.body!,
'tone2', 'ding',
); );
} }
// Assuming GetMaterialApp is initialized and context is valid for navigation // Assuming GetMaterialApp is initialized and context is valid for navigation
// Get.off(const CallPage()); // Get.off(const CallPage());
} catch (e) {} } catch (e) {}
} else if (message.notification!.title! == 'Driver Cancel Your Trip'.tr) { } else if (message.notification!.title! == 'Driver Cancelled Your Trip') {
// Get.snackbar( // Get.snackbar(
// 'You will be pay the cost to driver or we will get it from you on next trip' // 'You will be pay the cost to driver or we will get it from you on next trip'
// .tr, // .tr,
@@ -335,7 +338,7 @@ class FirebaseMessagesController extends GetxController {
// backgroundColor: AppColor.redColor); // backgroundColor: AppColor.redColor);
if (Platform.isAndroid) { if (Platform.isAndroid) {
notificationController.showNotification( notificationController.showNotification(
'Driver Cancel Your Trip'.tr, 'Driver Cancelled Your Trip'.tr,
'you will pay to Driver you will be pay the cost of driver time look to your SEFER Wallet' 'you will pay to Driver you will be pay the cost of driver time look to your SEFER Wallet'
.tr, .tr,
'cancel'); 'cancel');
@@ -344,7 +347,7 @@ class FirebaseMessagesController extends GetxController {
box.remove(BoxName.tokenParent); box.remove(BoxName.tokenParent);
Get.find<MapPassengerController>().restCounter(); Get.find<MapPassengerController>().restCounter();
Get.offAll(const MapPagePassenger()); Get.offAll(() => const MapPagePassenger());
} }
// else if (message.notification!.title! == 'Order Applied') { // else if (message.notification!.title! == 'Order Applied') {
// Get.snackbar( // Get.snackbar(
@@ -401,7 +404,7 @@ class FirebaseMessagesController extends GetxController {
title: 'Ok I will go now.'.tr, title: 'Ok I will go now.'.tr,
onPressed: () { onPressed: () {
FirebaseMessagesController().sendNotificationToPassengerToken( FirebaseMessagesController().sendNotificationToPassengerToken(
'Hi ,I will go now'.tr, 'Hi ,I will go now',
'I will go now'.tr, 'I will go now'.tr,
Get.find<MapPassengerController>().driverToken, Get.find<MapPassengerController>().driverToken,
[], [],
@@ -418,7 +421,7 @@ class FirebaseMessagesController extends GetxController {
Future<dynamic> passengerDialog(String message) { Future<dynamic> passengerDialog(String message) {
return Get.defaultDialog( return Get.defaultDialog(
barrierDismissible: false, barrierDismissible: false,
title: 'message From passenger'.tr, title: 'message From Driver'.tr,
titleStyle: AppStyle.title, titleStyle: AppStyle.title,
middleTextStyle: AppStyle.title, middleTextStyle: AppStyle.title,
middleText: message.tr, middleText: message.tr,

View File

@@ -85,6 +85,8 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:timezone/data/latest.dart' as tz; import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz; import 'package:timezone/timezone.dart' as tz;
import '../../print.dart';
class NotificationController extends GetxController { class NotificationController extends GetxController {
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
@@ -185,13 +187,16 @@ class NotificationController extends GetxController {
// Initialize and set Cairo timezone // Initialize and set Cairo timezone
tz.initializeTimeZones(); tz.initializeTimeZones();
var cairoLocation; var cairoLocation;
if (box.read(BoxName.countryCode).toString() == 'Egypt') { // if (box.read(BoxName.countryCode).toString() == 'Egypt') {
cairoLocation = tz.getLocation('Africa/Cairo'); cairoLocation = tz.getLocation('Africa/Cairo');
} else {} // todo get for location country // } else {
// cairoLocation = tz.getLocation('UTC');
// } // todo get for location country
// Set Cairo timezone // Set Cairo timezone
Log.print('cairoLocation: ${cairoLocation}');
final now = tz.TZDateTime.now( final now = tz.TZDateTime.now(
cairoLocation); // Use Cairo timezone for the current time cairoLocation); // Use Cairo timezone for the current time
tz.TZDateTime scheduledDate = tz.TZDateTime( tz.TZDateTime scheduledDate = tz.TZDateTime(
cairoLocation, now.year, now.month, now.day, hour, minute); cairoLocation, now.year, now.month, now.day, hour, minute);

View File

@@ -1780,7 +1780,7 @@ class MapPassengerController extends GetxController {
// getCarForFirstConfirm(carType); // getCarForFirstConfirm(carType);
confirmRideForAllDriverAvailable(); confirmRideForAllDriverAvailable();
// delayAndFetchRideStatusForAllDriverAvailable(rideId); // delayAndFetchRideStatusForAllDriverAvailable(rideId);
} else if (rideStatusDelayed == 'Apply') { } else if (rideStatusDelayed == 'Apply' || statusRide == 'Apply') {
Log.print('rideStatusDelayed == Apply: ${rideStatusDelayed}'); Log.print('rideStatusDelayed == Apply: ${rideStatusDelayed}');
// todo play sound // todo play sound
Get.find<AudioRecorderController>() Get.find<AudioRecorderController>()
@@ -3364,7 +3364,7 @@ class MapPassengerController extends GetxController {
reloadCount++; reloadCount++;
Log.print('reloadCount: $reloadCount'); Log.print('reloadCount: $reloadCount');
if (!rideConfirm) { if (rideConfirm == false) {
clearMarkersExceptStartEnd(); clearMarkersExceptStartEnd();
// _smoothlyUpdateMarker(); // _smoothlyUpdateMarker();
// startCarLocationSearch(box.read(BoxName.carType)); // startCarLocationSearch(box.read(BoxName.carType));
@@ -3391,59 +3391,122 @@ class MapPassengerController extends GetxController {
late Duration durationFromDriverToPassenger; late Duration durationFromDriverToPassenger;
double nearestDistance = double.infinity; double nearestDistance = double.infinity;
Future<CarLocation?> getNearestDriverByPassengerLocation() async { // Future<CarLocation?> getNearestDriverByPassengerLocation() async {
if (polyLines.isEmpty || data.isEmpty) { // if (polyLines.isEmpty || data.isEmpty) {
return null; // Early return if data is empty // return null; // Early return if data is empty
} // }
// if (!rideConfirm) {
// if (dataCarsLocationByPassenger != 'failure') {
// if (dataCarsLocationByPassenger != null) {
// if (dataCarsLocationByPassenger['message'].length > 0) {
// double nearestDistance = double
// .infinity; // Initialize nearest distance to a large number
// CarLocation? nearestCar;
// for (var i = 0;
// i < dataCarsLocationByPassenger['message'].length;
// i++) {
// var carLocation = dataCarsLocationByPassenger['message'][i];
// // Calculate the distance between passenger's location and current driver's location
// final distance = Geolocator.distanceBetween(
// passengerLocation.latitude,
// passengerLocation.longitude,
// double.parse(carLocation['latitude']),
// double.parse(carLocation['longitude']),
// );
// // Calculate duration assuming an average speed of 25 km/h (adjust as needed)
// int durationToPassenger =
// (distance * 25 * (1000 / 3600)).round(); // 25 km/h in m/s
// // Update the UI with the distance and duration for each car
// update();
// // If this distance is smaller than the nearest distance found so far, update nearestCar
// if (distance < nearestDistance) {
// nearestDistance = distance;
// nearestCar = CarLocation(
// distance: distance,
// duration: durationToPassenger.toDouble(),
// id: carLocation['driver_id'],
// latitude: double.parse(carLocation['latitude']),
// longitude: double.parse(carLocation['longitude']),
// );
// // Update the UI with the nearest driver
// update();
// }
// }
// // Return the nearest car found
// return nearestCar;
// }
// }
// }
// }
// // Return null if no drivers are found or if ride is confirmed
// return null;
// }
Future<CarLocation?> getNearestDriverByPassengerLocation() async {
// if (polyLines.isEmpty && data.isEmpty) {
// return null; // Early return if data is empty
// }
// Log.print('rideConfirm: ${rideConfirm}');
// Log.print('dataCarsLocationByPassenger: ${dataCarsLocationByPassenger}');
if (!rideConfirm) { if (!rideConfirm) {
if (dataCarsLocationByPassenger != 'failure') { if (dataCarsLocationByPassenger != 'failure') {
if (dataCarsLocationByPassenger != null) { if (dataCarsLocationByPassenger != null &&
if (dataCarsLocationByPassenger['message'].length > 0) { dataCarsLocationByPassenger['message'] != null &&
double nearestDistance = double dataCarsLocationByPassenger['message'].length > 0) {
.infinity; // Initialize nearest distance to a large number double nearestDistance =
CarLocation? nearestCar; double.infinity; // Initialize nearest distance
CarLocation? nearestCar;
for (var i = 0; for (var i = 0;
i < dataCarsLocationByPassenger['message'].length; i < dataCarsLocationByPassenger['message'].length;
i++) { i++) {
var carLocation = dataCarsLocationByPassenger['message'][i]; var carLocation = dataCarsLocationByPassenger['message'][i];
Log.print('carLocation: ${carLocation}');
// Calculate the distance between passenger's location and current driver's location // Calculate distance between passenger's location and 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']),
);
// Calculate duration assuming an average speed of 25 km/h (adjust as needed)
int durationToPassenger = (distance * 25 * (1000 / 3600)).round();
Log.print('distance: ${distance}');
Log.print('durationToPassenger: ${durationToPassenger}');
// Update the UI with the distance and duration for each car
update();
// If this distance is smaller than the nearest distance found so far, update nearestCar
if (distance < nearestDistance) {
nearestDistance = distance;
nearestCar = CarLocation(
distance: distance,
duration: durationToPassenger.toDouble(),
id: carLocation['driver_id'],
latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']),
); );
Log.print('nearestCar: ${nearestCar}');
// Calculate duration assuming an average speed of 25 km/h (adjust as needed) // Update the UI with the nearest driver
int durationToPassenger =
(distance * 25 * (1000 / 3600)).round(); // 25 km/h in m/s
// Update the UI with the distance and duration for each car
update(); update();
// If this distance is smaller than the nearest distance found so far, update nearestCar
if (distance < nearestDistance) {
nearestDistance = distance;
nearestCar = CarLocation(
distance: distance,
duration: durationToPassenger.toDouble(),
id: carLocation['driver_id'],
latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']),
);
// Update the UI with the nearest driver
update();
}
} }
// Return the nearest car found
return nearestCar;
} }
// Return the nearest car found
return nearestCar;
} }
} }
} }

View File

@@ -240,7 +240,7 @@ Download the SEFER app now and enjoy your ride!
}); });
if (response != 'failure') { if (response != 'failure') {
var d = jsonDecode(response); var d = response;
Get.snackbar('Success', 'Invite sent successfully'.tr); Get.snackbar('Success', 'Invite sent successfully'.tr);
String message = '${'*SEFER APP CODE*'.tr}\n\n' String message = '${'*SEFER APP CODE*'.tr}\n\n'

View File

@@ -56,7 +56,8 @@ class MyTranslation extends Translations {
"I want to order for someone else": "أريد أن أطلب لشخص آخر", "I want to order for someone else": "أريد أن أطلب لشخص آخر",
"Cancel Trip from driver": "إلغاء الرحلة من السائق", "Cancel Trip from driver": "إلغاء الرحلة من السائق",
"If you want order to another person": "إذا كنت تريد الطلب لشخص آخر", "If you want order to another person": "إذا كنت تريد الطلب لشخص آخر",
"Ok I will go now.": "حسنًا، سأذهب الآن.",
"Hi, I will go now": "مرحبًا، سأذهب الآن.",
"upgrade price": "رفع السعر", "upgrade price": "رفع السعر",
'airport': 'مطار', 'airport': 'مطار',
"Best choice for a comfortable car with a flexible route and stop points. This airport offers visa entry at this price.": "Best choice for a comfortable car with a flexible route and stop points. This airport offers visa entry at this price.":

View File

@@ -87,11 +87,11 @@ class ApplyOrderWidget extends StatelessWidget {
width: 10, width: 10,
), ),
Container( Container(
height: Get.height * .34, height: Get.height * .31,
width: Get.width * .9, width: Get.width * .9,
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
@@ -231,7 +231,7 @@ class ApplyOrderWidget extends StatelessWidget {
IconButton( IconButton(
onPressed: () async { onPressed: () async {
Get.defaultDialog( Get.defaultDialog(
title: 'Select one message'.tr, title: 'Select one message',
titleStyle: AppStyle.title, titleStyle: AppStyle.title,
content: SizedBox( content: SizedBox(
width: 300, width: 300,
@@ -242,7 +242,7 @@ class ApplyOrderWidget extends StatelessWidget {
onTap: () { onTap: () {
FirebaseMessagesController() FirebaseMessagesController()
.sendNotificationToDriverMAP( .sendNotificationToDriverMAP(
'message From passenger'.tr, 'message From passenger',
'Hello, I\'m at the agreed-upon location' 'Hello, I\'m at the agreed-upon location'
.tr, .tr,
controller.driverToken controller.driverToken
@@ -274,7 +274,7 @@ class ApplyOrderWidget extends StatelessWidget {
onTap: () { onTap: () {
FirebaseMessagesController() FirebaseMessagesController()
.sendNotificationToDriverMAP( .sendNotificationToDriverMAP(
'message From passenger'.tr, 'message From passenger',
'My location is correct. You can search for me using the navigation app' 'My location is correct. You can search for me using the navigation app'
.tr, .tr,
controller.driverToken, controller.driverToken,
@@ -471,7 +471,7 @@ class DriverArrivePassengerAndWaitMinute extends StatelessWidget {
color: controller.remainingTimeDriverWaitPassenger5Minute < 60 color: controller.remainingTimeDriverWaitPassenger5Minute < 60
? AppColor.redColor ? AppColor.redColor
: AppColor.greenColor, : AppColor.greenColor,
minHeight: 15, minHeight: 25,
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
value: value:
controller.progressTimerDriverWaitPassenger5Minute.toDouble(), controller.progressTimerDriverWaitPassenger5Minute.toDouble(),

View File

@@ -5,11 +5,13 @@ import 'package:SEFER/views/auth/sms_verfy_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../../constant/box_name.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
import '../../../constant/notification.dart'; import '../../../constant/notification.dart';
import '../../../controller/firebase/local_notification.dart'; import '../../../controller/firebase/local_notification.dart';
import '../../../controller/functions/tts.dart'; import '../../../controller/functions/tts.dart';
import '../../../controller/home/map_passenger_controller.dart'; import '../../../controller/home/map_passenger_controller.dart';
import '../../../main.dart';
GetBuilder<MapPassengerController> leftMainMenuIcons() { GetBuilder<MapPassengerController> leftMainMenuIcons() {
final textToSpeechController = Get.put(TextToSpeechController()); final textToSpeechController = Get.put(TextToSpeechController());
@@ -103,6 +105,7 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
// randomMessage.split(':')[1], // randomMessage.split(':')[1],
// "ding", // "ding",
// ); // );
// print(box.read(BoxName.countryCode).toString());
// }, // },
// icon: const Icon( // icon: const Icon(
// Icons.voice_chat, // Icons.voice_chat,