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());
} else if (message.notification!.title! == 'Order Applied') {
Get.snackbar(
"The order has been accepted by another driver.", // Corrected grammar
"Be more mindful next time to avoid dropping orders.", // Improved sentence structure
"The order has been accepted by another driver.".tr, // Corrected grammar
"Be more mindful next time to avoid dropping orders.".tr, // Improved sentence structure
backgroundColor: AppColor.yellowColor,
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 'package:SEFER/constant/table_names.dart';
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.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/home/payment/captain_wallet_controller.dart';
import 'package:SEFER/main.dart';
import 'package:permission_handler/permission_handler.dart';
// LocationController.dart
class LocationController extends GetxController {
@@ -17,6 +19,14 @@ class LocationController extends GetxController {
bool isLoading = false;
bool isActive = false;
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';
LocationData? get currentLocation => _currentLocation;
Timer? _locationTimer;
@@ -24,6 +34,9 @@ class LocationController extends GetxController {
@override
void onInit() async {
super.onInit();
requestLocationPermission();
location = Location();
getLocation();
// startLocationUpdates();
@@ -31,6 +44,20 @@ class LocationController extends GetxController {
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 {
if (box.read(BoxName.driverID) != null) {
_locationTimer =
@@ -41,21 +68,35 @@ class LocationController extends GetxController {
// if (isActive) {
if (double.parse(totalPoints) > -300) {
print('total point is $totalPoints');
await getLocation();
await CRUD()
.post(link: AppLink.addCarsLocationByPassenger, payload: {
'driver_id': box.read(BoxName.driverID).toString(),
'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(),
'status': box.read(BoxName.statusDriverLocation).toString()
});
await sql.insertData({
'driver_id': box.read(BoxName.driverID),
'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(),
'created_at': DateTime.now().toString(),
}, TableName.carLocations);
await getLocation();
if (box.read(BoxName.driverID) != null) {
await CRUD()
.post(link: AppLink.addCarsLocationByPassenger, payload: {
'driver_id': box.read(BoxName.driverID).toString(),
'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(),
'heading': heading.toString(),
'speed': speed.toString(),
'status': box.read(BoxName.statusDriverLocation).toString()
});
if (Get.find<MapDriverController>().rideId == null) {
await sql.insertData({
'driver_id': box.read(BoxName.driverID),
'latitude': myLocation.latitude.toString(),
'longitude': myLocation.longitude.toString(),
'created_at': DateTime.now().toString(),
}, 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 {
isLoading = true;
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
LocationData _locationData = await location.getLocation();
myLocation =
(_locationData.latitude != null && _locationData.longitude != null
? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!;
myLocation = LatLng(_locationData.latitude!, _locationData.longitude!);
accuracy = _locationData.accuracy!;
latitude = _locationData.latitude!;
longitude = _locationData.longitude!;
heading = _locationData.heading!;
speed = _locationData.speed!;
speedAccuracy = _locationData.speedAccuracy!;
headingAccuracy = _locationData.headingAccuracy!;
// Print location details
// print('myLocation: ${myLocation}');
// print('Accuracy: ${_locationData.accuracy}');
// print('Latitude: ${_locationData.latitude}');
// print('Longitude: ${_locationData.longitude}');
// print('Time: ${_locationData.time}');
// print('myLocation: $myLocation');
// print('Accuracy: $accuracy');
// print('Latitude: $latitude');
// print('Longitude: $longitude');
// print('heading: $heading');
// print('speed: $speed');
// print('speedAccuracy: $speedAccuracy');
// print('headingAccuracy: $headingAccuracy');
isLoading = false;
update();
}

View File

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

View File

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

View File

@@ -87,7 +87,7 @@ class MapPassengerController extends GetxController {
List<LatLng> polylineCoordinates3 = [];
List<LatLng> polylineCoordinates4 = [];
List<List<LatLng>> polylineCoordinatesPointsAll = [];
List<LatLng> carsLocationByPassenger = [];
List carsLocationByPassenger = [];
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor tripIcon = BitmapDescriptor.defaultMarker;
@@ -144,7 +144,7 @@ class MapPassengerController extends GetxController {
double paymentPageShown = Get.height * .6;
late LatLng southwest;
late LatLng northeast;
List<CarLocationModel> carLocations = <CarLocationModel>[];
List<CarLocationModel> carLocationsModels = <CarLocationModel>[];
var dataCarsLocationByPassenger;
var datadriverCarsLocationToPassengerAfterApplied;
CarLocation? nearestCar;
@@ -840,6 +840,7 @@ class MapPassengerController extends GetxController {
: '0',
box.read(BoxName.email).toString(),
];
print(body);
FirebaseMessagesController().sendNotificationToDriverMapPolyline(
'Order',
jsonDecode(value)['message'].toString(),
@@ -847,7 +848,7 @@ class MapPassengerController extends GetxController {
.toString(),
body,
polylineCoordinates.toString());
// //print(dataCarsLocationByPassenger);
print(dataCarsLocationByPassenger);
// //print(dataCarsLocationByPassenger['message'][0]['token'].toString());
});
delayAndFetchRideStatus(rideId);
@@ -923,13 +924,46 @@ class MapPassengerController extends GetxController {
polylineCoordinates.toString());
}
delayAndFetchRideStatus(rideId);
delayAndFetchRideStatusForAllDriverAvailable(rideId);
update();
}
String statusRide = 'wait';
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 {
if (shouldFetch) {
// //print('shouldFetch is =$shouldFetch');
@@ -947,18 +981,7 @@ class MapPassengerController extends GetxController {
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();
// }
}
});
}
@@ -1025,6 +1048,8 @@ class MapPassengerController extends GetxController {
}
late LatLng currentDriverLocation;
late double headingList;
Future getCarsLocationByPassenger() async {
// if (rideConfirm == false) {
carsLocationByPassenger = [];
@@ -1057,28 +1082,28 @@ class MapPassengerController extends GetxController {
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++) {
currentDriverLocation = LatLng(
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']),
double.parse(dataCarsLocationByPassenger['message'][i]['longitude']),
);
var json = dataCarsLocationByPassenger['message'][i];
print(json);
CarLocationModel model = CarLocationModel.fromJson(json);
carLocationsModels.add(model);
// Update lastDriverLocation on each iteration
previousLocationOfDrivers = currentDriverLocation;
// currentDriverLocation = LatLng(
// double.parse(json['latitude']),
// double.parse(json['longitude']),
// );
// // headingList = double.parse(json['heading']);
carsLocationByPassenger.add(currentDriverLocation);
driversToken.add(dataCarsLocationByPassenger['message'][i]['token']);
// // Update lastDriverLocation on each iteration
// 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();
}
}
@@ -1126,11 +1151,7 @@ class MapPassengerController extends GetxController {
for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
// }
// 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(
onTap: () => print('marker pressed'),
infoWindow: InfoWindow(
@@ -1141,7 +1162,8 @@ class MapPassengerController extends GetxController {
.toString()),
position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
driverCarsLocationToPassengerAfterApplied[i].longitude),
rotation: rotationCar,
rotation: datadriverCarsLocationToPassengerAfterApplied['message'][0]
['heading'],
);
markers.add(driverAcceptedMarker);
update();
@@ -1624,12 +1646,12 @@ class MapPassengerController extends GetxController {
// print('currentLocationOfDrivers $currentLocationOfDrivers');
// }
final marker = Marker(
infoWindow: InfoWindow(title: '${item.latitude} minutes'),
markerId: MarkerId(durationToPassenger.toString()),
position: LatLng(item.latitude, item.longitude),
rotation: math.Random().nextDouble() * 360,
// Other properties for the marker, such as icon, info window, etc.
);
infoWindow: InfoWindow(title: '${item.latitude} minutes'),
markerId: MarkerId(durationToPassenger.toString()),
position: LatLng(item.latitude, item.longitude),
rotation: item.headingList
// Other properties for the marker, such as icon, info window, etc.
);
markers.add(marker);
update();
}

View File

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

View File

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

View File

@@ -1,5 +1,7 @@
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_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
@@ -14,6 +16,7 @@ import 'constant/credential.dart';
import 'constant/info.dart';
import 'controller/firebase/firbase_messge.dart';
import 'controller/firebase/local_notification.dart';
import 'controller/functions/location_background_controller.dart';
import 'controller/local/local_controller.dart';
import 'controller/local/translations.dart';
import 'firebase_options.dart';
@@ -31,9 +34,17 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
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 {
WidgetsFlutterBinding.ensureInitialized();
WakelockPlus.enable();
await BackgroundLocation.startLocationService();
if (Platform.isAndroid) {
await NotificationController().initNotifications();
}
@@ -46,7 +57,9 @@ void main() async {
print(Get.deviceLocale!.countryCode);
Stripe.publishableKey = AK.publishableKey;
// if (box.read(BoxName.driverID) != null) {
// Get.put(LocationBackgroundController());
// }
if (Platform.isAndroid || Platform.isIOS) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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