9/20/1
This commit is contained in:
@@ -10,7 +10,7 @@ class TimerController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
startTimer();
|
||||
// startTimer();//TODO check if it true
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class MapController extends GetxController {
|
||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
double height = 150;
|
||||
DateTime currentTime = DateTime.now();
|
||||
final location = Location();
|
||||
late LocationData currentLocation;
|
||||
double heightMenu = 0;
|
||||
@@ -187,6 +188,7 @@ class MapController extends GetxController {
|
||||
delayAndFetchRideStatus(rideId);
|
||||
if (shouldFetch == false) {
|
||||
startTimer();
|
||||
update();
|
||||
}
|
||||
update();
|
||||
}
|
||||
@@ -204,15 +206,16 @@ class MapController extends GetxController {
|
||||
decod['data'].toString() == 'Refused') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
rideConfirm = false;
|
||||
|
||||
startTimer();
|
||||
update();
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
shouldFetch = true;
|
||||
update();
|
||||
// delayAndFetchRideStatus(
|
||||
// rideId); // Repeat the delay and fetch operation
|
||||
}
|
||||
}
|
||||
});
|
||||
startTimer();
|
||||
}
|
||||
|
||||
void startTimer() async {
|
||||
@@ -240,6 +243,108 @@ class MapController extends GetxController {
|
||||
return response['status'];
|
||||
}
|
||||
|
||||
Future getCarsLocationByPassenger() async {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds =
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}');
|
||||
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
|
||||
'southwestLat': southwest.latitude.toString(),
|
||||
'southwestLon': southwest.longitude.toString(),
|
||||
'northeastLat': northeast.latitude.toString(),
|
||||
'northeastLon': northeast.longitude.toString(),
|
||||
});
|
||||
if (res == 'failure') {
|
||||
Get.defaultDialog(
|
||||
title: 'No Car in your site.Sorry!',
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
markerReloadingTimer.cancel();
|
||||
}));
|
||||
} else {
|
||||
dataCarsLocationByPassenger = jsonDecode(res);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(
|
||||
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']),
|
||||
double.parse(
|
||||
dataCarsLocationByPassenger['message'][i]['longitude'])));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Future getDriverCarsLocationToPassengerAfterApplied() async {
|
||||
driverCarsLocationToPassengerAfterApplied = [];
|
||||
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
|
||||
payload: {
|
||||
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
|
||||
});
|
||||
|
||||
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
|
||||
|
||||
driverCarsLocationToPassengerAfterApplied.add(LatLng(
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude'])));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future runEvery50SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 60;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
}
|
||||
|
||||
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
|
||||
// Clear existing markers
|
||||
markers.clear();
|
||||
update();
|
||||
for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
|
||||
// }
|
||||
// for (var item in driverCarsLocationToPassengerAfterApplied) {
|
||||
final marker = Marker(
|
||||
infoWindow: InfoWindow(
|
||||
title:
|
||||
'${driverCarsLocationToPassengerAfterApplied[i].latitude} minutes'),
|
||||
markerId: MarkerId(
|
||||
datadriverCarsLocationToPassengerAfterApplied['message'][0]['id']
|
||||
.toString()),
|
||||
position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
|
||||
driverCarsLocationToPassengerAfterApplied[i].longitude),
|
||||
);
|
||||
markers.add(marker);
|
||||
update();
|
||||
mapController?.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
driverCarsLocationToPassengerAfterApplied[i].latitude,
|
||||
driverCarsLocationToPassengerAfterApplied[i].longitude)));
|
||||
update();
|
||||
} // Update the map with the new markers
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
print(rideConfirm);
|
||||
|
||||
@@ -398,100 +503,6 @@ class MapController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
Future getCarsLocationByPassenger() async {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds =
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
'Northeast: ${bounds.northeast.latitude}, ${bounds.northeast.longitude}');
|
||||
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
|
||||
'southwestLat': southwest.latitude.toString(),
|
||||
'southwestLon': southwest.longitude.toString(),
|
||||
'northeastLat': northeast.latitude.toString(),
|
||||
'northeastLon': northeast.longitude.toString(),
|
||||
});
|
||||
if (res == 'failure') {
|
||||
Get.defaultDialog(
|
||||
title: 'No Car in your site.Sorry!',
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
markerReloadingTimer.cancel();
|
||||
}));
|
||||
} else {
|
||||
dataCarsLocationByPassenger = jsonDecode(res);
|
||||
// print(dataCarsLocationByPassenger);
|
||||
|
||||
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(
|
||||
double.parse(dataCarsLocationByPassenger['message'][i]['latitude']),
|
||||
double.parse(
|
||||
dataCarsLocationByPassenger['message'][i]['longitude'])));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Future getDriverCarsLocationToPassengerAfterApplied() async {
|
||||
driverCarsLocationToPassengerAfterApplied = [];
|
||||
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
|
||||
payload: {
|
||||
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
|
||||
});
|
||||
|
||||
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
|
||||
|
||||
driverCarsLocationToPassengerAfterApplied.add(LatLng(
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude'])));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future runEvery50SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 60;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
}
|
||||
|
||||
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
|
||||
// Clear existing markers
|
||||
markers.clear();
|
||||
|
||||
for (var item in driverCarsLocationToPassengerAfterApplied) {
|
||||
final marker = Marker(
|
||||
infoWindow: InfoWindow(title: '${item.latitude} minutes'),
|
||||
markerId: MarkerId(item.toString()),
|
||||
position: LatLng(item.latitude, item.longitude),
|
||||
);
|
||||
markers.add(marker);
|
||||
update();
|
||||
mapController?.animateCamera(
|
||||
CameraUpdate.newLatLng(LatLng(item.latitude, item.longitude)));
|
||||
update();
|
||||
} // Update the map with the new markers
|
||||
}
|
||||
|
||||
LatLngBounds calculateBounds(
|
||||
double centerLat, double centerLng, double radius) {
|
||||
// double radius = 4000; // 10 km in meters
|
||||
@@ -571,7 +582,10 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
String duratioByPassenger = '';
|
||||
late DateTime newTime1 = DateTime.now();
|
||||
String distanceByPassenger = '';
|
||||
late Duration durationfromDriverToPassenger;
|
||||
|
||||
void getNearestDriverByPassengerLocation() async {
|
||||
if (polylines.isEmpty || data.isEmpty) {
|
||||
double nearestDistance = double.infinity;
|
||||
@@ -607,6 +621,8 @@ class MapController extends GetxController {
|
||||
distanceByPassenger =
|
||||
data['rows'][0]['elements'][0]['distance']['text'];
|
||||
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
||||
durationfromDriverToPassenger = Duration(seconds: duration1.toInt());
|
||||
newTime1 = currentTime.add(durationfromDriverToPassenger);
|
||||
duratioByPassenger =
|
||||
data['rows'][0]['elements'][0]['duration']['text'];
|
||||
|
||||
@@ -771,7 +787,7 @@ class MapController extends GetxController {
|
||||
late double cost = 0;
|
||||
late double distance = 0;
|
||||
late double duration = 0;
|
||||
DateTime currentTime = DateTime.now();
|
||||
|
||||
late Duration durationToAdd;
|
||||
late DateTime newTime = DateTime.now();
|
||||
Future bottomSheet() async {
|
||||
|
||||
@@ -44,32 +44,33 @@ class CreditCardController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
String? cardNumber = await SecureStorage().readData(BoxName.cardNumber);
|
||||
String? cardHolderName =
|
||||
await SecureStorage().readData(BoxName.cardHolderName);
|
||||
String? expiryDate = await SecureStorage().readData(BoxName.expiryDate);
|
||||
String? cvvCode = await SecureStorage().readData(BoxName.cvvCode);
|
||||
openPayment();
|
||||
// String? cardNumber = await SecureStorage().readData(BoxName.cardNumber);
|
||||
// String? cardHolderName =
|
||||
// await SecureStorage().readData(BoxName.cardHolderName);
|
||||
// String? expiryDate = await SecureStorage().readData(BoxName.expiryDate);
|
||||
// String? cvvCode = await SecureStorage().readData(BoxName.cvvCode);
|
||||
|
||||
print('cardNumber: $cardNumber');
|
||||
print('cardHolderName: $cardHolderName');
|
||||
print('expiryDate: $expiryDate');
|
||||
print('cvvCode: $cvvCode');
|
||||
// print('cardNumber: $cardNumber');
|
||||
// print('cardHolderName: $cardHolderName');
|
||||
// print('expiryDate: $expiryDate');
|
||||
// print('cvvCode: $cvvCode');
|
||||
|
||||
if (cvvCode != null && cvvCode.isNotEmpty) {
|
||||
final maskedCardNumber = DigitObscuringFormatter()
|
||||
.formatEditUpdate(
|
||||
TextEditingValue.empty,
|
||||
TextEditingValue(text: cardNumber ?? ''),
|
||||
)
|
||||
.text;
|
||||
// if (cvvCode != null && cvvCode.isNotEmpty) {
|
||||
// final maskedCardNumber = DigitObscuringFormatter()
|
||||
// .formatEditUpdate(
|
||||
// TextEditingValue.empty,
|
||||
// TextEditingValue(text: cardNumber ?? ''),
|
||||
// )
|
||||
// .text;
|
||||
|
||||
print('maskedCardNumber: $maskedCardNumber');
|
||||
// print('maskedCardNumber: $maskedCardNumber');
|
||||
|
||||
cardNumberController.text = maskedCardNumber;
|
||||
cardHolderNameController.text = cardHolderName ?? '';
|
||||
expiryDateController.text = expiryDate ?? '';
|
||||
cvvCodeController.text = cvvCode;
|
||||
}
|
||||
// cardNumberController.text = maskedCardNumber;
|
||||
// cardHolderNameController.text = cardHolderName ?? '';
|
||||
// expiryDateController.text = expiryDate ?? '';
|
||||
// cvvCodeController.text = cvvCode;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user