2/14/1
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/controller/home/captin/map_driver_controller.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../constant/links.dart';
|
||||
@@ -204,11 +205,12 @@ class HomeCaptainController extends GetxController {
|
||||
}
|
||||
|
||||
addToken() async {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
}).then((value) => print('Token Added'));
|
||||
MapDriverController().driverCallPassenger();
|
||||
// box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
|
||||
getPaymentToday() async {
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../../constant/api_key.dart';
|
||||
@@ -45,6 +46,7 @@ class MapDriverController extends GetxController {
|
||||
late String step3;
|
||||
late String step4;
|
||||
late String duration;
|
||||
late String totalCost;
|
||||
late String distance;
|
||||
late String name;
|
||||
late String phone;
|
||||
@@ -242,6 +244,46 @@ class MapDriverController extends GetxController {
|
||||
tokenPassenger);
|
||||
}
|
||||
|
||||
bool isSocialPressed = false;
|
||||
driverCallPassenger() async {
|
||||
String scam = await getDriverScam();
|
||||
if (scam != 'failure') {
|
||||
if (int.parse(scam) > 3) {
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
Get.find<LocationController>().stopLocationUpdates();
|
||||
await CRUD().post(link: AppLink.addNotificationCaptain, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'title': 'scams operations'.tr,
|
||||
'body':
|
||||
'you have connect to passengers and let them cancel the order'.tr,
|
||||
});
|
||||
} else if (isSocialPressed == true) {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
await CRUD().post(link: AppLink.adddriverScam, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'passengerID': passengerId,
|
||||
'rideID': rideId,
|
||||
'isDriverCalledPassenger': '$isSocialPressed'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getDriverScam() async {
|
||||
var res = await CRUD().post(link: AppLink.getdriverScam, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
});
|
||||
if (res == 'failure') {
|
||||
print('Scam is failure');
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
return '0';
|
||||
}
|
||||
var d = jsonDecode(res);
|
||||
print('Scam is ');
|
||||
print(d['message'][0]['count']);
|
||||
return d['message'][0]['count'];
|
||||
}
|
||||
|
||||
void startRideFromDriver() async {
|
||||
changeRideToBeginToPassenger();
|
||||
isPassengerInfoWindow = false;
|
||||
@@ -283,14 +325,20 @@ class MapDriverController extends GetxController {
|
||||
// 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
||||
}
|
||||
|
||||
addWaittingTimeCostFromPassengerToDriverWallet() async {
|
||||
calculateDistanseBetweenDriverAndPassengerLocation() {
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
latLngpassengerLocation.latitude,
|
||||
latLngpassengerLocation.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
if (distance2 > 80) {
|
||||
return distance2;
|
||||
}
|
||||
|
||||
addWaittingTimeCostFromPassengerToDriverWallet() async {
|
||||
double distance2 = calculateDistanseBetweenDriverAndPassengerLocation();
|
||||
|
||||
if (distance2 > 40) {
|
||||
Get.defaultDialog(
|
||||
title: 'Your are far from passenger location'.tr,
|
||||
middleText:
|
||||
@@ -321,6 +369,7 @@ class MapDriverController extends GetxController {
|
||||
'passenger_id': passengerId,
|
||||
'balance': (cost * -1).toString()
|
||||
});
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
@@ -335,21 +384,30 @@ class MapDriverController extends GetxController {
|
||||
'rideTimeFinish': DateTime.now().toString(),
|
||||
'status': 'Finished'
|
||||
});
|
||||
Get.back();
|
||||
if (walletChecked == 'true') {
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'ba lance': ((-1) * double.parse(totalCost)).toString()
|
||||
});
|
||||
}
|
||||
|
||||
// Get.back();
|
||||
Future.delayed(const Duration(milliseconds: 300));
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Driver Finish Trip',
|
||||
'you will pay to Driver'.tr + ' $totalCost \$'.tr,
|
||||
tokenPassenger,
|
||||
[
|
||||
box.read(BoxName.driverID),
|
||||
rideId,
|
||||
box.read(BoxName.tokenDriver),
|
||||
],
|
||||
);
|
||||
Get.to(() => RatePassenger(), arguments: {
|
||||
'rideId': rideId,
|
||||
'passengerId': passengerId,
|
||||
'driverId': driverId
|
||||
});
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Driver Finish Trip',
|
||||
box.read(BoxName.name).toString(),
|
||||
tokenPassenger, [
|
||||
box.read(BoxName.driverID),
|
||||
rideId,
|
||||
box.read(BoxName.tokenDriver),
|
||||
]);
|
||||
}
|
||||
|
||||
void cancelCheckRidefromPassenger() async {
|
||||
@@ -623,6 +681,7 @@ class MapDriverController extends GetxController {
|
||||
passengerLocation = Get.arguments['passengerLocation'];
|
||||
passengerDestination = Get.arguments['passengerDestination'];
|
||||
duration = Get.arguments['Duration'];
|
||||
totalCost = Get.arguments['totalCost'];
|
||||
passengerId = Get.arguments['passengerId'];
|
||||
driverId = Get.arguments['driverId'];
|
||||
distance = Get.arguments['Distance'];
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
@@ -38,7 +39,7 @@ class OrderRequestController extends GetxController {
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT COUNT(*) AS count
|
||||
SELECT COUNT(*) AS count
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
@@ -95,12 +96,16 @@ class OrderRequestController extends GetxController {
|
||||
'status': 'Refused'
|
||||
});
|
||||
Get.back();
|
||||
// applied = true;
|
||||
sql.insertData({
|
||||
'order_id': orderID,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'rideId': orderID
|
||||
}, TableName.driverOrdersRefuse);
|
||||
getRefusedOrderByCaptain();
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
update();
|
||||
// Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:ride/views/home/my_wallet/walet_captain.dart';
|
||||
|
||||
import '../../../../constant/style.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
@@ -34,7 +33,7 @@ class ConnectWidget extends StatelessWidget {
|
||||
barrierDismissible: false,
|
||||
title: double.parse(captainWalletController.totalPoints) <
|
||||
-100
|
||||
? 'You dont have Points'
|
||||
? 'You dont have Points'.tr
|
||||
: 'You Are Stopped For this Day !'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Text(
|
||||
|
||||
Reference in New Issue
Block a user