7/23/2
This commit is contained in:
@@ -133,6 +133,11 @@ class AppLink {
|
|||||||
"$ride/RegisrationCar/selectDriverAndCarForMishwariTrip.php";
|
"$ride/RegisrationCar/selectDriverAndCarForMishwariTrip.php";
|
||||||
static String updateRegisrationCar = "$ride/RegisrationCar/update.php";
|
static String updateRegisrationCar = "$ride/RegisrationCar/update.php";
|
||||||
|
|
||||||
|
//-----------------mishwari------------------
|
||||||
|
|
||||||
|
static String addMishwari = "$ride/mishwari/add.php";
|
||||||
|
static String getMishwari = "$ride/mishwari/get.php";
|
||||||
|
|
||||||
//-----------------DriverOrder------------------
|
//-----------------DriverOrder------------------
|
||||||
|
|
||||||
static String addDriverOrder = "$ride/driver_order/add.php";
|
static String addDriverOrder = "$ride/driver_order/add.php";
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:SEFER/views/home/HomePage/trip_monitor/trip_monitor.dart';
|
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -16,7 +15,6 @@ import '../../constant/style.dart';
|
|||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
import '../../views/Rate/rate_captain.dart';
|
import '../../views/Rate/rate_captain.dart';
|
||||||
import '../../views/home/map_page_passenger.dart';
|
import '../../views/home/map_page_passenger.dart';
|
||||||
import '../../views/home/map_widget.dart/call_passenger_page.dart';
|
|
||||||
import '../../views/home/profile/promos_passenger_page.dart';
|
import '../../views/home/profile/promos_passenger_page.dart';
|
||||||
import '../auth/google_sign.dart';
|
import '../auth/google_sign.dart';
|
||||||
import '../functions/audio_record1.dart';
|
import '../functions/audio_record1.dart';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math' show cos;
|
import 'dart:math' show cos, pow, sqrt;
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:SEFER/controller/functions/tts.dart';
|
import 'package:SEFER/controller/functions/tts.dart';
|
||||||
@@ -892,33 +892,60 @@ class MapPassengerController extends GetxController {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, double>? extractCoordinatesFromWhatsAppLink(String link) {
|
Map<String, double>? extractCoordinatesFromLink(String link) {
|
||||||
try {
|
try {
|
||||||
|
// Extract the URL part from the link by finding the first occurrence of "http"
|
||||||
|
int urlStartIndex = link.indexOf(RegExp(r'https?://'));
|
||||||
|
if (urlStartIndex == -1) {
|
||||||
|
throw FormatException('No URL found in the provided link.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the URL and clean it
|
||||||
|
link = link.substring(urlStartIndex).trim();
|
||||||
|
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
|
|
||||||
if (uri.host == 'maps.google.com' || uri.host == 'www.google.com') {
|
// Common coordinate query parameters
|
||||||
String? query = uri.queryParameters['q'];
|
List<String> coordinateParams = ['q', 'cp', 'll'];
|
||||||
query ??= uri.queryParameters['ll'];
|
|
||||||
|
|
||||||
if (query != null) {
|
|
||||||
List<String> coordinates = query.split(',');
|
|
||||||
|
|
||||||
|
// Try to extract coordinates from query parameters
|
||||||
|
for (var param in coordinateParams) {
|
||||||
|
String? value = uri.queryParameters[param];
|
||||||
|
if (value != null && (value.contains(',') || value.contains('~'))) {
|
||||||
|
List<String> coordinates =
|
||||||
|
value.contains(',') ? value.split(',') : value.split('~');
|
||||||
if (coordinates.length == 2) {
|
if (coordinates.length == 2) {
|
||||||
double latitude = double.parse(coordinates[0]);
|
double? latitude = double.tryParse(coordinates[0].trim());
|
||||||
double longitude = double.parse(coordinates[1]);
|
double? longitude = double.tryParse(coordinates[1].trim());
|
||||||
|
if (latitude != null && longitude != null) {
|
||||||
return {
|
return {
|
||||||
'latitude': latitude,
|
'latitude': latitude,
|
||||||
'longitude': longitude,
|
'longitude': longitude,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (uri.host == 'goo.gl') {
|
}
|
||||||
// Shortened URLs might need to be expanded first
|
}
|
||||||
// Implement additional logic to expand the URL here if necessary
|
|
||||||
|
// Try to extract coordinates from the path
|
||||||
|
List<String> pathSegments = uri.pathSegments;
|
||||||
|
for (var segment in pathSegments) {
|
||||||
|
if (segment.contains(',')) {
|
||||||
|
List<String> coordinates = segment.split(',');
|
||||||
|
if (coordinates.length == 2) {
|
||||||
|
double? latitude = double.tryParse(coordinates[0].trim());
|
||||||
|
double? longitude = double.tryParse(coordinates[1].trim());
|
||||||
|
if (latitude != null && longitude != null) {
|
||||||
|
return {
|
||||||
|
'latitude': latitude,
|
||||||
|
'longitude': longitude,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error parsing WhatsApp location link: $e');
|
print('Error parsing location link: $e');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -927,7 +954,7 @@ class MapPassengerController extends GetxController {
|
|||||||
double latitudeWhatsApp = 0;
|
double latitudeWhatsApp = 0;
|
||||||
double longitudeWhatsApp = 0;
|
double longitudeWhatsApp = 0;
|
||||||
void handleWhatsAppLink(String link) {
|
void handleWhatsAppLink(String link) {
|
||||||
Map<String, double>? coordinates = extractCoordinatesFromWhatsAppLink(link);
|
Map<String, double>? coordinates = extractCoordinatesFromLink(link);
|
||||||
|
|
||||||
if (coordinates != null) {
|
if (coordinates != null) {
|
||||||
latitudeWhatsApp = coordinates['latitude']!;
|
latitudeWhatsApp = coordinates['latitude']!;
|
||||||
@@ -1289,118 +1316,275 @@ class MapPassengerController extends GetxController {
|
|||||||
late LatLng currentDriverLocation;
|
late LatLng currentDriverLocation;
|
||||||
late double headingList;
|
late double headingList;
|
||||||
|
|
||||||
Future getCarsLocationByPassengerAndReloadMarker() async {
|
// Future getCarsLocationByPassengerAndReloadMarker() async {
|
||||||
|
// if (statusRide == 'wait') {
|
||||||
|
// carsLocationByPassenger = [];
|
||||||
|
// LatLngBounds bounds = calculateBounds(
|
||||||
|
// passengerLocation.latitude, passengerLocation.longitude, 7000);
|
||||||
|
// var res;
|
||||||
|
// if (box.read(BoxName.carType) == 'Lady') {
|
||||||
|
// res = await CRUD()
|
||||||
|
// .get(link: AppLink.getFemalDriverLocationByPassenger, payload: {
|
||||||
|
// 'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
|
// 'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
|
// 'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
|
// 'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
|
// });
|
||||||
|
// } else if (box.read(BoxName.carType) == 'Speed') {
|
||||||
|
// res = await CRUD().get(
|
||||||
|
// link: AppLink.getCarsLocationByPassengerSpeed,
|
||||||
|
// payload: {
|
||||||
|
// 'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
|
// 'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
|
// 'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
|
// 'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// } else if (box.read(BoxName.carType) == 'Delivery') {
|
||||||
|
// res = await CRUD().get(
|
||||||
|
// link: AppLink.getCarsLocationByPassengerDelivery,
|
||||||
|
// payload: {
|
||||||
|
// 'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
|
// 'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
|
// 'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
|
// 'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// res = await CRUD()
|
||||||
|
// .get(link: AppLink.getCarsLocationByPassenger, payload: {
|
||||||
|
// 'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
|
// 'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
|
// 'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
|
// 'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// if (res == 'failure') {
|
||||||
|
// noCarString = true;
|
||||||
|
// dataCarsLocationByPassenger = res;
|
||||||
|
// update();
|
||||||
|
// } else {
|
||||||
|
// // Get.snackbar('no car', 'message');
|
||||||
|
// noCarString = false;
|
||||||
|
// dataCarsLocationByPassenger = jsonDecode(res);
|
||||||
|
// // if (dataCarsLocationByPassenger.length > carsOrder) {
|
||||||
|
// driverId = dataCarsLocationByPassenger['message'][carsOrder]
|
||||||
|
// ['driver_id']
|
||||||
|
// .toString();
|
||||||
|
// gender = dataCarsLocationByPassenger['message'][carsOrder]['gender']
|
||||||
|
// .toString();
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// carsLocationByPassenger.clear(); // Clear existing markers
|
||||||
|
|
||||||
|
// // late LatLng lastDriverLocation; // Initialize a variable for last location
|
||||||
|
|
||||||
|
// for (var i = 0;
|
||||||
|
// i < dataCarsLocationByPassenger['message'].length;
|
||||||
|
// i++) {
|
||||||
|
// var json = dataCarsLocationByPassenger['message'][i];
|
||||||
|
// // CarLocationModel model = CarLocationModel.fromJson(json);
|
||||||
|
// if (carLocationsModels.length < i + 1) {
|
||||||
|
// // carLocationsModels.add(model);
|
||||||
|
// markers.add(
|
||||||
|
// Marker(
|
||||||
|
// markerId: MarkerId(json['latitude']),
|
||||||
|
// position: LatLng(
|
||||||
|
// double.parse(json['latitude']),
|
||||||
|
// double.parse(json['longitude']),
|
||||||
|
// ),
|
||||||
|
// rotation: double.parse(json['heading']),
|
||||||
|
// icon: json['model'].toString().contains('دراجة')
|
||||||
|
// ? motoIcon
|
||||||
|
// : json['gender'] == 'Male'.tr
|
||||||
|
// ? carIcon
|
||||||
|
// : ladyIcon,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// driversToken.add(json['token']);
|
||||||
|
// // driversToken = json['token'];
|
||||||
|
// } else {
|
||||||
|
// // carLocationsModels[i] = model;
|
||||||
|
// markers[i] = Marker(
|
||||||
|
// markerId: MarkerId(json['latitude']),
|
||||||
|
// position: LatLng(
|
||||||
|
// double.parse(json['latitude']),
|
||||||
|
// double.parse(json['longitude']),
|
||||||
|
// ),
|
||||||
|
// rotation: double.parse(json['heading']),
|
||||||
|
// icon: json['model'].contains('دراجة')
|
||||||
|
// ? motoIcon
|
||||||
|
// : json['gender'] == 'Male'.tr
|
||||||
|
// ? carIcon
|
||||||
|
// : ladyIcon,
|
||||||
|
// );
|
||||||
|
// // driversToken = json['token'];
|
||||||
|
// driversToken.add(json['token']);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// update();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
Map<String, Timer> _animationTimers = {};
|
||||||
|
final int updateIntervalMs = 100; // Update every 100ms
|
||||||
|
final double minMovementThreshold =
|
||||||
|
1.0; // Minimum movement in meters to trigger update
|
||||||
|
|
||||||
|
Future<void> getCarsLocationByPassengerAndReloadMarker() async {
|
||||||
if (statusRide == 'wait') {
|
if (statusRide == 'wait') {
|
||||||
carsLocationByPassenger = [];
|
|
||||||
LatLngBounds bounds = calculateBounds(
|
LatLngBounds bounds = calculateBounds(
|
||||||
passengerLocation.latitude, passengerLocation.longitude, 7000);
|
passengerLocation.latitude, passengerLocation.longitude, 7000);
|
||||||
var res;
|
|
||||||
if (box.read(BoxName.carType) == 'Lady') {
|
var res = await _fetchCarLocations(bounds);
|
||||||
res = await CRUD()
|
|
||||||
.get(link: AppLink.getFemalDriverLocationByPassenger, payload: {
|
|
||||||
'southwestLat': bounds.southwest.latitude.toString(),
|
|
||||||
'southwestLon': bounds.southwest.longitude.toString(),
|
|
||||||
'northeastLat': bounds.northeast.latitude.toString(),
|
|
||||||
'northeastLon': bounds.northeast.longitude.toString(),
|
|
||||||
});
|
|
||||||
} else if (box.read(BoxName.carType) == 'Speed') {
|
|
||||||
res = await CRUD().get(
|
|
||||||
link: AppLink.getCarsLocationByPassengerSpeed,
|
|
||||||
payload: {
|
|
||||||
'southwestLat': bounds.southwest.latitude.toString(),
|
|
||||||
'southwestLon': bounds.southwest.longitude.toString(),
|
|
||||||
'northeastLat': bounds.northeast.latitude.toString(),
|
|
||||||
'northeastLon': bounds.northeast.longitude.toString(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else if (box.read(BoxName.carType) == 'Delivery') {
|
|
||||||
res = await CRUD().get(
|
|
||||||
link: AppLink.getCarsLocationByPassengerDelivery,
|
|
||||||
payload: {
|
|
||||||
'southwestLat': bounds.southwest.latitude.toString(),
|
|
||||||
'southwestLon': bounds.southwest.longitude.toString(),
|
|
||||||
'northeastLat': bounds.northeast.latitude.toString(),
|
|
||||||
'northeastLon': bounds.northeast.longitude.toString(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
res = await CRUD()
|
|
||||||
.get(link: AppLink.getCarsLocationByPassenger, payload: {
|
|
||||||
'southwestLat': bounds.southwest.latitude.toString(),
|
|
||||||
'southwestLon': bounds.southwest.longitude.toString(),
|
|
||||||
'northeastLat': bounds.northeast.latitude.toString(),
|
|
||||||
'northeastLon': bounds.northeast.longitude.toString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (res == 'failure') {
|
if (res == 'failure') {
|
||||||
noCarString = true;
|
noCarString = true;
|
||||||
dataCarsLocationByPassenger = res;
|
dataCarsLocationByPassenger = res;
|
||||||
update();
|
|
||||||
} else {
|
} else {
|
||||||
// Get.snackbar('no car', 'message');
|
|
||||||
noCarString = false;
|
noCarString = false;
|
||||||
dataCarsLocationByPassenger = jsonDecode(res);
|
dataCarsLocationByPassenger = jsonDecode(res);
|
||||||
// if (dataCarsLocationByPassenger.length > carsOrder) {
|
|
||||||
driverId = dataCarsLocationByPassenger['message'][carsOrder]
|
driverId = dataCarsLocationByPassenger['message'][carsOrder]
|
||||||
['driver_id']
|
['driver_id']
|
||||||
.toString();
|
.toString();
|
||||||
gender = dataCarsLocationByPassenger['message'][carsOrder]['gender']
|
gender = dataCarsLocationByPassenger['message'][carsOrder]['gender']
|
||||||
.toString();
|
.toString();
|
||||||
// }
|
|
||||||
|
|
||||||
carsLocationByPassenger.clear(); // Clear existing markers
|
_updateMarkers(dataCarsLocationByPassenger['message']);
|
||||||
|
|
||||||
// late LatLng lastDriverLocation; // Initialize a variable for last location
|
|
||||||
|
|
||||||
for (var i = 0;
|
|
||||||
i < dataCarsLocationByPassenger['message'].length;
|
|
||||||
i++) {
|
|
||||||
var json = dataCarsLocationByPassenger['message'][i];
|
|
||||||
// CarLocationModel model = CarLocationModel.fromJson(json);
|
|
||||||
if (carLocationsModels.length < i + 1) {
|
|
||||||
// carLocationsModels.add(model);
|
|
||||||
markers.add(
|
|
||||||
Marker(
|
|
||||||
markerId: MarkerId(json['latitude']),
|
|
||||||
position: LatLng(
|
|
||||||
double.parse(json['latitude']),
|
|
||||||
double.parse(json['longitude']),
|
|
||||||
),
|
|
||||||
rotation: double.parse(json['heading']),
|
|
||||||
icon: json['model'].toString().contains('دراجة')
|
|
||||||
? motoIcon
|
|
||||||
: json['gender'] == 'Male'.tr
|
|
||||||
? carIcon
|
|
||||||
: ladyIcon,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
driversToken.add(json['token']);
|
|
||||||
// driversToken = json['token'];
|
|
||||||
} else {
|
|
||||||
// carLocationsModels[i] = model;
|
|
||||||
markers[i] = Marker(
|
|
||||||
markerId: MarkerId(json['latitude']),
|
|
||||||
position: LatLng(
|
|
||||||
double.parse(json['latitude']),
|
|
||||||
double.parse(json['longitude']),
|
|
||||||
),
|
|
||||||
rotation: double.parse(json['heading']),
|
|
||||||
icon: json['model'].contains('دراجة')
|
|
||||||
? motoIcon
|
|
||||||
: json['gender'] == 'Male'.tr
|
|
||||||
? carIcon
|
|
||||||
: ladyIcon,
|
|
||||||
);
|
|
||||||
// driversToken = json['token'];
|
|
||||||
driversToken.add(json['token']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> _fetchCarLocations(LatLngBounds bounds) async {
|
||||||
|
var payload = {
|
||||||
|
'southwestLat': bounds.southwest.latitude.toString(),
|
||||||
|
'southwestLon': bounds.southwest.longitude.toString(),
|
||||||
|
'northeastLat': bounds.northeast.latitude.toString(),
|
||||||
|
'northeastLon': bounds.northeast.longitude.toString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
String link;
|
||||||
|
switch (box.read(BoxName.carType)) {
|
||||||
|
case 'Lady':
|
||||||
|
link = AppLink.getFemalDriverLocationByPassenger;
|
||||||
|
break;
|
||||||
|
case 'Speed':
|
||||||
|
link = AppLink.getCarsLocationByPassengerSpeed;
|
||||||
|
break;
|
||||||
|
case 'Delivery':
|
||||||
|
link = AppLink.getCarsLocationByPassengerDelivery;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
link = AppLink.getCarsLocationByPassenger;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await CRUD().get(link: link, payload: payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateMarkers(List<dynamic> carsData) {
|
||||||
|
driversToken.clear();
|
||||||
|
|
||||||
|
for (var json in carsData) {
|
||||||
|
String markerId = json['driver_id'].toString();
|
||||||
|
LatLng newPosition = LatLng(
|
||||||
|
double.parse(json['latitude']),
|
||||||
|
double.parse(json['longitude']),
|
||||||
|
);
|
||||||
|
double newHeading = double.parse(json['heading']);
|
||||||
|
BitmapDescriptor icon = _getIconForCar(json);
|
||||||
|
|
||||||
|
_updateOrCreateMarker(markerId, newPosition, newHeading, icon);
|
||||||
|
driversToken.add(json['token']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove markers for cars that are no longer present
|
||||||
|
markers.removeWhere((marker) => !carsData
|
||||||
|
.any((car) => car['driver_id'].toString() == marker.markerId.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
BitmapDescriptor _getIconForCar(Map<String, dynamic> carData) {
|
||||||
|
if (carData['model'].toString().contains('دراجة')) {
|
||||||
|
return motoIcon;
|
||||||
|
} else if (carData['gender'] == 'Male'.tr) {
|
||||||
|
return carIcon;
|
||||||
|
} else {
|
||||||
|
return ladyIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateOrCreateMarker(String markerId, LatLng newPosition,
|
||||||
|
double newHeading, BitmapDescriptor icon) {
|
||||||
|
Marker? existingMarker = markers.cast<Marker?>().firstWhere(
|
||||||
|
(m) => m?.markerId == MarkerId(markerId),
|
||||||
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingMarker == null) {
|
||||||
|
markers.add(Marker(
|
||||||
|
markerId: MarkerId(markerId),
|
||||||
|
position: newPosition,
|
||||||
|
rotation: newHeading,
|
||||||
|
icon: icon,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
double distance =
|
||||||
|
_calculateDistance(existingMarker.position, newPosition);
|
||||||
|
if (distance >= minMovementThreshold) {
|
||||||
|
_smoothlyUpdateMarker(existingMarker, newPosition, newHeading, icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _smoothlyUpdateMarker(Marker oldMarker, LatLng newPosition,
|
||||||
|
double newHeading, BitmapDescriptor icon) {
|
||||||
|
String markerId = oldMarker.markerId.value;
|
||||||
|
LatLng startPosition = oldMarker.position;
|
||||||
|
double startHeading = oldMarker.rotation ?? 0;
|
||||||
|
|
||||||
|
_animationTimers[markerId]?.cancel();
|
||||||
|
_animationTimers[markerId] =
|
||||||
|
Timer.periodic(Duration(milliseconds: updateIntervalMs), (timer) {
|
||||||
|
double progress =
|
||||||
|
timer.tick / (500 / updateIntervalMs); // 500ms total duration
|
||||||
|
if (progress >= 1.0) {
|
||||||
|
timer.cancel();
|
||||||
|
_animationTimers.remove(markerId);
|
||||||
|
progress = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LatLng intermediatePosition = LatLng(
|
||||||
|
startPosition.latitude +
|
||||||
|
(newPosition.latitude - startPosition.latitude) * progress,
|
||||||
|
startPosition.longitude +
|
||||||
|
(newPosition.longitude - startPosition.longitude) * progress);
|
||||||
|
double intermediateHeading =
|
||||||
|
startHeading + (newHeading - startHeading) * progress;
|
||||||
|
|
||||||
|
markers.removeWhere((m) => m.markerId == oldMarker.markerId);
|
||||||
|
markers.add(Marker(
|
||||||
|
markerId: oldMarker.markerId,
|
||||||
|
position: intermediatePosition,
|
||||||
|
rotation: intermediateHeading,
|
||||||
|
icon: icon,
|
||||||
|
));
|
||||||
|
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
double _calculateDistance(LatLng start, LatLng end) {
|
||||||
|
// Implement distance calculation (e.g., Haversine formula)
|
||||||
|
// For simplicity, this is a placeholder. Replace with actual implementation.
|
||||||
|
return 1000 *
|
||||||
|
sqrt(pow(start.latitude - end.latitude, 2) +
|
||||||
|
pow(start.longitude - end.longitude, 2));
|
||||||
|
}
|
||||||
|
|
||||||
Future getTokenForParent() async {
|
Future getTokenForParent() async {
|
||||||
if (box.read(BoxName.sosPhonePassenger) == null) {
|
if (box.read(BoxName.sosPhonePassenger) == null) {
|
||||||
Get.defaultDialog(
|
Get.defaultDialog(
|
||||||
@@ -1558,6 +1742,11 @@ class MapPassengerController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer? _timer;
|
||||||
|
// final int updateIntervalMs = 100; // Update every 100ms
|
||||||
|
// final double minMovementThreshold =
|
||||||
|
// 1.0; // Minimum movement in meters to trigger update
|
||||||
|
|
||||||
void clearMarkersExceptStartEnd() {
|
void clearMarkersExceptStartEnd() {
|
||||||
Set<Marker> markersToRemove = markers
|
Set<Marker> markersToRemove = markers
|
||||||
.where((marker) =>
|
.where((marker) =>
|
||||||
@@ -1567,39 +1756,72 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
for (Marker marker in markersToRemove) {
|
for (Marker marker in markersToRemove) {
|
||||||
markers.remove(marker);
|
markers.remove(marker);
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
|
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
|
||||||
clearMarkersExceptStartEnd();
|
clearMarkersExceptStartEnd();
|
||||||
// for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
|
|
||||||
LatLng driverPosition = LatLng(
|
LatLng driverPosition = LatLng(
|
||||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||||
['latitude']),
|
['latitude']),
|
||||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||||
['longitude']));
|
['longitude']));
|
||||||
final driverAcceptedMarker = Marker(
|
|
||||||
markerId: const MarkerId('driverToPassengers'),
|
double heading = double.parse(
|
||||||
position: driverPosition,
|
datadriverCarsLocationToPassengerAfterApplied['message'][0]['heading']
|
||||||
rotation: double.parse(
|
.toString());
|
||||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
|
||||||
['heading']),
|
BitmapDescriptor icon =
|
||||||
icon: datadriverCarsLocationToPassengerAfterApplied['message'][0]['model']
|
datadriverCarsLocationToPassengerAfterApplied['message'][0]['model']
|
||||||
|
.toString()
|
||||||
.contains('دراجة')
|
.contains('دراجة')
|
||||||
? motoIcon
|
? motoIcon
|
||||||
: datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
: datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||||
['gender'] ==
|
['gender'] ==
|
||||||
'Male'.tr
|
'Male'.tr
|
||||||
? carIcon
|
? carIcon
|
||||||
: ladyIcon, // Default to carIcon if gender is not Male or Female
|
: ladyIcon;
|
||||||
|
|
||||||
|
_updateMarkerPosition(driverPosition, heading, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateMarkerPosition(
|
||||||
|
LatLng newPosition, double newHeading, BitmapDescriptor icon) {
|
||||||
|
const String markerId = 'driverToPassengers';
|
||||||
|
Marker? existingMarker = markers.cast<Marker?>().firstWhere(
|
||||||
|
(m) => m?.markerId == const MarkerId(markerId),
|
||||||
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
markers.add(driverAcceptedMarker);
|
if (existingMarker == null) {
|
||||||
// update();
|
// If the marker doesn't exist, create it at the new position
|
||||||
mapController?.animateCamera(CameraUpdate.newLatLng(driverPosition));
|
markers.add(Marker(
|
||||||
|
markerId: const MarkerId(markerId),
|
||||||
|
position: newPosition,
|
||||||
|
rotation: newHeading,
|
||||||
|
icon: icon,
|
||||||
|
));
|
||||||
update();
|
update();
|
||||||
// } // Update the map with the new markers
|
} else {
|
||||||
|
// If the marker exists, check if the movement is significant enough to update
|
||||||
|
double distance =
|
||||||
|
_calculateDistance(existingMarker.position, newPosition);
|
||||||
|
if (distance >= minMovementThreshold) {
|
||||||
|
_smoothlyUpdateMarker(existingMarker, newPosition, newHeading, icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mapController?.animateCamera(CameraUpdate.newLatLng(newPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
_timer?.cancel();
|
||||||
|
_animationTimers.forEach((_, timer) => timer.cancel());
|
||||||
|
_animationTimers.clear();
|
||||||
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
restCounter() {
|
restCounter() {
|
||||||
@@ -1907,9 +2129,11 @@ class MapPassengerController extends GetxController {
|
|||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
|
||||||
// scale: 1.0,
|
// scale: 1.0,
|
||||||
);
|
);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/picker.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
markerIcon = value;
|
markerIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1920,9 +2144,11 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/A.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
startIcon = value;
|
startIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1931,9 +2157,11 @@ class MapPassengerController extends GetxController {
|
|||||||
void addCustomEndIcon() {
|
void addCustomEndIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/b.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
endIcon = value;
|
endIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1942,9 +2170,11 @@ class MapPassengerController extends GetxController {
|
|||||||
void addCustomCarIcon() {
|
void addCustomCarIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/car.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
carIcon = value;
|
carIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1953,9 +2183,11 @@ class MapPassengerController extends GetxController {
|
|||||||
void addCustomMotoIcon() {
|
void addCustomMotoIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/moto1.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/moto1.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
motoIcon = value;
|
motoIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1964,9 +2196,11 @@ class MapPassengerController extends GetxController {
|
|||||||
void addCustomLadyIcon() {
|
void addCustomLadyIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/lady1.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/lady1.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
ladyIcon = value;
|
ladyIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -1975,9 +2209,11 @@ class MapPassengerController extends GetxController {
|
|||||||
void addCustomStepIcon() {
|
void addCustomStepIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png',
|
BitmapDescriptor.asset(
|
||||||
mipmaps: false)
|
config,
|
||||||
.then((value) {
|
'assets/images/brand.png',
|
||||||
|
// mipmaps: false,
|
||||||
|
).then((value) {
|
||||||
tripIcon = value;
|
tripIcon = value;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -2817,12 +3053,14 @@ class MapPassengerController extends GetxController {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List driversForMishwari = [];
|
||||||
Future selectDriverAndCarForMishwariTrip() async {
|
Future selectDriverAndCarForMishwariTrip() async {
|
||||||
var res = await CRUD()
|
var res = await CRUD()
|
||||||
.get(link: AppLink.selectDriverAndCarForMishwariTrip, payload: {});
|
.get(link: AppLink.selectDriverAndCarForMishwariTrip, payload: {});
|
||||||
if (res != 'failure') {
|
if (res != 'failure') {
|
||||||
var d = jsonDecode(res);
|
var d = jsonDecode(res);
|
||||||
return d['message'];
|
driversForMishwari = d['message'];
|
||||||
|
update();
|
||||||
} else {
|
} else {
|
||||||
return 'No driver available now try later time\nthanks for using our app'
|
return 'No driver available now try later time\nthanks for using our app'
|
||||||
.tr;
|
.tr;
|
||||||
@@ -2839,14 +3077,10 @@ class MapPassengerController extends GetxController {
|
|||||||
// isBottomSheetShown = false;
|
// isBottomSheetShown = false;
|
||||||
update();
|
update();
|
||||||
// add dialoug for select driver and car
|
// add dialoug for select driver and car
|
||||||
List driversForMishwari = await selectDriverAndCarForMishwariTrip();
|
await selectDriverAndCarForMishwariTrip();
|
||||||
Future.delayed(Duration.zero);
|
Future.delayed(Duration.zero);
|
||||||
Log.print('driversForMishwari: ${driversForMishwari}');
|
|
||||||
Get.to(() => CupertinoDriverListWidget(
|
|
||||||
drivers: driversForMishwari,
|
|
||||||
));
|
|
||||||
|
|
||||||
// add dialoug to select date and time
|
Get.to(() => CupertinoDriverListWidget());
|
||||||
|
|
||||||
// changeCashConfirmPageShown();
|
// changeCashConfirmPageShown();
|
||||||
}
|
}
|
||||||
@@ -2856,15 +3090,36 @@ class MapPassengerController extends GetxController {
|
|||||||
try {
|
try {
|
||||||
// Prepare trip data
|
// Prepare trip data
|
||||||
Map<String, dynamic> tripData = {
|
Map<String, dynamic> tripData = {
|
||||||
'driver_id': driver['id'],
|
'id': driver['id'],
|
||||||
'passenger_id': box.read(BoxName.passengerID),
|
'phone': driver['phone'],
|
||||||
'trip_datetime': tripDateTime.toIso8601String(),
|
'gender': driver['gender'],
|
||||||
// Add other necessary trip details
|
'name': driver['name'],
|
||||||
|
'name_english': driver['name_english'],
|
||||||
|
'address': driver['address'],
|
||||||
|
'religion': driver['religion'],
|
||||||
|
'age': driver['age'],
|
||||||
|
'education': driver['education'],
|
||||||
|
'license_type': driver['license_type'],
|
||||||
|
'national_number': driver['national_number'],
|
||||||
|
'car_plate': driver['car_plate'],
|
||||||
|
'make': driver['make'],
|
||||||
|
'model': driver['model'],
|
||||||
|
'year': driver['year'],
|
||||||
|
'color': driver['color'],
|
||||||
|
'color_hex': driver['color_hex'],
|
||||||
|
'displacement': driver['displacement'],
|
||||||
|
'fuel': driver['fuel'],
|
||||||
|
'token': driver['token'],
|
||||||
|
'rating': driver['rating'],
|
||||||
|
'countRide': driver['countRide'],
|
||||||
|
'passengerId': box.read(BoxName.passengerID),
|
||||||
|
'timeSelected': tripDateTime.toIso8601String(),
|
||||||
|
'status': 'pending', // Or other appropriate status
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send data to server
|
// Send data to server
|
||||||
var response =
|
var response =
|
||||||
await CRUD().post(link: AppLink.addAdminUser, payload: tripData);
|
await CRUD().post(link: AppLink.addMishwari, payload: tripData);
|
||||||
|
|
||||||
if (response != 'failure') {
|
if (response != 'failure') {
|
||||||
// Trip saved successfully
|
// Trip saved successfully
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:SEFER/views/auth/login_page.dart';
|
import 'package:SEFER/views/auth/login_page.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:uni_links/uni_links.dart';
|
// import 'package:uni_links/uni_links.dart';
|
||||||
|
|
||||||
import '../../constant/box_name.dart';
|
import '../../constant/box_name.dart';
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
@@ -32,27 +32,27 @@ class SplashScreenController extends GetxController
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription? _sub;
|
StreamSubscription? _sub;
|
||||||
Future<void> initUniLinks() async {
|
// Future<void> initUniLinks() async {
|
||||||
// Handle initial URI if the app was launched from a link
|
// // Handle initial URI if the app was launched from a link
|
||||||
try {
|
// try {
|
||||||
final initialUri = await getInitialUri();
|
// final initialUri = await getInitialUri();
|
||||||
if (initialUri != null) {
|
// if (initialUri != null) {
|
||||||
handleLink(initialUri);
|
// handleLink(initialUri);
|
||||||
}
|
// }
|
||||||
} on PlatformException {
|
// } on PlatformException {
|
||||||
// Handle exception by warning the user their action did not succeed
|
// // Handle exception by warning the user their action did not succeed
|
||||||
print("Failed to get initial uri");
|
// print("Failed to get initial uri");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Listen to new links while the app is running
|
// // Listen to new links while the app is running
|
||||||
_sub = uriLinkStream.listen((Uri? uri) {
|
// _sub = uriLinkStream.listen((Uri? uri) {
|
||||||
if (uri != null) {
|
// if (uri != null) {
|
||||||
handleLink(uri);
|
// handleLink(uri);
|
||||||
}
|
// }
|
||||||
}, onError: (Object err) {
|
// }, onError: (Object err) {
|
||||||
print('Error occurred: $err');
|
// print('Error occurred: $err');
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
void handleLink(Uri uri) {
|
void handleLink(Uri uri) {
|
||||||
if (uri.host == 'sefer.live' && uri.path == '/tripmonitor') {
|
if (uri.host == 'sefer.live' && uri.path == '/tripmonitor') {
|
||||||
@@ -76,7 +76,7 @@ class SplashScreenController extends GetxController
|
|||||||
void onInit() async {
|
void onInit() async {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
checkForUpdate();
|
checkForUpdate();
|
||||||
initUniLinks();
|
// initUniLinks();
|
||||||
animationController = AnimationController(
|
animationController = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration: const Duration(seconds: 4),
|
duration: const Duration(seconds: 4),
|
||||||
|
|||||||
@@ -3,16 +3,13 @@ import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
|||||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../../constant/api_key.dart';
|
import '../../../constant/api_key.dart';
|
||||||
|
|
||||||
class CupertinoDriverListWidget extends StatelessWidget {
|
class CupertinoDriverListWidget extends StatelessWidget {
|
||||||
final List drivers;
|
MapPassengerController mapPassengerController =
|
||||||
|
Get.put(MapPassengerController());
|
||||||
const CupertinoDriverListWidget({super.key, required this.drivers});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
@@ -21,10 +18,10 @@ class CupertinoDriverListWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
itemCount: drivers.length,
|
itemCount: mapPassengerController.driversForMishwari.length,
|
||||||
separatorBuilder: (context, index) => const Divider(height: 1),
|
separatorBuilder: (context, index) => const Divider(height: 1),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var driver = drivers[index];
|
var driver = mapPassengerController.driversForMishwari[index];
|
||||||
return Container(
|
return Container(
|
||||||
decoration: AppStyle.boxDecoration1,
|
decoration: AppStyle.boxDecoration1,
|
||||||
child: CupertinoListTile(
|
child: CupertinoListTile(
|
||||||
@@ -137,7 +134,7 @@ class CupertinoDriverListWidget extends StatelessWidget {
|
|||||||
title: 'OK'.tr,
|
title: 'OK'.tr,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
showDateTimePickerDialog();
|
showDateTimePickerDialog(driver);
|
||||||
}));
|
}));
|
||||||
print('${'Selected driver'.tr}: ${driver['NAME']}');
|
print('${'Selected driver'.tr}: ${driver['NAME']}');
|
||||||
// Get.back(); // Close the dialog
|
// Get.back(); // Close the dialog
|
||||||
@@ -186,13 +183,13 @@ class CupertinoDriverListWidget extends StatelessWidget {
|
|||||||
title: 'OK'.tr,
|
title: 'OK'.tr,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
showDateTimePickerDialog();
|
showDateTimePickerDialog(driver);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDateTimePickerDialog() {
|
void showDateTimePickerDialog(Map<String, dynamic> driver) {
|
||||||
DateTime selectedDateTime = DateTime.now();
|
DateTime selectedDateTime = DateTime.now();
|
||||||
|
|
||||||
Get.defaultDialog(
|
Get.defaultDialog(
|
||||||
@@ -211,10 +208,10 @@ class CupertinoDriverListWidget extends StatelessWidget {
|
|||||||
title: 'Confirm Trip'.tr,
|
title: 'Confirm Trip'.tr,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
DateTime selectedDateTime =
|
DateTime selectedDateTime =
|
||||||
Get.find<MapPassengerController>().selectedDateTime.value;
|
mapPassengerController.selectedDateTime.value;
|
||||||
// Save trip data and set up notifications
|
// Save trip data and set up notifications
|
||||||
// await Get.find<MapPassengerController>().saveTripData(driver, selectedDateTime);
|
|
||||||
Get.back();
|
Get.back();
|
||||||
|
await mapPassengerController.saveTripData(driver, selectedDateTime);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -258,28 +255,3 @@ class DateTimePickerWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> setLocalNotification(DateTime tripDateTime) async {
|
|
||||||
// FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
|
||||||
// FlutterLocalNotificationsPlugin();
|
|
||||||
|
|
||||||
// var androidPlatformChannelSpecifics = const AndroidNotificationDetails(
|
|
||||||
// 'trip_reminder_channel',
|
|
||||||
// 'Trip Reminders',
|
|
||||||
// importance: Importance.max,
|
|
||||||
// priority: Priority.high,
|
|
||||||
// );
|
|
||||||
// var iOSPlatformChannelSpecifics = IOSNotificationDetails();
|
|
||||||
// var platformChannelSpecifics = NotificationDetails(
|
|
||||||
// android: androidPlatformChannelSpecifics,
|
|
||||||
// iOS: iOSPlatformChannelSpecifics,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// await flutterLocalNotificationsPlugin.schedule(
|
|
||||||
// 0,
|
|
||||||
// 'Trip Reminder'.tr,
|
|
||||||
// 'Your trip is scheduled in 30 minutes'.tr,
|
|
||||||
// tripDateTime.subtract(const Duration(minutes: 30)),
|
|
||||||
// platformChannelSpecifics,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user