9/13/1
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/controller/functions/launch.dart';
|
||||
import 'package:ride/controller/home/map_page_controller.dart';
|
||||
import 'package:ride/views/home/profile/promos_passenger_page.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
@@ -206,19 +207,84 @@ class FirebasMessagesController extends GetxController {
|
||||
print(passengerList);
|
||||
print('9999999999999my Apply Ride 999999999999999');
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: message.notification!.title.toString(),
|
||||
content: Row(
|
||||
children: [Text(myList[1].toString())],
|
||||
Get.snackbar(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'message',
|
||||
colorText: AppColor.greenColor,
|
||||
duration: const Duration(seconds: 11),
|
||||
instantInit: true,
|
||||
snackPosition: SnackPosition.TOP,
|
||||
titleText: Text(
|
||||
'Applied'.tr,
|
||||
style: const TextStyle(color: AppColor.redColor),
|
||||
),
|
||||
messageText: Text(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
icon: const Icon(Icons.approval),
|
||||
shouldIconPulse: true,
|
||||
maxWidth: double.infinity,
|
||||
margin: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
borderRadius: 8,
|
||||
borderColor: AppColor.primaryColor,
|
||||
borderWidth: 2,
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
leftBarIndicatorColor: AppColor.greenColor,
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 4,
|
||||
spreadRadius: 2,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok',
|
||||
onPressed: () {
|
||||
// MapController().rideConfirm = true;
|
||||
},
|
||||
));
|
||||
],
|
||||
backgroundGradient: const LinearGradient(
|
||||
colors: [AppColor.greenColor, AppColor.accentColor],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
onTap: (GetSnackBar snackBar) {
|
||||
// Do something when the snackbar is tapped.
|
||||
// MapController().rideConfirm = false;
|
||||
// update();
|
||||
},
|
||||
isDismissible: true,
|
||||
showProgressIndicator: false,
|
||||
dismissDirection: DismissDirection.up,
|
||||
progressIndicatorController: null,
|
||||
progressIndicatorBackgroundColor: Colors.transparent,
|
||||
progressIndicatorValueColor: null,
|
||||
snackStyle: SnackStyle.GROUNDED,
|
||||
forwardAnimationCurve: Curves.easeInToLinear,
|
||||
reverseAnimationCurve: Curves.easeInOut,
|
||||
animationDuration: const Duration(milliseconds: 4000),
|
||||
barBlur: 8,
|
||||
overlayBlur: 0,
|
||||
snackbarStatus: null,
|
||||
overlayColor: AppColor.primaryColor.withOpacity(0.5),
|
||||
userInputForm: null,
|
||||
);
|
||||
|
||||
// Get.defaultDialog(
|
||||
// barrierDismissible: false,
|
||||
// title: message.notification!.title.toString(),
|
||||
// content: Row(
|
||||
// children: [Text(myList[1].toString())],
|
||||
// ),
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'Ok',
|
||||
// onPressed: () {
|
||||
// // MapController().rideConfirm = true;
|
||||
// },
|
||||
// ),
|
||||
// cancel: MyElevatedButton(
|
||||
// title: 'Cancel',
|
||||
// onPressed: () {
|
||||
// Get.back();
|
||||
// },
|
||||
// ));
|
||||
} else if (message.notification!.title!.contains('Promo')) {
|
||||
Get.to(const PromosPassengerPage());
|
||||
}
|
||||
@@ -370,9 +436,6 @@ class FirebasMessagesController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// void sendNotificationToManager(String title, body) async {
|
||||
// // tokens = box.read(BoxName.tokenManager);
|
||||
|
||||
// for (var i = 0; i < tokens.length; i++) {
|
||||
// http
|
||||
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
|
||||
@@ -59,8 +59,12 @@ class MapController extends GetxController {
|
||||
var dataCarsLocationByPassenger;
|
||||
CarLocation? nearestCar;
|
||||
late Timer markerReloadingTimer;
|
||||
|
||||
bool shouldFetch = true; // Flag to determine if fetch should be executed
|
||||
int selectedPassengerCount = 1;
|
||||
double progress = 0;
|
||||
int durationTimer = 25;
|
||||
int remainingTime = 0;
|
||||
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
selectedPassengerCount = newValue;
|
||||
update();
|
||||
@@ -126,9 +130,11 @@ class MapController extends GetxController {
|
||||
}
|
||||
|
||||
changeConfirmRide() async {
|
||||
// rideConfirm = true;
|
||||
// update();
|
||||
rideConfirm = true;
|
||||
shouldFetch = true;
|
||||
update();
|
||||
// print('rideConfirm= $rideConfirm');
|
||||
var rideId;
|
||||
await getCarsLocationByPassenger();
|
||||
await CRUD().post(link: AppLink.addRides, payload: {
|
||||
"start_location": '${data[0]['start_address']}',
|
||||
@@ -148,6 +154,7 @@ class MapController extends GetxController {
|
||||
}).then((value) {
|
||||
// print(jsonDecode(value)['message']);
|
||||
// List<String> body = [
|
||||
rideId = jsonDecode(value)['message'];
|
||||
List<String> body = [
|
||||
// '${data[0]['start_address']}',
|
||||
// '${data[0]['end_address']}',
|
||||
@@ -171,29 +178,63 @@ class MapController extends GetxController {
|
||||
dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
body,
|
||||
);
|
||||
// FirebasMessagesController().sendNotificationToDriverId(
|
||||
// 'Order',
|
||||
// jsonDecode(value)['message'].toString(),
|
||||
// body[0],
|
||||
// body[1],
|
||||
// body[2],
|
||||
// body[3],
|
||||
// body[4],
|
||||
// body[5],
|
||||
// body[6],
|
||||
// body[7],
|
||||
// body[8],
|
||||
// body[9],
|
||||
// body[10],
|
||||
// dataCarsLocationByPassenger['message'][0]['token'].toString(),
|
||||
// );
|
||||
print(dataCarsLocationByPassenger);
|
||||
print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
// print(dataCarsLocationByPassenger);
|
||||
// print(dataCarsLocationByPassenger['message'][0]['token'].toString());
|
||||
});
|
||||
|
||||
delayAndFetchRideStatus(rideId);
|
||||
if (shouldFetch == false) {
|
||||
startTimer();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void delayAndFetchRideStatus(String rideId) {
|
||||
Timer(const Duration(seconds: 3), () async {
|
||||
if (shouldFetch) {
|
||||
// print('shouldFetch is =$shouldFetch');
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideStatus, payload: {'order_id': rideId});
|
||||
var decod = jsonDecode(res);
|
||||
// print(' 0000000000000000000000000000000000000000000000000');
|
||||
// print(decod['data']);
|
||||
if (decod['data'].toString() == 'Apply' ||
|
||||
decod['data'].toString() == 'Refused') {
|
||||
shouldFetch = false; // Stop further fetches
|
||||
rideConfirm = false;
|
||||
|
||||
update();
|
||||
} else {
|
||||
delayAndFetchRideStatus(
|
||||
rideId); // Repeat the delay and fetch operation
|
||||
}
|
||||
}
|
||||
});
|
||||
startTimer();
|
||||
}
|
||||
|
||||
void startTimer() async {
|
||||
for (int i = 0; i <= durationTimer; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progress = i / durationTimer;
|
||||
remainingTime = durationTimer - i;
|
||||
|
||||
update();
|
||||
}
|
||||
timerEnded();
|
||||
}
|
||||
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
// refuseOrder();
|
||||
}
|
||||
|
||||
Future<String> getRideStatus(int rideId) async {
|
||||
final response = await CRUD()
|
||||
.get(link: AppLink.getRideStatus, payload: {'order_id': rideId});
|
||||
|
||||
return response['status'];
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
print(rideConfirm);
|
||||
|
||||
@@ -202,11 +243,13 @@ class MapController extends GetxController {
|
||||
clearpolyline();
|
||||
data = [];
|
||||
changeCancelRidePageShow();
|
||||
rideConfirm = false;
|
||||
update();
|
||||
} else {
|
||||
clearPlaces();
|
||||
clearpolyline();
|
||||
data = [];
|
||||
rideConfirm = false;
|
||||
changeCancelRidePageShow();
|
||||
|
||||
await CRUD().post(link: AppLink.addCancelRide, payload: {
|
||||
@@ -349,7 +392,7 @@ class MapController extends GetxController {
|
||||
Future getCarsLocationByPassenger() async {
|
||||
carsLocationByPassenger = [];
|
||||
LatLngBounds bounds =
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 10);
|
||||
calculateBounds(mylocation.latitude, mylocation.longitude, 8000);
|
||||
print(
|
||||
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user