2/4/1
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
@@ -13,9 +14,11 @@ import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
@@ -99,7 +102,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
if (message.data.isNotEmpty) {
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
// If the app is in the background or terminated, show a system tray message
|
||||
RemoteNotification? notification = message.notification;
|
||||
@@ -108,7 +111,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
if (notification != null && android != null) {
|
||||
// print('onMessageOpenedApp: ${notification.title} ${notification.body}');
|
||||
if (message.data.isNotEmpty) {
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -117,11 +120,11 @@ class FirebaseMessagesController extends GetxController {
|
||||
// print(
|
||||
// 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||
RemoteNotification? notification = message.notification;
|
||||
firebasetitles(message);
|
||||
fireBaseTitles(message);
|
||||
});
|
||||
}
|
||||
|
||||
void firebasetitles(RemoteMessage message) {
|
||||
void fireBaseTitles(RemoteMessage message) {
|
||||
if (message.notification!.title!.contains('Order')) {
|
||||
var myListString = message.data['DriverList'];
|
||||
print(myListString);
|
||||
@@ -181,13 +184,49 @@ class FirebaseMessagesController extends GetxController {
|
||||
Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
|
||||
// mapController.driverArrivePassenger();
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('Captain Finish Trip')) {
|
||||
// MapPassengerController mapController =
|
||||
// Get.find<MapPassengerController>();
|
||||
Get.snackbar('Ride Finished'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
// mapController.isRideFinished = true;//todo fix that for dfinish ride in passenger app
|
||||
update();
|
||||
} else if (message.notification!.title!.contains('Driver Finish Trip')) {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.defaultDialog(
|
||||
title: 'Driver Finish Trip'.tr,
|
||||
content: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Your fee is ${Get.find<MapPassengerController>().totalPassenger.toStringAsFixed(2)}'),
|
||||
Text('Do you want to pay Tips for this Driver'.tr)
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Yes'.tr,
|
||||
onPressed: () async {
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
'passengerID': box.read(BoxName.passengerID),
|
||||
'driverID': driverList[0].toString(),
|
||||
'rideID': driverList[1].toString(),
|
||||
'tipAmount': '1',
|
||||
});
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'You Have Tips',
|
||||
'1\$ tips',
|
||||
driverList[2].toString(),
|
||||
);
|
||||
}
|
||||
Get.to(() => RateCaptainFromPassenger(), arguments: {
|
||||
'driverId': driverList[0].toString(),
|
||||
'rideId': driverList[1].toString(),
|
||||
});
|
||||
},
|
||||
kolor: AppColor.greenColor,
|
||||
),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'No,I want'.tr,
|
||||
onPressed: () {
|
||||
Get.offAll(() => RateCaptainFromPassenger());
|
||||
},
|
||||
kolor: AppColor.redColor,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user