25-12-1/1
This commit is contained in:
@@ -87,34 +87,70 @@ class LoginController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
getJwtWallet() async {
|
||||
final random = Random();
|
||||
Future<String> getJwtWallet() async {
|
||||
try {
|
||||
final random = Random();
|
||||
|
||||
if (random.nextBool()) {
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
} else {
|
||||
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
|
||||
// Perform security check randomly
|
||||
if (random.nextBool()) {
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
} else {
|
||||
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
|
||||
}
|
||||
|
||||
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
final dev = GetPlatform.isAndroid ? 'android' : 'ios';
|
||||
|
||||
var payload = {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${AK.allowed}$dev',
|
||||
'fingerPrint': fingerPrint,
|
||||
};
|
||||
|
||||
var response = await http.post(
|
||||
Uri.parse(AppLink.loginJwtWalletRider),
|
||||
body: payload,
|
||||
);
|
||||
|
||||
// Handle bad responses
|
||||
if (response.statusCode != 200) {
|
||||
_showJwtErrorDialog(
|
||||
"حدث خطأ أثناء الاتصال بالخادم. يرجى المحاولة مرة أخرى.");
|
||||
throw Exception("JWT request failed");
|
||||
}
|
||||
|
||||
var data = jsonDecode(response.body);
|
||||
|
||||
// Validate JWT response structure
|
||||
if (!data.containsKey('jwt') || !data.containsKey('hmac')) {
|
||||
_showJwtErrorDialog("تعذّر التحقق من الأمان. يرجى إعادة المحاولة.");
|
||||
throw Exception("Invalid JWT response format");
|
||||
}
|
||||
|
||||
// Save HMAC locally
|
||||
await box.write(BoxName.hmac, data['hmac']);
|
||||
|
||||
return data['jwt'].toString();
|
||||
} catch (e) {
|
||||
_showJwtErrorDialog("حدث خلل غير متوقع. يرجى المحاولة مرة أخرى.");
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
// print('fingerPrint: ${fingerPrint}');
|
||||
dev = Platform.isAndroid ? 'android' : 'ios';
|
||||
var payload = {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'password': AK.passnpassenger,
|
||||
'aud': '${AK.allowed}$dev',
|
||||
'fingerPrint': fingerPrint
|
||||
};
|
||||
var response1 = await http.post(
|
||||
Uri.parse(AppLink.loginJwtWalletRider),
|
||||
body: payload,
|
||||
void _showJwtErrorDialog(String message) {
|
||||
if (Get.context == null) return;
|
||||
|
||||
Get.defaultDialog(
|
||||
title: "خطأ في الاتصال",
|
||||
middleText: message,
|
||||
textConfirm: "إعادة المحاولة",
|
||||
confirmTextColor: Colors.white,
|
||||
onConfirm: () {
|
||||
Get.back();
|
||||
getJwtWallet();
|
||||
},
|
||||
);
|
||||
await box.write(BoxName.hmac, jsonDecode(response1.body)['hmac']);
|
||||
// Log.print('jsonDecoeded[hmac]: ${jsonDecoeded['hmac']}');
|
||||
// Log.print('req: ${response1.request}');
|
||||
// Log.print('response: ${response1.body}');
|
||||
// Log.print('payload: ${payload}');
|
||||
return jsonDecode(response1.body)['jwt'].toString();
|
||||
}
|
||||
|
||||
getJWT() async {
|
||||
|
||||
@@ -19,21 +19,78 @@ class PhoneAuthHelper {
|
||||
static final String _verifyOtpUrl = '${_baseUrl}verifyOtp.php';
|
||||
static final String _registerUrl = '${_baseUrl}register_passenger.php';
|
||||
|
||||
static String formatSyrianPhone(String phone) {
|
||||
// Remove spaces, symbols, +, -, ()
|
||||
phone = phone.replaceAll(RegExp(r'[ \-\(\)\+]'), '').trim();
|
||||
|
||||
// Normalize 00963 → 963
|
||||
if (phone.startsWith('00963')) {
|
||||
phone = phone.replaceFirst('00963', '963');
|
||||
}
|
||||
|
||||
// Normalize 0963 → 963
|
||||
if (phone.startsWith('0963')) {
|
||||
phone = phone.replaceFirst('0963', '963');
|
||||
}
|
||||
|
||||
// NEW: Fix 96309xxxx → 9639xxxx
|
||||
if (phone.startsWith('96309')) {
|
||||
phone = '9639' + phone.substring(5); // remove the "0" after 963
|
||||
}
|
||||
|
||||
// If starts with 9630 → correct to 9639
|
||||
if (phone.startsWith('9630')) {
|
||||
phone = '9639' + phone.substring(4);
|
||||
}
|
||||
|
||||
// If already in correct format: 9639xxxxxxxx
|
||||
if (phone.startsWith('9639') && phone.length == 12) {
|
||||
return phone;
|
||||
}
|
||||
|
||||
// If starts with 963 but missing the 9
|
||||
if (phone.startsWith('963') && phone.length > 3) {
|
||||
// Ensure it begins with 9639
|
||||
if (!phone.startsWith('9639')) {
|
||||
phone = '9639' + phone.substring(3);
|
||||
}
|
||||
return phone;
|
||||
}
|
||||
|
||||
// If starts with 09xxxxxxxx → 9639xxxxxxxx
|
||||
if (phone.startsWith('09')) {
|
||||
return '963' + phone.substring(1);
|
||||
}
|
||||
|
||||
// If 9xxxxxxxx (9 digits)
|
||||
if (phone.startsWith('9') && phone.length == 9) {
|
||||
return '963' + phone;
|
||||
}
|
||||
|
||||
// If starts with incorrect 0xxxxxxx → assume Syrian and fix
|
||||
if (phone.startsWith('0') && phone.length == 10) {
|
||||
return '963' + phone.substring(1);
|
||||
}
|
||||
|
||||
return phone;
|
||||
}
|
||||
|
||||
/// Sends an OTP to the provided phone number.
|
||||
static Future<bool> sendOtp(String phoneNumber) async {
|
||||
try {
|
||||
// Log.print('_sendOtpUrl: ${_sendOtpUrl}');
|
||||
// Log.print('phoneNumber: ${phoneNumber}');
|
||||
// إصلاح الرقم قبل الإرسال
|
||||
final fixedPhone = formatSyrianPhone(phoneNumber);
|
||||
|
||||
final response = await CRUD().post(
|
||||
link: _sendOtpUrl,
|
||||
payload: {'receiver': phoneNumber},
|
||||
payload: {'receiver': fixedPhone}, // ← ← استخدام الرقم المُعدّل
|
||||
);
|
||||
// Log.print('response: ${response}');
|
||||
|
||||
if (response != 'failure') {
|
||||
final data = (response);
|
||||
final data = response;
|
||||
|
||||
if (data['status'] == 'success') {
|
||||
mySnackbarSuccess('An OTP has been sent to your WhatsApp number.'.tr);
|
||||
mySnackbarSuccess('An OTP has been sent to your number.'.tr);
|
||||
return true;
|
||||
} else {
|
||||
mySnackeBarError(data['message'] ?? 'Failed to send OTP.');
|
||||
@@ -44,19 +101,20 @@ class PhoneAuthHelper {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
// Log.print('e: ${e}');
|
||||
// mySnackeBarError('An error occurred: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Verifies the OTP and logs the user in.
|
||||
|
||||
static Future<void> verifyOtp(String phoneNumber, String otp) async {
|
||||
static Future<void> verifyOtp(String phoneNumber) async {
|
||||
try {
|
||||
final fixedPhone = formatSyrianPhone(phoneNumber);
|
||||
final response = await CRUD().post(
|
||||
link: _verifyOtpUrl,
|
||||
payload: {'phone_number': phoneNumber, 'otp': otp},
|
||||
payload: {
|
||||
'phone_number': fixedPhone,
|
||||
},
|
||||
);
|
||||
|
||||
if (response != 'failure') {
|
||||
@@ -96,13 +154,12 @@ class PhoneAuthHelper {
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint
|
||||
});
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
|
||||
payload: {
|
||||
'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint
|
||||
});
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.paymentServer}/ride/firebase/add.php", payload: {
|
||||
'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint
|
||||
});
|
||||
}
|
||||
|
||||
static Future<void> registerUser({
|
||||
|
||||
@@ -222,19 +222,19 @@ class RegisterController extends GetxController {
|
||||
|
||||
if (res1 != 'failure') {
|
||||
//Multi-server signup (moved inside the successful registration check)
|
||||
if (AppLink.IntaleqAlexandriaServer != AppLink.IntaleqSyriaServer) {
|
||||
List<Future> signUp = [
|
||||
CRUD().post(
|
||||
link: '${AppLink.IntaleqAlexandriaServer}/auth/signup.php',
|
||||
payload: payload,
|
||||
),
|
||||
CRUD().post(
|
||||
link: '${AppLink.IntaleqGizaServer}/auth/signup.php',
|
||||
payload: payload,
|
||||
)
|
||||
];
|
||||
await Future.wait(signUp); // Wait for both sign-ups to complete.
|
||||
}
|
||||
// if (AppLink.IntaleqAlexandriaServer != AppLink.IntaleqSyriaServer) {
|
||||
// List<Future> signUp = [
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.IntaleqAlexandriaServer}/auth/signup.php',
|
||||
// payload: payload,
|
||||
// ),
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.IntaleqGizaServer}/auth/signup.php',
|
||||
// payload: payload,
|
||||
// )
|
||||
// ];
|
||||
// await Future.wait(signUp); // Wait for both sign-ups to complete.
|
||||
// }
|
||||
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(
|
||||
@@ -297,19 +297,19 @@ class RegisterController extends GetxController {
|
||||
);
|
||||
|
||||
if (res1 != 'failure') {
|
||||
if (AppLink.IntaleqAlexandriaServer != AppLink.IntaleqSyriaServer) {
|
||||
List<Future> signUp = [
|
||||
CRUD().post(
|
||||
link: '${AppLink.IntaleqAlexandriaServer}/auth/signup.php',
|
||||
payload: payload,
|
||||
),
|
||||
CRUD().post(
|
||||
link: '${AppLink.IntaleqGizaServer}/auth/signup.php',
|
||||
payload: payload,
|
||||
)
|
||||
];
|
||||
await Future.wait(signUp);
|
||||
}
|
||||
// if (AppLink.IntaleqAlexandriaServer != AppLink.IntaleqSyriaServer) {
|
||||
// List<Future> signUp = [
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.IntaleqAlexandriaServer}/auth/signup.php',
|
||||
// payload: payload,
|
||||
// ),
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.IntaleqGizaServer}/auth/signup.php',
|
||||
// payload: payload,
|
||||
// )
|
||||
// ];
|
||||
// await Future.wait(signUp);
|
||||
// }
|
||||
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.isFirstTime, '0');
|
||||
|
||||
@@ -91,18 +91,8 @@ class OtpVerificationController extends GetxController {
|
||||
);
|
||||
|
||||
if (response != 'failure' && response['status'] == 'success') {
|
||||
final fcm = Get.isRegistered<FirebaseMessagesController>()
|
||||
? Get.find<FirebaseMessagesController>()
|
||||
: Get.put(FirebaseMessagesController());
|
||||
|
||||
// await fcm.sendNotificationToDriverMAP(
|
||||
// 'token change',
|
||||
// 'change device'.tr,
|
||||
// ptoken.toString(),
|
||||
// [],
|
||||
// 'cancel',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
category: 'token change',
|
||||
target: ptoken.toString(),
|
||||
title: 'token change'.tr,
|
||||
body: 'change device'.tr,
|
||||
@@ -110,21 +100,7 @@ class OtpVerificationController extends GetxController {
|
||||
tone: 'cancel',
|
||||
driverList: [],
|
||||
);
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
|
||||
payload: {
|
||||
'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint.toString(),
|
||||
});
|
||||
// CRUD().post(
|
||||
// link:
|
||||
// '${AppLink.seferPaymentServer}/auth/token/update_passenger_token.php',
|
||||
// payload: {
|
||||
// 'token': box.read(BoxName.tokenFCM).toString(),
|
||||
// 'fingerPrint': fingerPrint.toString(),
|
||||
// 'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
// });
|
||||
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
} else {
|
||||
Get.snackbar('Verification Failed', 'OTP is incorrect or expired');
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:Intaleq/controller/functions/encrypt_decrypt.dart';
|
||||
import 'package:Intaleq/views/home/HomePage/trip_monitor/trip_link_monitor.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:Intaleq/controller/functions/toast.dart';
|
||||
import 'package:Intaleq/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../constant/table_names.dart';
|
||||
import '../../env/env.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
@@ -23,9 +18,7 @@ import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../auth/google_sign.dart';
|
||||
import '../functions/audio_record1.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
import 'access_token.dart';
|
||||
import 'local_notification.dart';
|
||||
import 'notification_service.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
@@ -76,9 +69,13 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
// Log.print('fcmToken: ${token}');
|
||||
Log.print('fcmToken: ${token}');
|
||||
box.write(BoxName.tokenFCM, (token.toString()));
|
||||
});
|
||||
// 🔹 الاشتراك في topic
|
||||
await fcmToken
|
||||
.subscribeToTopic("passengers"); // أو "users" حسب نوع المستخدم
|
||||
print("Subscribed to 'passengers' topic ✅");
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
// If the app is in the background or terminated, show a system tray message
|
||||
@@ -104,115 +101,106 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> fireBaseTitles(RemoteMessage message) async {
|
||||
if (message.notification!.title! == 'Order'.tr) {
|
||||
// [!! تعديل !!]
|
||||
// اقرأ "النوع" من حمولة البيانات، وليس من العنوان
|
||||
String category = message.data['category'] ?? '';
|
||||
|
||||
// اقرأ العنوان (للعرض)
|
||||
String title = message.notification?.title ?? '';
|
||||
String body = message.notification?.body ?? '';
|
||||
|
||||
if (category == 'ORDER') {
|
||||
// <-- مثال: كان 'Order'.tr
|
||||
Log.print('message: ${message}');
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Order'.tr, message.notification!.body!, 'Order');
|
||||
notificationController.showNotification(title, body, 'Order');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Accepted Ride') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Accepted Ride'.tr, 'Driver Accepted the Ride for You'.tr, 'ding');
|
||||
}
|
||||
|
||||
// ... داخل معالج الإشعارات في تطبيق الراكب ...
|
||||
else if (category == 'Accepted Ride') {
|
||||
// <-- كان 'Accepted Ride'
|
||||
var driverListJson = message.data['driverList'];
|
||||
if (driverListJson != null) {
|
||||
var myList = jsonDecode(driverListJson) as List<dynamic>;
|
||||
final controller = Get.find<MapPassengerController>();
|
||||
// controller.currentRideState.value = RideState.driverApplied;
|
||||
await controller.processRideAcceptance(
|
||||
driverIdFromFCM: myList[0].toString(),
|
||||
rideIdFromFCM: myList[3].toString());
|
||||
} else {
|
||||
Log.print('❌ خطأ: RIDE_ACCEPTED وصل بدون driverList');
|
||||
}
|
||||
var passengerList = message.data['passengerList'];
|
||||
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
Log.print('myList: ${myList}');
|
||||
final controller = Get.find<MapPassengerController>();
|
||||
controller.driverId = myList[0].toString();
|
||||
// assume rideId lives at index 2 in your list:
|
||||
controller.rideId = myList[3].toString();
|
||||
|
||||
controller
|
||||
..statusRide = 'Apply'
|
||||
..isSearchingWindow = false
|
||||
..update();
|
||||
await controller.rideAppliedFromDriver(true);
|
||||
|
||||
// driverAppliedTripSnakBar();
|
||||
} else if (message.notification!.title! == 'Promo'.tr) {
|
||||
} else if (category == 'Promo') {
|
||||
// <-- كان 'Promo'.tr
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Promo', 'Show latest promo'.tr, 'promo');
|
||||
notificationController.showNotification(title, body, 'promo');
|
||||
}
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title! == 'Trip Monitoring'.tr) {
|
||||
} else if (category == 'Trip Monitoring') {
|
||||
// <-- كان 'Trip Monitoring'.tr
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Trip Monitoring'.tr, '', 'iphone_ringtone');
|
||||
notificationController.showNotification(title, body, 'iphone_ringtone');
|
||||
}
|
||||
var myListString = message.data['DriverList'];
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.toNamed('/tripmonitor', arguments: {
|
||||
Get.to(() => TripMonitor(), arguments: {
|
||||
'rideId': myList[0].toString(),
|
||||
'driverId': myList[1].toString(),
|
||||
});
|
||||
} else if (message.notification!.title! == 'token change'.tr) {
|
||||
} else if (category == 'token change') {
|
||||
// <-- كان 'token change'.tr
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'token change'.tr, 'token change'.tr, 'cancel');
|
||||
notificationController.showNotification(title, body, 'cancel');
|
||||
}
|
||||
GoogleSignInHelper.signOut();
|
||||
} else if (message.notification!.title! ==
|
||||
'Driver Is Going To Passenger'.tr) {
|
||||
} else if (category == 'Driver Is Going To Passenger') {
|
||||
// <-- كان 'Driver Is Going To Passenger'
|
||||
Get.find<MapPassengerController>().isDriverInPassengerWay = true;
|
||||
Get.find<MapPassengerController>().update();
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification('Driver is Going To You'.tr,
|
||||
'Please stay on the picked point.'.tr, 'tone1');
|
||||
notificationController.showNotification(title, body, 'tone1');
|
||||
}
|
||||
// Get.snackbar('Driver is Going To Passenger', '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
} else if (message.notification!.title! == 'message From passenger') {
|
||||
} else if (category == 'message From passenger') {
|
||||
// <-- كان 'message From passenger'
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'message From passenger'.tr, ''.tr, 'ding');
|
||||
notificationController.showNotification(title, body, 'ding');
|
||||
}
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
passengerDialog(body);
|
||||
update();
|
||||
} else if (message.notification!.title! == 'message From Driver') {
|
||||
} else if (category == 'message From Driver') {
|
||||
// <-- كان 'message From Driver'
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'message From Driver'.tr, ''.tr, 'ding');
|
||||
notificationController.showNotification(title, body, 'ding');
|
||||
}
|
||||
passengerDialog(message.notification!.body!);
|
||||
|
||||
passengerDialog(body);
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Trip is Begin') {
|
||||
} else if (category == 'Trip is Begin') {
|
||||
// <-- كان 'Trip is Begin'
|
||||
Log.print('[FCM] استقبل إشعار "TRIP_BEGUN".');
|
||||
final controller = Get.find<MapPassengerController>();
|
||||
controller.processRideBegin();
|
||||
} else if (category == 'Hi ,I will go now') {
|
||||
// <-- كان 'Hi ,I will go now'.tr
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Trip is Begin'.tr, ''.tr, 'start');
|
||||
}
|
||||
Get.find<MapPassengerController>().getBeginRideFromDriver();
|
||||
// Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
|
||||
box.write(BoxName.passengerWalletTotal, '0');
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Hi ,I will go now'.tr) {
|
||||
// Get.snackbar('Hi ,I will go now', '',
|
||||
// backgroundColor: AppColor.greenColor);
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'ding');
|
||||
notificationController.showNotification(title, body, 'ding');
|
||||
}
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site'.tr) {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Hi ,I Arrive your site'.tr, ''.tr, 'ding');
|
||||
}
|
||||
driverArrivePassengerDialoge();
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title! == "Cancel Trip from driver") {
|
||||
} else if (category == 'Hi ,I Arrive your site') {
|
||||
// <-- كان 'Hi ,I Arrive your site'.tr
|
||||
final controller = Get.find<MapPassengerController>();
|
||||
// if (controller.currentRideState.value == RideState.driverApplied) {
|
||||
Log.print('[FCM] السائق وصل. تغيير الحالة إلى driverArrived');
|
||||
controller.currentRideState.value = RideState.driverArrived;
|
||||
// }
|
||||
} else if (category == 'Cancel Trip from driver') {
|
||||
// <-- كان "Cancel Trip from driver"
|
||||
Get.back();
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification("Cancel Trip from driver".tr,
|
||||
"We will look for a new driver.\nPlease wait.".tr, 'cancel');
|
||||
notificationController.showNotification(title, body, 'cancel');
|
||||
}
|
||||
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,
|
||||
confirm: MyElevatedButton(
|
||||
kolor: AppColor.greenColor,
|
||||
@@ -229,66 +217,42 @@ class FirebaseMessagesController extends GetxController {
|
||||
onPressed: () {
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
},
|
||||
)
|
||||
// Get.find<MapPassengerController>()
|
||||
// .searchNewDriverAfterRejectingFromDriver();
|
||||
);
|
||||
} else if (message.notification!.title! == 'Driver Finish Trip'.tr) {
|
||||
// الخطوة 1: استقبل البيانات وتحقق من وجودها
|
||||
));
|
||||
} else if (category == 'Driver Finish Trip') {
|
||||
// <-- كان 'Driver Finish Trip'.tr
|
||||
final rawData = message.data['DriverList'];
|
||||
List<dynamic> driverList = []; // ابدأ بقائمة فارغة كإجراء وقائي
|
||||
|
||||
// الخطوة 2: قم بفك تشفير البيانات بأمان
|
||||
List<dynamic> driverList = [];
|
||||
if (rawData != null && rawData is String) {
|
||||
try {
|
||||
driverList = jsonDecode(rawData);
|
||||
Log.print('Successfully decoded DriverList: $driverList');
|
||||
} catch (e) {
|
||||
Log.print('Error decoding DriverList JSON: $e');
|
||||
// اترك القائمة فارغة في حالة حدوث خطأ
|
||||
}
|
||||
} else {
|
||||
Log.print('Error: DriverList data is null or not a String.');
|
||||
}
|
||||
|
||||
// الخطوة 3: استخدم البيانات فقط إذا كانت القائمة تحتوي على العناصر المطلوبة
|
||||
// هذا يمنع خطأ "RangeError" إذا كانت القائمة أقصر من المتوقع
|
||||
if (driverList.length >= 4) {
|
||||
if (driverList.length >= 3) {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
"Driver Finish Trip".tr,
|
||||
'${'you will pay to Driver'.tr} ${driverList[3].toString()} \$', // تم تحسين طريقة عرض النص
|
||||
title,
|
||||
'${'you will pay to Driver'.tr} ${driverList[3].toString()} \$',
|
||||
'tone1');
|
||||
}
|
||||
|
||||
Get.find<AudioRecorderController>().stopRecording();
|
||||
|
||||
if ((double.tryParse(
|
||||
box.read(BoxName.passengerWalletTotal).toString()) ??
|
||||
0) <
|
||||
0) {
|
||||
box.write(BoxName.passengerWalletTotal, 0);
|
||||
}
|
||||
|
||||
// ... (باقي كود المحفظة) ...
|
||||
Get.find<MapPassengerController>().tripFinishedFromDriver();
|
||||
|
||||
NotificationController().showNotification(
|
||||
'Don’t forget your personal belongings.'.tr,
|
||||
'Please make sure you have all your personal belongings and that any remaining fare, if applicable, has been added to your wallet before leaving. Thank you for choosing the Intaleq app'
|
||||
.tr,
|
||||
'ding');
|
||||
|
||||
// ... (إشعار "لا تنسى متعلقاتك") ...
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
'price': driverList[3].toString()
|
||||
});
|
||||
} else {
|
||||
Log.print(
|
||||
'Error: Decoded driverList does not have enough elements. Received: $driverList');
|
||||
// هنا يمكنك عرض رسالة خطأ للمستخدم إذا لزم الأمر
|
||||
Log.print('Error: TRIP_FINISHED decoded list error.');
|
||||
}
|
||||
} else if (message.notification!.title! == "Finish Monitor".tr) {
|
||||
} else if (category == 'Finish Monitor') {
|
||||
// <-- كان "Finish Monitor".tr
|
||||
Get.defaultDialog(
|
||||
titleStyle: AppStyle.title,
|
||||
title: 'Trip finished '.tr,
|
||||
@@ -298,69 +262,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
onPressed: () {
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
}));
|
||||
}
|
||||
// else if (message.notification!.title! == "Trip Monitoring".tr) {
|
||||
// Get.to(() => const TripMonitor());
|
||||
// }
|
||||
else if (message.notification!.title! == 'Call Income') {
|
||||
try {
|
||||
var myListString = message.data['DriverList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// if (Platform.isAndroid) {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Call Income'.tr,
|
||||
message.notification!.body!,
|
||||
'iphone_ringtone',
|
||||
);
|
||||
}
|
||||
// }
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// Get.to(() => PassengerCallPage(
|
||||
// channelName: driverList[1].toString(),
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
// ));
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Call Income from Driver'.tr) {
|
||||
try {
|
||||
var myListString = message.data['DriverList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// if (Platform.isAndroid) {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Call Income'.tr,
|
||||
message.notification!.body!,
|
||||
'iphone_ringtone',
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// Get.to(() => PassengerCallPage(
|
||||
// channelName: driverList[1].toString(),
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
// ));
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Call End'.tr) {
|
||||
try {
|
||||
var myListString = message.data['DriverList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Call End'.tr,
|
||||
message.notification!.body!,
|
||||
'ding',
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// Get.off(const CallPage());
|
||||
} catch (e) {}
|
||||
} 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,
|
||||
// 'message',
|
||||
// backgroundColor: AppColor.redColor);
|
||||
} else if (category == 'Driver Cancelled Your Trip') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'Driver Cancelled Your Trip'.tr,
|
||||
@@ -374,18 +276,10 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
}
|
||||
// else if (message.notification!.title! == 'Order Applied') {
|
||||
// Get.snackbar(
|
||||
// "The order has been accepted by another driver."
|
||||
// .tr, // Corrected grammar
|
||||
// "Be more mindful next time to avoid dropping orders."
|
||||
// .tr, // Improved sentence structure
|
||||
// backgroundColor: AppColor.yellowColor,
|
||||
// snackPosition: SnackPosition.BOTTOM,
|
||||
// );
|
||||
// }
|
||||
// ... (باقي الحالات مثل Call Income, Call End, إلخ) ...
|
||||
// ... بنفس الطريقة ...
|
||||
|
||||
else if (message.notification!.title! == 'Order Applied'.tr) {
|
||||
else if (category == 'Order Applied') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
'The order Accepted by another Driver'.tr,
|
||||
@@ -395,6 +289,308 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Future<void> fireBaseTitles(RemoteMessage message) async {
|
||||
// if (message.notification!.title! == 'Order'.tr) {
|
||||
// Log.print('message: ${message}');
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Order'.tr, message.notification!.body!, 'Order');
|
||||
// }
|
||||
// } else // ... داخل معالج الإشعارات في تطبيق الراكب ...
|
||||
|
||||
// if (message.notification!.title! == 'Accepted Ride') {
|
||||
// // ...
|
||||
|
||||
// // انظر هنا: قمنا بتغيير "passengerList" إلى "driverList"
|
||||
// var driverListJson = message.data['driverList'];
|
||||
|
||||
// // تأكد من أن البيانات ليست null قبل المتابعة
|
||||
// if (driverListJson != null) {
|
||||
// var myList = jsonDecode(driverListJson) as List<dynamic>;
|
||||
// Log.print('myList: ${myList}');
|
||||
|
||||
// final controller = Get.find<MapPassengerController>();
|
||||
|
||||
// // استدعاء الدالة الموحدة الجديدة التي أنشأناها
|
||||
// await controller.processRideAcceptance(
|
||||
// driverIdFromFCM: myList[0].toString(),
|
||||
// rideIdFromFCM: myList[3].toString());
|
||||
// } else {
|
||||
// Log.print(
|
||||
// '❌ خطأ فادح: إشعار "Accepted Ride" وصل بدون بيانات (driverList is null)');
|
||||
// }
|
||||
// } else if (message.notification!.title! == 'Promo'.tr) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Promo', 'Show latest promo'.tr, 'promo');
|
||||
// }
|
||||
// Get.to(const PromosPassengerPage());
|
||||
// } else if (message.notification!.title! == 'Trip Monitoring'.tr) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Trip Monitoring'.tr, '', 'iphone_ringtone');
|
||||
// }
|
||||
// var myListString = message.data['DriverList'];
|
||||
// var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
// Get.toNamed('/tripmonitor', arguments: {
|
||||
// 'rideId': myList[0].toString(),
|
||||
// 'driverId': myList[1].toString(),
|
||||
// });
|
||||
// } else if (message.notification!.title! == 'token change'.tr) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'token change'.tr, 'token change'.tr, 'cancel');
|
||||
// }
|
||||
// GoogleSignInHelper.signOut();
|
||||
// } else if (message.notification!.title! == 'Driver Is Going To Passenger') {
|
||||
// Get.find<MapPassengerController>().isDriverInPassengerWay = true;
|
||||
// Get.find<MapPassengerController>().update();
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification('Driver is Going To You'.tr,
|
||||
// 'Please stay on the picked point.'.tr, 'tone1');
|
||||
// }
|
||||
// // Get.snackbar('Driver is Going To Passenger', '',
|
||||
// // backgroundColor: AppColor.greenColor);
|
||||
// } else if (message.notification!.title! == 'message From passenger') {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'message From passenger'.tr, ''.tr, 'ding');
|
||||
// }
|
||||
// passengerDialog(message.notification!.body!);
|
||||
|
||||
// update();
|
||||
// } else if (message.notification!.title! == 'message From Driver') {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'message From Driver'.tr, ''.tr, 'ding');
|
||||
// }
|
||||
// passengerDialog(message.notification!.body!);
|
||||
|
||||
// update();
|
||||
// } else // (هذا الكود في معالج الإشعارات لديك)
|
||||
// if (message.notification!.title! == 'Trip is Begin') {
|
||||
// Log.print('[FCM] استقبل إشعار "Trip is Begin".');
|
||||
|
||||
// // (تم حذف الإشعار المحلي من هنا، نُقل إلى الدالة الموحدة)
|
||||
|
||||
// final controller = Get.find<MapPassengerController>();
|
||||
|
||||
// // استدعاء حارس البوابة الجديد والآمن
|
||||
// controller.processRideBegin();
|
||||
|
||||
// // (تم حذف كل الأوامر التالية من هنا)
|
||||
// // Get.find<MapPassengerController>().getBeginRideFromDriver();
|
||||
// // box.write(BoxName.passengerWalletTotal, '0');
|
||||
// // update();
|
||||
// } else if (message.notification!.title! == 'Hi ,I will go now'.tr) {
|
||||
// // Get.snackbar('Hi ,I will go now', '',
|
||||
// // backgroundColor: AppColor.greenColor);
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'ding');
|
||||
// }
|
||||
// update();
|
||||
// } // ... داخل معالج الإشعارات (FCM Handler) ...
|
||||
// if (message.notification!.title! == 'Hi ,I Arrive your site'.tr) {
|
||||
// final controller = Get.find<MapPassengerController>();
|
||||
|
||||
// // 1. التأكد أننا في الحالة الصحيحة (السائق كان في الطريق)
|
||||
// if (controller.currentRideState.value == RideState.driverApplied) {
|
||||
// Log.print('[FCM] السائق وصل. تغيير الحالة إلى driverArrived');
|
||||
|
||||
// // 2. تغيير الحالة فقط!
|
||||
// controller.currentRideState.value = RideState.driverArrived;
|
||||
// }
|
||||
// } else if (message.notification!.title! == "Cancel Trip from driver") {
|
||||
// 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,
|
||||
// confirm: MyElevatedButton(
|
||||
// kolor: AppColor.greenColor,
|
||||
// title: 'Ok'.tr,
|
||||
// onPressed: () async {
|
||||
// Get.back();
|
||||
// await Get.find<MapPassengerController>()
|
||||
// .reSearchAfterCanceledFromDriver();
|
||||
// },
|
||||
// ),
|
||||
// cancel: MyElevatedButton(
|
||||
// title: 'Cancel'.tr,
|
||||
// kolor: AppColor.redColor,
|
||||
// onPressed: () {
|
||||
// Get.offAll(() => const MapPagePassenger());
|
||||
// },
|
||||
// )
|
||||
// // Get.find<MapPassengerController>()
|
||||
// // .searchNewDriverAfterRejectingFromDriver();
|
||||
// );
|
||||
// } else if (message.notification!.title! == 'Driver Finish Trip'.tr) {
|
||||
// // الخطوة 1: استقبل البيانات وتحقق من وجودها
|
||||
// final rawData = message.data['DriverList'];
|
||||
// List<dynamic> driverList = []; // ابدأ بقائمة فارغة كإجراء وقائي
|
||||
|
||||
// // الخطوة 2: قم بفك تشفير البيانات بأمان
|
||||
// if (rawData != null && rawData is String) {
|
||||
// try {
|
||||
// driverList = jsonDecode(rawData);
|
||||
// Log.print('Successfully decoded DriverList: $driverList');
|
||||
// } catch (e) {
|
||||
// Log.print('Error decoding DriverList JSON: $e');
|
||||
// // اترك القائمة فارغة في حالة حدوث خطأ
|
||||
// }
|
||||
// } else {
|
||||
// Log.print('Error: DriverList data is null or not a String.');
|
||||
// }
|
||||
|
||||
// // الخطوة 3: استخدم البيانات فقط إذا كانت القائمة تحتوي على العناصر المطلوبة
|
||||
// // هذا يمنع خطأ "RangeError" إذا كانت القائمة أقصر من المتوقع
|
||||
// if (driverList.length >= 4) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// "Driver Finish Trip".tr,
|
||||
// '${'you will pay to Driver'.tr} ${driverList[3].toString()} \$', // تم تحسين طريقة عرض النص
|
||||
// 'tone1');
|
||||
// }
|
||||
|
||||
// Get.find<AudioRecorderController>().stopRecording();
|
||||
|
||||
// if ((double.tryParse(
|
||||
// box.read(BoxName.passengerWalletTotal).toString()) ??
|
||||
// 0) <
|
||||
// 0) {
|
||||
// box.write(BoxName.passengerWalletTotal, 0);
|
||||
// }
|
||||
|
||||
// Get.find<MapPassengerController>().tripFinishedFromDriver();
|
||||
|
||||
// NotificationController().showNotification(
|
||||
// 'Don’t forget your personal belongings.'.tr,
|
||||
// 'Please make sure you have all your personal belongings and that any remaining fare, if applicable, has been added to your wallet before leaving. Thank you for choosing the Intaleq app'
|
||||
// .tr,
|
||||
// 'ding');
|
||||
|
||||
// Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
// 'driverId': driverList[0].toString(),
|
||||
// 'rideId': driverList[1].toString(),
|
||||
// 'price': driverList[3].toString()
|
||||
// });
|
||||
// } else {
|
||||
// Log.print(
|
||||
// 'Error: Decoded driverList does not have enough elements. Received: $driverList');
|
||||
// // هنا يمكنك عرض رسالة خطأ للمستخدم إذا لزم الأمر
|
||||
// }
|
||||
// } else if (message.notification!.title! == "Finish Monitor".tr) {
|
||||
// Get.defaultDialog(
|
||||
// titleStyle: AppStyle.title,
|
||||
// title: 'Trip finished '.tr,
|
||||
// middleText: '',
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'Ok'.tr,
|
||||
// onPressed: () {
|
||||
// Get.offAll(() => const MapPagePassenger());
|
||||
// }));
|
||||
// }
|
||||
// // else if (message.notification!.title! == "Trip Monitoring".tr) {
|
||||
// // Get.to(() => const TripMonitor());
|
||||
// // }
|
||||
// else if (message.notification!.title! == 'Call Income') {
|
||||
// try {
|
||||
// var myListString = message.data['DriverList'];
|
||||
// var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// // if (Platform.isAndroid) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Call Income'.tr,
|
||||
// message.notification!.body!,
|
||||
// 'iphone_ringtone',
|
||||
// );
|
||||
// }
|
||||
// // }
|
||||
// // Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// // Get.to(() => PassengerCallPage(
|
||||
// // channelName: driverList[1].toString(),
|
||||
// // token: driverList[0].toString(),
|
||||
// // remoteID: driverList[2].toString(),
|
||||
// // ));
|
||||
// } catch (e) {}
|
||||
// } else if (message.notification!.title! == 'Call Income from Driver'.tr) {
|
||||
// try {
|
||||
// var myListString = message.data['DriverList'];
|
||||
// var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// // if (Platform.isAndroid) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Call Income'.tr,
|
||||
// message.notification!.body!,
|
||||
// 'iphone_ringtone',
|
||||
// );
|
||||
// }
|
||||
// // Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// // Get.to(() => PassengerCallPage(
|
||||
// // channelName: driverList[1].toString(),
|
||||
// // token: driverList[0].toString(),
|
||||
// // remoteID: driverList[2].toString(),
|
||||
// // ));
|
||||
// } catch (e) {}
|
||||
// } else if (message.notification!.title! == 'Call End'.tr) {
|
||||
// try {
|
||||
// var myListString = message.data['DriverList'];
|
||||
// var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Call End'.tr,
|
||||
// message.notification!.body!,
|
||||
// 'ding',
|
||||
// );
|
||||
// }
|
||||
// // Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
// // Get.off(const CallPage());
|
||||
// } catch (e) {}
|
||||
// } 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,
|
||||
// // 'message',
|
||||
// // backgroundColor: AppColor.redColor);
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'Driver Cancelled Your Trip'.tr,
|
||||
// 'you will pay to Driver you will be pay the cost of driver time look to your Intaleq Wallet'
|
||||
// .tr,
|
||||
// 'cancel');
|
||||
// }
|
||||
// box.write(BoxName.parentTripSelected, false);
|
||||
// box.remove(BoxName.tokenParent);
|
||||
|
||||
// Get.find<MapPassengerController>().restCounter();
|
||||
// Get.offAll(() => const MapPagePassenger());
|
||||
// }
|
||||
// // else if (message.notification!.title! == 'Order Applied') {
|
||||
// // Get.snackbar(
|
||||
// // "The order has been accepted by another driver."
|
||||
// // .tr, // Corrected grammar
|
||||
// // "Be more mindful next time to avoid dropping orders."
|
||||
// // .tr, // Improved sentence structure
|
||||
// // backgroundColor: AppColor.yellowColor,
|
||||
// // snackPosition: SnackPosition.BOTTOM,
|
||||
// // );
|
||||
// // }
|
||||
|
||||
// else if (message.notification!.title! == 'Order Applied'.tr) {
|
||||
// if (Platform.isAndroid) {
|
||||
// notificationController.showNotification(
|
||||
// 'The order Accepted by another Driver'.tr,
|
||||
// 'We regret to inform you that another driver has accepted this order.'
|
||||
// .tr,
|
||||
// 'order');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
SnackbarController driverAppliedTripSnakBar() {
|
||||
return Get.snackbar(
|
||||
@@ -418,40 +614,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
Future<dynamic> driverArrivePassengerDialoge() {
|
||||
return Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Hi ,I Arrive your site'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: 'Please go to Car Driver'.tr,
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok I will go now.'.tr,
|
||||
onPressed: () {
|
||||
// sendNotificationToPassengerToken(
|
||||
// 'Hi ,I will go now',
|
||||
// 'I will go now'.tr,
|
||||
// Get.find<MapPassengerController>().driverToken,
|
||||
// [],
|
||||
// 'ding');
|
||||
NotificationService.sendNotification(
|
||||
target:
|
||||
Get.find<MapPassengerController>().driverToken.toString(),
|
||||
title: 'Hi ,I will go now'.tr,
|
||||
body: 'I will go now'.tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'ding',
|
||||
driverList: [],
|
||||
);
|
||||
Get.find<MapPassengerController>()
|
||||
.startTimerDriverWaitPassenger5Minute();
|
||||
|
||||
Get.back();
|
||||
Get.find<MapPassengerController>().remainingTime = 0;
|
||||
Get.find<MapPassengerController>().update();
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> passengerDialog(String message) {
|
||||
return Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
@@ -500,246 +662,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
}
|
||||
|
||||
// void sendNotificationAll(String title, body, tone) async {
|
||||
// // Get the token you want to subtract.
|
||||
// String token = box.read(BoxName.tokenFCM);
|
||||
// tokens = box.read(BoxName.tokens);
|
||||
// // Subtract the token from the list of tokens.
|
||||
// tokens.remove(token);
|
||||
|
||||
// // Save the list of tokens back to the box.
|
||||
// // box.write(BoxName.tokens, tokens);
|
||||
// tokens = box.read(BoxName.tokens);
|
||||
// for (var i = 0; i < tokens.length; i++) {
|
||||
// http
|
||||
// .post(
|
||||
// Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'key=${AK.serverAPI}'
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'message': {
|
||||
// 'token': token,
|
||||
// 'notification': {
|
||||
// 'title': title,
|
||||
// 'body': body,
|
||||
// },
|
||||
// // 'data': {
|
||||
// // 'DriverList': jsonEncode(data),
|
||||
// // },
|
||||
// 'android': {
|
||||
// 'priority': 'HIGH ', // Set priority to high
|
||||
// 'notification': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// 'apns': {
|
||||
// 'headers': {
|
||||
// 'apns-priority': '10', // Set APNs priority to 10
|
||||
// },
|
||||
// 'payload': {
|
||||
// 'aps': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// )
|
||||
// .whenComplete(() {})
|
||||
// .catchError((e) {});
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (var i = 0; i < tokens.length; i++) {
|
||||
// http
|
||||
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'key=${storage.read(key: BoxName.serverAPI}'
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'notification': <String, dynamic>{
|
||||
// 'title': title,
|
||||
// 'body': body,
|
||||
// 'sound': 'true'
|
||||
// },
|
||||
// 'priority': 'HIGH ',
|
||||
// 'data': <String, dynamic>{
|
||||
// 'click_action': 'FLUTTER_NOTIFICATION_CLICK',
|
||||
// 'id': '1',
|
||||
// 'status': 'done'
|
||||
// },
|
||||
// 'to': tokens[i],
|
||||
// }))
|
||||
// .whenComplete(() {})
|
||||
// .catchError((e) {
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// late String serviceAccountKeyJson;
|
||||
// '{"type": "service_account", "project_id": "intaleq-d48a7", "private_key_id": "d63a627dad96d0050c08a76c2920b1e48ddc4d38", "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHgHWUIlGskFWT\\nkjBvSiAYzXz51NbyMtqlvq1rZaiokd/yzqcEsjgxcAEGap93gRu72cuJ7QzDOpec\\nXSmhQwaGrdDyGyuS5x8nBa9ea3QEUGKjk975OhgIDoaIX2YHjah+jf/p3CPvwovC\\n+qypLsErv5DtcFfKtHkL+Z8gKJojU3p0gP2cVLHlhodGG4767w1f70fIv5LmQRHh\\nE0x5GgjO7MfA1CJewgHDWzj9GTuTd9o3G5nF6ojn8H1EOWminNDrsHAagsplY7iV\\nNmdvGoIAg2kRt66y5k4Li7EiH3e2ILvomGvUe3ahxBTcyFAt7UuAC5aPTmB0OCtN\\n39vMkJGtAgMBAAECggEAQ/FoWcBMX4AyXNUzQJuWjcvhzbXiVE7kbwEez44qH+q6\\nQdeGQw+tGo0iFDzYvVrPhqzYaEs+hvib7Kk/xcdtYA2vNNzy/I9Q6TnC7V2b/+Ie\\njcYM8IUL7SaBQ811kon4gc07hDowVPXFImy7w8yEBjGyGmMhywumk+D6A/o/8Fph\\n3lGRzgYZ7K7+mXxDpJVFp8DwX+uqP/3wOzcITXE12GZpvB+re7TQTs01qjsSTJ3/\\nCZMC6CvwYr3BvJzvgrn2TNZ6N6yowHE2iJo/HnoY/DutiB1V0B2EAMgcy05ZUouH\\nnTTOMAyV5LdcxgCtzlz+meCuhV5SUtfSz27bnUluMwKBgQDz+qJM38NhUpW7tmxZ\\nQsYwlo3Zp2a38UV8VC4mNDM9jjsft9QRHShos7potlIvmn9ryxP87SGNZrW9xy/k\\ngvTbDXu65/TwCUa3HYFCC+eJ5S4bBK/ctFwn1sr5AFjxavY2VV6YHUIzGezo8Bsj\\n1R5IGy3UHreTWngDapJYpA3JQwKBgQDRVNK7UP/Qt4qovrTVlNJ5mHjpwk7VoKBC\\nV0yrfbYVjYETFRFMrsKkcwCTQ3uk3lEl/UzAt2vV6o4Ql8KDzYJ/8ZHHXp9Z2eK9\\nTgR2fOIaEh2JJUjyVAUtuJo7RFl61K3a080+ZGWuZCY6K+prGneFqGuJ7XTtveGy\\njIsZTUhSTwKBgQCS0n5/Qp1iYP+IsjQr1zpLnR6KH+p5wXEua75F8V3wqjo8UTUG\\ng4SA1b/VKfr1eMU7ij9iExYA8RFnvom8u248sLWH+fT1yq9KnS/fHijdXBTN35kx\\neTyIIQOOqz3bMqIuelttsRXYiL6AQ5Yhjywk+m4u27lfrK7SZ3zgaQF+3wKBgEBy\\nfgKfmHLY3z6+oAwVqos3LxrA8OaCcnSaTgeKR5HxI+kNFmtmbpSUt3ufTiTfMVqh\\n1oyKrA+LDDv9jSxpDCF57SjVb/gIxe8EYwlbv3zJUQCVUxUQWxvNduaCT44qhnAV\\nv13TKR78xGwqcxyQZHXo+VrYmaRMTn1bGcQrb/WvAoGAIWUnnGQsvf6SwPQ/7gXC\\nVAq4i3E+coLStVyPK552HVorKa7J+TQnNBGHjCaQhxfCgp59/4qeT5AizzQaMhuS\\noGiUwGeo4RY4A1EEGoUpUk3zWZfC+bAjHVDyIjfN0YfxobL6Sh/97N68PMzb6ppq\\nybvddSGGsqZgucSxkEhIdTw=\\n-----END PRIVATE KEY-----\\n", "client_email": "firebase-adminsdk-fbsvc@intaleq-d48a7.iam.gserviceaccount.com", "client_id": "100558924056484926665", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40intaleq-d48a7.iam.gserviceaccount.com", "universe_domain": "googleapis.com"}';
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
// try {
|
||||
// // var encryptedKey = Env.privateKeyFCM;
|
||||
// // // Log.print('encryptedKey: ${encryptedKey}');
|
||||
// // serviceAccountKeyJson =
|
||||
// // EncryptionHelper.instance.decryptData(encryptedKey);
|
||||
// // Log.print('serviceAccountKeyJson: ${serviceAccountKeyJson}');
|
||||
// } catch (e) {
|
||||
// print('🔴 Error decrypting FCM key: $e');
|
||||
// }
|
||||
}
|
||||
|
||||
// Future<void> sendNotificationToDriverMAP(
|
||||
// String title, String body, String token, List<String> data, String tone,
|
||||
// {int retryCount = 1}) async {
|
||||
// try {
|
||||
// if (serviceAccountKeyJson.isEmpty) {
|
||||
// print("🔴 Error: Service Account Key is empty");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Initialize AccessTokenManager
|
||||
// final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
|
||||
// // Log.print(
|
||||
// // 'accessTokenManager: ${accessTokenManager.serviceAccountJsonKey}');
|
||||
|
||||
// // Obtain an OAuth 2.0 access token
|
||||
// final accessToken = await accessTokenManager.getAccessToken();
|
||||
// // Log.print('accessToken: ${accessToken}');
|
||||
|
||||
// // Send the notification
|
||||
// final response = await http.post(
|
||||
// Uri.parse(
|
||||
// 'https://fcm.googleapis.com/v1/projects/intaleq-d48a7/messages:send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'Bearer $accessToken',
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'message': {
|
||||
// 'token': token,
|
||||
// 'notification': {
|
||||
// 'title': title,
|
||||
// 'body': body,
|
||||
// },
|
||||
// 'data': {
|
||||
// 'DriverList': jsonEncode(data),
|
||||
// },
|
||||
// 'android': {
|
||||
// 'priority': 'HIGH ', // Set priority to high
|
||||
// 'notification': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// 'apns': {
|
||||
// 'headers': {
|
||||
// 'apns-priority': '10', // Set APNs priority to 10
|
||||
// },
|
||||
// 'payload': {
|
||||
// 'aps': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// );
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// print(
|
||||
// 'Notification sent successfully. Status code: ${response.statusCode}');
|
||||
// // print('Response token: ${token}');
|
||||
// } else {
|
||||
// print(
|
||||
// 'Failed to send notification. Status code: ${response.statusCode}');
|
||||
// print('Response body: ${response.body}');
|
||||
// if (retryCount > 0) {
|
||||
// print('Retrying... Attempts remaining: $retryCount');
|
||||
// await Future.delayed(
|
||||
// Duration(seconds: 2)); // Optional delay before retrying
|
||||
// return sendNotificationToDriverMAP(title, body, token, data, tone,
|
||||
// retryCount: retryCount - 1);
|
||||
// }
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('Error sending notification: $e');
|
||||
// if (retryCount > 0) {
|
||||
// print('Retrying... Attempts remaining: $retryCount');
|
||||
// await Future.delayed(
|
||||
// Duration(seconds: 2)); // Optional delay before retrying
|
||||
// return sendNotificationToDriverMAP(title, body, token, data, tone,
|
||||
// retryCount: retryCount - 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void sendNotificationToPassengerToken(
|
||||
// String title, body, token, List<String> map, String tone) async {
|
||||
// try {
|
||||
// if (serviceAccountKeyJson.isEmpty) {
|
||||
// print("🔴 Error: Service Account Key is empty");
|
||||
// return;
|
||||
// }
|
||||
// // Initialize AccessTokenManager
|
||||
// final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
|
||||
|
||||
// // Obtain an OAuth 2.0 access token
|
||||
// final accessToken = await accessTokenManager.getAccessToken();
|
||||
// // Log.print('accessToken: ${accessToken}');
|
||||
|
||||
// // Send the notification
|
||||
// final response = await http.post(
|
||||
// Uri.parse(
|
||||
// 'https://fcm.googleapis.com/v1/projects/intaleq-d48a7/messages:send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'Bearer $accessToken',
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'message': {
|
||||
// 'token': token,
|
||||
// 'notification': {
|
||||
// 'title': title,
|
||||
// 'body': body,
|
||||
// },
|
||||
// 'android': {
|
||||
// 'priority': 'HIGH ', // Set priority to high
|
||||
// 'notification': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// 'apns': {
|
||||
// 'headers': {
|
||||
// 'apns-priority': '10', // Set APNs priority to 10
|
||||
// },
|
||||
// 'payload': {
|
||||
// 'aps': {
|
||||
// 'sound': tone,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// );
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// print('✅ Notification sent successfully!');
|
||||
// } else {
|
||||
// print(
|
||||
// '🔴 Failed to send notification. Status code: ${response.statusCode}');
|
||||
// print('Response body: ${response.body}');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('🔴 Error sending notification: $e');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
class DriverTipWidget extends StatelessWidget {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:Intaleq/print.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
@@ -5,11 +6,13 @@ class NotificationService {
|
||||
// استبدل هذا الرابط بالرابط الصحيح لملف PHP على السيرفر الخاص بك
|
||||
static const String _serverUrl =
|
||||
'https://syria.intaleq.xyz/intaleq/fcm/send_fcm.php';
|
||||
|
||||
static const String _batchServerUrl =
|
||||
'https://syria.intaleq.xyz/intaleq/fcm/send_fcm_batch.php';
|
||||
static Future<void> sendNotification({
|
||||
required String target,
|
||||
required String title,
|
||||
required String body,
|
||||
required String? category, // <-- [الإضافة الأولى]
|
||||
String? tone,
|
||||
List<String>? driverList, // <-- [تعديل 1] : إضافة المتغير الجديد
|
||||
bool isTopic = false,
|
||||
@@ -21,7 +24,10 @@ class NotificationService {
|
||||
'body': body,
|
||||
'isTopic': isTopic,
|
||||
};
|
||||
|
||||
if (category != null) {
|
||||
payload['category'] =
|
||||
category; // <-- [الإضافة الثانية] (النص الثابت للتحكم)
|
||||
}
|
||||
// نضيف النغمة فقط إذا لم تكن فارغة
|
||||
if (tone != null) {
|
||||
payload['tone'] = tone;
|
||||
@@ -52,4 +58,56 @@ class NotificationService {
|
||||
print('❌ An error occurred while sending notification: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// [4] !! دالة جديدة مضافة !!
|
||||
/// ترسل إشعاراً "مجمعاً" إلى قائمة من السائقين
|
||||
static Future<void> sendBatchNotification({
|
||||
required List<String> targets, // <-- قائمة التوكينز
|
||||
required String title,
|
||||
required String body,
|
||||
String? tone,
|
||||
List<String>? driverList, // <-- بيانات الرحلة (نفسها للجميع)
|
||||
}) async {
|
||||
// لا ترسل شيئاً إذا كانت القائمة فارغة
|
||||
if (targets.isEmpty) {
|
||||
Log.print('⚠️ [Batch] No targets to send to. Skipped.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final Map<String, dynamic> payload = {
|
||||
// "targets" بدلاً من "target"
|
||||
'targets': jsonEncode(targets), // تشفير قائمة التوكينز
|
||||
'title': title,
|
||||
'body': body,
|
||||
};
|
||||
|
||||
if (tone != null) {
|
||||
payload['tone'] = tone;
|
||||
}
|
||||
|
||||
// بيانات الرحلة (DriverList)
|
||||
if (driverList != null) {
|
||||
payload['driverList'] = jsonEncode(driverList);
|
||||
}
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(_batchServerUrl), // <-- !! تستخدم الرابط الجديد
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(payload),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Log.print('✅ [Batch] Notifications sent successfully.');
|
||||
Log.print('Server Response: ${response.body}');
|
||||
} else {
|
||||
Log.print('❌ [Batch] Failed to send. Status: ${response.statusCode}');
|
||||
Log.print('Server Error: ${response.body}');
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print('❌ [Batch] An error occurred: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ import 'encrypt_decrypt.dart';
|
||||
import 'upload_image.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:jwt_decoder/jwt_decoder.dart';
|
||||
|
||||
import 'network/connection_check.dart';
|
||||
import 'network/net_guard.dart';
|
||||
|
||||
class CRUD {
|
||||
@@ -364,29 +361,29 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getTokenParent({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
// Uses Basic Auth, so it's a separate implementation.
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
return jsonDecode(response.body);
|
||||
}
|
||||
// Consider adding error handling here.
|
||||
return null;
|
||||
}
|
||||
// Future<dynamic> getTokenParent({
|
||||
// required String link,
|
||||
// Map<String, dynamic>? payload,
|
||||
// }) async {
|
||||
// // Uses Basic Auth, so it's a separate implementation.
|
||||
// var url = Uri.parse(
|
||||
// link,
|
||||
// );
|
||||
// var response = await http.post(
|
||||
// url,
|
||||
// body: payload,
|
||||
// headers: {
|
||||
// "Content-Type": "application/x-www-form-urlencoded",
|
||||
// 'Authorization':
|
||||
// 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
|
||||
// },
|
||||
// );
|
||||
// if (response.statusCode == 200) {
|
||||
// return jsonDecode(response.body);
|
||||
// }
|
||||
// // Consider adding error handling here.
|
||||
// return null;
|
||||
// }
|
||||
|
||||
Future sendWhatsAppAuth(String to, String token) async {
|
||||
var res = await CRUD()
|
||||
|
||||
@@ -8,11 +8,32 @@ void showInBrowser(String url) async {
|
||||
}
|
||||
|
||||
Future<void> makePhoneCall(String phoneNumber) async {
|
||||
// 1. تنظيف الرقم (إزالة المسافات والفواصل)
|
||||
String formattedNumber = phoneNumber.replaceAll(RegExp(r'\s+'), '');
|
||||
|
||||
// 2. التحقق من طول الرقم لتحديد طريقة التنسيق
|
||||
if (formattedNumber.length > 6) {
|
||||
// --- التعديل المطلوب ---
|
||||
if (formattedNumber.startsWith('09')) {
|
||||
// إذا كان يبدأ بـ 09 (رقم موبايل سوري محلي)
|
||||
// نحذف أول خانة (الصفر) ونضيف +963
|
||||
formattedNumber = '+963${formattedNumber.substring(1)}';
|
||||
} else if (!formattedNumber.startsWith('+')) {
|
||||
// إذا لم يكن يبدأ بـ + (ولم يكن يبدأ بـ 09)، نضيف + في البداية
|
||||
// هذا للحفاظ على منطقك القديم للأرقام الدولية الأخرى
|
||||
formattedNumber = '+$formattedNumber';
|
||||
}
|
||||
}
|
||||
|
||||
// 3. التنفيذ (Launch)
|
||||
final Uri launchUri = Uri(
|
||||
scheme: 'tel',
|
||||
path: phoneNumber,
|
||||
path: formattedNumber,
|
||||
);
|
||||
await launchUrl(launchUri);
|
||||
|
||||
if (await canLaunchUrl(launchUri)) {
|
||||
await launchUrl(launchUri);
|
||||
}
|
||||
}
|
||||
|
||||
void launchCommunication(
|
||||
|
||||
@@ -1,148 +1,148 @@
|
||||
import 'dart:async';
|
||||
// import 'dart:async';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:Intaleq/constant/box_name.dart';
|
||||
import 'package:Intaleq/constant/links.dart';
|
||||
import 'package:Intaleq/controller/functions/crud.dart';
|
||||
import 'package:Intaleq/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:Intaleq/main.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
// import 'package:location/location.dart';
|
||||
// import 'package:Intaleq/constant/box_name.dart';
|
||||
// import 'package:Intaleq/constant/links.dart';
|
||||
// import 'package:Intaleq/controller/functions/crud.dart';
|
||||
// import 'package:Intaleq/controller/home/payment/captain_wallet_controller.dart';
|
||||
// import 'package:Intaleq/main.dart';
|
||||
|
||||
// LocationController.dart
|
||||
class LocationController extends GetxController {
|
||||
LocationData? _currentLocation;
|
||||
late Location location;
|
||||
bool isLoading = false;
|
||||
late double heading = 0;
|
||||
late double accuracy = 0;
|
||||
late double previousTime = 0;
|
||||
late double latitude;
|
||||
late double totalDistance = 0;
|
||||
late double longitude;
|
||||
late DateTime time;
|
||||
late double speed = 0;
|
||||
late double speedAccuracy = 0;
|
||||
late double headingAccuracy = 0;
|
||||
bool isActive = false;
|
||||
late LatLng myLocation;
|
||||
String totalPoints = '0';
|
||||
LocationData? get currentLocation => _currentLocation;
|
||||
Timer? _locationTimer;
|
||||
// // LocationController.dart
|
||||
// class LocationController extends GetxController {
|
||||
// LocationData? _currentLocation;
|
||||
// late Location location;
|
||||
// bool isLoading = false;
|
||||
// late double heading = 0;
|
||||
// late double accuracy = 0;
|
||||
// late double previousTime = 0;
|
||||
// late double latitude;
|
||||
// late double totalDistance = 0;
|
||||
// late double longitude;
|
||||
// late DateTime time;
|
||||
// late double speed = 0;
|
||||
// late double speedAccuracy = 0;
|
||||
// late double headingAccuracy = 0;
|
||||
// bool isActive = false;
|
||||
// late LatLng myLocation;
|
||||
// String totalPoints = '0';
|
||||
// LocationData? get currentLocation => _currentLocation;
|
||||
// Timer? _locationTimer;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
location = Location();
|
||||
getLocation();
|
||||
// startLocationUpdates();
|
||||
// @override
|
||||
// void onInit() async {
|
||||
// super.onInit();
|
||||
// location = Location();
|
||||
// getLocation();
|
||||
// // startLocationUpdates();
|
||||
|
||||
totalPoints = Get.put(CaptainWalletController()).totalPoints;
|
||||
}
|
||||
// totalPoints = Get.put(CaptainWalletController()).totalPoints;
|
||||
// }
|
||||
|
||||
Future<void> startLocationUpdates() async {
|
||||
if (box.read(BoxName.driverID) != null) {
|
||||
_locationTimer =
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
try {
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
// Future<void> startLocationUpdates() async {
|
||||
// if (box.read(BoxName.driverID) != null) {
|
||||
// _locationTimer =
|
||||
// Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
// try {
|
||||
// totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
|
||||
// if (isActive) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
await getLocation();
|
||||
// // if (isActive) {
|
||||
// if (double.parse(totalPoints) > -300) {
|
||||
// await getLocation();
|
||||
|
||||
// if (box.read(BoxName.driverID) != null) {
|
||||
await CRUD()
|
||||
.post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'heading': heading.toString(),
|
||||
'speed': (speed * 3.6).toStringAsFixed(1),
|
||||
'distance': totalDistance == 0
|
||||
? '0'
|
||||
: totalDistance < 1
|
||||
? totalDistance.toStringAsFixed(3)
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
}
|
||||
// // if (box.read(BoxName.driverID) != null) {
|
||||
// await CRUD()
|
||||
// .post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
// 'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// 'latitude': myLocation.latitude.toString(),
|
||||
// 'longitude': myLocation.longitude.toString(),
|
||||
// 'heading': heading.toString(),
|
||||
// 'speed': (speed * 3.6).toStringAsFixed(1),
|
||||
// 'distance': totalDistance == 0
|
||||
// ? '0'
|
||||
// : totalDistance < 1
|
||||
// ? totalDistance.toStringAsFixed(3)
|
||||
// : totalDistance.toStringAsFixed(1),
|
||||
// 'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
// });
|
||||
// }
|
||||
|
||||
// }
|
||||
} catch (e) {
|
||||
// Handle the error gracefully
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// // }
|
||||
// } catch (e) {
|
||||
// // Handle the error gracefully
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
void stopLocationUpdates() {
|
||||
_locationTimer?.cancel();
|
||||
}
|
||||
// void stopLocationUpdates() {
|
||||
// _locationTimer?.cancel();
|
||||
// }
|
||||
|
||||
Future<void> getLocation() async {
|
||||
// isLoading = true;
|
||||
// update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
// Future<void> getLocation() async {
|
||||
// // isLoading = true;
|
||||
// // update();
|
||||
// bool serviceEnabled;
|
||||
// PermissionStatus permissionGranted;
|
||||
|
||||
// Check if location services are enabled
|
||||
serviceEnabled = await location.serviceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
serviceEnabled = await location.requestService();
|
||||
if (!serviceEnabled) {
|
||||
// Location services are still not enabled, handle the error
|
||||
return;
|
||||
}
|
||||
}
|
||||
// // Check if location services are enabled
|
||||
// serviceEnabled = await location.serviceEnabled();
|
||||
// if (!serviceEnabled) {
|
||||
// serviceEnabled = await location.requestService();
|
||||
// if (!serviceEnabled) {
|
||||
// // Location services are still not enabled, handle the error
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check if the app has permission to access location
|
||||
permissionGranted = await location.hasPermission();
|
||||
if (permissionGranted == PermissionStatus.denied) {
|
||||
permissionGranted = await location.requestPermission();
|
||||
if (permissionGranted != PermissionStatus.granted) {
|
||||
// Location permission is still not granted, handle the error
|
||||
return;
|
||||
}
|
||||
}
|
||||
// // Check if the app has permission to access location
|
||||
// permissionGranted = await location.hasPermission();
|
||||
// if (permissionGranted == PermissionStatus.denied) {
|
||||
// permissionGranted = await location.requestPermission();
|
||||
// if (permissionGranted != PermissionStatus.granted) {
|
||||
// // Location permission is still not granted, handle the error
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Configure location accuracy
|
||||
// LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
// // Configure location accuracy
|
||||
// // LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
myLocation =
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
speed = _locationData.speed!;
|
||||
heading = _locationData.heading!;
|
||||
// Calculate the distance between the current location and the previous location
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// if (previousTime > 0) {
|
||||
// double distance = calculateDistanceInKmPerHour(
|
||||
// previousTime, _locationData.time, speed);
|
||||
// totalDistance += distance;
|
||||
// }
|
||||
// // Get the current location
|
||||
// LocationData _locationData = await location.getLocation();
|
||||
// myLocation =
|
||||
// (_locationData.latitude != null && _locationData.longitude != null
|
||||
// ? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
// : null)!;
|
||||
// speed = _locationData.speed!;
|
||||
// heading = _locationData.heading!;
|
||||
// // Calculate the distance between the current location and the previous location
|
||||
// // if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// // if (previousTime > 0) {
|
||||
// // double distance = calculateDistanceInKmPerHour(
|
||||
// // previousTime, _locationData.time, speed);
|
||||
// // totalDistance += distance;
|
||||
// // }
|
||||
|
||||
// previousTime = _locationData.time!;
|
||||
// }
|
||||
// Print location details
|
||||
// isLoading = false;
|
||||
update();
|
||||
}
|
||||
// // previousTime = _locationData.time!;
|
||||
// // }
|
||||
// // Print location details
|
||||
// // isLoading = false;
|
||||
// update();
|
||||
// }
|
||||
|
||||
double calculateDistanceInKmPerHour(
|
||||
double? startTime, double? endTime, double speedInMetersPerSecond) {
|
||||
// Calculate the time difference in hours
|
||||
double timeDifferenceInHours = (endTime! - startTime!) / 1000 / 3600;
|
||||
// double calculateDistanceInKmPerHour(
|
||||
// double? startTime, double? endTime, double speedInMetersPerSecond) {
|
||||
// // Calculate the time difference in hours
|
||||
// double timeDifferenceInHours = (endTime! - startTime!) / 1000 / 3600;
|
||||
|
||||
// Convert speed to kilometers per hour
|
||||
double speedInKmPerHour = speedInMetersPerSecond * 3.6;
|
||||
// // Convert speed to kilometers per hour
|
||||
// double speedInKmPerHour = speedInMetersPerSecond * 3.6;
|
||||
|
||||
// Calculate the distance in kilometers
|
||||
double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours;
|
||||
// // Calculate the distance in kilometers
|
||||
// double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours;
|
||||
|
||||
return distanceInKilometers;
|
||||
}
|
||||
}
|
||||
// return distanceInKilometers;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
@@ -7,10 +8,9 @@ import '../../../constant/colors.dart';
|
||||
import '../functions/launch.dart';
|
||||
|
||||
class ContactUsController extends GetxController {
|
||||
final String phone1 = '+201018805430';
|
||||
final String phone2 = '+201080182934';
|
||||
final TimeOfDay workStartTime = const TimeOfDay(hour: 12, minute: 0);
|
||||
final TimeOfDay workEndTime = const TimeOfDay(hour: 19, minute: 0);
|
||||
/// WORKING HOURS (10:00 → 16:00)
|
||||
final TimeOfDay workStartTime = const TimeOfDay(hour: 10, minute: 0);
|
||||
final TimeOfDay workEndTime = const TimeOfDay(hour: 16, minute: 0);
|
||||
|
||||
bool _isWithinWorkTime(TimeOfDay now) {
|
||||
return (now.hour > workStartTime.hour ||
|
||||
@@ -20,8 +20,23 @@ class ContactUsController extends GetxController {
|
||||
(now.hour == workEndTime.hour && now.minute <= workEndTime.minute));
|
||||
}
|
||||
|
||||
/// PHONE LIST (USED FOR CALLS + WHATSAPP)
|
||||
final List<String> phoneNumbers = [
|
||||
'+963952475734',
|
||||
'+963952475740',
|
||||
'+963952475742'
|
||||
];
|
||||
|
||||
/// RANDOM PHONE SELECTOR
|
||||
String getRandomPhone() {
|
||||
final random = Random();
|
||||
return phoneNumbers[random.nextInt(phoneNumbers.length)];
|
||||
}
|
||||
|
||||
/// SHOW DIALOG
|
||||
void showContactDialog(BuildContext context) {
|
||||
TimeOfDay now = TimeOfDay.now();
|
||||
bool withinHours = _isWithinWorkTime(now);
|
||||
|
||||
showCupertinoModalPopup(
|
||||
context: context,
|
||||
@@ -29,25 +44,34 @@ class ContactUsController extends GetxController {
|
||||
title: Text('Contact Us'.tr),
|
||||
message: Text('Choose a contact option'.tr),
|
||||
actions: <Widget>[
|
||||
if (_isWithinWorkTime(now))
|
||||
/// 📞 CALL (RANDOM) — ONLY DURING WORK HOURS
|
||||
if (withinHours)
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(phone1),
|
||||
onPressed: () => makePhoneCall(
|
||||
phone1,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.phone),
|
||||
Text('Call Support'.tr),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
final phone = getRandomPhone();
|
||||
makePhoneCall(phone);
|
||||
},
|
||||
),
|
||||
if (_isWithinWorkTime(now))
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(phone2),
|
||||
onPressed: () => makePhoneCall(phone2),
|
||||
),
|
||||
if (!_isWithinWorkTime(now))
|
||||
|
||||
/// ⛔ OUTSIDE WORK HOURS — SHOW INFO
|
||||
if (!withinHours)
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.'
|
||||
.tr),
|
||||
'Work time is from 10:00 AM to 16:00 PM.\nYou can send a WhatsApp message or email.'
|
||||
.tr,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
|
||||
/// 💬 WHATSAPP (RANDOM)
|
||||
CupertinoActionSheetAction(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@@ -59,15 +83,21 @@ class ContactUsController extends GetxController {
|
||||
Text('Send WhatsApp Message'.tr),
|
||||
],
|
||||
),
|
||||
onPressed: () =>
|
||||
launchCommunication('whatsapp', phone1, 'Hello'.tr),
|
||||
onPressed: () {
|
||||
final phone = getRandomPhone();
|
||||
launchCommunication('whatsapp', phone, 'Hello'.tr);
|
||||
},
|
||||
),
|
||||
|
||||
/// 📧 EMAIL
|
||||
CupertinoActionSheetAction(
|
||||
child: Text('Send Email'.tr),
|
||||
onPressed: () =>
|
||||
launchCommunication('email', 'support@sefer.live', 'Hello'.tr),
|
||||
onPressed: () => launchCommunication(
|
||||
'email', 'support@intaleqapp.com', 'Hello'.tr),
|
||||
),
|
||||
],
|
||||
|
||||
/// ❌ CANCEL BUTTON
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: Text('Cancel'.tr),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -112,7 +112,7 @@ class WayPointController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
Get.put(LocationController());
|
||||
// Get.put(LocationController());
|
||||
addWayPoints();
|
||||
myLocation = Get.find<MapPassengerController>().passengerLocation;
|
||||
super.onInit();
|
||||
|
||||
@@ -162,7 +162,7 @@ ${'Download the Intaleq app now and enjoy your ride!'.tr}
|
||||
|
||||
// 2. If it already starts with the country code, we assume it's correct.
|
||||
if (digitsOnly.startsWith('963')) {
|
||||
return '+$digitsOnly';
|
||||
return '$digitsOnly';
|
||||
}
|
||||
|
||||
// 3. If it starts with '09' (common local format), remove the leading '0'.
|
||||
@@ -171,7 +171,7 @@ ${'Download the Intaleq app now and enjoy your ride!'.tr}
|
||||
}
|
||||
|
||||
// 4. Prepend the Syrian country code.
|
||||
return '+963$digitsOnly';
|
||||
return '963$digitsOnly';
|
||||
}
|
||||
|
||||
/// **IMPROVEMENT**: This method now uses the new phone formatting logic and
|
||||
|
||||
@@ -6603,7 +6603,7 @@ const List<Country> countries = [
|
||||
code: "SY",
|
||||
dialCode: "963",
|
||||
minLength: 9,
|
||||
maxLength: 9,
|
||||
maxLength: 10,
|
||||
),
|
||||
Country(
|
||||
name: "Taiwan",
|
||||
|
||||
@@ -201,7 +201,16 @@ class MyTranslation extends Translations {
|
||||
"Top up Wallet": "تعبئة المحفظة",
|
||||
"Add funds using our secure methods":
|
||||
"أضف رصيداً باستخدام طرقنا الآمنة",
|
||||
"Speed": "سرعة",
|
||||
'Driver is waiting': 'الكابتن في انتظارك',
|
||||
'Type your message...': 'اكتب رسالتك...',
|
||||
'Driver Accepted Request': 'الكابتن قبل الطلب',
|
||||
'Message': 'رسالة',
|
||||
'Call': 'اتصال',
|
||||
"You can call or record audio during this trip.":
|
||||
"يمكنك الاتصال أو تسجيل صوت أثناء هذه الرحلة.",
|
||||
"Warning: Speeding detected!": "تحذير: تم الكشف عن تجاوز السرعة!",
|
||||
'Fixed Price': 'سعر ثابت',
|
||||
'Report': 'إبلاغ',
|
||||
"Comfort": "مريحة",
|
||||
"Intaleq Balance": "رصيد انطلق",
|
||||
'Search for a starting point': 'ابحث عن نقطة انطلاق',
|
||||
@@ -316,6 +325,8 @@ class MyTranslation extends Translations {
|
||||
"Van for familly": "سيارة فان للعائلة",
|
||||
"Are you sure to delete this location?":
|
||||
"هل أنت متأكد من حذف هذا الموقع؟",
|
||||
'Change Work location?': 'تغيير موقع العمل؟',
|
||||
'Change Home location?': 'تغيير موقع البيت؟',
|
||||
"Submit a Complaint": "تقديم شكوى",
|
||||
"Submit Complaint": "إرسال الشكوى",
|
||||
"No trip history found": "لا يوجد سجل للرحلات",
|
||||
@@ -395,6 +406,41 @@ class MyTranslation extends Translations {
|
||||
"OK": "موافق",
|
||||
"Confirm Pick-up Location": "تأكيد موقع الانطلاق",
|
||||
"Set Location on Map": "حدد الموقع على الخريطة",
|
||||
'Leave a detailed comment (Optional)':
|
||||
'اترك تعليقاً مفصلاً (اختياري)',
|
||||
'Share your experience to help us improve...':
|
||||
'شارك تجربتك لمساعدتنا على التحسن...',
|
||||
'Your valuable feedback helps us improve our service quality.':
|
||||
'ملاحظاتك القيمة تساعدنا في تحسين جودة خدماتنا.',
|
||||
'witout zero': 'بدون صفر',
|
||||
'Top up Balance': 'اشحن الرصيد',
|
||||
'An error occurred': 'حدث خطأ',
|
||||
'Send WhatsApp Message': 'إرسال رسالة واتساب',
|
||||
'How was your trip with': 'كيف كانت رحلتك مع',
|
||||
'Drawing route on map...': 'جارٍ رسم المسار على الخريطة...',
|
||||
'Please wait while we prepare your trip.':
|
||||
'يرجى الانتظار بينما نحضر رحلتك.',
|
||||
'Submit Rating': 'إرسال التقييم',
|
||||
'Call Support': 'الاتصال بالدعم',
|
||||
"You can contact us during working hours from 10:00 - 16:00.":
|
||||
"يمكنك التواصل معنا خلال ساعات العمل من 10:00 إلى 16:00.",
|
||||
"Intaleq is the safest and most reliable ride-sharing app designed especially for passengers in Syria. We provide a comfortable, respectful, and affordable riding experience with features that prioritize your safety and convenience. Our trusted captains are verified, insured, and supported by regular car maintenance carried out by top engineers. We also offer on-road support services to make sure every trip is smooth and worry-free. With Intaleq, you enjoy quality, safety, and peace of mind—every time you ride.":
|
||||
"""إنطلِق هو التطبيق الأكثر أماناً وموثوقية لمشاركة الركوب والمصمم خصيصاً للركّاب في سوريا. نوفر لك تجربة تنقّل مريحة، محترمة، وبأسعار مناسبة، مع ميزات تضع سلامتك وراحتك في المقام الأول.
|
||||
|
||||
جميع الكباتن لدينا موثوقون، مُؤمَّنون، وتخضع سياراتهم لصيانة دورية يقوم بها مهندسون مختصون لضمان أفضل جودة. كما نقدّم خدمات دعم على الطريق لضمان أن تكون كل رحلة سلسة وخالية من القلق.
|
||||
|
||||
مع إنطلِق، ستستمتع دائماً بالأمان، والجودة، وراحة البال في كل رحلة تقوم بها.""",
|
||||
'Work time is from 10:00 AM to 16:00 PM.\nYou can send a WhatsApp message or email.':
|
||||
'وقت العمل من 10:00 صباحاً إلى 16:00 مساءً.\nيمكنك إرسال رسالة واتساب أو بريد إلكتروني.',
|
||||
'Sorry': 'عذراً',
|
||||
"Customer MSISDN doesn’t have customer wallet":
|
||||
"رقم هاتف العميل لا يحتوي على محفظة عميل",
|
||||
'Please enter the number without the leading 0':
|
||||
'يرجى إدخال الرقم بدون الصفر الأولي',
|
||||
'Please enter your phone number': 'يرجى إدخال رقم هاتفك',
|
||||
'Phone number seems too short': 'يبدو أن رقم الهاتف قصير جدًا',
|
||||
'No cars are available at the moment. Please try again later.':
|
||||
'لا توجد سيارات متاحة حالياً. الرجاء المحاولة مرة أخرى لاحقاً.',
|
||||
"Nearest Car: ~": "أقرب سيارة: ~",
|
||||
"Nearest Car": "أقرب سيارة",
|
||||
"No cars nearby": "لا توجد سيارات قريبة",
|
||||
|
||||
@@ -56,6 +56,7 @@ class PassengerNotificationController extends GetxController {
|
||||
// 'iphone_ringtone',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
category: title,
|
||||
target: 'token'.toString(),
|
||||
title: title,
|
||||
body: body.tr,
|
||||
|
||||
@@ -31,9 +31,9 @@ class PassengerWalletHistoryController extends GetxController {
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
MyDialog().getDialog('An error occurred'.tr, e.toString(), () {
|
||||
Get.back();
|
||||
});
|
||||
// MyDialog().getDialog('An error occurred'.tr, '', () {
|
||||
// Get.back();
|
||||
// });
|
||||
} finally {
|
||||
isLoading = false;
|
||||
update();
|
||||
|
||||
@@ -144,8 +144,9 @@ class PaymentController extends GetxController {
|
||||
// 'cancel',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
category: 'Cancel',
|
||||
target: Get.find<MapPassengerController>().driverToken.toString(),
|
||||
title: 'Cancel',
|
||||
title: 'Cancel'.tr,
|
||||
body:
|
||||
'Trip Cancelled. The cost of the trip will be added to your wallet.'
|
||||
.tr,
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:Intaleq/main.dart';
|
||||
import 'package:Intaleq/views/home/map_page_passenger.dart';
|
||||
import 'package:Intaleq/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../firebase/notification_service.dart';
|
||||
import '../payment/payment_controller.dart';
|
||||
|
||||
@@ -18,7 +17,7 @@ import '../payment/payment_controller.dart';
|
||||
class RateController extends GetxController {
|
||||
double selectedRateItemId = -1;
|
||||
TextEditingController comment = TextEditingController();
|
||||
String? rideId, passengerId, driverId, price;
|
||||
String? rideId, passengerId, driverId, driverName, price;
|
||||
late GlobalKey<FormState> formKey;
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -26,6 +25,7 @@ class RateController extends GetxController {
|
||||
passengerId = Get.arguments['passengerId'];
|
||||
rideId = Get.arguments['rideId'];
|
||||
driverId = Get.arguments['driverId'];
|
||||
driverName = Get.arguments['driverName'];
|
||||
price = Get.arguments['price'];
|
||||
box.write(BoxName.tipPercentage, '0');
|
||||
super.onInit();
|
||||
@@ -61,7 +61,7 @@ class RateController extends GetxController {
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? tip.toStringAsFixed(0)
|
||||
: (tip * 100).toString());
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
await CRUD().postWallet(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': Get.find<MapPassengerController>().driverId.toString(),
|
||||
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
|
||||
'amount': box.read(BoxName.countryCode) == 'Egypt'
|
||||
@@ -71,16 +71,10 @@ class RateController extends GetxController {
|
||||
'token': token1,
|
||||
});
|
||||
if (res != 'failure') {
|
||||
// Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
// 'You Have Tips'.tr,
|
||||
// '${'${tip.toString()}\$${' tips\nTotal is'.tr}'} ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
// Get.find<MapPassengerController>().driverToken.toString(),
|
||||
// [],
|
||||
// 'ding',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
category: 'You Have Tips',
|
||||
target: Get.find<MapPassengerController>().driverToken.toString(),
|
||||
title: 'You Have Tips',
|
||||
title: 'You Have Tips'.tr,
|
||||
body:
|
||||
'${'${tip.toString()}\$${' tips\nTotal is'.tr}'} ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
isTopic: false, // Important: this is a token
|
||||
@@ -91,26 +85,15 @@ class RateController extends GetxController {
|
||||
}
|
||||
}
|
||||
await CRUD().post(
|
||||
link: "${AppLink.IntaleqSyriaServer}/ride/rate/addRateToDriver.php",
|
||||
payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'driver_id': driverId.toString(),
|
||||
'ride_id': rideId.toString(),
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
|
||||
if (AppLink.endPoint != AppLink.IntaleqSyriaServer) {
|
||||
CRUD().post(
|
||||
link: "${AppLink.endPoint}/ride/rate/addRateToDriver.php",
|
||||
payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'driver_id': driverId.toString(),
|
||||
'ride_id': rideId.toString(),
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
}
|
||||
link: "${AppLink.server}/ride/rate/addRateToDriver.php",
|
||||
payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'driver_id': driverId.toString(),
|
||||
'ride_id': rideId.toString(),
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
},
|
||||
);
|
||||
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
|
||||
Reference in New Issue
Block a user