7/21/2
This commit is contained in:
@@ -24,7 +24,9 @@ import '../../constant/links.dart';
|
||||
import '../../constant/table_names.dart';
|
||||
import '../../main.dart';
|
||||
import '../../models/model/locations.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/home/map_widget.dart/car_details_widget_to_go.dart';
|
||||
import '../../views/home/map_widget.dart/select_driver_mishwari.dart';
|
||||
import '../../views/widgets/elevated_btn.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../functions/audio_record1.dart';
|
||||
@@ -2815,6 +2817,72 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
Future selectDriverAndCarForMishwariTrip() async {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.selectDriverAndCarForMishwariTrip, payload: {});
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res);
|
||||
return d['message'];
|
||||
} else {
|
||||
return 'No driver available now try later time\nthanks for using our app'
|
||||
.tr;
|
||||
}
|
||||
}
|
||||
|
||||
final Rx<DateTime> selectedDateTime = DateTime.now().obs;
|
||||
|
||||
void updateDateTime(DateTime newDateTime) {
|
||||
selectedDateTime.value = newDateTime;
|
||||
}
|
||||
|
||||
Future mishwariOption() async {
|
||||
// isBottomSheetShown = false;
|
||||
update();
|
||||
// add dialoug for select driver and car
|
||||
List driversForMishwari = await selectDriverAndCarForMishwariTrip();
|
||||
Future.delayed(Duration.zero);
|
||||
Log.print('driversForMishwari: ${driversForMishwari}');
|
||||
Get.to(() => CupertinoDriverListWidget(
|
||||
drivers: driversForMishwari,
|
||||
));
|
||||
|
||||
// add dialoug to select date and time
|
||||
|
||||
// changeCashConfirmPageShown();
|
||||
}
|
||||
|
||||
Future<void> saveTripData(
|
||||
Map<String, dynamic> driver, DateTime tripDateTime) async {
|
||||
try {
|
||||
// Prepare trip data
|
||||
Map<String, dynamic> tripData = {
|
||||
'driver_id': driver['id'],
|
||||
'passenger_id': box.read(BoxName.passengerID),
|
||||
'trip_datetime': tripDateTime.toIso8601String(),
|
||||
// Add other necessary trip details
|
||||
};
|
||||
|
||||
// Send data to server
|
||||
var response =
|
||||
await CRUD().post(link: AppLink.addAdminUser, payload: tripData);
|
||||
|
||||
if (response != 'failure') {
|
||||
// Trip saved successfully
|
||||
Get.snackbar('Success'.tr, 'Trip booked successfully'.tr);
|
||||
|
||||
// Set up local notification
|
||||
// await setLocalNotification(tripDateTime);
|
||||
|
||||
// Send notification to driver
|
||||
// await FirebaseMessagesController().sendNotificationToDriverMAP();
|
||||
} else {
|
||||
throw Exception('Failed to save trip');
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar('Error'.tr, 'Failed to book trip: $e'.tr);
|
||||
}
|
||||
}
|
||||
|
||||
initilizeGetStorage() async {
|
||||
if (box.read(BoxName.addWork) == null) {
|
||||
box.write(BoxName.addWork, 'addWork');
|
||||
|
||||
Reference in New Issue
Block a user