9/27/1
This commit is contained in:
@@ -14,12 +14,12 @@ if (flutterRoot == null) {
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '2'
|
||||
flutterVersionCode = '3'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '2.1.1'
|
||||
flutterVersionName = '2.1.2'
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class TableName {
|
||||
static const String placesFavorite = "placesFavorite";
|
||||
static const String carLocations = "carLocations";
|
||||
static const String driverOrdersRefuse = "driverOrdersRefuse";
|
||||
}
|
||||
|
||||
@@ -112,12 +112,6 @@ class FirebasMessagesController extends GetxController {
|
||||
'body': message.notification!.body
|
||||
});
|
||||
} else if (message.notification!.title!.contains('Apply Ride')) {
|
||||
// MapController mapController = Get.put(MapController());
|
||||
// mapController.rideConfirm = false;
|
||||
// print('-----------------------------rideConfirm===' +
|
||||
// mapController.rideConfirm.toString());
|
||||
// update();
|
||||
|
||||
var passengerList = message.data['passengerList'];
|
||||
print(passengerList);
|
||||
print('9999999999999my Apply Ride 999999999999999');
|
||||
|
||||
@@ -23,18 +23,10 @@ class LocationController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
location = Location();
|
||||
getLocation();
|
||||
startLocationUpdates();
|
||||
}
|
||||
|
||||
void startLocationUpdates() async {
|
||||
// if (Get.find<HomeCaptainController>().isActive) {
|
||||
// Start the timer to get location every 20 seconds
|
||||
_locationTimer = Timer.periodic(const Duration(seconds: 20), (timer) async {
|
||||
await getLocation();
|
||||
|
||||
@@ -44,7 +36,10 @@ class LocationController extends GetxController {
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
});
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
void stopLocationUpdates() {
|
||||
_locationTimer?.cancel();
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
|
||||
1
lib/controller/home/captin/LocationService.dart
Normal file
1
lib/controller/home/captin/LocationService.dart
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -3,22 +3,29 @@ import 'package:ride/constant/box_name.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../main.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
|
||||
class HomeCaptainController extends GetxController {
|
||||
bool isActive = false;
|
||||
DateTime? activeStartTime;
|
||||
Duration activeDuration = Duration.zero;
|
||||
Timer? activeTimer;
|
||||
// Inject the LocationController class
|
||||
final locationController = Get.find<LocationController>();
|
||||
|
||||
void onButtonSelected() {
|
||||
isActive = !isActive;
|
||||
|
||||
if (isActive) {
|
||||
locationController.startLocationUpdates();
|
||||
activeStartTime = DateTime.now();
|
||||
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
activeDuration = DateTime.now().difference(activeStartTime!);
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
locationController.stopLocationUpdates();
|
||||
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
savePeriod(activeDuration);
|
||||
|
||||
@@ -1,20 +1,72 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../functions/crud.dart';
|
||||
|
||||
class TimerController extends GetxController {
|
||||
class OrderRequestController extends GetxController {
|
||||
double progress = 0;
|
||||
int duration = 25;
|
||||
int remainingTime = 0;
|
||||
String countRefuse = '0';
|
||||
bool applied = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// startTimer();//TODO check if it true
|
||||
getRefusedOrderByCaptain();
|
||||
update();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void startTimer() async {
|
||||
void changeApplied() {
|
||||
applied = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void getRefusedOrderByCaptain() async {
|
||||
DateTime today = DateTime.now();
|
||||
int todayDay = today.day;
|
||||
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT COUNT(*) AS count
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
''';
|
||||
|
||||
try {
|
||||
List<Map<String, dynamic>> results =
|
||||
await sql.getCustomQuery(customQuery);
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3) {
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
title: 'You Are Stopped For this Day !'.tr,
|
||||
content: Text(
|
||||
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () => Get.back()));
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error executing custom query: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void startTimer(String driverID, orderID) async {
|
||||
for (int i = 0; i <= duration; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progress = i / duration;
|
||||
@@ -22,21 +74,29 @@ class TimerController extends GetxController {
|
||||
|
||||
update();
|
||||
}
|
||||
timerEnded();
|
||||
if (remainingTime == 0) {
|
||||
if (applied == false) {
|
||||
print('applied=========================');
|
||||
print(applied);
|
||||
refuseOrder(driverID, orderID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void refuseOrder(String driverID, orderID) async {
|
||||
await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': driverID,
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': orderID,
|
||||
'status': 'Refused'
|
||||
});
|
||||
Get.back();
|
||||
}
|
||||
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
// refuseOrder();
|
||||
sql.insertData({
|
||||
'order_id': orderID,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
getRefusedOrderByCaptain();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../home_captain_controller.dart';
|
||||
import '../order_request_controller.dart';
|
||||
|
||||
class ConnectWidget extends StatelessWidget {
|
||||
const ConnectWidget({
|
||||
@@ -10,17 +11,26 @@ class ConnectWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final OrderRequestController orderRequestController =
|
||||
Get.put(OrderRequestController());
|
||||
return Center(
|
||||
child: GetBuilder<HomeCaptainController>(
|
||||
builder: (homeCaptainController) => CupertinoButton(
|
||||
child: Text(homeCaptainController.isActive
|
||||
? 'Connected'.tr
|
||||
: 'Not Connected'.tr),
|
||||
onPressed: homeCaptainController.onButtonSelected,
|
||||
color: homeCaptainController.isActive
|
||||
? CupertinoColors.activeGreen
|
||||
: CupertinoColors.inactiveGray,
|
||||
),
|
||||
builder: (homeCaptainController) =>
|
||||
int.parse(orderRequestController.countRefuse) > 3
|
||||
? CupertinoButton(
|
||||
child: Text('You are Stopped'.tr),
|
||||
onPressed: () {},
|
||||
color: CupertinoColors.destructiveRed,
|
||||
)
|
||||
: CupertinoButton(
|
||||
child: Text(homeCaptainController.isActive
|
||||
? 'Connected'.tr
|
||||
: 'Not Connected'.tr),
|
||||
onPressed: homeCaptainController.onButtonSelected,
|
||||
color: homeCaptainController.isActive
|
||||
? CupertinoColors.activeGreen
|
||||
: CupertinoColors.inactiveGray,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ import '../../main.dart';
|
||||
import '../../models/model/locations.dart';
|
||||
|
||||
class MapController extends GetxController {
|
||||
bool isloading = true;
|
||||
bool isLoading = true;
|
||||
TextEditingController placeController = TextEditingController();
|
||||
List data = [];
|
||||
List<LatLng> bounds = [];
|
||||
List places = [];
|
||||
LatLngBounds? boundsdata;
|
||||
List<Marker> markers = [];
|
||||
List<Polyline> polylines = [];
|
||||
late LatLng mylocation;
|
||||
late LatLng newMylocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||
List<Polyline> polyLines = [];
|
||||
late LatLng myLocation;
|
||||
late LatLng newMyLocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng myDestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
List<LatLng> carsLocationByPassenger = [];
|
||||
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
|
||||
@@ -43,17 +43,17 @@ class MapController extends GetxController {
|
||||
double mainBottomMenuMap = Get.height * .2;
|
||||
bool heightMenuBool = false;
|
||||
bool isPickerShown = false;
|
||||
bool isButtomSheetShown = false;
|
||||
bool isBottomSheetShown = false;
|
||||
bool mapType = false;
|
||||
bool mapTraficON = false;
|
||||
bool mapTrafficON = false;
|
||||
bool isCancelRidePageShown = false;
|
||||
bool isCashConfirmPageShown = false;
|
||||
bool isPaymentMethodPageShown = false;
|
||||
bool rideConfirm = false;
|
||||
bool isMainBottomMenuMap = true;
|
||||
double heightButtomSheetShown = 0;
|
||||
double heightBottomSheetShown = 0;
|
||||
double cashConfirmPageShown = 250;
|
||||
double widthMapTypeAndTrafic = 50;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
double paymentPageShown = Get.height * .6;
|
||||
late LatLng southwest;
|
||||
late LatLng northeast;
|
||||
@@ -65,18 +65,21 @@ class MapController extends GetxController {
|
||||
bool shouldFetch = true; // Flag to determine if fetch should be executed
|
||||
int selectedPassengerCount = 1;
|
||||
double progress = 0;
|
||||
double progressTimerToPassengerFromDriverAfterApplied = 0;
|
||||
int durationTimer = 25;
|
||||
int remainingTime = 25;
|
||||
|
||||
int remainingTimeToPassengerFromDriverAfterApplied = 60;
|
||||
int timeToPassengerFromDriverAfterApplied = 0;
|
||||
Timer? timerToPassengerFromDriverAfterApplied;
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
selectedPassengerCount = newValue;
|
||||
update();
|
||||
}
|
||||
|
||||
// final mainBottomMenuMap = GlobalKey<AnimatedContainer>();
|
||||
void changeButtomSheetShown() {
|
||||
isButtomSheetShown = !isButtomSheetShown;
|
||||
heightButtomSheetShown = isButtomSheetShown == true ? 250 : 0;
|
||||
void changeBottomSheetShown() {
|
||||
isBottomSheetShown = !isBottomSheetShown;
|
||||
heightBottomSheetShown = isBottomSheetShown == true ? 250 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -99,7 +102,7 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void changeMapTraffic() {
|
||||
mapTraficON = !mapTraficON;
|
||||
mapTrafficON = !mapTrafficON;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -113,12 +116,35 @@ class MapController extends GetxController {
|
||||
|
||||
void getDrawerMenu() {
|
||||
heightMenuBool = !heightMenuBool;
|
||||
widthMapTypeAndTrafic = heightMenuBool == true ? 0 : 50;
|
||||
widthMapTypeAndTraffic = heightMenuBool == true ? 0 : 50;
|
||||
heightMenu = heightMenuBool == true ? 100 : 0;
|
||||
widthMenu = heightMenuBool == true ? 110 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void startTimerToPassengerFromDriverAfterApplied() async {
|
||||
for (int i = 0; i <= timeToPassengerFromDriverAfterApplied; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressTimerToPassengerFromDriverAfterApplied =
|
||||
i / timeToPassengerFromDriverAfterApplied;
|
||||
remainingTimeToPassengerFromDriverAfterApplied =
|
||||
timeToPassengerFromDriverAfterApplied - i;
|
||||
update();
|
||||
if (remainingTimeToPassengerFromDriverAfterApplied == 0) {
|
||||
driverArrivePassenger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void driverArrivePassenger() {
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void cancelTimerToPassengerFromDriverAfterApplied() {
|
||||
timerToPassengerFromDriverAfterApplied?.cancel();
|
||||
}
|
||||
|
||||
void clearPlaces() {
|
||||
places = [];
|
||||
update();
|
||||
@@ -133,18 +159,20 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
var rideId;
|
||||
int carsOrder = 0;
|
||||
changeConfirmRide() async {
|
||||
rideConfirm = true;
|
||||
shouldFetch = true;
|
||||
timeToPassengerFromDriverAfterApplied = 60;
|
||||
update();
|
||||
// print('rideConfirm= $rideConfirm');
|
||||
|
||||
await getCarsLocationByPassenger();
|
||||
await CRUD().post(link: AppLink.addRides, payload: {
|
||||
"start_location": '${data[0]['start_address']}',
|
||||
// '${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location": '${data[0]['end_address']}',
|
||||
// '${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
"start_location": //'${data[0]['start_address']}',
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
"end_location": //'${data[0]['end_address']}',
|
||||
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"endtime": durationToAdd.toString(),
|
||||
@@ -153,7 +181,7 @@ class MapController extends GetxController {
|
||||
"driver_id": dataCarsLocationByPassenger['message'][0]['id'].toString(),
|
||||
"status": "waiting",
|
||||
"price_for_driver": totalDriver.toString(),
|
||||
"price_for_passenger": totaME.toString(),
|
||||
"price_for_passenger": totalME.toString(),
|
||||
"distance": distance.toString()
|
||||
}).then((value) {
|
||||
// print(jsonDecode(value)['message']);
|
||||
@@ -168,18 +196,18 @@ class MapController extends GetxController {
|
||||
totalDriver.toString(),
|
||||
duration.toString(),
|
||||
distance.toString(),
|
||||
dataCarsLocationByPassenger['message'][0]['id'].toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['id'].toString(),
|
||||
box.read(BoxName.pasengerID).toString(),
|
||||
box.read(BoxName.name).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
duratioByPassenger.toString(),
|
||||
durationByPassenger.toString(),
|
||||
distanceByPassenger.toString(),
|
||||
];
|
||||
FirebasMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
jsonDecode(value)['message'].toString(),
|
||||
dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['token'].toString(),
|
||||
body,
|
||||
);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
@@ -202,12 +230,15 @@ class MapController extends GetxController {
|
||||
var decod = jsonDecode(res);
|
||||
print(' 0000000000000000000000000000000000000000000000000');
|
||||
print(decod['data']);
|
||||
if (decod['data'].toString() == 'Apply' ||
|
||||
decod['data'].toString() == 'Refused') {
|
||||
if (decod['data'].toString() == 'Apply') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
rideConfirm = false;
|
||||
update();
|
||||
startTimer();
|
||||
} else if (decod['data'].toString() == 'Refused') {
|
||||
carsOrder++;
|
||||
update();
|
||||
changeConfirmRide();
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
@@ -224,6 +255,13 @@ class MapController extends GetxController {
|
||||
remainingTime = durationTimer - i;
|
||||
if (remainingTime == 0) {
|
||||
rideConfirm = false;
|
||||
// print(timeToPassengerFromDriverAfterApplied);
|
||||
timeToPassengerFromDriverAfterApplied += duration1;
|
||||
// print(duration1);
|
||||
|
||||
// print('timeToPassengerFromDriverAfterApplied====' +
|
||||
// timeToPassengerFromDriverAfterApplied.toString());
|
||||
startTimerToPassengerFromDriverAfterApplied();
|
||||
update();
|
||||
}
|
||||
update();
|
||||
@@ -234,7 +272,7 @@ class MapController extends GetxController {
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
|
||||
runEvery50SecondsUntilConditionMet();
|
||||
runEvery30SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
update();
|
||||
}
|
||||
@@ -249,7 +287,7 @@ class MapController extends GetxController {
|
||||
Future getCarsLocationByPassenger() async {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds =
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 8000);
|
||||
calculateBounds(myLocation.latitude, myLocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
@@ -293,21 +331,22 @@ class MapController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
|
||||
payload: {
|
||||
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
|
||||
'driver_id': dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driver_id']
|
||||
});
|
||||
|
||||
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
|
||||
|
||||
driverCarsLocationToPassengerAfterApplied.add(LatLng(
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude'])));
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message']
|
||||
[carsOrder]['longitude'])));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future runEvery50SecondsUntilConditionMet() async {
|
||||
Future runEvery30SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 60;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
@@ -316,7 +355,7 @@ class MapController extends GetxController {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
30)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
@@ -353,7 +392,7 @@ class MapController extends GetxController {
|
||||
|
||||
if (rideConfirm == false) {
|
||||
clearPlaces();
|
||||
clearpolyline();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
rideConfirm = false;
|
||||
@@ -361,7 +400,7 @@ class MapController extends GetxController {
|
||||
update();
|
||||
} else {
|
||||
clearPlaces();
|
||||
clearpolyline();
|
||||
clearPolyline();
|
||||
data = [];
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
@@ -417,7 +456,7 @@ class MapController extends GetxController {
|
||||
Future getPlaces() async {
|
||||
var url =
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${mylocation.latitude},${mylocation.longitude}&radius=50000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -433,8 +472,8 @@ class MapController extends GetxController {
|
||||
return LatLng(lat, lng);
|
||||
}
|
||||
|
||||
void clearpolyline() {
|
||||
polylines = [];
|
||||
void clearPolyline() {
|
||||
polyLines = [];
|
||||
polylineCoordinates.clear();
|
||||
update();
|
||||
}
|
||||
@@ -452,8 +491,8 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
size: Size(50, 50),
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: Size(Get.width * .6, Get.height * .6),
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
|
||||
@@ -464,7 +503,7 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
isloading = true;
|
||||
isLoading = true;
|
||||
update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
@@ -494,7 +533,7 @@ class MapController extends GetxController {
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
mylocation =
|
||||
myLocation =
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
@@ -504,7 +543,7 @@ class MapController extends GetxController {
|
||||
print('Latitude: ${_locationData.latitude}');
|
||||
print('Longitude: ${_locationData.longitude}');
|
||||
print('Time: ${_locationData.time}');
|
||||
isloading = false;
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -530,15 +569,21 @@ class MapController extends GetxController {
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(mylocation),
|
||||
CameraUpdate.newLatLng(myLocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
// void startMarkerReloading() {
|
||||
// int count = 0;
|
||||
// markerReloadingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
|
||||
// print('timer==============================');
|
||||
// reloadMarkers();
|
||||
//
|
||||
// count++;
|
||||
// if (count == 10) {
|
||||
// timer.cancel();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@@ -547,7 +592,7 @@ class MapController extends GetxController {
|
||||
late int duration1;
|
||||
void startMarkerReloading() {
|
||||
// Schedule timer 1 to reload markers at a specific time
|
||||
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 30));
|
||||
DateTime scheduledTime1 = DateTime.now().add(const Duration(seconds: 20));
|
||||
markerReloadingTimer1 =
|
||||
Timer(scheduledTime1.difference(DateTime.now()), () {
|
||||
print('timer 1 ==============================');
|
||||
@@ -555,7 +600,7 @@ class MapController extends GetxController {
|
||||
});
|
||||
|
||||
// Schedule timer 2 to reload markers at a specific time
|
||||
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 60));
|
||||
DateTime scheduledTime2 = DateTime.now().add(const Duration(seconds: 40));
|
||||
markerReloadingTimer2 =
|
||||
Timer(scheduledTime2.difference(DateTime.now()), () {
|
||||
print('timer 2 ==============================');
|
||||
@@ -564,11 +609,15 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
void reloadMarkers() async {
|
||||
//TODO await getCarsLocationByPassenger();
|
||||
await getCarsLocationByPassenger();
|
||||
|
||||
// Clear existing markers
|
||||
// mapController!.showMarkerInfoWindow(MarkerId('g'));
|
||||
markers.clear();
|
||||
update();
|
||||
// if (rideConfirm) {
|
||||
getNearestDriverByPassengerLocation();
|
||||
// }
|
||||
// Add new markers
|
||||
// Example: Add a marker for each item in a list
|
||||
for (var item in carsLocationByPassenger) {
|
||||
@@ -583,16 +632,17 @@ class MapController extends GetxController {
|
||||
|
||||
// Update the map with the new markers
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(
|
||||
LatLng(mylocation.latitude, mylocation.longitude)));
|
||||
LatLng(myLocation.latitude, myLocation.longitude)));
|
||||
}
|
||||
|
||||
String duratioByPassenger = '';
|
||||
String durationByPassenger = '';
|
||||
late DateTime newTime1 = DateTime.now();
|
||||
late DateTime timeFromDriverToPassenger = DateTime.now();
|
||||
String distanceByPassenger = '';
|
||||
late Duration durationfromDriverToPassenger;
|
||||
late Duration durationFromDriverToPassenger;
|
||||
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
if (polylines.isEmpty || data.isEmpty) {
|
||||
if (polyLines.isEmpty || data.isEmpty) {
|
||||
double nearestDistance = double.infinity;
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
var carLocation = dataCarsLocationByPassenger['message'][i];
|
||||
@@ -617,7 +667,7 @@ class MapController extends GetxController {
|
||||
update();
|
||||
// Make API request to get exact distance and duration
|
||||
String apiUrl =
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${mylocation.latitude},${mylocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${myLocation.latitude},${myLocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
|
||||
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
||||
if (response['status'] == "OK") {
|
||||
var data = response;
|
||||
@@ -626,9 +676,11 @@ class MapController extends GetxController {
|
||||
distanceByPassenger =
|
||||
data['rows'][0]['elements'][0]['distance']['text'];
|
||||
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
||||
durationfromDriverToPassenger = Duration(seconds: duration1.toInt());
|
||||
newTime1 = currentTime.add(durationfromDriverToPassenger);
|
||||
duratioByPassenger =
|
||||
durationFromDriverToPassenger = Duration(seconds: duration1.toInt());
|
||||
newTime1 = currentTime.add(durationFromDriverToPassenger);
|
||||
timeFromDriverToPassenger =
|
||||
newTime1.add(Duration(minutes: 2.toInt()));
|
||||
durationByPassenger =
|
||||
data['rows'][0]['elements'][0]['duration']['text'];
|
||||
update();
|
||||
if (distance1 < nearestDistance) {
|
||||
@@ -665,9 +717,9 @@ class MapController extends GetxController {
|
||||
getMap(String origin, destination) async {
|
||||
var origin1 = fromString(origin);
|
||||
var destination1 = fromString(destination);
|
||||
isloading = false;
|
||||
mydestination = destination1;
|
||||
mylocation = origin1;
|
||||
isLoading = false;
|
||||
myDestination = destination1;
|
||||
myLocation = origin1;
|
||||
update();
|
||||
await getCarsLocationByPassenger();
|
||||
// print(carsLocationByPassenger);
|
||||
@@ -703,20 +755,20 @@ class MapController extends GetxController {
|
||||
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 5) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 13));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 7));
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
||||
}
|
||||
if (polylines.isNotEmpty) {
|
||||
clearpolyline();
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
@@ -725,7 +777,7 @@ class MapController extends GetxController {
|
||||
color: Colors.blue,
|
||||
);
|
||||
|
||||
polylines.add(polyline);
|
||||
polyLines.add(polyline);
|
||||
rideConfirm = false;
|
||||
update();
|
||||
}
|
||||
@@ -733,15 +785,15 @@ class MapController extends GetxController {
|
||||
|
||||
showBottomSheet1() async {
|
||||
bottomSheet();
|
||||
isButtomSheetShown = true;
|
||||
heightButtomSheetShown = 250;
|
||||
isBottomSheetShown = true;
|
||||
heightBottomSheetShown = 250;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
final promo = TextEditingController();
|
||||
bool promoTaken = false;
|
||||
void applyPromoCodetoPassenger() async {
|
||||
void applyPromoCodeToPassenger() async {
|
||||
//TAWJIHI
|
||||
|
||||
CRUD().get(link: AppLink.getPassengersPromo, payload: {
|
||||
@@ -758,11 +810,11 @@ class MapController extends GetxController {
|
||||
},
|
||||
));
|
||||
}
|
||||
var decod = jsonDecode(value);
|
||||
var decode = jsonDecode(value);
|
||||
|
||||
if (decod["status"] == "success") {
|
||||
if (decode["status"] == "success") {
|
||||
print(totalPassenger);
|
||||
var firstElement = decod["message"][0];
|
||||
var firstElement = decode["message"][0];
|
||||
totalPassenger = totalPassenger -
|
||||
(totalPassenger * int.parse(firstElement['amount']) / 100);
|
||||
promoTaken = true;
|
||||
@@ -783,7 +835,7 @@ class MapController extends GetxController {
|
||||
return distance;
|
||||
}
|
||||
|
||||
late double totaME = 0;
|
||||
late double totalME = 0;
|
||||
late double tax = 0;
|
||||
late double totalPassenger = 0;
|
||||
late double totalDriver = 0;
|
||||
@@ -811,7 +863,7 @@ class MapController extends GetxController {
|
||||
totalDriver = cost + costDuration;
|
||||
totalPassenger = totalDriver + (totalDriver * .16);
|
||||
tax = totalPassenger * .04;
|
||||
totaME = totalPassenger - totalDriver - tax;
|
||||
totalME = totalPassenger - totalDriver - tax;
|
||||
update();
|
||||
if (currentTime.hour >= 21) {
|
||||
if (distanceText.contains('km')) {
|
||||
@@ -862,17 +914,17 @@ class MapController extends GetxController {
|
||||
update();
|
||||
if (totalDriver < .5) {
|
||||
totalDriver = .85;
|
||||
totaME = .11;
|
||||
totalME = .11;
|
||||
update();
|
||||
} else {
|
||||
totalDriver = .95;
|
||||
totaME = .05;
|
||||
totalME = .05;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// buttomSheetMapPage();
|
||||
changeButtomSheetShown();
|
||||
changeBottomSheetShown();
|
||||
}
|
||||
|
||||
// Get.bottomSheet(
|
||||
|
||||
@@ -24,7 +24,7 @@ class DbSql {
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ${TableName.carLocations}(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
driver_id INTEGER,
|
||||
driver_id TEXT,
|
||||
latitude REAL,
|
||||
longitude REAL,
|
||||
created_at TEXT,
|
||||
@@ -40,6 +40,14 @@ class DbSql {
|
||||
rate TEXT
|
||||
)
|
||||
''');
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ${TableName.driverOrdersRefuse}(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
order_id TEXT,
|
||||
created_at TEXT,
|
||||
driver_id TEXT
|
||||
)
|
||||
''');
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -49,6 +57,11 @@ class DbSql {
|
||||
return await db.query(table);
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getCustomQuery(String query) async {
|
||||
Database db = await instance.database;
|
||||
return await db.rawQuery(query);
|
||||
}
|
||||
|
||||
Future<int> insertData(Map<String, dynamic> map, String table) async {
|
||||
Database db = await instance.database;
|
||||
return await db.insert(table, map);
|
||||
@@ -64,4 +77,9 @@ class DbSql {
|
||||
Database db = await instance.database;
|
||||
return await db.delete(table, where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
Future<int> deleteAllData(String table) async {
|
||||
Database db = await instance.database;
|
||||
return await db.delete(table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:ride/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/widgets/circle_container.dart';
|
||||
|
||||
import '../../../controller/functions/location_controller.dart';
|
||||
import '../../../controller/home/captin/widget/connect.dart';
|
||||
@@ -15,7 +19,8 @@ class HomeCaptain extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(LocationController());
|
||||
|
||||
final OrderRequestController orderRequestController =
|
||||
Get.put(OrderRequestController());
|
||||
Get.put(HomeCaptainController());
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -31,8 +36,21 @@ class HomeCaptain extends StatelessWidget {
|
||||
: const SizedBox(),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => box.remove(BoxName.periods),
|
||||
icon: Icon(Icons.remove))
|
||||
// onPressed: () => box.remove(BoxName.periods),
|
||||
onPressed: () => sql.deleteAllData(TableName.driverOrdersRefuse),
|
||||
icon: const Icon(Icons.remove)),
|
||||
GetBuilder<OrderRequestController>(
|
||||
builder: (orderRequestController) => IconButton(
|
||||
onPressed: () =>
|
||||
orderRequestController.getRefusedOrderByCaptain(),
|
||||
icon: const Icon(Icons.get_app)),
|
||||
),
|
||||
GetBuilder<OrderRequestController>(
|
||||
builder: (orderRequestController) => MyCircleContainer(
|
||||
child: Text(
|
||||
orderRequestController.countRefuse.toString(),
|
||||
style: AppStyle.title,
|
||||
)))
|
||||
],
|
||||
),
|
||||
drawer: const Drawer(),
|
||||
@@ -94,7 +112,7 @@ class HomeCaptain extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'map_widget.dart/map_menu_widget.dart';
|
||||
import 'map_widget.dart/menu_map_page.dart';
|
||||
import 'map_widget.dart/payment_method.page.dart';
|
||||
import 'map_widget.dart/timer_for_cancell_trip_from_passenger.dart';
|
||||
import 'map_widget.dart/timer_to_passenger_from_driver.dart';
|
||||
|
||||
class MapPage extends StatelessWidget {
|
||||
const MapPage({super.key});
|
||||
@@ -64,7 +65,7 @@ class MapPage extends StatelessWidget {
|
||||
child: Stack(
|
||||
children: [
|
||||
GetBuilder<MapController>(
|
||||
builder: (controller) => controller.isloading
|
||||
builder: (controller) => controller.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: GoogleMap(
|
||||
onMapCreated: controller.onMapCreated,
|
||||
@@ -83,11 +84,11 @@ class MapPage extends StatelessWidget {
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () async {
|
||||
controller.clearpolyline();
|
||||
controller.clearPolyline();
|
||||
if (controller.dataCarsLocationByPassenger !=
|
||||
null) {
|
||||
await controller.getMap(
|
||||
'${controller.mylocation.latitude},${controller.mylocation.longitude}',
|
||||
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
|
||||
'${argument.latitude.toString()},${argument.longitude.toString()}');
|
||||
|
||||
Get.back();
|
||||
@@ -182,11 +183,11 @@ class MapPage extends StatelessWidget {
|
||||
onTap: (argument) {
|
||||
controller.hidePlaces();
|
||||
|
||||
controller.changeButtomSheetShown();
|
||||
controller.changeBottomSheetShown();
|
||||
// controller.bottomSheet();
|
||||
},
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: controller.mylocation,
|
||||
target: controller.myLocation,
|
||||
zoom: 15,
|
||||
),
|
||||
markers: {
|
||||
@@ -206,22 +207,27 @@ class MapPage extends StatelessWidget {
|
||||
markerId: MarkerId(carLocation.toString())),
|
||||
Marker(
|
||||
markerId: MarkerId('MyLocation'.tr),
|
||||
position: controller.mylocation,
|
||||
position: controller.myLocation,
|
||||
draggable: true,
|
||||
icon: controller.markerIcon,
|
||||
infoWindow: InfoWindow(
|
||||
title: 'Time',
|
||||
snippet: controller.durationFromDriverToPassenger
|
||||
.toString(),
|
||||
),
|
||||
onDragEnd: (value) {
|
||||
print(value);
|
||||
},
|
||||
infoWindow: InfoWindow(title: 'my location'.tr),
|
||||
),
|
||||
Marker(
|
||||
markerId: MarkerId('Target'.tr),
|
||||
position: controller.mydestination,
|
||||
draggable: true,
|
||||
onDragEnd: (v) {
|
||||
print(v);
|
||||
},
|
||||
// infoWindow: InfoWindow(title: 'my location'.tr),
|
||||
),
|
||||
// Marker(
|
||||
// markerId: MarkerId('Target'.tr),
|
||||
// position: controller.myDestination,
|
||||
// draggable: true,
|
||||
// onDragEnd: (v) {
|
||||
// print(v);
|
||||
// },
|
||||
// ),
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
@@ -261,6 +267,18 @@ class MapPage extends StatelessWidget {
|
||||
// radius: 60,
|
||||
// fillColor: AppColor.primaryColor,)
|
||||
// },
|
||||
|
||||
circles: <Circle>{
|
||||
Circle(
|
||||
circleId: const CircleId('circle_id'),
|
||||
center: controller.myLocation,
|
||||
radius: 100,
|
||||
fillColor: Colors.blue.withOpacity(0.3),
|
||||
strokeColor: Colors.blue,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
},
|
||||
|
||||
mapType: controller.mapType
|
||||
? MapType.satellite
|
||||
: MapType.normal,
|
||||
@@ -268,11 +286,11 @@ class MapPage extends StatelessWidget {
|
||||
// liteModeEnabled: true, tiltGesturesEnabled: false,
|
||||
|
||||
// indoorViewEnabled: true,
|
||||
trafficEnabled: controller.mapTraficON,
|
||||
trafficEnabled: controller.mapTrafficON,
|
||||
buildingsEnabled: true,
|
||||
mapToolbarEnabled: true,
|
||||
onCameraMove: (position) {
|
||||
controller.newMylocation = position.target;
|
||||
controller.newMyLocation = position.target;
|
||||
// print('my' + controller.mylocation.toString());
|
||||
// print('new' + controller.newMylocation.toString());
|
||||
},
|
||||
@@ -292,34 +310,9 @@ class MapPage extends StatelessWidget {
|
||||
const CancelRidePageShow(),
|
||||
const CashConfirmPageShown(),
|
||||
const PaymentMethodPage(),
|
||||
timerForCancellTripFromPassenger(),
|
||||
const DriverTimeArrivePassengerPage(),
|
||||
GetBuilder<MapController>(builder: (controller) {
|
||||
if (controller.remainingTime == 0
|
||||
//&&
|
||||
// controller.newTime1.isBefore(
|
||||
// controller.currentTime.add(const Duration(minutes: 2)),
|
||||
// )
|
||||
) {
|
||||
return Center(
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
// height: 100,
|
||||
// width: 100,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'You Can cancel Ride After Captain did not come in the time'
|
||||
.tr,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
}),
|
||||
timerForCancelTripFromPassenger(),
|
||||
// const DriverTimeArrivePassengerPage(),
|
||||
const TimerToPassengerFromDriver(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -336,7 +329,8 @@ class CancelRidePageShow extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MapController>(
|
||||
builder: (controller) =>
|
||||
controller.data.isNotEmpty && controller.remainingTime > 0
|
||||
(controller.data.isNotEmpty && controller.remainingTime > 0) ||
|
||||
controller.timeToPassengerFromDriverAfterApplied == 0
|
||||
? Positioned.directional(
|
||||
end: 10,
|
||||
top: 55,
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../../../controller/home/map_page_controller.dart';
|
||||
GetBuilder<MapController> buttomSheetMapPage() {
|
||||
Get.put(PaymentController());
|
||||
return GetBuilder<MapController>(
|
||||
builder: (controller) => controller.isButtomSheetShown
|
||||
builder: (controller) => controller.isBottomSheetShown
|
||||
? Positioned(
|
||||
left: 5,
|
||||
bottom: 0,
|
||||
@@ -23,7 +23,7 @@ GetBuilder<MapController> buttomSheetMapPage() {
|
||||
onEnd: () {
|
||||
controller.height = 250;
|
||||
},
|
||||
height: controller.heightButtomSheetShown,
|
||||
height: controller.heightBottomSheetShown,
|
||||
duration: const Duration(seconds: 2),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -283,7 +283,7 @@ GetBuilder<MapController> buttomSheetMapPage() {
|
||||
'Add Promo'.tr,
|
||||
onPressed:
|
||||
() async {
|
||||
controller.applyPromoCodetoPassenger();
|
||||
controller.applyPromoCodeToPassenger();
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -508,7 +508,7 @@ class Details extends StatelessWidget {
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Text(
|
||||
'totaME ${controller.totaME.toStringAsFixed(2)} ',
|
||||
'totaME ${controller.totalME.toStringAsFixed(2)} ',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -30,7 +30,7 @@ class DriverTimeArrivePassengerPage extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
controller.duratioByPassenger.toString() +
|
||||
controller.durationByPassenger.toString() +
|
||||
' to arrive you.'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
|
||||
@@ -63,10 +63,10 @@ GetBuilder<MapController> formSearchPlaces() {
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Confirm'.tr,
|
||||
onPressed: () async {
|
||||
controller.clearpolyline();
|
||||
controller.clearPolyline();
|
||||
controller.data = [];
|
||||
await controller.getMap(
|
||||
'${controller.mylocation.latitude.toString()},${controller.mylocation.longitude.toString()}',
|
||||
'${controller.myLocation.latitude.toString()},${controller.myLocation.longitude.toString()}',
|
||||
"${res['geometry']['location']['lat']},${res['geometry']['location']['lng']}");
|
||||
controller.places = [];
|
||||
controller.placeController.clear();
|
||||
|
||||
@@ -13,7 +13,7 @@ GetBuilder<MapController> leftMainMenuIcons() {
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTrafic,
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
color: AppColor.secondaryColor,
|
||||
@@ -34,7 +34,7 @@ GetBuilder<MapController> leftMainMenuIcons() {
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTrafic,
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
border: Border.all(),
|
||||
|
||||
@@ -104,7 +104,7 @@ class MainBottomMenuMap extends StatelessWidget {
|
||||
child: Text(
|
||||
(controller.nearestCar != null
|
||||
? controller
|
||||
.duratioByPassenger
|
||||
.durationByPassenger
|
||||
.toString()
|
||||
: 'N/A')),
|
||||
),
|
||||
@@ -195,7 +195,7 @@ class FavioratePlacesDialogu extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await controller.getMap(
|
||||
'${controller.mylocation.latitude},${controller.mylocation.longitude}',
|
||||
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
|
||||
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
|
||||
);
|
||||
// controller.changePickerShown();
|
||||
|
||||
@@ -135,13 +135,13 @@ class PickerAnimtionContainerFormPlaces extends StatelessWidget {
|
||||
onPressed: () async {
|
||||
await controller
|
||||
.getMap(
|
||||
'${controller.mylocation.latitude},${controller.mylocation.longitude}',
|
||||
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
|
||||
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
|
||||
);
|
||||
controller
|
||||
.changePickerShown();
|
||||
controller
|
||||
.changeButtomSheetShown();
|
||||
.changeBottomSheetShown();
|
||||
controller
|
||||
.bottomSheet();
|
||||
Get.back();
|
||||
@@ -193,11 +193,11 @@ class PickerAnimtionContainerFormPlaces extends StatelessWidget {
|
||||
title: 'Go to this Target'.tr,
|
||||
onPressed: () async {
|
||||
await controller.getMap(
|
||||
'${controller.mylocation.latitude},${controller.mylocation.longitude}',
|
||||
'${controller.newMylocation.latitude},${controller.newMylocation.longitude}',
|
||||
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
|
||||
'${controller.newMyLocation.latitude},${controller.newMyLocation.longitude}',
|
||||
);
|
||||
controller.changePickerShown();
|
||||
controller.changeButtomSheetShown();
|
||||
controller.changeBottomSheetShown();
|
||||
controller.bottomSheet();
|
||||
// await sql
|
||||
// .getAllData(TableName.placesFavorite)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/views/home/map_page.dart';
|
||||
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/home/map_page_controller.dart';
|
||||
|
||||
GetBuilder<MapController> timerForCancellTripFromPassenger() {
|
||||
GetBuilder<MapController> timerForCancelTripFromPassenger() {
|
||||
return GetBuilder<MapController>(
|
||||
builder: (controller) {
|
||||
final isNearEnd =
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/home/map_page_controller.dart';
|
||||
|
||||
class TimerToPassengerFromDriver extends StatelessWidget {
|
||||
const TimerToPassengerFromDriver({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MapController>(builder: (controller) {
|
||||
if (controller.remainingTime == 0 &&
|
||||
controller.timeToPassengerFromDriverAfterApplied > 60) {
|
||||
return Positioned(
|
||||
left: 10,
|
||||
right: 10,
|
||||
bottom: Get.height * .35,
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration,
|
||||
height: 140,
|
||||
// width: 100,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'You Can cancel Ride After Captain did not come in the time'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
LinearProgressIndicator(
|
||||
backgroundColor: AppColor.accentColor,
|
||||
color:
|
||||
controller.timeToPassengerFromDriverAfterApplied <
|
||||
60
|
||||
? AppColor.redColor
|
||||
: AppColor.greenColor,
|
||||
minHeight: 50,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
value: controller
|
||||
.progressTimerToPassengerFromDriverAfterApplied
|
||||
.toDouble(),
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
controller
|
||||
.remainingTimeToPassengerFromDriverAfterApplied
|
||||
.toString(),
|
||||
style: AppStyle.title,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import 'package:ride/views/widgets/my_scafold.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../constant/table_names.dart';
|
||||
import '../../controller/functions/crud.dart';
|
||||
import '../../controller/functions/launch.dart';
|
||||
import '../../controller/home/captin/order_request_controller.dart';
|
||||
@@ -15,14 +16,15 @@ import '../widgets/elevated_btn.dart';
|
||||
|
||||
class OrderRequestPage extends StatelessWidget {
|
||||
OrderRequestPage({super.key});
|
||||
TimerController timerController = Get.put(TimerController());
|
||||
OrderRequestController orderRequestController =
|
||||
Get.put(OrderRequestController());
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final arguments = Get.arguments;
|
||||
final myListString = arguments['myListString'];
|
||||
final myList = arguments['DriverList'];
|
||||
final body = arguments['body'];
|
||||
|
||||
orderRequestController.startTimer(myList[6].toString(), body.toString());
|
||||
return MyScafolld(
|
||||
title: 'Order Request Page',
|
||||
body: [
|
||||
@@ -147,6 +149,7 @@ class OrderRequestPage extends StatelessWidget {
|
||||
MyElevatedButton(
|
||||
title: 'Apply Order'.tr,
|
||||
onPressed: () async {
|
||||
orderRequestController.changeApplied();
|
||||
await CRUD().postFromDialogue(
|
||||
link: AppLink.addDriverOrder,
|
||||
payload: {
|
||||
@@ -161,7 +164,7 @@ class OrderRequestPage extends StatelessWidget {
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
box.read(BoxName.tokenDriver).toString(),
|
||||
];
|
||||
print(bodyToPassenger);
|
||||
// print(bodyToPassenger);
|
||||
FirebasMessagesController()
|
||||
.sendNotificanToPassengerToken(
|
||||
'Apply Ride',
|
||||
@@ -170,10 +173,10 @@ class OrderRequestPage extends StatelessWidget {
|
||||
// box.read(BoxName.tokenDriver).toString(),
|
||||
bodyToPassenger,
|
||||
);
|
||||
Get.back();
|
||||
Get.back(); //todo go to passenger
|
||||
},
|
||||
),
|
||||
GetBuilder<TimerController>(
|
||||
GetBuilder<OrderRequestController>(
|
||||
builder: (timerController) {
|
||||
final isNearEnd = timerController.remainingTime <=
|
||||
5; // Define a threshold for "near end"
|
||||
@@ -202,8 +205,9 @@ class OrderRequestPage extends StatelessWidget {
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
box.read(BoxName.tokenDriver).toString(),
|
||||
];
|
||||
timerController.refuseOrder(
|
||||
orderRequestController.refuseOrder(
|
||||
myList[6].toString(), body.toString());
|
||||
|
||||
FirebasMessagesController()
|
||||
.sendNotificanToPassengerToken(
|
||||
'Refused Ride',
|
||||
|
||||
Reference in New Issue
Block a user