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