6/9/1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:SEFER/views/home/HomePage/trip_monitor/trip_monitor.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -138,6 +139,15 @@ class FirebaseMessagesController extends GetxController {
|
||||
NotificationController()
|
||||
.showNotification('Promo', 'Show latest promo'.tr, 'promo');
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title! == 'Trip Monitoring') {
|
||||
NotificationController().showNotification(
|
||||
'Trip Monitoring'.tr, 'Show latest promo'.tr, 'iphone_ringtone');
|
||||
var myListString = message.data['passengerList'];
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.to(const TripMonitor(), arguments: {
|
||||
'rideId': myList[0].toString(),
|
||||
'driverId': myList[1].toString(),
|
||||
});
|
||||
} else if (message.notification!.title! == 'token change') {
|
||||
NotificationController()
|
||||
.showNotification('token change', 'token change', 'cancel');
|
||||
@@ -186,16 +196,23 @@ class FirebaseMessagesController extends GetxController {
|
||||
box.write(BoxName.passengerWalletTotal, 0);
|
||||
}
|
||||
Get.find<MapPassengerController>().tripFinishedFromDriver();
|
||||
// if (Get.find<PaymentController>().isCashChecked == false &&
|
||||
// Get.find<PaymentController>().isWalletChecked == true) {
|
||||
// // driverFinishTripDialoge(driverList);
|
||||
// } else {
|
||||
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
'price': driverList[3].toString()
|
||||
});
|
||||
// }
|
||||
} else if (message.notification!.title! == "Finish Monitor") {
|
||||
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! == 'Call Income') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
@@ -265,6 +282,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
.tr,
|
||||
'cancel');
|
||||
}
|
||||
box.write(BoxName.parentTripSelected, false);
|
||||
box.remove(BoxName.tokenParent);
|
||||
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
|
||||
@@ -41,7 +41,39 @@ class CRUD {
|
||||
|
||||
return jsonData['status'];
|
||||
}
|
||||
|
||||
// }
|
||||
Future<dynamic> getTokenParent({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
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()))}',
|
||||
},
|
||||
);
|
||||
print("-----request----" + response.request.toString());
|
||||
// print("-----headers-----" + response.headers.toString());
|
||||
print("-----payload-----" + payload.toString());
|
||||
if (response.statusCode == 200) {
|
||||
print(response.body);
|
||||
var jsonData = jsonDecode(response.body);
|
||||
// if (jsonData['status'] == 'success') {
|
||||
// print(jsonData);
|
||||
|
||||
return jsonData;
|
||||
// }
|
||||
|
||||
// return jsonData['status'];
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getAgoraToken({
|
||||
required String channelName,
|
||||
|
||||
@@ -18,7 +18,7 @@ class SmsEgyptController extends GetxController {
|
||||
"password": AK.smsPasswordEgypt,
|
||||
"message": "${AppInformation.appName} app code is $otp\ncopy it to app",
|
||||
"language": box.read(BoxName.lang) == 'en' ? "e" : 'r',
|
||||
"sender": "SEFER EGY", // todo add sefer sender name
|
||||
"sender": "Sefer Egy",
|
||||
"receiver": "2$phone"
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:SEFER/controller/functions/tts.dart';
|
||||
import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
import 'package:SEFER/views/widgets/my_textField.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -44,7 +45,7 @@ class MapPassengerController extends GetxController {
|
||||
TextEditingController wayPoint4Controller = TextEditingController();
|
||||
TextEditingController sosPhonePassengerProfile = TextEditingController();
|
||||
final sosFormKey = GlobalKey<FormState>();
|
||||
final increasFeeFormKey = GlobalKey<FormState>();
|
||||
final increaseFeeFormKey = GlobalKey<FormState>();
|
||||
List data = [];
|
||||
List<LatLng> bounds = [];
|
||||
List placesStart = [];
|
||||
@@ -338,7 +339,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
increaseFeeByPassengerAndReOrder() async {
|
||||
if (increasFeeFormKey.currentState!.validate()) {
|
||||
if (increaseFeeFormKey.currentState!.validate()) {
|
||||
if (double.parse(increasFeeFromPassenger.text) > totalPassenger) {
|
||||
totalPassenger = double.parse(increasFeeFromPassenger.text);
|
||||
Get.back();
|
||||
@@ -675,6 +676,16 @@ class MapPassengerController extends GetxController {
|
||||
box.write(BoxName.arrivalTime, '');
|
||||
remainingTimeTimerRideBegin = 0;
|
||||
box.write(BoxName.passengerWalletTotal, '0');
|
||||
if (box.read(BoxName.parentTripSelected) == true) {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
"Finish Monitor",
|
||||
"Finish Monitor".tr,
|
||||
box.read(BoxName.tokenParent),
|
||||
[],
|
||||
);
|
||||
box.write(BoxName.parentTripSelected, false);
|
||||
box.remove(BoxName.tokenParent);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -1088,32 +1099,35 @@ class MapPassengerController extends GetxController {
|
||||
Timer(const Duration(milliseconds: 200), () async {
|
||||
if (shouldFetch) {
|
||||
// //print('shouldFetch is =$shouldFetch');
|
||||
var res = await getRideStatus(rideId);
|
||||
// print(res);
|
||||
// var decod = jsonDecode(res);
|
||||
print(
|
||||
' 000000000000000000delayAndFetchRideStatus0000000000000000000000000000000');
|
||||
print(res);
|
||||
if (res.toString() == 'Apply') {
|
||||
// getUpdatedRideForDriverApply(rideId);
|
||||
shouldFetch = false; // Stop further fetches
|
||||
statusRide = 'Apply';
|
||||
rideConfirm = false;
|
||||
isSearchingWindow = false;
|
||||
update();
|
||||
startTimerFromDriverToPassengerAfterApplied();
|
||||
// startTimer();
|
||||
} else if (res.toString() == 'Refused') {
|
||||
statusRide = 'Refused';
|
||||
// isDriversTokensSend = false;
|
||||
if (isDriversTokensSend == false) {
|
||||
confirmRideForAllDriverAvailable();
|
||||
isDriversTokensSend = true;
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied > 0) {
|
||||
var res = await getRideStatus(rideId);
|
||||
|
||||
// print(res);
|
||||
// var decod = jsonDecode(res);
|
||||
print(
|
||||
' 000000000000000000delayAndFetchRideStatus0000000000000000000000000000000');
|
||||
print(res);
|
||||
if (res.toString() == 'Apply') {
|
||||
// getUpdatedRideForDriverApply(rideId);
|
||||
shouldFetch = false; // Stop further fetches
|
||||
statusRide = 'Apply';
|
||||
rideConfirm = false;
|
||||
isSearchingWindow = false;
|
||||
update();
|
||||
startTimerFromDriverToPassengerAfterApplied();
|
||||
// startTimer();
|
||||
} else if (res.toString() == 'Refused') {
|
||||
statusRide = 'Refused';
|
||||
// isDriversTokensSend = false;
|
||||
if (isDriversTokensSend == false) {
|
||||
confirmRideForAllDriverAvailable();
|
||||
isDriversTokensSend = true;
|
||||
}
|
||||
} else if (isDriversTokensSend == false) {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
update();
|
||||
}
|
||||
} else if (isDriversTokensSend == false) {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
update();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1210,7 +1224,7 @@ class MapPassengerController extends GetxController {
|
||||
driverRate = response['data']['ratingDriver'];
|
||||
}
|
||||
driversToken.remove(driverToken);
|
||||
for (var i = 0; i < driversToken.length; i++) {
|
||||
for (var i = 1; i < driversToken.length; i++) {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'Order Applied',
|
||||
'$driverName Apply order\nTake attention in other order'.tr,
|
||||
@@ -1310,6 +1324,107 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future getTokenForParent() async {
|
||||
if (box.read(BoxName.sosPhonePassenger) == null) {
|
||||
Get.defaultDialog(
|
||||
title: 'Add SOS Phone'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Form(
|
||||
key: sosFormKey,
|
||||
child: MyTextForm(
|
||||
controller: sosPhonePassengerProfile,
|
||||
label: 'insert sos phone'.tr,
|
||||
hint: 'insert sos phone'.tr,
|
||||
type: TextInputType.phone,
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Add SOS Phone'.tr,
|
||||
onPressed: () async {
|
||||
if (sosFormKey.currentState!.validate()) {
|
||||
Get.back();
|
||||
await CRUD().post(
|
||||
link: AppLink.updateprofile,
|
||||
payload: {
|
||||
'id': box.read(BoxName.passengerID),
|
||||
'sosPhone': sosPhonePassengerProfile.text,
|
||||
},
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
var res = await CRUD().getTokenParent(
|
||||
link: AppLink.getTokenParent,
|
||||
payload: {'phone': '+2' + box.read(BoxName.sosPhonePassenger)});
|
||||
|
||||
// Check if `res` is already a map
|
||||
if (res is Map<String, dynamic>) {
|
||||
var res1 = res;
|
||||
handleResponse(res1);
|
||||
} else {
|
||||
// If it's a string, decode it
|
||||
var res1 = jsonDecode(res);
|
||||
handleResponse(res1);
|
||||
}
|
||||
}
|
||||
|
||||
void handleResponse(Map<String, dynamic> res1) {
|
||||
if (res1['message'] == "No passenger found for the given phone number") {
|
||||
print(res1);
|
||||
Get.defaultDialog(
|
||||
title: "No user found for the given phone number".tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
"No passenger found for the given phone number".tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
"Send Sefer app to him".tr,
|
||||
style: AppStyle.title.copyWith(color: AppColor.greenColor),
|
||||
)
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
var phone = box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '+2${box.read(BoxName.sosPhonePassenger)}'
|
||||
: '+962${box.read(BoxName.sosPhonePassenger)}';
|
||||
var message = '''Dear ,
|
||||
|
||||
🚀 I have just started an exciting trip and I would like to share the details of my journey and my current location with you in real-time! Please download the SEFER app. It will allow you to view my trip details and my latest location.
|
||||
|
||||
👉 Download link:
|
||||
Android [https://play.google.com/store/apps/details?id=com.mobileapp.store.ride]
|
||||
iOS [https://getapp.cc/app/6458734951]
|
||||
|
||||
I look forward to keeping you close during my adventure!
|
||||
|
||||
SEFER ,'''
|
||||
.tr;
|
||||
launchCommunication('whatsapp', phone, message);
|
||||
}),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}));
|
||||
} else if (res1['status'] == 'success') {
|
||||
var tokenParent = res1['data'][0]['token'];
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
"Trip Monitoring",
|
||||
"Trip Monitoring".tr,
|
||||
tokenParent,
|
||||
[rideId, driverId]);
|
||||
box.write(BoxName.parentTripSelected, true);
|
||||
box.write(BoxName.tokenParent, tokenParent);
|
||||
}
|
||||
}
|
||||
|
||||
LatLng driverLocationToPassenger = const LatLng(32, 35);
|
||||
Future getDriverCarsLocationToPassengerAfterApplied() async {
|
||||
driverCarsLocationToPassengerAfterApplied = [];
|
||||
|
||||
@@ -28,7 +28,7 @@ class ComplaintController extends GetxController {
|
||||
Get.defaultDialog(
|
||||
title: 'Success'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: 'Feedback data saved successfully'.tr,
|
||||
middleText: 'Complaint data saved successfully'.tr,
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
kolor: AppColor.greenColor,
|
||||
|
||||
@@ -19,16 +19,16 @@ class PromosController extends GetxController {
|
||||
Future getPromoByToday() async {
|
||||
var res = await CRUD().get(link: AppLink.getPromoBytody, payload: {});
|
||||
if (res.toString() == 'failure') {
|
||||
Get.defaultDialog(
|
||||
title: 'No Promo for today .'.tr,
|
||||
middleText: '',
|
||||
titleStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
// Get.defaultDialog(
|
||||
// title: 'No Promo for today .'.tr,
|
||||
// middleText: '',
|
||||
// titleStyle: AppStyle.title,
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'Back'.tr,
|
||||
// onPressed: () {
|
||||
// Get.back();
|
||||
// Get.back();
|
||||
// }));
|
||||
isLoading = false;
|
||||
update();
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
class TripMonitorController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map tripData = {};
|
||||
late String rideId;
|
||||
late String driverId;
|
||||
GoogleMapController? mapController;
|
||||
List myListString = [];
|
||||
late Timer timer;
|
||||
late LatLng parentLocation;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
double rotation = 0;
|
||||
double speed = 0;
|
||||
|
||||
getLocationParent() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getLocationParents, payload: {"driver_id": driverId});
|
||||
if (res != 'failure') {
|
||||
tripData = jsonDecode(res);
|
||||
parentLocation = LatLng(
|
||||
double.parse(tripData['message'][0]['latitude'].toString()),
|
||||
double.parse(tripData['message'][0]['longitude'].toString()));
|
||||
rotation = double.parse(tripData['message'][0]['heading'].toString());
|
||||
speed = double.parse(tripData['message'][0]['speed'].toString());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void onMapCreated(GoogleMapController controller) async {
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(parentLocation),
|
||||
);
|
||||
update();
|
||||
// Set up a timer or interval to trigger the marker update every 3 seconds.
|
||||
timer = Timer.periodic(const Duration(seconds: 10), (_) async {
|
||||
await getLocationParent();
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(parentLocation));
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
init() async {
|
||||
final arguments = Get.arguments;
|
||||
driverId = arguments['driverId'];
|
||||
rideId = arguments['rideId'];
|
||||
await getLocationParent();
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
addCustomCarIcon();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
timer.cancel();
|
||||
mapController?.dispose();
|
||||
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,48 @@ class MyTranslation extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
"ar": {
|
||||
"Enter your complaint here": "أدخل شكواك هنا",
|
||||
"Complaint": "شكوى",
|
||||
"Please enter your complaint.": "الرجاء إدخال شكواك.",
|
||||
"Submit": "إرسال",
|
||||
"Complaint data saved successfully": "تم حفظ بيانات الشكوى بنجاح",
|
||||
"Trip Monitor": "مراقبة الرحلة",
|
||||
"Insert SOS Phone": "أدخل رقم الهاتف للطوارئ",
|
||||
"Add SOS Phone": "أضف رقم الهاتف للطوارئ",
|
||||
"Trip Monitoring": "مراقبة الرحلة",
|
||||
'''Dear ,
|
||||
|
||||
🚀 I have just started an exciting trip and I would like to share the details of my journey and my current location with you in real-time! Please download the SEFER app. It will allow you to view my trip details and my latest location.
|
||||
|
||||
👉 Download link:
|
||||
Android [https://play.google.com/store/apps/details?id=com.mobileapp.store.ride]
|
||||
iOS [https://getapp.cc/app/6458734951]
|
||||
|
||||
I look forward to keeping you close during my adventure!
|
||||
|
||||
SEFER ,''': '''عزيزي ،
|
||||
|
||||
|
||||
🚀 لقد بدأت للتو رحلة مثيرة وأود مشاركة تفاصيل رحلتي وموقعي الحالي معك في الوقت الفعلي! يرجى تنزيل تطبيق سفر. سيمكنك ذلك من عرض تفاصيل رحلتي وموقعي الأخير.
|
||||
|
||||
|
||||
👉 رابط التحميل:
|
||||
Android [https://play.google.com/store/apps/details?id=com.mobileapp.store.ride]
|
||||
iOS [https://getapp.cc/app/6458734951]
|
||||
|
||||
|
||||
أتطلع إلى إبقائك قريبًا خلال مغامرتي!
|
||||
|
||||
|
||||
سفر ،''',
|
||||
"Send Sefer app to him": "أرسل له تطبيق سفر",
|
||||
"No passenger found for the given phone number":
|
||||
"لم يتم العثور على راكب لرقم الهاتف المعطى",
|
||||
"No user found for the given phone number":
|
||||
"لم يتم العثور على مستخدم لرقم الهاتف المعطى",
|
||||
"This price is": "هذا السعر هو",
|
||||
"Work": "عمل",
|
||||
"Add Home": "أضف منزل",
|
||||
"Notifications": "إشعارات",
|
||||
'💳 Pay with Credit Card': "ادفع باستخدام بطاقة الائتمان💳",
|
||||
"⚠️ You need to choose an amount!": "⚠️ يجب عليك اختيار مبلغ!",
|
||||
|
||||
@@ -61,14 +61,27 @@ class PaymentController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
String paymentToken = '';
|
||||
Future<String> generateToken(String amount) async {
|
||||
var res = await CRUD().post(link: AppLink.addPaymentToken, payload: {
|
||||
'passengerId': box.read(BoxName.passengerID).toString(),
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
print('paymentToken ${d['message']}');
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
addPassengerWallet() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
paymentToken = await generateToken(selectedAmount.toString());
|
||||
// double sallaryAccountNowBeforeAdding =
|
||||
// double.parse(box.read(BoxName.passengerWalletTotal).toString());
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': selectedAmount.toString()
|
||||
'balance': selectedAmount.toString(),
|
||||
'token': paymentToken,
|
||||
}).then((value) {
|
||||
getPassengerWallet();
|
||||
// sallaryAccountNowBeforeAdding = sallaryAccountNowBeforeAdding +
|
||||
|
||||
@@ -68,8 +68,8 @@ class ProfileController extends GetxController {
|
||||
),
|
||||
MyElevatedButton(
|
||||
title: 'Update'.tr,
|
||||
onPressed: () {
|
||||
updateColumn({
|
||||
onPressed: () async {
|
||||
await updateColumn({
|
||||
'id': box.read(BoxName.passengerID),
|
||||
columnName: txtController.text,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user