2/10/1
This commit is contained in:
@@ -17,6 +17,7 @@ import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.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/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
@@ -146,36 +147,11 @@ class FirebaseMessagesController extends GetxController {
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
driverID = myList[2].toString();
|
||||
|
||||
Get.snackbar(
|
||||
'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),
|
||||
);
|
||||
driverAppliedTripSnakBar();
|
||||
} else if (message.notification!.title! == 'Promo') {
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title == 'Cancel Trip') {
|
||||
Get.defaultDialog(
|
||||
title: 'Passenger Cancel Trip'.tr,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.offAll(HomeCaptain());
|
||||
}));
|
||||
cancelTripDialog();
|
||||
} else if (message.notification!.title! == 'DriverIsGoingToPassenger') {
|
||||
Get.snackbar('Driver is Going To Passenger', '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
@@ -187,87 +163,134 @@ class FirebaseMessagesController extends GetxController {
|
||||
backgroundColor: AppColor.greenColor);
|
||||
update();
|
||||
} else if (message.notification!.title! == 'Hi ,I Arrive your site') {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Hi ,I Arrive your site'.tr,
|
||||
middleText: 'Please go to Car Driver'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok I will go now.'.tr,
|
||||
onPressed: () {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Hi ,I will go now'.tr,
|
||||
'I will go now'.tr,
|
||||
Get.find<MapPassengerController>().driverToken, []);
|
||||
Get.back();
|
||||
}));
|
||||
driverArrivePassengerDialoge();
|
||||
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
|
||||
} 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) {
|
||||
Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: DriverTipWidget(),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var tip = (Get.find<MapPassengerController>().totalPassenger) *
|
||||
(double.parse(box.read(BoxName.tipPercentage.toString())));
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': tip.toString(),
|
||||
});
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * tip).toString()
|
||||
});
|
||||
|
||||
await CRUD()
|
||||
.post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': driverList[0].toString(),
|
||||
'paymentID':
|
||||
'${Get.find<MapPassengerController>().rideId}tip',
|
||||
'amount': (tip * 100).toString(),
|
||||
'paymentMethod': 'visa-tip',
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
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,
|
||||
title: 'Hi ,I Arrive your site'.tr,
|
||||
middleText: 'Please go to Car Driver'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok I will go now.'.tr,
|
||||
onPressed: () {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Hi ,I will go now'.tr,
|
||||
'I will go now'.tr,
|
||||
Get.find<MapPassengerController>().driverToken, []);
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> driverFinishTripDialoge(List<dynamic> driverList) {
|
||||
return Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: const DriverTipWidget(),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var tip = (Get.find<MapPassengerController>().totalPassenger) *
|
||||
(double.parse(box.read(BoxName.tipPercentage.toString())));
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': tip.toString(),
|
||||
});
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'balance': ((-1) * tip).toString()
|
||||
});
|
||||
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': driverList[0].toString(),
|
||||
'paymentID': '${Get.find<MapPassengerController>().rideId}tip',
|
||||
'amount': (tip * 100).toString(),
|
||||
'paymentMethod': 'visa-tip',
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'${tip.toString()}\$ tips\nTotal is ${tip + (Get.find<MapPassengerController>().totalPassenger)}',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.to(() => RateDriverFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
}
|
||||
|
||||
void sendNotificationAll(String title, body) async {
|
||||
// Get the token you want to subtract.
|
||||
String token = box.read(BoxName.tokenFCM);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
@@ -63,7 +64,7 @@ class MapDriverController extends GetxController {
|
||||
bool isPassengerInfoWindow = false;
|
||||
bool isBtnRideBegin = false;
|
||||
bool isArrivedSend = true;
|
||||
bool isBtnPassengerWait = false;
|
||||
bool isdriverWaitTimeEnd = false;
|
||||
bool isRideFinished = false;
|
||||
bool isRideStarted = false;
|
||||
double passengerInfoWindow = Get.height * .35;
|
||||
@@ -211,11 +212,11 @@ class MapDriverController extends GetxController {
|
||||
progressInPassengerLocationFromDriver = i / (timeWaitingPassenger * 60);
|
||||
remainingTimeInPassengerLocatioWait = (timeWaitingPassenger * 60) - i;
|
||||
if (remainingTimeInPassengerLocatioWait == 0) {
|
||||
isBtnPassengerWait = true;
|
||||
print(isBtnPassengerWait);
|
||||
isdriverWaitTimeEnd = true;
|
||||
print(isdriverWaitTimeEnd);
|
||||
update();
|
||||
}
|
||||
print(isBtnPassengerWait);
|
||||
print(isdriverWaitTimeEnd);
|
||||
print(
|
||||
'remainingTimeInPassengerLocatioWait $remainingTimeInPassengerLocatioWait');
|
||||
|
||||
@@ -282,6 +283,48 @@ class MapDriverController extends GetxController {
|
||||
// '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 {
|
||||
isRideFinished = true;
|
||||
isRideStarted = false;
|
||||
@@ -436,6 +479,7 @@ class MapDriverController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
double distanceBetweenDriverAndPassengerWhenConfirm = 0;
|
||||
getMap(String origin, destination) async {
|
||||
isLoading = false;
|
||||
|
||||
@@ -447,6 +491,8 @@ class MapDriverController extends GetxController {
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
print(data);
|
||||
distanceBetweenDriverAndPassengerWhenConfirm =
|
||||
(data[0]['distance']['value']) / 1000;
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
|
||||
@@ -650,6 +650,7 @@ class MapPassengerController extends GetxController {
|
||||
late String licensePlate;
|
||||
changeConfirmRide() async {
|
||||
await getCarsLocationByPassenger();
|
||||
await getNearestDriverByPassengerLocation();
|
||||
|
||||
if (dataCarsLocationByPassenger != 'failure') {
|
||||
driverToken =
|
||||
@@ -1423,7 +1424,7 @@ class MapPassengerController extends GetxController {
|
||||
String distanceByPassenger = '';
|
||||
late Duration durationFromDriverToPassenger;
|
||||
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
getNearestDriverByPassengerLocation() async {
|
||||
if (polyLines.isEmpty || data.isEmpty) {
|
||||
if (rideConfirm == false) {
|
||||
double nearestDistance = double.infinity;
|
||||
@@ -1493,7 +1494,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
calculateDistanceBetweenPassengerAndDriverBeforecancelRide() async {
|
||||
// await getDriverCarsLocationToPassengerAfterApplied();
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
double distance = Geolocator.distanceBetween(
|
||||
passengerLocation.latitude,
|
||||
passengerLocation.longitude,
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/box_name.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/home/captin/map_driver_controller.dart';
|
||||
import 'package:ride/main.dart';
|
||||
@@ -217,11 +218,13 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
controller.isArrivedSend =
|
||||
false;
|
||||
})
|
||||
: const SizedBox(),
|
||||
: const SizedBox()
|
||||
],
|
||||
),
|
||||
controller.remainingTimeInPassengerLocatioWait <
|
||||
300
|
||||
300 &&
|
||||
controller.remainingTimeInPassengerLocatioWait !=
|
||||
0
|
||||
? Stack(
|
||||
children: [
|
||||
LinearProgressIndicator(
|
||||
@@ -249,7 +252,30 @@ class PassengerInfoWindow extends StatelessWidget {
|
||||
)
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
: 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(),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -90,7 +90,8 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
textToSpeechController.speakText('''hello this is hamza''');
|
||||
textToSpeechController.speakText(
|
||||
'''hello this is ${box.read(BoxName.name)}''');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.voice_chat,
|
||||
|
||||
@@ -72,7 +72,7 @@ class TimerToPassengerFromDriver extends StatelessWidget {
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
// 'status': 'Applied'
|
||||
// });
|
||||
controller
|
||||
await controller
|
||||
.calculateDistanceBetweenPassengerAndDriverBeforecancelRide();
|
||||
})
|
||||
: const SizedBox()
|
||||
|
||||
Reference in New Issue
Block a user