This commit is contained in:
Hamza Aleghwairyeen
2024-04-06 12:50:44 +03:00
parent 03c2289653
commit c7595de6c3
11 changed files with 149 additions and 44 deletions

View File

@@ -63,5 +63,6 @@ class BoxName {
static const String color = "color"; static const String color = "color";
static const String owner = "owner"; static const String owner = "owner";
static const String registrationDate = "registrationDate"; static const String registrationDate = "registrationDate";
static const List recentLocations = []; static const String recentLocations = 'recentLocations';
static const String tripData = 'tripData';
} }

View File

@@ -203,7 +203,7 @@ class FirebaseMessagesController extends GetxController {
var myListString = message.data['passengerList']; var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>; var driverList = jsonDecode(myListString) as List<dynamic>;
NotificationController().showNotification( NotificationController().showNotification(
'Driver Finish Trip'.tr, 'Call Income'.tr,
message.notification!.body!, message.notification!.body!,
'order', 'order',
); );

View File

@@ -104,8 +104,7 @@ class CRUD {
); );
var headers = { var headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': 'Authorization': 'Bearer ${Env.chatGPTkeySeferNew}'
'Bearer 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'
}; };
var data = json.encode({ var data = json.encode({
"model": "gpt-3.5-turbo", "model": "gpt-3.5-turbo",
@@ -252,9 +251,9 @@ class CRUD {
} }
Future<void> sendVerificationRequest(String phoneNumber) async { Future<void> sendVerificationRequest(String phoneNumber) async {
final accountSid = "ACb4ad857efe0903bfd6238a763a2ce4d1"; final accountSid = AK.accountSIDTwillo;
final authToken = "14f39ef4628bb8a4f18469f462f8af75"; final authToken = AK.authTokenTwillo;
final verifySid = "VAf6e6022a7e95186aa5b1da25411859bd"; final verifySid = AK.twilloRecoveryCode;
final Uri verificationUri = Uri.parse( final Uri verificationUri = Uri.parse(
'https://verify.twilio.com/v2/Services/$verifySid/Verifications'); 'https://verify.twilio.com/v2/Services/$verifySid/Verifications');

View File

@@ -443,7 +443,9 @@ class MapDriverController extends GetxController {
isRideFinished = true; isRideFinished = true;
isRideStarted = false; isRideStarted = false;
isPriceWindow = false; isPriceWindow = false;
totalCost = price.toStringAsFixed(2); totalCost = carType == 'Comfort' || carType == 'Free Ride'
? price.toStringAsFixed(1)
: totalPassenger;
paymentAmount = totalCost; paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off'); box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger(); // changeRideToBeginToPassenger();
@@ -470,7 +472,9 @@ class MapDriverController extends GetxController {
Future.delayed(const Duration(milliseconds: 300)); Future.delayed(const Duration(milliseconds: 300));
FirebaseMessagesController().sendNotificationToPassengerToken( FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Finish Trip', 'Driver Finish Trip',
'you will pay to Driver'.tr + ' $price \$'.tr, 'you will pay to Driver'.tr +
' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$'
.tr,
tokenPassenger, tokenPassenger,
[ [
box.read(BoxName.driverID), box.read(BoxName.driverID),

View File

@@ -587,7 +587,61 @@ class MapPassengerController extends GetxController {
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
progressTimerRideBegin = i / durationToRide; progressTimerRideBegin = i / durationToRide;
remainingTimeTimerRideBegin = durationToRide - i; remainingTimeTimerRideBegin = durationToRide - i;
bool sendSOS = false;
if (speed > 100 && sendSOS == false) {
Get.defaultDialog(
barrierDismissible: false,
title: "Warning: Speeding detected!".tr,
titleStyle: AppStyle.title,
content: Text(
"We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button."
.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: "Share Trip Details".tr,
onPressed: () {
Get.back();
// Implement sharing trip details logic here
String message = "**Emergency SOS from Passenger:**\n";
// Get trip details from GetX or relevant provider
String origin = passengerLocation.toString();
String destination = myDestination.toString();
String driverName = firstName;
String driverCarPlate = licensePlate;
// Add trip details to the message
message += "* ${'Origin'.tr}: $origin\n";
message += "* ${'Destination'.tr}: $destination\n";
message += "* ${'Driver Name'.tr}: $driverName\n";
message += "* ${'Driver Car Plate'.tr}: $driverCarPlate\n\n";
message += "* ${'Driver phone'.tr}:$driverPhone\n\n";
// Add any additional information you want to include (optional)
// - Example: current location (using GetX LocationController)
message +=
"${'Current Location'.tr}:https://www.google.com/maps/place/${passengerLocation.latitude},${passengerLocation.longitude} \n";
// Append a call to action
message += "Please help! Contact me as soon as possible.".tr;
// Launch WhatsApp communication with the constructed message
launchCommunication(
'whatsapp', box.read(BoxName.sosPhonePassenger), message);
sendSOS = true;
},
kolor: AppColor.redColor,
),
cancel: MyElevatedButton(
title: "Cancel".tr,
onPressed: () {
Get.back();
},
kolor: AppColor.greenColor,
),
);
}
int minutes = (remainingTimeTimerRideBegin / 60).floor(); int minutes = (remainingTimeTimerRideBegin / 60).floor();
int seconds = remainingTimeTimerRideBegin % 60; int seconds = remainingTimeTimerRideBegin % 60;
stringRemainingTimeRideBegin = stringRemainingTimeRideBegin =
@@ -636,7 +690,7 @@ class MapPassengerController extends GetxController {
} }
} }
void getRideStatusFromStartApp() async { getRideStatusFromStartApp() async {
try { try {
var res = await CRUD().get( var res = await CRUD().get(
link: AppLink.getRideStatusFromStartApp, link: AppLink.getRideStatusFromStartApp,
@@ -648,15 +702,36 @@ class MapPassengerController extends GetxController {
if (decode['data']['status'] == 'Begin') { if (decode['data']['status'] == 'Begin') {
//todo from sql or get storage //todo from sql or get storage
getMap( List<dynamic> pol = box.read(BoxName.tripData);
decode['data']['start_location'], decode['data']['end_location']); Map<String, dynamic> tripData =
// timeToPassengerFromDriverAfterApplied = 0; box.read(BoxName.tripData) as Map<String, dynamic>;
// remainingTime = 0; final points = decodePolyline(
// remainingTimeToPassengerFromDriverAfterApplied = 0; tripData["routes"][0]["overview_polyline"]["points"]);
// // isCancelRidePageShown = true;
// rideIsBeginPassengerTimer(); for (int i = 0; i < points.length; i++) {
// // //print('rideTimerBegin: $rideTimerBegin'); double lat = points[i][0].toDouble();
// rideTimerBegin = true; double lng = points[i][1].toDouble();
polylineCoordinates.add(LatLng(lat, lng));
}
var polyline = Polyline(
polylineId: const PolylineId('begin trip'),
points: polylineCoordinates,
width: 10,
color: Colors.blue,
);
polyLines.add(polyline);
timeToPassengerFromDriverAfterApplied = 0;
remainingTime = 0;
remainingTimeToPassengerFromDriverAfterApplied = 0;
remainingTimeDriverWaitPassenger5Minute = 0;
rideTimerBegin = true;
isDriverInPassengerWay = false;
isDriverArrivePassenger = false;
update();
// isCancelRidePageShown = true;
rideIsBeginPassengerTimer();
runWhenRideIsBegin();
update(); update();
} }
} catch (e) { } catch (e) {
@@ -1578,6 +1653,7 @@ class MapPassengerController extends GetxController {
}); });
} }
double speed = 0;
Future<void> getLocation() async { Future<void> getLocation() async {
isLoading = true; isLoading = true;
update(); update();
@@ -1614,6 +1690,7 @@ class MapPassengerController extends GetxController {
? LatLng(_locationData.latitude!, _locationData.longitude!) ? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!; : null)!;
newStartPointLocation = passengerLocation; newStartPointLocation = passengerLocation;
speed = _locationData.speed!;
// //print location details // //print location details
// //print('Accuracy: ${_locationData.accuracy}'); // //print('Accuracy: ${_locationData.accuracy}');
// //print('Latitude: ${_locationData.latitude}'); // //print('Latitude: ${_locationData.latitude}');
@@ -1886,6 +1963,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs']; data = response['routes'][0]['legs'];
// //print(data); // //print(data);
box.write(BoxName.tripData, response);
startNameAddress = data[0]['start_address']; startNameAddress = data[0]['start_address'];
endNameAddress = data[0]['end_address']; endNameAddress = data[0]['end_address'];
isLoading = false; isLoading = false;
@@ -2367,8 +2445,9 @@ class MapPassengerController extends GetxController {
await addToken(); await addToken();
await getKazanPercent(); await getKazanPercent();
await getPassengerRate(); await getPassengerRate();
await getRideStatusFromStartApp();
startMarkerReloading(); startMarkerReloading();
// await getCarsLocationByPassenger();
// await getNearestDriverByPassengerLocation(); // await getNearestDriverByPassengerLocation();
initilizeGetStorage(); initilizeGetStorage();

View File

@@ -478,11 +478,22 @@ class MyTranslation extends Translations {
'Distance from Passenger to destination is ': 'Distance from Passenger to destination is ':
"المسافة من الراكب إلى الوجهة هي ", "المسافة من الراكب إلى الوجهة هي ",
'Cost Of Trip IS ': "تكلفة الرحلة هي ", 'Cost Of Trip IS ': "تكلفة الرحلة هي ",
"We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button.":
"لقد لاحظنا أن السرعة تتجاوز ١٠٠ كم/ساعة. يرجى التباطؤ من أجل سلامتك. إذا كنت تشعر بعدم الأمان، يمكنك مشاركة تفاصيل رحلتك مع جهة اتصال أو الاتصال بالشرطة باستخدام زر SOS الأحمر.",
'Warning: Speeding detected!': "تحذير: تم رصد السرعة الزائدة!",
"Please help! Contact me as soon as possible.":
"الرجاء المساعدة! اتصل بي في أقرب وقت ممكن.",
'Share Trip Details': "مشاركة تفاصيل الرحلة",
'No ride found yet': '‏لا يوجد طلبات متوفرة حاليا', 'No ride found yet': '‏لا يوجد طلبات متوفرة حاليا',
'Accept Order': "‏اقبل الطلب", 'Accept Order': "‏اقبل الطلب",
'reject your order.': "رفض طلبك.", 'reject your order.': "رفض طلبك.",
'Bottom Bar Example': "مثال لشريط الأسفل", 'Bottom Bar Example': "مثال لشريط الأسفل",
'Driver phone': '‏رقم السائق',
'Statistics': "الإحصائيات", 'Statistics': "الإحصائيات",
'Origin': "نقطة الانطلاق",
'Destination': 'الوجهة',
'Driver Name': 'اسم السائق',
'Driver Car Plate': 'لوحة السيارة',
'Available for rides': '‏مشاوير متاحة', 'Available for rides': '‏مشاوير متاحة',
'Scan Id': "مسح الهوية", 'Scan Id': "مسح الهوية",
'Camera not initilaized yet': "الكاميرا لم تُثبت بعد", 'Camera not initilaized yet': "الكاميرا لم تُثبت بعد",

View File

@@ -9,13 +9,13 @@ import '../functions/crud.dart';
class RideAvailableController extends GetxController { class RideAvailableController extends GetxController {
bool isLoading = false; bool isLoading = false;
Map rideAvalibleMap = {}; Map rideAvailableMap = {};
getRideAvalible() async { getRideAvailable() async {
isLoading = true; isLoading = true;
var res = await CRUD().get(link: AppLink.getRideWaiting, payload: {}); var res = await CRUD().get(link: AppLink.getRideWaiting, payload: {});
if (res != 'failure') { if (res != 'failure') {
rideAvalibleMap = jsonDecode(res); rideAvailableMap = jsonDecode(res);
print(rideAvalibleMap); print(rideAvailableMap);
isLoading = false; isLoading = false;
update(); update();
} else { } else {
@@ -34,7 +34,7 @@ class RideAvailableController extends GetxController {
@override @override
void onInit() { void onInit() {
getRideAvalible(); getRideAvailable();
super.onInit(); super.onInit();
} }
} }

View File

@@ -37,18 +37,18 @@ GetBuilder<HomeCaptainController> callPage() {
onTap: () async { onTap: () async {
// await callController.initAgoraFull(); // await callController.initAgoraFull();
// callController.join(); // callController.join();
FirebaseMessagesController().sendNotificationToPassengerToken( // FirebaseMessagesController().sendNotificationToPassengerToken(
'Call Income', // 'Call Income',
'You have call from driver ${box.read(BoxName.nameDriver)}', // 'You have call from driver ${box.read(BoxName.nameDriver)}',
Get.find<MapDriverController>().tokenPassenger, // Get.find<MapDriverController>().tokenPassenger,
[ // [
callController.token, // callController.token,
callController.channelName, // callController.channelName,
callController.uid.toString(), // callController.uid.toString(),
callController.remoteUid.toString(), // callController.remoteUid.toString(),
], // ],
); // );
callController.join(); // callController.join();
}, },
child: Container( child: Container(
width: 50, width: 50,

View File

@@ -21,8 +21,8 @@ GetBuilder<MapDriverController> driverEndRideBar() {
child: Container( child: Container(
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration,
height: mapDriverController.remainingTimeTimerRideBegin < 60 height: mapDriverController.remainingTimeTimerRideBegin < 60
? mapDriverController.driverEndPage = 160 ? mapDriverController.driverEndPage = 180
: 130, : 150,
width: 240, width: 240,
child: Column( child: Column(
children: [ children: [

View File

@@ -170,7 +170,8 @@ class RideBeginPassenger extends StatelessWidget {
phoneNumber = phoneNumber.replaceAll('0', ''); phoneNumber = phoneNumber.replaceAll('0', '');
print(phoneNumber); // Output: 798583061 print(phoneNumber); // Output: 798583061
var phone = var phone =
'+${box.read(BoxName.countryCode)}${box.read(BoxName.sosPhonePassenger)}'; // '+${box.read(BoxName.countryCode)}${box.read(BoxName.sosPhonePassenger)}';
'+20${box.read(BoxName.sosPhonePassenger)}';
controller.sendWhatsapp(phone); controller.sendWhatsapp(phone);
} }
}, },

View File

@@ -33,9 +33,9 @@ class AvailableRidesPage extends StatelessWidget {
: Padding( : Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: rideAvailableController child: rideAvailableController
.rideAvalibleMap['message'].length == .rideAvailableMap['message'].length ==
1 && 1 &&
rideAvailableController.rideAvalibleMap['message'] rideAvailableController.rideAvailableMap['message']
[0]['start_location'] == [0]['start_location'] ==
null null
? Center( ? Center(
@@ -46,10 +46,10 @@ class AvailableRidesPage extends StatelessWidget {
) )
: ListView.builder( : ListView.builder(
itemCount: rideAvailableController itemCount: rideAvailableController
.rideAvalibleMap['message'].length, .rideAvailableMap['message'].length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
var list = rideAvailableController var list = rideAvailableController
.rideAvalibleMap['message'][index]; .rideAvailableMap['message'][index];
return Container( return Container(
width: Get.width * .9, width: Get.width * .9,
decoration: AppStyle.boxDecoration1, decoration: AppStyle.boxDecoration1,
@@ -146,6 +146,16 @@ class AvailableRidesPage extends StatelessWidget {
'order_id': list['id'], 'order_id': list['id'],
'status': 'Apply' 'status': 'Apply'
}); });
await CRUD().post(
link: AppLink.updateRides,
payload: {
'id': list['id'],
'driverGoToPassengerTime':
DateTime.now()
.toString(),
'status': 'Applied'
});
// print(bodyToPassenger); // print(bodyToPassenger);
FirebaseMessagesController() FirebaseMessagesController()
.sendNotificationToPassengerToken( .sendNotificationToPassengerToken(