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 owner = "owner";
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 driverList = jsonDecode(myListString) as List<dynamic>;
NotificationController().showNotification(
'Driver Finish Trip'.tr,
'Call Income'.tr,
message.notification!.body!,
'order',
);

View File

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

View File

@@ -443,7 +443,9 @@ class MapDriverController extends GetxController {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
totalCost = price.toStringAsFixed(2);
totalCost = carType == 'Comfort' || carType == 'Free Ride'
? price.toStringAsFixed(1)
: totalPassenger;
paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger();
@@ -470,7 +472,9 @@ class MapDriverController extends GetxController {
Future.delayed(const Duration(milliseconds: 300));
FirebaseMessagesController().sendNotificationToPassengerToken(
'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,
[
box.read(BoxName.driverID),

View File

@@ -587,7 +587,61 @@ class MapPassengerController extends GetxController {
await Future.delayed(const Duration(seconds: 1));
progressTimerRideBegin = i / durationToRide;
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 seconds = remainingTimeTimerRideBegin % 60;
stringRemainingTimeRideBegin =
@@ -636,7 +690,7 @@ class MapPassengerController extends GetxController {
}
}
void getRideStatusFromStartApp() async {
getRideStatusFromStartApp() async {
try {
var res = await CRUD().get(
link: AppLink.getRideStatusFromStartApp,
@@ -648,15 +702,36 @@ class MapPassengerController extends GetxController {
if (decode['data']['status'] == 'Begin') {
//todo from sql or get storage
getMap(
decode['data']['start_location'], decode['data']['end_location']);
// timeToPassengerFromDriverAfterApplied = 0;
// remainingTime = 0;
// remainingTimeToPassengerFromDriverAfterApplied = 0;
// // isCancelRidePageShown = true;
// rideIsBeginPassengerTimer();
// // //print('rideTimerBegin: $rideTimerBegin');
// rideTimerBegin = true;
List<dynamic> pol = box.read(BoxName.tripData);
Map<String, dynamic> tripData =
box.read(BoxName.tripData) as Map<String, dynamic>;
final points = decodePolyline(
tripData["routes"][0]["overview_polyline"]["points"]);
for (int i = 0; i < points.length; i++) {
double lat = points[i][0].toDouble();
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();
}
} catch (e) {
@@ -1578,6 +1653,7 @@ class MapPassengerController extends GetxController {
});
}
double speed = 0;
Future<void> getLocation() async {
isLoading = true;
update();
@@ -1614,6 +1690,7 @@ class MapPassengerController extends GetxController {
? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!;
newStartPointLocation = passengerLocation;
speed = _locationData.speed!;
// //print location details
// //print('Accuracy: ${_locationData.accuracy}');
// //print('Latitude: ${_locationData.latitude}');
@@ -1886,6 +1963,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// //print(data);
box.write(BoxName.tripData, response);
startNameAddress = data[0]['start_address'];
endNameAddress = data[0]['end_address'];
isLoading = false;
@@ -2367,8 +2445,9 @@ class MapPassengerController extends GetxController {
await addToken();
await getKazanPercent();
await getPassengerRate();
await getRideStatusFromStartApp();
startMarkerReloading();
// await getCarsLocationByPassenger();
// await getNearestDriverByPassengerLocation();
initilizeGetStorage();

View File

@@ -478,11 +478,22 @@ class MyTranslation extends Translations {
'Distance from Passenger to destination 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': '‏لا يوجد طلبات متوفرة حاليا',
'Accept Order': "‏اقبل الطلب",
'reject your order.': "رفض طلبك.",
'Bottom Bar Example': "مثال لشريط الأسفل",
'Driver phone': '‏رقم السائق',
'Statistics': "الإحصائيات",
'Origin': "نقطة الانطلاق",
'Destination': 'الوجهة',
'Driver Name': 'اسم السائق',
'Driver Car Plate': 'لوحة السيارة',
'Available for rides': '‏مشاوير متاحة',
'Scan Id': "مسح الهوية",
'Camera not initilaized yet': "الكاميرا لم تُثبت بعد",

View File

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

View File

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

View File

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

View File

@@ -170,7 +170,8 @@ class RideBeginPassenger extends StatelessWidget {
phoneNumber = phoneNumber.replaceAll('0', '');
print(phoneNumber); // Output: 798583061
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);
}
},

View File

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