25-10-5/1

This commit is contained in:
Hamza-Ayed
2025-10-08 13:14:07 +03:00
parent 1cc66029a3
commit 482c1296bc
22 changed files with 770 additions and 559 deletions

View File

@@ -14,6 +14,7 @@ import 'package:sefer_driver/views/widgets/mydialoug.dart';
import '../../../../../constant/colors.dart';
import '../../../../../constant/links.dart';
import '../../../../../controller/firebase/firbase_messge.dart';
import '../../../../../controller/firebase/notification_service.dart';
import '../../../../../controller/functions/crud.dart';
import '../../../../../controller/home/captin/order_request_controller.dart';
import '../../../../../controller/home/navigation/navigation_view.dart';
@@ -318,8 +319,16 @@ void _sendAcceptanceNotification(String? customerToken, rideId) {
// Safely check for customer token
final String? token = customerToken;
if (token != null && token.isNotEmpty) {
_firebaseMessagesController.sendNotificationToDriverMAP('Accepted Ride',
'your ride is applied'.tr, token, bodyToPassenger, 'start.wav');
// _firebaseMessagesController.sendNotificationToDriverMAP('Accepted Ride',
// 'your ride is applied'.tr, token, bodyToPassenger, 'start.wav');
NotificationService.sendNotification(
target: token.toString(),
title: 'Accepted Ride',
body: 'your ride is Accepted'.tr,
isTopic: false, // Important: this is a token
tone: 'start',
driverList: [],
);
} else {}
} catch (e) {}
}

View File

@@ -9,7 +9,9 @@ import 'package:sefer_driver/views/widgets/elevated_btn.dart';
import '../../../../constant/box_name.dart';
import '../../../../constant/style.dart';
import '../../../../controller/firebase/notification_service.dart';
import '../../../../main.dart';
import '../../../../print.dart';
// Changed: إعادة تصميم كاملة لتصبح شريط معلومات علوي مدمج
class PassengerInfoWindow extends StatelessWidget {
@@ -154,12 +156,23 @@ class PassengerInfoWindow extends StatelessWidget {
if (await controller
.calculateDistanceBetweenDriverAndPassengerLocation() <
140) {
fcm.sendNotificationToDriverMAP(
'Hi ,I Arrive your site',
'I Arrive at your site'.tr,
controller.tokenPassenger,
[],
'ding.wav',
// fcm.sendNotificationToDriverMAP(
// 'Hi ,I Arrive your site',
// 'I Arrive at your site'.tr,
// controller.tokenPassenger,
// [],
// 'ding.wav',
// );
Log.print(
'controller.tokenPassenger: ${controller.tokenPassenger}');
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'Hi ,I Arrive your site'.tr,
body: 'I Arrive at your site'.tr,
isTopic: false, // Important: this is a token
tone: 'ding',
driverList: [],
);
controller.startTimerToShowDriverWaitPassengerDuration();
controller.isArrivedSend = false;
@@ -239,13 +252,22 @@ class PassengerInfoWindow extends StatelessWidget {
kolor: AppColor.deepPurpleAccent,
onPressed: () {
MyDialog().getDialog('Are you sure to cancel?'.tr, '', () async {
fcm.sendNotificationToDriverMAP(
'Driver Cancelled Your Trip',
'You will need to pay the cost to the driver, or it will be deducted from your next trip'
.tr,
controller.tokenPassenger,
[],
'cancel.wav');
// fcm.sendNotificationToDriverMAP(
// 'Driver Cancelled Your Trip',
// 'You will need to pay the cost to the driver, or it will be deducted from your next trip'
// .tr,
// controller.tokenPassenger,
// [],
// 'cancel.wav');
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'Driver Cancelled Your Trip',
body:
'You will need to pay the cost to the driver, or it will be deducted from your next trip',
isTopic: false, // Important: this is a token
tone: 'cancel',
driverList: [],
);
box.write(BoxName.rideStatus, 'Cancel');
await controller.addWaitingTimeCostFromPassengerToDriverWallet();
controller.isdriverWaitTimeEnd = false;

View File

@@ -201,6 +201,7 @@ import '../../../../constant/box_name.dart';
import '../../../../constant/colors.dart';
import '../../../../constant/style.dart';
import '../../../../controller/firebase/firbase_messge.dart';
import '../../../../controller/firebase/notification_service.dart';
import '../../../../controller/functions/launch.dart';
import '../../../../controller/home/captin/map_driver_controller.dart';
import '../../../../main.dart';
@@ -339,23 +340,39 @@ class SosConnect extends StatelessWidget {
_buildMessageTile(
text: "Where are you, sir?".tr,
onTap: () {
fcm.sendNotificationToDriverMAP(
'message From Driver',
"Where are you, sir?".tr,
controller.tokenPassenger,
[],
'ding.wav');
// fcm.sendNotificationToDriverMAP(
// 'message From Driver',
// "Where are you, sir?".tr,
// controller.tokenPassenger,
// [],
// 'ding');
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'message From Driver'.tr,
body: "Where are you, sir?".tr,
isTopic: false, // Important: this is a token
tone: 'ding',
driverList: [],
);
Get.back();
}),
_buildMessageTile(
text: "I've been trying to reach you but your phone is off.".tr,
onTap: () {
fcm.sendNotificationToDriverMAP(
'message From Driver',
"I've been trying to reach you but your phone is off.".tr,
controller.tokenPassenger,
[],
'ding.wav');
// fcm.sendNotificationToDriverMAP(
// 'message From Driver',
// "I've been trying to reach you but your phone is off.".tr,
// controller.tokenPassenger,
// [],
// 'ding');
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'message From Driver'.tr,
body: "I've been trying to reach you but your phone is off.".tr,
isTopic: false, // Important: this is a token
tone: 'ding',
driverList: [],
);
Get.back();
}),
const SizedBox(height: 16),
@@ -374,12 +391,20 @@ class SosConnect extends StatelessWidget {
),
IconButton(
onPressed: () {
fcm.sendNotificationToDriverMAP(
'message From Driver',
controller.messageToPassenger.text,
controller.tokenPassenger,
[],
'ding.wav');
// fcm.sendNotificationToDriverMAP(
// 'message From Driver',
// controller.messageToPassenger.text,
// controller.tokenPassenger,
// [],
// 'ding');
NotificationService.sendNotification(
target: controller.tokenPassenger.toString(),
title: 'message From Driver'.tr,
body: 'change device'.tr,
isTopic: false, // Important: this is a token
tone: 'cancel',
driverList: [],
);
controller.messageToPassenger.clear();
Get.back();
},

View File

@@ -8,6 +8,7 @@ import '../../../../constant/box_name.dart';
import '../../../../constant/links.dart';
import '../../../../controller/firebase/firbase_messge.dart';
import '../../../../controller/firebase/local_notification.dart';
import '../../../../controller/firebase/notification_service.dart';
import '../../../../controller/functions/crud.dart';
import '../../../../main.dart';
import '../../../../models/model/order_data.dart';
@@ -228,12 +229,20 @@ class _OrderOverlayState extends State<OrderOverlay>
? Get.find<FirebaseMessagesController>()
: Get.put(FirebaseMessagesController());
fmc.sendNotificationToDriverMAP(
"Accepted Ride",
'your ride is Accepted'.tr,
_getData(9).toString(),
bodyToPassenger,
'start.wav',
// fmc.sendNotificationToDriverMAP(
// "Accepted Ride",
// 'your ride is Accepted'.tr,
// _getData(9).toString(),
// bodyToPassenger,
// 'start.wav',
// );
NotificationService.sendNotification(
target: _getData(9).toString(),
title: "Accepted Ride",
body: 'your ride is Accepted'.tr,
isTopic: false, // Important: this is a token
tone: 'start',
driverList: [],
);
final payload = {
// بيانات أساسية

View File

@@ -13,10 +13,12 @@ import 'dart:math' as math;
import '../../../../constant/colors.dart';
import '../../../../constant/links.dart';
import '../../../../constant/style.dart';
import '../../../../controller/firebase/notification_service.dart';
import '../../../../controller/functions/crud.dart';
import '../../../../controller/functions/encrypt_decrypt.dart';
import '../../../../controller/functions/launch.dart';
import '../../../../controller/home/captin/order_request_controller.dart';
import '../../../../print.dart';
import '../../../widgets/elevated_btn.dart';
class OrderRequestPage extends StatefulWidget {
@@ -279,12 +281,20 @@ class _OrderRequestPageState extends State<OrderRequestPage> {
? Get.find<FirebaseMessagesController>()
: Get.put(FirebaseMessagesController());
fmc.sendNotificationToDriverMAP(
"Accepted Ride",
'your ride is Accepted'.tr,
controller.myList[9].toString(),
bodyToPassenger,
'start.wav',
// fmc.sendNotificationToDriverMAP(
// "Accepted Ride",
// 'your ride is Accepted'.tr,
// controller.myList[9].toString(),
// bodyToPassenger,
// 'start',
// );
NotificationService.sendNotification(
target: controller.myList[9].toString(),
title: "Accepted Ride",
body: 'your ride is Accepted'.tr,
isTopic: false, // Important: this is a token
tone: 'start',
driverList: [],
);
Get.back();
box.write(BoxName.rideArguments, {
@@ -338,6 +348,8 @@ class _OrderRequestPageState extends State<OrderRequestPage> {
});
Get.to(() => PassengerLocationMapPage(),
arguments: box.read(BoxName.rideArguments));
Log.print(
'box.read(BoxName.rideArguments): ${box.read(BoxName.rideArguments)}');
}
},
),
@@ -372,13 +384,22 @@ class _OrderRequestPageState extends State<OrderRequestPage> {
box.read(BoxName.tokenDriver).toString(),
];
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Order Under Review'.tr,
'${box.read(BoxName.nameDriver)} ${'is reviewing your order. They may need more information or a higher price.'.tr}',
controller.myList[9].toString(),
bodyToPassenger,
'notification.wav');
// FirebaseMessagesController()
// .sendNotificationToPassengerToken(
// 'Order Under Review'.tr,
// '${box.read(BoxName.nameDriver)} ${'is reviewing your order. They may need more information or a higher price.'.tr}',
// controller.myList[9].toString(),
// bodyToPassenger,
// 'notification');
NotificationService.sendNotification(
target: controller.myList[9].toString(),
title: 'Order Under Review'.tr,
body:
'${box.read(BoxName.nameDriver)} ${'is reviewing your order. They may need more information or a higher price.'.tr}',
isTopic: false, // Important: this is a token
tone: 'start',
driverList: [],
);
controller.refuseOrder(
EncryptionHelper.instance.encryptData(

View File

@@ -11,6 +11,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../../../constant/colors.dart'; // Your AppColor
import '../../../../constant/links.dart'; // Your AppLink
import '../../../../constant/style.dart'; // Your AppStyle
import '../../../../controller/firebase/notification_service.dart';
import '../../../../controller/functions/crud.dart';
import '../../../../controller/functions/launch.dart';
import '../../../../controller/home/captin/order_request_controller.dart';
@@ -385,16 +386,28 @@ class OrderSpeedRequest extends StatelessWidget {
box.read(BoxName.tokenDriver).toString(),
rideId.toString(),
];
Get.put(FirebaseMessagesController())
.sendNotificationToDriverMAP(
'Accepted Ride',
'your ride is applied'.tr,
controller.arguments?['DriverList']
?[9]
?.toString() ??
_getData(9), // Safer access
bodyToPassenger,
'start.wav');
// Get.put(FirebaseMessagesController())
// .sendNotificationToDriverMAP(
// 'Accepted Ride',
// 'your ride is applied'.tr,
// controller.arguments?['DriverList']
// ?[9]
// ?.toString() ??
// _getData(9), // Safer access
// bodyToPassenger,
// 'start.wav');
NotificationService.sendNotification(
target: controller.arguments?['DriverList']
?[9]
?.toString() ??
_getData(9),
title: 'Accepted Ride',
body: 'your ride is applied'.tr,
isTopic:
false, // Important: this is a token
tone: 'start',
driverList: [],
);
// Using rideId (_getData(16)) for order_id consistently
CRUD().postFromDialogue(