4/9/3
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/widget/call_page.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -200,18 +201,41 @@ class FirebaseMessagesController extends GetxController {
|
||||
});
|
||||
}
|
||||
} else if (message.notification!.title! == 'Call Income') {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
NotificationController().showNotification(
|
||||
'Call Income'.tr,
|
||||
message.notification!.body!,
|
||||
'order',
|
||||
);
|
||||
Get.to(() => PassengerCallPage(
|
||||
channelName: driverList[1].toString(),
|
||||
token: driverList[0].toString(),
|
||||
remoteID: driverList[2].toString(),
|
||||
));
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController().showNotification(
|
||||
'Call Income'.tr,
|
||||
message.notification!.body!,
|
||||
'order',
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.to(() => PassengerCallPage(
|
||||
channelName: driverList[1].toString(),
|
||||
token: driverList[0].toString(),
|
||||
remoteID: driverList[2].toString(),
|
||||
));
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Call End') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController().showNotification(
|
||||
'Call End'.tr,
|
||||
message.notification!.body!,
|
||||
'order',
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.off(const CallPage());
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Driver Cancel Your Trip') {
|
||||
// Get.snackbar(
|
||||
// 'You will be pay the cost to driver or we will get it from you on next trip'
|
||||
|
||||
@@ -1,159 +1,160 @@
|
||||
// // import 'dart:io';
|
||||
// //
|
||||
// // import 'package:flutter/material.dart';
|
||||
// // import 'package:flutter_sound/flutter_sound.dart';
|
||||
// // import 'package:get/get.dart';
|
||||
// // import 'package:permission_handler/permission_handler.dart';
|
||||
// //
|
||||
// // import '../home/map_passenger_controller.dart';
|
||||
// //
|
||||
// // class AudioController extends GetxController {
|
||||
// // final recorder = FlutterSoundRecorder();
|
||||
// // bool isRecording = false;
|
||||
// //
|
||||
// // @override
|
||||
// // void onInit() {
|
||||
// // super.onInit();
|
||||
// // initRecorder();
|
||||
// // }
|
||||
// //
|
||||
// // Future<void> initRecorder() async {
|
||||
// // final status = await Permission.microphone.request();
|
||||
// // if (status != PermissionStatus.granted) {
|
||||
// // if (status.isPermanentlyDenied) {
|
||||
// // // Handle permission permanently denied
|
||||
// // showPermissionDeniedDialog();
|
||||
// // } else if (status.isDenied) {
|
||||
// // // Handle permission denied
|
||||
// // showPermissionDeniedSnackbar();
|
||||
// // } else if (status.isRestricted) {
|
||||
// // // Handle permission restricted
|
||||
// // showPermissionDeniedSnackbar();
|
||||
// // }
|
||||
// // return;
|
||||
// // }
|
||||
// // await recorder.openRecorder();
|
||||
// // recorder.setSubscriptionDuration(const Duration(minutes: 50));
|
||||
// // }
|
||||
// //
|
||||
// // Future<void> startRecording() async {
|
||||
// // if (!recorder.isStopped) {
|
||||
// // await recorder.startRecorder();
|
||||
// // }
|
||||
// // isRecording = true;
|
||||
// // update();
|
||||
// // }
|
||||
// //
|
||||
// // Future<void> stopRecording() async {
|
||||
// // final filePath = await recorder.stopRecorder();
|
||||
// // final audioFile = File(filePath!);
|
||||
// // print('Recorded file path: $audioFile');
|
||||
// // // Now you can send this file to the server
|
||||
// // isRecording = false;
|
||||
// // update();
|
||||
// // }
|
||||
// //
|
||||
// // @override
|
||||
// // void onClose() {
|
||||
// // recorder.stopRecorder();
|
||||
// // super.onClose();
|
||||
// // }
|
||||
// //
|
||||
// // void showPermissionDeniedDialog() {
|
||||
// // showDialog(
|
||||
// // context: Get.context!,
|
||||
// // builder: (context) => AlertDialog(
|
||||
// // title: const Text('Microphone Permission'),
|
||||
// // content:
|
||||
// // const Text('Microphone permission is required to record audio.'),
|
||||
// // actions: [
|
||||
// // TextButton(
|
||||
// // onPressed: () {
|
||||
// // Navigator.of(context).pop();
|
||||
// // openAppSettings();
|
||||
// // },
|
||||
// // child: const Text('Open Settings'),
|
||||
// // ),
|
||||
// // TextButton(
|
||||
// // onPressed: () {
|
||||
// // Navigator.of(context).pop();
|
||||
// // },
|
||||
// // child: const Text('Cancel'),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
// //
|
||||
// // void showPermissionDeniedSnackbar() {
|
||||
// // Get.snackbar(
|
||||
// // 'Microphone Permission',
|
||||
// // 'Microphone permission is required to record audio.',
|
||||
// // snackPosition: SnackPosition.BOTTOM,
|
||||
// // duration: const Duration(seconds: 5),
|
||||
// // mainButton: TextButton(
|
||||
// // onPressed: () {
|
||||
// // openAppSettings();
|
||||
// // },
|
||||
// // child: const Text(
|
||||
// // 'Open Settings',
|
||||
// // style: TextStyle(color: Colors.white),
|
||||
// // ),
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// import 'dart:io';
|
||||
//
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_sound/flutter_sound.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// // import 'package:flutter_sound/flutter_sound.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
//
|
||||
// class AudioController extends GetxController {
|
||||
// final flutterSoundHelper = FlutterSoundHelper();
|
||||
// import '../home/map_passenger_controller.dart';
|
||||
//
|
||||
// class AudioController extends GetxController {
|
||||
// final recorder = FlutterSoundRecorder();
|
||||
// bool isRecording = false;
|
||||
//
|
||||
// Future<void> startRecording() async {
|
||||
// if (!await flutterSoundHelper.hasPermissions()) {
|
||||
// await flutterSoundHelper.requestPermissions();
|
||||
// }
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// initRecorder();
|
||||
// }
|
||||
//
|
||||
// if (!await flutterSoundHelper.hasPermissions()) {
|
||||
// Future<void> initRecorder() async {
|
||||
// final status = await Permission.microphone.request();
|
||||
// if (status != PermissionStatus.granted) {
|
||||
// if (status.isPermanentlyDenied) {
|
||||
// // Handle permission permanently denied
|
||||
// showPermissionDeniedDialog();
|
||||
// } else if (status.isDenied) {
|
||||
// // Handle permission denied
|
||||
// showPermissionDeniedSnackbar();
|
||||
// } else if (status.isRestricted) {
|
||||
// // Handle permission restricted
|
||||
// showPermissionDeniedSnackbar();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// await recorder.openRecorder();
|
||||
// recorder.setSubscriptionDuration(const Duration(minutes: 50));
|
||||
// }
|
||||
//
|
||||
// await flutterSoundHelper.startRecorder();
|
||||
// Future<void> startRecording() async {
|
||||
// if (!recorder.isStopped) {
|
||||
// await recorder.startRecorder();
|
||||
// }
|
||||
// isRecording = true;
|
||||
// update();
|
||||
// }
|
||||
//
|
||||
// Future<void> stopRecording() async {
|
||||
// if (!isRecording) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// await flutterSoundHelper.stopRecorder();
|
||||
// final filePath = await recorder.stopRecorder();
|
||||
// final audioFile = File(filePath!);
|
||||
// print('Recorded file path: $audioFile');
|
||||
// // Now you can send this file to the server
|
||||
// isRecording = false;
|
||||
// update();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void onClose() {
|
||||
// recorder.stopRecorder();
|
||||
// super.onClose();
|
||||
// }
|
||||
//
|
||||
// void showPermissionDeniedDialog() {
|
||||
// showDialog(
|
||||
// context: Get.context!,
|
||||
// builder: (context) => AlertDialog(
|
||||
// title: const Text('Microphone Permission'),
|
||||
// content:
|
||||
// const Text('Microphone permission is required to record audio.'),
|
||||
// actions: [
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// openAppSettings();
|
||||
// },
|
||||
// child: const Text('Open Settings'),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: const Text('Cancel'),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// void showPermissionDeniedSnackbar() {
|
||||
// Get.snackbar(
|
||||
// 'Microphone Permission',
|
||||
// 'Microphone permission is required to record audio.',
|
||||
// snackPosition: SnackPosition.BOTTOM,
|
||||
// duration: const Duration(seconds: 5),
|
||||
// mainButton: TextButton(
|
||||
// onPressed: () {
|
||||
// openAppSettings();
|
||||
// },
|
||||
// child: const Text(
|
||||
// 'Open Settings',
|
||||
// style: TextStyle(color: Colors.white),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class FlutterSoundHelper {
|
||||
// final flutterSound = FlutterSoundRecorder();
|
||||
//
|
||||
// Future<bool> hasPermissions() async {
|
||||
// return await Permission.microphone.isGranted;
|
||||
// }
|
||||
//
|
||||
// Future<void> requestPermissions() async {
|
||||
// await Permission.microphone.request();
|
||||
// }
|
||||
//
|
||||
// Future<void> startRecorder() async {
|
||||
// await flutterSound.openRecorder();
|
||||
// await flutterSound.startRecorder(toFile: 'audio.wav');
|
||||
// }
|
||||
//
|
||||
// Future<void> stopRecorder() async {
|
||||
// await flutterSound.stopRecorder();
|
||||
// await flutterSound.closeRecorder();
|
||||
// }
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_sound/flutter_sound.dart';
|
||||
import 'package:get/get.dart';
|
||||
// import 'package:flutter_sound/flutter_sound.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class AudioController extends GetxController {
|
||||
final flutterSoundHelper = FlutterSoundHelper();
|
||||
|
||||
bool isRecording = false;
|
||||
|
||||
Future<void> startRecording() async {
|
||||
if (!await flutterSoundHelper.hasPermissions()) {
|
||||
await flutterSoundHelper.requestPermissions();
|
||||
}
|
||||
|
||||
if (!await flutterSoundHelper.hasPermissions()) {
|
||||
return;
|
||||
}
|
||||
|
||||
await flutterSoundHelper.startRecorder();
|
||||
isRecording = true;
|
||||
}
|
||||
|
||||
Future<void> stopRecording() async {
|
||||
if (!isRecording) {
|
||||
return;
|
||||
}
|
||||
|
||||
await flutterSoundHelper.stopRecorder();
|
||||
isRecording = false;
|
||||
}
|
||||
}
|
||||
|
||||
class FlutterSoundHelper {
|
||||
final flutterSound = FlutterSoundRecorder();
|
||||
|
||||
Future<bool> hasPermissions() async {
|
||||
return await Permission.microphone.isGranted;
|
||||
}
|
||||
|
||||
Future<void> requestPermissions() async {
|
||||
await Permission.microphone.request();
|
||||
}
|
||||
|
||||
Future<void> startRecorder() async {
|
||||
await flutterSound.openRecorder();
|
||||
await flutterSound.startRecorder(toFile: 'audio.wav');
|
||||
}
|
||||
|
||||
Future<void> stopRecorder() async {
|
||||
await flutterSound.stopRecorder();
|
||||
await flutterSound.closeRecorder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,7 +935,7 @@ class MapPassengerController extends GetxController {
|
||||
box.read(BoxName.carType),
|
||||
kazan.toStringAsFixed(0),
|
||||
passengerRate.toStringAsFixed(2),
|
||||
];
|
||||
]; //
|
||||
print(body);
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Order',
|
||||
|
||||
@@ -25,7 +25,7 @@ class CallController extends GetxController {
|
||||
channelName = Get.find<MapDriverController>().rideId; // 'sefer300'; //
|
||||
remoteUid = int.parse(Get.find<MapDriverController>().passengerPhone);
|
||||
uid = int.parse(box.read(BoxName.phoneDriver));
|
||||
// initAgoraFull();
|
||||
initAgoraFull();
|
||||
}
|
||||
|
||||
initAgoraFull() async {
|
||||
@@ -36,7 +36,7 @@ class CallController extends GetxController {
|
||||
setupVoiceSDKEngine();
|
||||
join();
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Call Income'.tr,
|
||||
'Call Income',
|
||||
'${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}',
|
||||
Get.find<MapDriverController>().tokenPassenger,
|
||||
[
|
||||
|
||||
@@ -70,8 +70,8 @@ GetBuilder<HomeCaptainController> callPage() {
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Call End'.tr,
|
||||
'Call End',
|
||||
'Call End'.tr,
|
||||
Get.find<MapDriverController>().tokenPassenger,
|
||||
[],
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ class RideBeginPassenger extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ProfileController profileController = Get.put(ProfileController());
|
||||
// AudioController audioController = Get.put(AudioController());
|
||||
AudioController audioController = Get.put(AudioController());
|
||||
return GetBuilder<MapPassengerController>(builder: (controller) {
|
||||
if (controller.rideTimerBegin ||
|
||||
controller.statusRide == 'Begin' && !controller.statusRideFromStart) {
|
||||
@@ -82,29 +82,29 @@ class RideBeginPassenger extends StatelessWidget {
|
||||
),
|
||||
tooltip: ' Add Note', // Optional tooltip for clarity
|
||||
),
|
||||
// audioController.isRecording == false
|
||||
// ? IconButton(
|
||||
// onPressed: () async {
|
||||
// await audioController.startRecording();
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// Icons.play_circle_fill_outlined,
|
||||
// color: AppColor.greenColor,
|
||||
// ),
|
||||
// tooltip:
|
||||
// ' Add Note', // Optional tooltip for clarity
|
||||
// )
|
||||
// : IconButton(
|
||||
// onPressed: () async {
|
||||
// await audioController.stopRecording();
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// Icons.stop_circle,
|
||||
// color: AppColor.greenColor,
|
||||
// ),
|
||||
// tooltip:
|
||||
// ' Add Note', // Optional tooltip for clarity
|
||||
// ),
|
||||
audioController.isRecording == false
|
||||
? IconButton(
|
||||
onPressed: () async {
|
||||
await audioController.startRecording();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.play_circle_fill_outlined,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
tooltip:
|
||||
' Add Note', // Optional tooltip for clarity
|
||||
)
|
||||
: IconButton(
|
||||
onPressed: () async {
|
||||
await audioController.stopRecording();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.stop_circle,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
tooltip:
|
||||
' Add Note', // Optional tooltip for clarity
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
|
||||
Reference in New Issue
Block a user