This commit is contained in:
Hamza-Ayed
2024-03-25 17:15:13 +03:00
parent 5c702e7d06
commit 0f79b2d86b
20 changed files with 327 additions and 179 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -223,8 +223,8 @@ class FirebaseMessagesController extends GetxController {
Get.offAll(const MapPagePassenger()); Get.offAll(const MapPagePassenger());
} else if (message.notification!.title! == 'Order Applied') { } else if (message.notification!.title! == 'Order Applied') {
Get.snackbar( Get.snackbar(
"The order has been accepted by another driver.", // Corrected grammar "The order has been accepted by another driver.".tr, // Corrected grammar
"Be more mindful next time to avoid dropping orders.", // Improved sentence structure "Be more mindful next time to avoid dropping orders.".tr, // Improved sentence structure
backgroundColor: AppColor.yellowColor, backgroundColor: AppColor.yellowColor,
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
); );

View File

@@ -0,0 +1,66 @@
// import 'dart:async';
// import 'package:background_location/background_location.dart';
// import 'package:get/get.dart';
// import 'package:permission_handler/permission_handler.dart';
//
// class LocationBackgroundController extends GetxController {
// @override
// void onInit() {
// super.onInit();
// requestLocationPermission();
// configureBackgroundLocation();
// }
//
// Future<void> requestLocationPermission() async {
// var status = await Permission.locationAlways.status;
// if (!status.isGranted) {
// await Permission.locationAlways.request();
// }
// }
//
// Future<void> configureBackgroundLocation() async {
// await BackgroundLocation.setAndroidNotification(
// title: "Background Location",
// message: "Tracking location...",
// icon: "@mipmap/ic_launcher",
// );
//
// BackgroundLocation.setAndroidConfiguration(1000);
// BackgroundLocation.startLocationService();
// BackgroundLocation.getLocationUpdates((location) {
// // Handle location updates here
// print("New location: ${location.latitude}, ${location.longitude}");
// });
// }
//
// startBackLocation() async {
// Timer.periodic(const Duration(seconds: 5), (timer) {
// getBackgroundLocation();
// });
// }
//
// getBackgroundLocation() async {
// var status = await Permission.locationAlways.status;
// if (status.isGranted) {
// await BackgroundLocation.startLocationService(
// distanceFilter: 20, forceAndroidLocationManager: true);
// BackgroundLocation.setAndroidConfiguration(
// Duration.microsecondsPerSecond); // Set interval to 5 seconds
//
// BackgroundLocation.getLocationUpdates((location1) {
// print('''\n
// Latitude: ${location1.latitude.toString()}
// Longitude: ${location1.longitude.toString()}
// Altitude: ${location1.altitude.toString()}
// Accuracy: ${location1.accuracy.toString()}
// Bearing: ${location1.bearing.toString()}
// Speed: ${location1.speed.toString()}
//
//
// ''');
// });
// } else {
// print('Location permission not granted');
// }
// }
// }

View File

@@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:SEFER/constant/table_names.dart'; import 'package:SEFER/constant/table_names.dart';
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart'; import 'package:location/location.dart';
@@ -9,6 +10,7 @@ import 'package:SEFER/constant/links.dart';
import 'package:SEFER/controller/functions/crud.dart'; import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart'; import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart';
import 'package:SEFER/main.dart'; import 'package:SEFER/main.dart';
import 'package:permission_handler/permission_handler.dart';
// LocationController.dart // LocationController.dart
class LocationController extends GetxController { class LocationController extends GetxController {
@@ -17,6 +19,14 @@ class LocationController extends GetxController {
bool isLoading = false; bool isLoading = false;
bool isActive = false; bool isActive = false;
late LatLng myLocation; late LatLng myLocation;
late double heading;
late double accuracy;
late double latitude;
late double longitude;
late DateTime time;
late double speed;
late double speedAccuracy;
late double headingAccuracy;
String totalPoints = '0'; String totalPoints = '0';
LocationData? get currentLocation => _currentLocation; LocationData? get currentLocation => _currentLocation;
Timer? _locationTimer; Timer? _locationTimer;
@@ -24,6 +34,9 @@ class LocationController extends GetxController {
@override @override
void onInit() async { void onInit() async {
super.onInit(); super.onInit();
requestLocationPermission();
location = Location(); location = Location();
getLocation(); getLocation();
// startLocationUpdates(); // startLocationUpdates();
@@ -31,6 +44,20 @@ class LocationController extends GetxController {
totalPoints = Get.put(CaptainWalletController()).totalPoints; totalPoints = Get.put(CaptainWalletController()).totalPoints;
} }
Future<void> requestLocationPermission() async {
if (box.read(BoxName.driverID) != null) {
var status = await Permission.locationAlways.status;
if (!status.isGranted) {
await Permission.locationAlways.request();
} else {
var status = await Permission.locationWhenInUse.status;
if (!status.isGranted) {
await Permission.locationWhenInUse.request();
}
}
}
}
Future<void> startLocationUpdates() async { Future<void> startLocationUpdates() async {
if (box.read(BoxName.driverID) != null) { if (box.read(BoxName.driverID) != null) {
_locationTimer = _locationTimer =
@@ -41,21 +68,35 @@ class LocationController extends GetxController {
// if (isActive) { // if (isActive) {
if (double.parse(totalPoints) > -300) { if (double.parse(totalPoints) > -300) {
print('total point is $totalPoints'); print('total point is $totalPoints');
await getLocation();
await getLocation();
if (box.read(BoxName.driverID) != null) {
await CRUD() await CRUD()
.post(link: AppLink.addCarsLocationByPassenger, payload: { .post(link: AppLink.addCarsLocationByPassenger, payload: {
'driver_id': box.read(BoxName.driverID).toString(), 'driver_id': box.read(BoxName.driverID).toString(),
'latitude': myLocation.latitude.toString(), 'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(), 'longitude': myLocation.longitude.toString(),
'heading': heading.toString(),
'speed': speed.toString(),
'status': box.read(BoxName.statusDriverLocation).toString() 'status': box.read(BoxName.statusDriverLocation).toString()
}); });
if (Get.find<MapDriverController>().rideId == null) {
await sql.insertData({ await sql.insertData({
'driver_id': box.read(BoxName.driverID), 'driver_id': box.read(BoxName.driverID),
'latitude': myLocation.latitude.toString(), 'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(), 'longitude': myLocation.longitude.toString(),
'created_at': DateTime.now().toString(), 'created_at': DateTime.now().toString(),
}, TableName.carLocations); }, TableName.carLocations);
} else {
await sql.insertData({
'order_id': Get.find<MapDriverController>().rideId,
'created_at': DateTime.now().toString(),
'lat': myLocation.latitude.toString(),
'lng': myLocation.longitude.toString(),
}, TableName.rideLocation);
}
}
// //
} }
@@ -75,45 +116,29 @@ class LocationController extends GetxController {
Future<void> getLocation() async { Future<void> getLocation() async {
isLoading = true; isLoading = true;
update(); update();
bool serviceEnabled;
PermissionStatus permissionGranted;
// Check if location services are enabled
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
// Location services are still not enabled, handle the error
return;
}
}
// Check if the app has permission to access location
permissionGranted = await location.hasPermission();
if (permissionGranted == PermissionStatus.denied) {
permissionGranted = await location.requestPermission();
if (permissionGranted != PermissionStatus.granted) {
// Location permission is still not granted, handle the error
return;
}
}
// Configure location accuracy
// LocationAccuracy desiredAccuracy = LocationAccuracy.high;
// Get the current location // Get the current location
LocationData _locationData = await location.getLocation(); LocationData _locationData = await location.getLocation();
myLocation = myLocation = LatLng(_locationData.latitude!, _locationData.longitude!);
(_locationData.latitude != null && _locationData.longitude != null
? LatLng(_locationData.latitude!, _locationData.longitude!) accuracy = _locationData.accuracy!;
: null)!; latitude = _locationData.latitude!;
longitude = _locationData.longitude!;
heading = _locationData.heading!;
speed = _locationData.speed!;
speedAccuracy = _locationData.speedAccuracy!;
headingAccuracy = _locationData.headingAccuracy!;
// Print location details // Print location details
// print('myLocation: ${myLocation}'); // print('myLocation: $myLocation');
// print('Accuracy: ${_locationData.accuracy}'); // print('Accuracy: $accuracy');
// print('Latitude: ${_locationData.latitude}'); // print('Latitude: $latitude');
// print('Longitude: ${_locationData.longitude}'); // print('Longitude: $longitude');
// print('Time: ${_locationData.time}'); // print('heading: $heading');
// print('speed: $speed');
// print('speedAccuracy: $speedAccuracy');
// print('headingAccuracy: $headingAccuracy');
isLoading = false; isLoading = false;
update(); update();
} }

View File

@@ -14,6 +14,7 @@ import '../../../main.dart';
import '../../../views/home/my_wallet/walet_captain.dart'; import '../../../views/home/my_wallet/walet_captain.dart';
import '../../../views/widgets/elevated_btn.dart'; import '../../../views/widgets/elevated_btn.dart';
import '../../functions/crud.dart'; import '../../functions/crud.dart';
import '../../functions/location_background_controller.dart';
import '../../functions/location_controller.dart'; import '../../functions/location_controller.dart';
import '../payment/captain_wallet_controller.dart'; import '../payment/captain_wallet_controller.dart';
@@ -39,6 +40,7 @@ class HomeCaptainController extends GetxController {
double widthMapTypeAndTraffic = 50; double widthMapTypeAndTraffic = 50;
// Inject the LocationController class // Inject the LocationController class
final locationController = Get.put(LocationController()); final locationController = Get.put(LocationController());
// final locationBackController = Get.put(LocationBackgroundController());
String formatDuration(Duration duration) { String formatDuration(Duration duration) {
String twoDigits(int n) => n.toString().padLeft(2, "0"); String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60)); String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
@@ -60,6 +62,7 @@ class HomeCaptainController extends GetxController {
if (isActive) { if (isActive) {
if (double.parse(totalPoints) > -300) { if (double.parse(totalPoints) > -300) {
locationController.startLocationUpdates(); locationController.startLocationUpdates();
// locationBackController.startBackLocation();
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!);

View File

@@ -546,7 +546,10 @@ update ui for totla results
// })); // }));
// } // }
// add wallet from passenger from driver // add wallet from passenger from driver
Get.to(() => RatePassenger()); Get.to(() => RatePassenger(), arguments: {
'passengerId': passengerId,
'rideId': rideId,
});
// Get.back(); // Get.back();
} }
@@ -653,22 +656,24 @@ update ui for totla results
final previousLocationOfDrivers = await sql.getCustomQuery('''SELECT final previousLocationOfDrivers = await sql.getCustomQuery('''SELECT
* *
FROM FROM
${TableName.carLocations} ${TableName.rideLocation}
WHERE WHERE
order_id = $rideId order_id = $rideId
ORDER BY ORDER BY
created_at DESC created_at DESC
LIMIT LIMIT
1'''); 1''');
print(previousLocationOfDrivers);
//get from sql //get from sql
if (previousLocationOfDrivers.isNotEmpty) { if (previousLocationOfDrivers.isNotEmpty) {
var lat = double.parse(previousLocationOfDrivers[0]['lat']); var lat = double.parse(previousLocationOfDrivers[0]['lat']);
var lng = double.parse(previousLocationOfDrivers[0]['lng']); var lng = double.parse(previousLocationOfDrivers[0]['lng']);
LatLng prev = LatLng(lat, lng); LatLng prev = LatLng(lat, lng);
recentAngelToMarker = calculateAngleBetweenLocations(prev, myLocation);
recentDistanceToDash = recentDistanceToDash =
calculateDistanceBetweenLocations(prev, myLocation); calculateDistanceBetweenLocations(prev, myLocation);
print('recentAngelToMarker $recentAngelToMarker');
print('recentDistanceToDash $recentDistanceToDash');
} }
sql.insertData({ sql.insertData({
'order_id': rideId, 'order_id': rideId,
@@ -683,7 +688,7 @@ LIMIT
position: locationController.myLocation, position: locationController.myLocation,
draggable: true, draggable: true,
icon: carIcon, icon: carIcon,
rotation: recentAngelToMarker, rotation: locationController.heading,
// infoWindow: const InfoWindow( // infoWindow: const InfoWindow(
// title: 'Time', // title: 'Time',
// ), // ),
@@ -724,7 +729,7 @@ LIMIT
void addCustomEndIcon() { void addCustomEndIcon() {
ImageConfiguration config = ImageConfiguration( ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio); size: const Size(25, 25), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png', BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png',
mipmaps: false) mipmaps: false)
.then((value) { .then((value) {

View File

@@ -87,7 +87,7 @@ class MapPassengerController extends GetxController {
List<LatLng> polylineCoordinates3 = []; List<LatLng> polylineCoordinates3 = [];
List<LatLng> polylineCoordinates4 = []; List<LatLng> polylineCoordinates4 = [];
List<List<LatLng>> polylineCoordinatesPointsAll = []; List<List<LatLng>> polylineCoordinatesPointsAll = [];
List<LatLng> carsLocationByPassenger = []; List carsLocationByPassenger = [];
List<LatLng> driverCarsLocationToPassengerAfterApplied = []; List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker; BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor tripIcon = BitmapDescriptor.defaultMarker; BitmapDescriptor tripIcon = BitmapDescriptor.defaultMarker;
@@ -144,7 +144,7 @@ class MapPassengerController extends GetxController {
double paymentPageShown = Get.height * .6; double paymentPageShown = Get.height * .6;
late LatLng southwest; late LatLng southwest;
late LatLng northeast; late LatLng northeast;
List<CarLocationModel> carLocations = <CarLocationModel>[]; List<CarLocationModel> carLocationsModels = <CarLocationModel>[];
var dataCarsLocationByPassenger; var dataCarsLocationByPassenger;
var datadriverCarsLocationToPassengerAfterApplied; var datadriverCarsLocationToPassengerAfterApplied;
CarLocation? nearestCar; CarLocation? nearestCar;
@@ -840,6 +840,7 @@ class MapPassengerController extends GetxController {
: '0', : '0',
box.read(BoxName.email).toString(), box.read(BoxName.email).toString(),
]; ];
print(body);
FirebaseMessagesController().sendNotificationToDriverMapPolyline( FirebaseMessagesController().sendNotificationToDriverMapPolyline(
'Order', 'Order',
jsonDecode(value)['message'].toString(), jsonDecode(value)['message'].toString(),
@@ -847,7 +848,7 @@ class MapPassengerController extends GetxController {
.toString(), .toString(),
body, body,
polylineCoordinates.toString()); polylineCoordinates.toString());
// //print(dataCarsLocationByPassenger); print(dataCarsLocationByPassenger);
// //print(dataCarsLocationByPassenger['message'][0]['token'].toString()); // //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
}); });
delayAndFetchRideStatus(rideId); delayAndFetchRideStatus(rideId);
@@ -923,13 +924,46 @@ class MapPassengerController extends GetxController {
polylineCoordinates.toString()); polylineCoordinates.toString());
} }
delayAndFetchRideStatus(rideId); delayAndFetchRideStatusForAllDriverAvailable(rideId);
update(); update();
} }
String statusRide = 'wait'; String statusRide = 'wait';
void delayAndFetchRideStatus(String rideId) { void delayAndFetchRideStatus(String rideId) {
Timer(const Duration(milliseconds: 200), () async {
if (shouldFetch) {
// //print('shouldFetch is =$shouldFetch');
var res = await CRUD()
.get(link: AppLink.getRideStatus, payload: {'id': rideId});
print(res);
var decod = jsonDecode(res);
print(' 0000000000000000000000000000000000000000000000000');
print(decod['data']);
if (decod['data'].toString() == 'Apply') {
// getUpdatedRideForDriverApply(rideId);
shouldFetch = false; // Stop further fetches
statusRide = 'Apply';
rideConfirm = false;
isSearchingWindow = false;
update();
startTimer();
} else if (decod['data'].toString() == 'Refused') {
// isDriversTokensSend = false;
if (isDriversTokensSend == false) {
confirmRideForAllDriverAvailable();
isDriversTokensSend = true;
}
} else if (isDriversTokensSend == false) {
delayAndFetchRideStatus(
rideId); // Repeat the delay and fetch operation
update();
}
}
});
}
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) {
Timer(const Duration(milliseconds: 200), () async { Timer(const Duration(milliseconds: 200), () async {
if (shouldFetch) { if (shouldFetch) {
// //print('shouldFetch is =$shouldFetch'); // //print('shouldFetch is =$shouldFetch');
@@ -947,19 +981,8 @@ class MapPassengerController extends GetxController {
isSearchingWindow = false; isSearchingWindow = false;
update(); update();
startTimer(); startTimer();
} else if (decod['data'].toString() == 'Refused') {
// isDriversTokensSend = false;
if (isDriversTokensSend == false) {
confirmRideForAllDriverAvailable();
isDriversTokensSend = true;
} }
} }
// else if (isDriversTokensSend == false) {
// delayAndFetchRideStatus(
// rideId); // Repeat the delay and fetch operation
// update();
// }
}
}); });
} }
@@ -1025,6 +1048,8 @@ class MapPassengerController extends GetxController {
} }
late LatLng currentDriverLocation; late LatLng currentDriverLocation;
late double headingList;
Future getCarsLocationByPassenger() async { Future getCarsLocationByPassenger() async {
// if (rideConfirm == false) { // if (rideConfirm == false) {
carsLocationByPassenger = []; carsLocationByPassenger = [];
@@ -1057,28 +1082,28 @@ class MapPassengerController extends GetxController {
carsLocationByPassenger.clear(); // Clear existing markers carsLocationByPassenger.clear(); // Clear existing markers
late LatLng lastDriverLocation; // Initialize a variable for last location // late LatLng lastDriverLocation; // Initialize a variable for last location
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) { for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
currentDriverLocation = LatLng( var json = dataCarsLocationByPassenger['message'][i];
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']), print(json);
double.parse(dataCarsLocationByPassenger['message'][i]['longitude']), CarLocationModel model = CarLocationModel.fromJson(json);
); carLocationsModels.add(model);
// Update lastDriverLocation on each iteration // currentDriverLocation = LatLng(
previousLocationOfDrivers = currentDriverLocation; // double.parse(json['latitude']),
// double.parse(json['longitude']),
// );
// // headingList = double.parse(json['heading']);
carsLocationByPassenger.add(currentDriverLocation); // // Update lastDriverLocation on each iteration
driversToken.add(dataCarsLocationByPassenger['message'][i]['token']); // previousLocationOfDrivers = currentDriverLocation;
// carsLocationByPassenger.add(currentDriverLocation);
// // carsLocationByPassenger.add(headingList);
driversToken.add(json['token']);
} }
// // Calculate rotation angle here (explained below)
// if (previousLocationOfDrivers != null) {
// angleDegrees = calculateAngleBetweenLocations(
// previousLocationOfDrivers, currentDriverLocation);
// // Use rotationAngle for marker rotation logic
// }
update(); update();
} }
} }
@@ -1126,11 +1151,7 @@ class MapPassengerController extends GetxController {
for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) { for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
// } // }
// for (var item in driverCarsLocationToPassengerAfterApplied) { // for (var item in driverCarsLocationToPassengerAfterApplied) {
double rotationCar = calculateAngleBetweenLocations(
LatLng(driverCarsLocationToPassengerAfterApplied[i - 1].latitude,
driverCarsLocationToPassengerAfterApplied[i - 1].longitude),
LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
driverCarsLocationToPassengerAfterApplied[i].longitude));
final driverAcceptedMarker = Marker( final driverAcceptedMarker = Marker(
onTap: () => print('marker pressed'), onTap: () => print('marker pressed'),
infoWindow: InfoWindow( infoWindow: InfoWindow(
@@ -1141,7 +1162,8 @@ class MapPassengerController extends GetxController {
.toString()), .toString()),
position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude, position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
driverCarsLocationToPassengerAfterApplied[i].longitude), driverCarsLocationToPassengerAfterApplied[i].longitude),
rotation: rotationCar, rotation: datadriverCarsLocationToPassengerAfterApplied['message'][0]
['heading'],
); );
markers.add(driverAcceptedMarker); markers.add(driverAcceptedMarker);
update(); update();
@@ -1627,7 +1649,7 @@ class MapPassengerController extends GetxController {
infoWindow: InfoWindow(title: '${item.latitude} minutes'), infoWindow: InfoWindow(title: '${item.latitude} minutes'),
markerId: MarkerId(durationToPassenger.toString()), markerId: MarkerId(durationToPassenger.toString()),
position: LatLng(item.latitude, item.longitude), position: LatLng(item.latitude, item.longitude),
rotation: math.Random().nextDouble() * 360, rotation: item.headingList
// Other properties for the marker, such as icon, info window, etc. // Other properties for the marker, such as icon, info window, etc.
); );
markers.add(marker); markers.add(marker);

View File

@@ -386,6 +386,7 @@ class MyTranslation extends Translations {
'Total price from ': 'المبلغ المطلوب من ', 'Total price from ': 'المبلغ المطلوب من ',
'Order Details Speed': 'طلب سريع', 'Order Details Speed': 'طلب سريع',
'Order Applied': "نفذ الطلب", 'Order Applied': "نفذ الطلب",
'accepted your order': 'قبل طلبك',
'We regret to inform you that another driver has accepted this order.': 'We regret to inform you that another driver has accepted this order.':
'نأسف لإبلاغك بأن سائقًا آخر قد قبل هذا الطلب', 'نأسف لإبلاغك بأن سائقًا آخر قد قبل هذا الطلب',
"The order has been accepted by another driver.": "The order has been accepted by another driver.":

View File

@@ -176,13 +176,14 @@ class PaymentController extends GetxController {
phone: box.read(BoxName.phoneDriver) == null phone: box.read(BoxName.phoneDriver) == null
? box.read(BoxName.phone).toString() ? box.read(BoxName.phone).toString()
: box.read(BoxName.phoneDriver).toString(), : box.read(BoxName.phoneDriver).toString(),
address: const Address( address: Address(
city: 'city', city: 'city',
country: 'Jordan', //'United States' country: box.read(BoxName.countryCode), //'United States'
line1: '', line1: '',
line2: '', line2: '',
postalCode: '12345', postalCode: '12345',
state: 'Boston')), state: box.read(BoxName.countryCode) // 'Boston'
)),
allowsDelayedPaymentMethods: true, allowsDelayedPaymentMethods: true,
customerEphemeralKeySecret: Stripe.merchantIdentifier, customerEphemeralKeySecret: Stripe.merchantIdentifier,
appearance: const PaymentSheetAppearance( appearance: const PaymentSheetAppearance(
@@ -193,9 +194,9 @@ class PaymentController extends GetxController {
), ),
billingDetailsCollectionConfiguration: billingDetailsCollectionConfiguration:
const BillingDetailsCollectionConfiguration( const BillingDetailsCollectionConfiguration(
name: CollectionMode.always, name: CollectionMode.automatic,
phone: CollectionMode.always, phone: CollectionMode.automatic,
email: CollectionMode.always, email: CollectionMode.automatic,
), ),
), ),
); );
@@ -352,36 +353,36 @@ class PaymentController extends GetxController {
"business_profile[name]": box.read(BoxName.nameDriver), "business_profile[name]": box.read(BoxName.nameDriver),
"business_profile[product_description]": "Captain", "business_profile[product_description]": "Captain",
"business_profile[support_address][city]": "San Francisco", "business_profile[support_address][city]": "San Francisco",
"business_profile[support_address][country]": "US", "business_profile[support_address][country]": 'US',
"business_profile[support_address][line1]": "business_profile[support_address][line1]":
licenseDetailsMap['message'][0]['address'].toString().trim()[0], licenseDetailsMap['message'][0]['address'].toString().trim()[0],
"business_profile[support_address][postal_code]": "business_profile[support_address][postal_code]":
licenseDetailsMap['message'][0]['postalCode'], licenseDetailsMap['message'][0]['postalCode'],
"business_profile[support_address][state]": "MA", "business_profile[support_address][state]": "MA",
"business_profile[support_email]": "support@mobile-app.store", "business_profile[support_email]": "support@sefer.live",
"business_profile[support_phone]": "555-123-4567", "business_profile[support_phone]": "555-123-4567",
"business_profile[url]": "https://mobile-app.store", "business_profile[url]": "https://sefer.live",
"business_type": "individual", "business_type": "individual",
"capabilities[card_payments][requested]": "true", "capabilities[card_payments][requested]": "true",
"capabilities[transfers][requested]": "true", "capabilities[transfers][requested]": "true",
"company[address][city]": "San Francisco", "company[address][city]": "ATTLEBORO",
"company[address][country]": "US", "company[address][country]": "US",
"company[address][line1]": "122 Main St", "company[address][line1]": "1249 NEWPORT AVE",
"company[address][postal_code]": "94111", "company[address][postal_code]": "02703 ",
"company[address][state]": "MA", "company[address][state]": "MA",
"company[name]": AppInformation.companyName, "company[name]": AppInformation.companyName,
"country": "us", "country": "us",
"default_currency": "usd", "default_currency": "usd",
"email": "support@mobile.store", "email": "support@sefer.live",
// "individual[ssn]": "123-45-6789", // // "individual[ssn]": "123-45-6789", //
"individual[id_number]": licenseDetailsMap['message'][0]['documentNo'], "individual[id_number]": licenseDetailsMap['message'][0]['documentNo'],
// "individual[id_type]": "drivers_license", // // "individual[id_type]": "drivers_license", //
"individual[address][city]": "San Francisco", "individual[address][city]": "ATTLEBORO",
"individual[address][country]": "US", "individual[address][country]": "US",
"individual[address][line1]": licenseDetailsMap['message'][0]['address'], "individual[address][line1]": licenseDetailsMap['message'][0]['address'],
// "individual[address][postal_code]": licenseDetailsMap['message'][0] // "individual[address][postal_code]": licenseDetailsMap['message'][0]
// ['postalCode'], // ['postalCode'],
"individual[address][state]": "CA", "individual[address][state]": "MA",
// "individual[ssn_last_4]": '1111', //////// // "individual[ssn_last_4]": '1111', ////////
"individual[dob][day]": day.toString(), "individual[dob][day]": day.toString(),
"individual[dob][month]": month.toString(), "individual[dob][month]": month.toString(),

View File

@@ -1,4 +1,5 @@
import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
import 'package:SEFER/views/home/home_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/box_name.dart';

View File

@@ -1,5 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:SEFER/constant/box_name.dart';
import 'package:background_location/background_location.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.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';
@@ -14,6 +16,7 @@ import 'constant/credential.dart';
import 'constant/info.dart'; import 'constant/info.dart';
import 'controller/firebase/firbase_messge.dart'; import 'controller/firebase/firbase_messge.dart';
import 'controller/firebase/local_notification.dart'; import 'controller/firebase/local_notification.dart';
import 'controller/functions/location_background_controller.dart';
import 'controller/local/local_controller.dart'; import 'controller/local/local_controller.dart';
import 'controller/local/translations.dart'; import 'controller/local/translations.dart';
import 'firebase_options.dart'; import 'firebase_options.dart';
@@ -31,9 +34,17 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
FirebaseMessagesController().fireBaseTitles(message); FirebaseMessagesController().fireBaseTitles(message);
} }
// @pragma('vm:entry-point')
// Future<void> backgroundLocation() async {
// await LocationBackgroundController().startBackLocation().then((location) {
// print('This is current Location ${location.toMap()}');
// });
// }
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
WakelockPlus.enable(); WakelockPlus.enable();
await BackgroundLocation.startLocationService();
if (Platform.isAndroid) { if (Platform.isAndroid) {
await NotificationController().initNotifications(); await NotificationController().initNotifications();
} }
@@ -46,7 +57,9 @@ void main() async {
print(Get.deviceLocale!.countryCode); print(Get.deviceLocale!.countryCode);
Stripe.publishableKey = AK.publishableKey; Stripe.publishableKey = AK.publishableKey;
// if (box.read(BoxName.driverID) != null) {
// Get.put(LocationBackgroundController());
// }
if (Platform.isAndroid || Platform.isIOS) { if (Platform.isAndroid || Platform.isIOS) {
await Firebase.initializeApp( await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform, options: DefaultFirebaseOptions.currentPlatform,

View File

@@ -60,7 +60,7 @@ class DbSql {
await db.execute(''' await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.rideLocation}( CREATE TABLE IF NOT EXISTS ${TableName.rideLocation}(
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
order_id TEXT UNIQUE, order_id TEXT ,
created_at TEXT, created_at TEXT,
lat TEXT, lat TEXT,
lng TEXT lng TEXT

View File

@@ -1,7 +1,9 @@
class CarLocationModel { class CarLocationModel {
int id; String id;
int driverId; String driverId;
double latitude; double latitude;
double heading;
double speed;
double longitude; double longitude;
DateTime createdAt; DateTime createdAt;
DateTime updatedAt; DateTime updatedAt;
@@ -11,6 +13,8 @@ class CarLocationModel {
required this.driverId, required this.driverId,
required this.latitude, required this.latitude,
required this.longitude, required this.longitude,
required this.heading,
required this.speed,
required this.createdAt, required this.createdAt,
required this.updatedAt, required this.updatedAt,
}); });
@@ -19,8 +23,10 @@ class CarLocationModel {
return CarLocationModel( return CarLocationModel(
id: json['id'], id: json['id'],
driverId: json['driver_id'], driverId: json['driver_id'],
latitude: json['latitude'], latitude: double.parse(json['latitude'].toString()),
longitude: json['longitude'], longitude: double.parse(json['longitude'].toString()),
heading: double.parse(json['heading'].toString()),
speed: double.parse(json['speed'].toString()),
createdAt: DateTime.parse(json['created_at']), createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']), updatedAt: DateTime.parse(json['updated_at']),
); );

View File

@@ -27,35 +27,36 @@ class RatePassenger extends StatelessWidget {
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration,
child: Column( child: Column(
children: [ children: [
// Padding( Padding(
// padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
// child: Container( child: Container(
// height: Get.height * .25, height: Get.height * .25,
// decoration: AppStyle.boxDecoration1, decoration: AppStyle.boxDecoration1,
// child: Column( child: Column(
// children: [ mainAxisAlignment: MainAxisAlignment.center,
// Text( children: [
// '${'Total price from '.tr}${Get.find<MapDriverController>().passengerName}', Text(
// style: AppStyle.title, '${'Total price from '.tr}${Get.find<MapDriverController>().passengerName}',
// ), style: AppStyle.title,
// Container( ),
// decoration: BoxDecoration( Container(
// border: Border.all( decoration: BoxDecoration(
// width: 2, border: Border.all(
// color: AppColor.greenColor, width: 2,
// )), color: AppColor.greenColor,
// child: Padding( )),
// padding: const EdgeInsets.all(4), child: Padding(
// child: Text( padding: const EdgeInsets.all(4),
// Get.find<MapDriverController>() child: Text(
// .totalPassenger, Get.find<MapDriverController>()
// style: AppStyle.number, .totalPassenger,
// ), style: AppStyle.number,
// ), ),
// ), ),
// ], ),
// )), ],
// ), )),
),
Center( Center(
child: RatingBar.builder( child: RatingBar.builder(
initialRating: 0, initialRating: 0,

View File

@@ -75,7 +75,7 @@ class GoogleDriverMap extends StatelessWidget {
position: locationController.myLocation, position: locationController.myLocation,
draggable: true, draggable: true,
icon: controller.carIcon, icon: controller.carIcon,
), rotation: locationController.heading),
Marker( Marker(
markerId: MarkerId('start'.tr), markerId: MarkerId('start'.tr),
position: controller.latLngpassengerLocation, position: controller.latLngpassengerLocation,

View File

@@ -1,5 +1,6 @@
import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart'; import 'package:SEFER/controller/firebase/firbase_messge.dart';
@@ -61,8 +62,8 @@ class OrderRequestPage extends StatelessWidget {
return MyScafolld( return MyScafolld(
title: 'Order Details'.tr, title: 'Order Details'.tr,
body: [ body: [
Column( ListView(
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// SizedBox(height: 200, child: Text(pointsList.toString())), // SizedBox(height: 200, child: Text(pointsList.toString())),
// Text(message.notification!.body.toString()), // Text(message.notification!.body.toString()),

View File

@@ -296,7 +296,7 @@ class OrderSpeedRequest extends StatelessWidget {
FirebaseMessagesController() FirebaseMessagesController()
.sendNotificationToPassengerToken( .sendNotificationToPassengerToken(
'Apply Ride', 'Apply Ride',
arguments['DriverList'][9].toString(), 'The ${box.read(BoxName.nameDriver)} ${'accepted your order'.tr}',
arguments['DriverList'][9].toString(), arguments['DriverList'][9].toString(),
// box.read(BoxName.tokenDriver).toString(), // box.read(BoxName.tokenDriver).toString(),
bodyToPassenger, bodyToPassenger,
@@ -338,17 +338,13 @@ class OrderSpeedRequest extends StatelessWidget {
), ),
GetBuilder<OrderRequestController>( GetBuilder<OrderRequestController>(
builder: (timerController) { builder: (timerController) {
final isNearEnd =
timerController.remainingTimeSpeed <=
5; // Define a threshold for "near end"
return Stack( return Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
CircularProgressIndicator( CircularProgressIndicator(
value: timerController.progressSpeed, value: timerController.progressSpeed,
// Set the color based on the "isNearEnd" condition // Set the color based on the "isNearEnd" condition
color: isNearEnd ? Colors.red : Colors.blue, color: Colors.blue,
), ),
Text( Text(
'${timerController.remainingTimeSpeed}', '${timerController.remainingTimeSpeed}',

View File

@@ -14,7 +14,8 @@ class ApplyOrderWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<MapPassengerController>(builder: (controller) { return GetBuilder<MapPassengerController>(builder: (controller) {
if (controller.statusRide == 'Apply') { if (controller.statusRide == 'Apply' &&
controller.isSearchingWindow == false) {
double _height = 250; double _height = 250;
return Positioned( return Positioned(
bottom: 0, bottom: 0,

View File

@@ -144,22 +144,28 @@ class GoogleMapPassengerWidget extends StatelessWidget {
zoom: 15, zoom: 15,
), ),
markers: { markers: {
// controller.carMarkerAplied, if (controller.statusRide != 'Apply' ||
for (var carLocation in controller.carsLocationByPassenger) !controller.rideTimerBegin)
for (var carLocation in controller.carLocationsModels)
Marker( Marker(
// anchor: const Offset(4, 4), // anchor: const Offset(4, 4),
position: carLocation, position: LatLng(
carLocation.latitude,
carLocation.longitude,
),
icon: controller.carIcon, icon: controller.carIcon,
markerId: MarkerId(carLocation.toString()), markerId: MarkerId(carLocation.toString()),
rotation: controller.angleDegrees, rotation: carLocation.heading,
), /////////////////// ), ///////////////////
// controller.carMarrkerAplied, // controller.carMarrkerAplied,
if (controller.statusRide == 'Apply')
for (var carLocation for (var carLocation
in controller.driverCarsLocationToPassengerAfterApplied) in controller.driverCarsLocationToPassengerAfterApplied)
Marker( Marker(
// anchor: const Offset(4, 4), // anchor: const Offset(4, 4),
position: carLocation, position: carLocation,
icon: controller.carIcon, icon: controller.carIcon,
rotation: controller.headingList,
markerId: MarkerId(carLocation.toString())), markerId: MarkerId(carLocation.toString())),
for (int i = 1; for (int i = 1;
i < controller.coordinatesWithoutEmpty.length - 1; i < controller.coordinatesWithoutEmpty.length - 1;

View File

@@ -115,7 +115,7 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
// NotificationController() // NotificationController()
// .showNotification('Order', 'hi this is', 'tone1'); // .showNotification('Order', 'hi this is', 'tone1');
// Get.to(() => DriverCallPage()); // Get.to(() => DriverCallPage());
print(controller.polylineCoordinates.toString()); print(controller.carLocationsModels);
// PassengerCallPage( // PassengerCallPage(
// channelName: '', // channelName: '',
// token: '', // token: '',