11/11/1
This commit is contained in:
@@ -67,7 +67,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
|
||||
NotificationController notificationController =
|
||||
Get.find<NotificationController>();
|
||||
Get.put(NotificationController());
|
||||
|
||||
Future getTokens() async {
|
||||
String? basicAuthCredentials =
|
||||
@@ -126,7 +126,11 @@ class FirebaseMessagesController extends GetxController {
|
||||
notificationController.showNotification(
|
||||
'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 myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
@@ -135,12 +139,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.find<MapPassengerController>().statusRide == 'Apply';
|
||||
Get.find<MapPassengerController>().isSearchingWindow == false;
|
||||
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();
|
||||
} else if (message.notification!.title! == 'Promo'.tr) {
|
||||
if (Platform.isAndroid) {
|
||||
@@ -177,7 +176,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else if (message.notification!.title! == 'message From passenger') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'message From passenger'.tr, ''.tr, 'tone2');
|
||||
'message From passenger'.tr, ''.tr, 'ding');
|
||||
}
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
@@ -185,7 +184,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else if (message.notification!.title! == 'message From Driver') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'message From passenger'.tr, ''.tr, 'tone2');
|
||||
'message From Driver'.tr, ''.tr, 'ding');
|
||||
}
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
@@ -204,19 +203,23 @@ class FirebaseMessagesController extends GetxController {
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
if (Platform.isAndroid) {
|
||||
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();
|
||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site'.tr) {
|
||||
driverArrivePassengerDialoge();
|
||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Hi ,I Arrive your site'.tr, ''.tr, 'tone2');
|
||||
'Hi ,I Arrive your site'.tr, ''.tr, 'ding');
|
||||
}
|
||||
driverArrivePassengerDialoge();
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title! == "Cancel Trip from driver".tr) {
|
||||
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(
|
||||
title: "The driver canceled your ride.".tr,
|
||||
middleText: "We will look for a new driver.\nPlease wait.".tr,
|
||||
@@ -321,13 +324,13 @@ class FirebaseMessagesController extends GetxController {
|
||||
notificationController.showNotification(
|
||||
'Call End'.tr,
|
||||
message.notification!.body!,
|
||||
'tone2',
|
||||
'ding',
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// Get.off(const CallPage());
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Driver Cancel Your Trip'.tr) {
|
||||
} else if (message.notification!.title! == 'Driver Cancelled Your Trip') {
|
||||
// Get.snackbar(
|
||||
// 'You will be pay the cost to driver or we will get it from you on next trip'
|
||||
// .tr,
|
||||
@@ -335,7 +338,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// backgroundColor: AppColor.redColor);
|
||||
if (Platform.isAndroid) {
|
||||
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'
|
||||
.tr,
|
||||
'cancel');
|
||||
@@ -344,7 +347,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
box.remove(BoxName.tokenParent);
|
||||
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
}
|
||||
// else if (message.notification!.title! == 'Order Applied') {
|
||||
// Get.snackbar(
|
||||
@@ -401,7 +404,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
title: 'Ok I will go now.'.tr,
|
||||
onPressed: () {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Hi ,I will go now'.tr,
|
||||
'Hi ,I will go now',
|
||||
'I will go now'.tr,
|
||||
Get.find<MapPassengerController>().driverToken,
|
||||
[],
|
||||
@@ -418,7 +421,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future<dynamic> passengerDialog(String message) {
|
||||
return Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'message From passenger'.tr,
|
||||
title: 'message From Driver'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleTextStyle: AppStyle.title,
|
||||
middleText: message.tr,
|
||||
|
||||
@@ -85,6 +85,8 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:timezone/data/latest.dart' as tz;
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
|
||||
import '../../print.dart';
|
||||
|
||||
class NotificationController extends GetxController {
|
||||
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
@@ -185,13 +187,16 @@ class NotificationController extends GetxController {
|
||||
// Initialize and set Cairo timezone
|
||||
tz.initializeTimeZones();
|
||||
var cairoLocation;
|
||||
if (box.read(BoxName.countryCode).toString() == 'Egypt') {
|
||||
cairoLocation = tz.getLocation('Africa/Cairo');
|
||||
} else {} // todo get for location country
|
||||
// if (box.read(BoxName.countryCode).toString() == 'Egypt') {
|
||||
cairoLocation = tz.getLocation('Africa/Cairo');
|
||||
// } else {
|
||||
// cairoLocation = tz.getLocation('UTC');
|
||||
// } // todo get for location country
|
||||
// Set Cairo timezone
|
||||
|
||||
Log.print('cairoLocation: ${cairoLocation}');
|
||||
final now = tz.TZDateTime.now(
|
||||
cairoLocation); // Use Cairo timezone for the current time
|
||||
|
||||
tz.TZDateTime scheduledDate = tz.TZDateTime(
|
||||
cairoLocation, now.year, now.month, now.day, hour, minute);
|
||||
|
||||
|
||||
@@ -1780,7 +1780,7 @@ class MapPassengerController extends GetxController {
|
||||
// getCarForFirstConfirm(carType);
|
||||
confirmRideForAllDriverAvailable();
|
||||
// delayAndFetchRideStatusForAllDriverAvailable(rideId);
|
||||
} else if (rideStatusDelayed == 'Apply') {
|
||||
} else if (rideStatusDelayed == 'Apply' || statusRide == 'Apply') {
|
||||
Log.print('rideStatusDelayed == Apply: ${rideStatusDelayed}');
|
||||
// todo play sound
|
||||
Get.find<AudioRecorderController>()
|
||||
@@ -3364,7 +3364,7 @@ class MapPassengerController extends GetxController {
|
||||
reloadCount++;
|
||||
Log.print('reloadCount: $reloadCount');
|
||||
|
||||
if (!rideConfirm) {
|
||||
if (rideConfirm == false) {
|
||||
clearMarkersExceptStartEnd();
|
||||
// _smoothlyUpdateMarker();
|
||||
// startCarLocationSearch(box.read(BoxName.carType));
|
||||
@@ -3391,59 +3391,122 @@ class MapPassengerController extends GetxController {
|
||||
late Duration durationFromDriverToPassenger;
|
||||
double nearestDistance = double.infinity;
|
||||
|
||||
Future<CarLocation?> getNearestDriverByPassengerLocation() async {
|
||||
if (polyLines.isEmpty || data.isEmpty) {
|
||||
return null; // Early return if data is empty
|
||||
}
|
||||
// Future<CarLocation?> getNearestDriverByPassengerLocation() async {
|
||||
// if (polyLines.isEmpty || data.isEmpty) {
|
||||
// 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 (dataCarsLocationByPassenger != 'failure') {
|
||||
if (dataCarsLocationByPassenger != null) {
|
||||
if (dataCarsLocationByPassenger['message'].length > 0) {
|
||||
double nearestDistance = double
|
||||
.infinity; // Initialize nearest distance to a large number
|
||||
CarLocation? nearestCar;
|
||||
if (dataCarsLocationByPassenger != null &&
|
||||
dataCarsLocationByPassenger['message'] != null &&
|
||||
dataCarsLocationByPassenger['message'].length > 0) {
|
||||
double nearestDistance =
|
||||
double.infinity; // Initialize nearest distance
|
||||
CarLocation? nearestCar;
|
||||
|
||||
for (var i = 0;
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
for (var i = 0;
|
||||
i < dataCarsLocationByPassenger['message'].length;
|
||||
i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
Log.print('carLocation: ${carLocation}');
|
||||
|
||||
// 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 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();
|
||||
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']),
|
||||
);
|
||||
|
||||
// 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
|
||||
Log.print('nearestCar: ${nearestCar}');
|
||||
// Update the UI with the nearest driver
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ Download the SEFER app now and enjoy your ride!
|
||||
});
|
||||
|
||||
if (response != 'failure') {
|
||||
var d = jsonDecode(response);
|
||||
var d = response;
|
||||
Get.snackbar('Success', 'Invite sent successfully'.tr);
|
||||
|
||||
String message = '${'*SEFER APP CODE*'.tr}\n\n'
|
||||
|
||||
@@ -56,7 +56,8 @@ class MyTranslation extends Translations {
|
||||
"I want to order for someone else": "أريد أن أطلب لشخص آخر",
|
||||
"Cancel Trip from driver": "إلغاء الرحلة من السائق",
|
||||
"If you want order to another person": "إذا كنت تريد الطلب لشخص آخر",
|
||||
|
||||
"Ok I will go now.": "حسنًا، سأذهب الآن.",
|
||||
"Hi, I will go now": "مرحبًا، سأذهب الآن.",
|
||||
"upgrade price": "رفع السعر",
|
||||
'airport': 'مطار',
|
||||
"Best choice for a comfortable car with a flexible route and stop points. This airport offers visa entry at this price.":
|
||||
|
||||
@@ -87,11 +87,11 @@ class ApplyOrderWidget extends StatelessWidget {
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
height: Get.height * .34,
|
||||
height: Get.height * .31,
|
||||
width: Get.width * .9,
|
||||
decoration: AppStyle.boxDecoration,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
@@ -231,7 +231,7 @@ class ApplyOrderWidget extends StatelessWidget {
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
Get.defaultDialog(
|
||||
title: 'Select one message'.tr,
|
||||
title: 'Select one message',
|
||||
titleStyle: AppStyle.title,
|
||||
content: SizedBox(
|
||||
width: 300,
|
||||
@@ -242,7 +242,7 @@ class ApplyOrderWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToDriverMAP(
|
||||
'message From passenger'.tr,
|
||||
'message From passenger',
|
||||
'Hello, I\'m at the agreed-upon location'
|
||||
.tr,
|
||||
controller.driverToken
|
||||
@@ -274,7 +274,7 @@ class ApplyOrderWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
FirebaseMessagesController()
|
||||
.sendNotificationToDriverMAP(
|
||||
'message From passenger'.tr,
|
||||
'message From passenger',
|
||||
'My location is correct. You can search for me using the navigation app'
|
||||
.tr,
|
||||
controller.driverToken,
|
||||
@@ -471,7 +471,7 @@ class DriverArrivePassengerAndWaitMinute extends StatelessWidget {
|
||||
color: controller.remainingTimeDriverWaitPassenger5Minute < 60
|
||||
? AppColor.redColor
|
||||
: AppColor.greenColor,
|
||||
minHeight: 15,
|
||||
minHeight: 25,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
value:
|
||||
controller.progressTimerDriverWaitPassenger5Minute.toDouble(),
|
||||
|
||||
@@ -5,11 +5,13 @@ import 'package:SEFER/views/auth/sms_verfy_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/notification.dart';
|
||||
import '../../../controller/firebase/local_notification.dart';
|
||||
import '../../../controller/functions/tts.dart';
|
||||
import '../../../controller/home/map_passenger_controller.dart';
|
||||
import '../../../main.dart';
|
||||
|
||||
GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
||||
final textToSpeechController = Get.put(TextToSpeechController());
|
||||
@@ -103,6 +105,7 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
||||
// randomMessage.split(':')[1],
|
||||
// "ding",
|
||||
// );
|
||||
// print(box.read(BoxName.countryCode).toString());
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// Icons.voice_chat,
|
||||
|
||||
Reference in New Issue
Block a user