2/10/1
This commit is contained in:
@@ -17,6 +17,7 @@ import '../../constant/style.dart';
|
|||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
import '../../views/Rate/rate_captain.dart';
|
import '../../views/Rate/rate_captain.dart';
|
||||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||||
|
import '../../views/home/map_page_passenger.dart';
|
||||||
import '../../views/home/profile/promos_passenger_page.dart';
|
import '../../views/home/profile/promos_passenger_page.dart';
|
||||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||||
import '../home/map_passenger_controller.dart';
|
import '../home/map_passenger_controller.dart';
|
||||||
@@ -146,36 +147,11 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||||
driverID = myList[2].toString();
|
driverID = myList[2].toString();
|
||||||
|
|
||||||
Get.snackbar(
|
driverAppliedTripSnakBar();
|
||||||
'Captain Applied the Ride for You'.tr,
|
|
||||||
'message',
|
|
||||||
colorText: AppColor.greenColor,
|
|
||||||
duration: const Duration(seconds: 11),
|
|
||||||
snackPosition: SnackPosition.TOP,
|
|
||||||
titleText: Text(
|
|
||||||
'Applied'.tr,
|
|
||||||
style: const TextStyle(color: AppColor.redColor),
|
|
||||||
),
|
|
||||||
messageText: Text(
|
|
||||||
'Captain Applied the Ride for You'.tr,
|
|
||||||
style: AppStyle.title,
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.approval),
|
|
||||||
shouldIconPulse: true,
|
|
||||||
margin: const EdgeInsets.all(16),
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
);
|
|
||||||
} else if (message.notification!.title! == 'Promo') {
|
} else if (message.notification!.title! == 'Promo') {
|
||||||
Get.to(const PromosPassengerPage());
|
Get.to(const PromosPassengerPage());
|
||||||
} else if (message.notification!.title == 'Cancel Trip') {
|
} else if (message.notification!.title == 'Cancel Trip') {
|
||||||
Get.defaultDialog(
|
cancelTripDialog();
|
||||||
title: 'Passenger Cancel Trip'.tr,
|
|
||||||
middleText: '',
|
|
||||||
confirm: MyElevatedButton(
|
|
||||||
title: 'Ok'.tr,
|
|
||||||
onPressed: () {
|
|
||||||
Get.offAll(HomeCaptain());
|
|
||||||
}));
|
|
||||||
} else if (message.notification!.title! == 'DriverIsGoingToPassenger') {
|
} else if (message.notification!.title! == 'DriverIsGoingToPassenger') {
|
||||||
Get.snackbar('Driver is Going To Passenger', '',
|
Get.snackbar('Driver is Going To Passenger', '',
|
||||||
backgroundColor: AppColor.greenColor);
|
backgroundColor: AppColor.greenColor);
|
||||||
@@ -187,7 +163,67 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
backgroundColor: AppColor.greenColor);
|
backgroundColor: AppColor.greenColor);
|
||||||
update();
|
update();
|
||||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site') {
|
} else if (message.notification!.title! == 'Hi ,I Arrive your site') {
|
||||||
Get.defaultDialog(
|
driverArrivePassengerDialoge();
|
||||||
|
|
||||||
|
update();
|
||||||
|
} else if (message.notification!.title! == 'Driver Finish Trip') {
|
||||||
|
var myListString = message.data['passengerList'];
|
||||||
|
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||||
|
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(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (message.notification!.title! == 'Driver Cancel 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);
|
||||||
|
Get.find<MapPassengerController>().restCounter();
|
||||||
|
Get.offAll(const MapPagePassenger());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SnackbarController driverAppliedTripSnakBar() {
|
||||||
|
return Get.snackbar(
|
||||||
|
'Driver Applied the Ride for You'.tr,
|
||||||
|
'message',
|
||||||
|
colorText: AppColor.greenColor,
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
snackPosition: SnackPosition.TOP,
|
||||||
|
titleText: Text(
|
||||||
|
'Applied'.tr,
|
||||||
|
style: const TextStyle(color: AppColor.redColor),
|
||||||
|
),
|
||||||
|
messageText: Text(
|
||||||
|
'Driver Applied the Ride for You'.tr,
|
||||||
|
style: AppStyle.title,
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.approval),
|
||||||
|
shouldIconPulse: true,
|
||||||
|
margin: const EdgeInsets.all(16),
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<dynamic> cancelTripDialog() {
|
||||||
|
return Get.defaultDialog(
|
||||||
|
title: 'Passenger Cancel Trip'.tr,
|
||||||
|
middleText: '',
|
||||||
|
confirm: MyElevatedButton(
|
||||||
|
title: 'Ok'.tr,
|
||||||
|
onPressed: () {
|
||||||
|
Get.offAll(HomeCaptain());
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<dynamic> driverArrivePassengerDialoge() {
|
||||||
|
return Get.defaultDialog(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
title: 'Hi ,I Arrive your site'.tr,
|
title: 'Hi ,I Arrive your site'.tr,
|
||||||
middleText: 'Please go to Car Driver'.tr,
|
middleText: 'Please go to Car Driver'.tr,
|
||||||
@@ -200,16 +236,12 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
Get.find<MapPassengerController>().driverToken, []);
|
Get.find<MapPassengerController>().driverToken, []);
|
||||||
Get.back();
|
Get.back();
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
Future<dynamic> driverFinishTripDialoge(List<dynamic> driverList) {
|
||||||
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
|
return Get.defaultDialog(
|
||||||
var myListString = message.data['passengerList'];
|
|
||||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
|
||||||
if (Get.find<PaymentController>().isCashChecked == false &&
|
|
||||||
Get.find<PaymentController>().isWalletChecked == true) {
|
|
||||||
Get.defaultDialog(
|
|
||||||
title: 'Driver Finish Trip'.tr,
|
title: 'Driver Finish Trip'.tr,
|
||||||
content: DriverTipWidget(),
|
content: const DriverTipWidget(),
|
||||||
confirm: MyElevatedButton(
|
confirm: MyElevatedButton(
|
||||||
title: 'Yes'.tr,
|
title: 'Yes'.tr,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -226,11 +258,9 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
'balance': ((-1) * tip).toString()
|
'balance': ((-1) * tip).toString()
|
||||||
});
|
});
|
||||||
|
|
||||||
await CRUD()
|
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||||
.post(link: AppLink.addDriversWalletPoints, payload: {
|
|
||||||
'driverID': driverList[0].toString(),
|
'driverID': driverList[0].toString(),
|
||||||
'paymentID':
|
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
|
||||||
'${Get.find<MapPassengerController>().rideId}tip',
|
|
||||||
'amount': (tip * 100).toString(),
|
'amount': (tip * 100).toString(),
|
||||||
'paymentMethod': 'visa-tip',
|
'paymentMethod': 'visa-tip',
|
||||||
});
|
});
|
||||||
@@ -259,13 +289,6 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
},
|
},
|
||||||
kolor: AppColor.redColor,
|
kolor: AppColor.redColor,
|
||||||
));
|
));
|
||||||
} else {
|
|
||||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
|
||||||
'driverId': driverList[0].toString(),
|
|
||||||
'rideId': driverList[1].toString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendNotificationAll(String title, body) async {
|
void sendNotificationAll(String title, body) async {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||||
@@ -63,7 +64,7 @@ class MapDriverController extends GetxController {
|
|||||||
bool isPassengerInfoWindow = false;
|
bool isPassengerInfoWindow = false;
|
||||||
bool isBtnRideBegin = false;
|
bool isBtnRideBegin = false;
|
||||||
bool isArrivedSend = true;
|
bool isArrivedSend = true;
|
||||||
bool isBtnPassengerWait = false;
|
bool isdriverWaitTimeEnd = false;
|
||||||
bool isRideFinished = false;
|
bool isRideFinished = false;
|
||||||
bool isRideStarted = false;
|
bool isRideStarted = false;
|
||||||
double passengerInfoWindow = Get.height * .35;
|
double passengerInfoWindow = Get.height * .35;
|
||||||
@@ -211,11 +212,11 @@ class MapDriverController extends GetxController {
|
|||||||
progressInPassengerLocationFromDriver = i / (timeWaitingPassenger * 60);
|
progressInPassengerLocationFromDriver = i / (timeWaitingPassenger * 60);
|
||||||
remainingTimeInPassengerLocatioWait = (timeWaitingPassenger * 60) - i;
|
remainingTimeInPassengerLocatioWait = (timeWaitingPassenger * 60) - i;
|
||||||
if (remainingTimeInPassengerLocatioWait == 0) {
|
if (remainingTimeInPassengerLocatioWait == 0) {
|
||||||
isBtnPassengerWait = true;
|
isdriverWaitTimeEnd = true;
|
||||||
print(isBtnPassengerWait);
|
print(isdriverWaitTimeEnd);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
print(isBtnPassengerWait);
|
print(isdriverWaitTimeEnd);
|
||||||
print(
|
print(
|
||||||
'remainingTimeInPassengerLocatioWait $remainingTimeInPassengerLocatioWait');
|
'remainingTimeInPassengerLocatioWait $remainingTimeInPassengerLocatioWait');
|
||||||
|
|
||||||
@@ -282,6 +283,48 @@ class MapDriverController extends GetxController {
|
|||||||
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addWaittingTimeCostFromPassengerToDriverWallet() async {
|
||||||
|
double distance2 = Geolocator.distanceBetween(
|
||||||
|
latLngpassengerLocation.latitude,
|
||||||
|
latLngpassengerLocation.longitude,
|
||||||
|
Get.find<LocationController>().myLocation.latitude,
|
||||||
|
Get.find<LocationController>().myLocation.longitude,
|
||||||
|
);
|
||||||
|
if (distance2 > 80) {
|
||||||
|
Get.defaultDialog(
|
||||||
|
title: 'Your are far from passenger location'.tr,
|
||||||
|
middleText:
|
||||||
|
'go to your passenger location before\nPassenger cancel trip'.tr,
|
||||||
|
confirm: MyElevatedButton(
|
||||||
|
title: 'Ok',
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
double cost =
|
||||||
|
(distanceBetweenDriverAndPassengerWhenConfirm * .08) + (5 * .06);
|
||||||
|
var res = await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||||
|
'rideId': rideId,
|
||||||
|
'amount': cost.toString(),
|
||||||
|
'payment_method': 'wait-cancel',
|
||||||
|
'passengerID': passengerId,
|
||||||
|
'driverID': box.read(BoxName.driverID).toString(),
|
||||||
|
});
|
||||||
|
if (res != 'failure') {
|
||||||
|
Get.snackbar(
|
||||||
|
'You will get cost of your work for this trip'.tr,
|
||||||
|
'you gain $cost \$ in your wallet',
|
||||||
|
backgroundColor: AppColor.deepPurpleAccent,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||||
|
'passenger_id': passengerId,
|
||||||
|
'balance': (cost * -1).toString()
|
||||||
|
});
|
||||||
|
Get.offAll(HomeCaptain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void finishRideFromDriver() async {
|
void finishRideFromDriver() async {
|
||||||
isRideFinished = true;
|
isRideFinished = true;
|
||||||
isRideStarted = false;
|
isRideStarted = false;
|
||||||
@@ -436,6 +479,7 @@ class MapDriverController extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double distanceBetweenDriverAndPassengerWhenConfirm = 0;
|
||||||
getMap(String origin, destination) async {
|
getMap(String origin, destination) async {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
@@ -447,6 +491,8 @@ class MapDriverController 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);
|
||||||
|
distanceBetweenDriverAndPassengerWhenConfirm =
|
||||||
|
(data[0]['distance']['value']) / 1000;
|
||||||
final points =
|
final points =
|
||||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||||
for (int i = 0; i < points.length; i++) {
|
for (int i = 0; i < points.length; i++) {
|
||||||
|
|||||||
@@ -650,6 +650,7 @@ class MapPassengerController extends GetxController {
|
|||||||
late String licensePlate;
|
late String licensePlate;
|
||||||
changeConfirmRide() async {
|
changeConfirmRide() async {
|
||||||
await getCarsLocationByPassenger();
|
await getCarsLocationByPassenger();
|
||||||
|
await getNearestDriverByPassengerLocation();
|
||||||
|
|
||||||
if (dataCarsLocationByPassenger != 'failure') {
|
if (dataCarsLocationByPassenger != 'failure') {
|
||||||
driverToken =
|
driverToken =
|
||||||
@@ -1423,7 +1424,7 @@ class MapPassengerController extends GetxController {
|
|||||||
String distanceByPassenger = '';
|
String distanceByPassenger = '';
|
||||||
late Duration durationFromDriverToPassenger;
|
late Duration durationFromDriverToPassenger;
|
||||||
|
|
||||||
void getNearestDriverByPassengerLocation() async {
|
getNearestDriverByPassengerLocation() async {
|
||||||
if (polyLines.isEmpty || data.isEmpty) {
|
if (polyLines.isEmpty || data.isEmpty) {
|
||||||
if (rideConfirm == false) {
|
if (rideConfirm == false) {
|
||||||
double nearestDistance = double.infinity;
|
double nearestDistance = double.infinity;
|
||||||
@@ -1493,7 +1494,7 @@ class MapPassengerController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
calculateDistanceBetweenPassengerAndDriverBeforecancelRide() async {
|
calculateDistanceBetweenPassengerAndDriverBeforecancelRide() async {
|
||||||
// await getDriverCarsLocationToPassengerAfterApplied();
|
await getDriverCarsLocationToPassengerAfterApplied();
|
||||||
double distance = Geolocator.distanceBetween(
|
double distance = Geolocator.distanceBetween(
|
||||||
passengerLocation.latitude,
|
passengerLocation.latitude,
|
||||||
passengerLocation.longitude,
|
passengerLocation.longitude,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter_font_icons/flutter_font_icons.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:ride/constant/box_name.dart';
|
import 'package:ride/constant/box_name.dart';
|
||||||
import 'package:ride/constant/colors.dart';
|
import 'package:ride/constant/colors.dart';
|
||||||
|
import 'package:ride/constant/info.dart';
|
||||||
import 'package:ride/controller/firebase/firbase_messge.dart';
|
import 'package:ride/controller/firebase/firbase_messge.dart';
|
||||||
import 'package:ride/controller/home/captin/map_driver_controller.dart';
|
import 'package:ride/controller/home/captin/map_driver_controller.dart';
|
||||||
import 'package:ride/main.dart';
|
import 'package:ride/main.dart';
|
||||||
@@ -217,11 +218,13 @@ class PassengerInfoWindow extends StatelessWidget {
|
|||||||
controller.isArrivedSend =
|
controller.isArrivedSend =
|
||||||
false;
|
false;
|
||||||
})
|
})
|
||||||
: const SizedBox(),
|
: const SizedBox()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
controller.remainingTimeInPassengerLocatioWait <
|
controller.remainingTimeInPassengerLocatioWait <
|
||||||
300
|
300 &&
|
||||||
|
controller.remainingTimeInPassengerLocatioWait !=
|
||||||
|
0
|
||||||
? Stack(
|
? Stack(
|
||||||
children: [
|
children: [
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
@@ -249,6 +252,29 @@ class PassengerInfoWindow extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
: controller.isdriverWaitTimeEnd
|
||||||
|
? MyElevatedButton(
|
||||||
|
title:
|
||||||
|
'You Can Cancel Trip And get Cost of Trip From ${AppInformation.appName}'
|
||||||
|
.tr,
|
||||||
|
kolor: AppColor
|
||||||
|
.deepPurpleAccent,
|
||||||
|
onPressed: () async {
|
||||||
|
FirebaseMessagesController()
|
||||||
|
.sendNotificationToPassengerToken(
|
||||||
|
'Driver Cancel Your Trip'
|
||||||
|
.tr,
|
||||||
|
'You will be pay the cost to driver or we will get it from you on next trip'
|
||||||
|
.tr,
|
||||||
|
controller
|
||||||
|
.tokenPassenger,
|
||||||
|
[]);
|
||||||
|
await controller
|
||||||
|
.addWaittingTimeCostFromPassengerToDriverWallet();
|
||||||
|
controller
|
||||||
|
.isdriverWaitTimeEnd =
|
||||||
|
false;
|
||||||
|
})
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
|||||||
borderRadius: BorderRadius.circular(15)),
|
borderRadius: BorderRadius.circular(15)),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
textToSpeechController.speakText('''hello this is hamza''');
|
textToSpeechController.speakText(
|
||||||
|
'''hello this is ${box.read(BoxName.name)}''');
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.voice_chat,
|
Icons.voice_chat,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class TimerToPassengerFromDriver extends StatelessWidget {
|
|||||||
// 'rideTimeStart': DateTime.now().toString(),
|
// 'rideTimeStart': DateTime.now().toString(),
|
||||||
// 'status': 'Applied'
|
// 'status': 'Applied'
|
||||||
// });
|
// });
|
||||||
controller
|
await controller
|
||||||
.calculateDistanceBetweenPassengerAndDriverBeforecancelRide();
|
.calculateDistanceBetweenPassengerAndDriverBeforecancelRide();
|
||||||
})
|
})
|
||||||
: const SizedBox()
|
: const SizedBox()
|
||||||
|
|||||||
Reference in New Issue
Block a user