This commit is contained in:
Hamza Aleghwairyeen
2024-04-09 02:52:52 +03:00
parent 207a87a5f0
commit d68eb5028f
11 changed files with 249 additions and 164 deletions

View File

@@ -196,6 +196,7 @@ class FirebaseMessagesController extends GetxController {
Get.to(() => RateDriverFromPassenger(), arguments: { Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(), 'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(), 'rideId': driverList[1].toString(),
'price': driverList[3].toString()
}); });
} }
} else if (message.notification!.title! == 'Call Income') { } else if (message.notification!.title! == 'Call Income') {
@@ -347,6 +348,7 @@ class FirebaseMessagesController extends GetxController {
Get.to(() => RateDriverFromPassenger(), arguments: { Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(), 'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(), 'rideId': driverList[1].toString(),
'price': driverList[3].toString()
}); });
}, },
kolor: AppColor.greenColor, kolor: AppColor.greenColor,
@@ -357,6 +359,7 @@ class FirebaseMessagesController extends GetxController {
Get.to(() => RateDriverFromPassenger(), arguments: { Get.to(() => RateDriverFromPassenger(), arguments: {
'driverId': driverList[0].toString(), 'driverId': driverList[0].toString(),
'rideId': driverList[1].toString(), 'rideId': driverList[1].toString(),
'price': driverList[3].toString()
}); });
}, },
kolor: AppColor.redColor, kolor: AppColor.redColor,

View File

@@ -1,101 +1,159 @@
import 'dart:io'; // 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 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import '../home/map_passenger_controller.dart';
class AudioController extends GetxController { class AudioController extends GetxController {
final recorder = FlutterSoundRecorder(); final flutterSoundHelper = FlutterSoundHelper();
bool isRecording = false; bool isRecording = false;
@override Future<void> startRecording() async {
void onInit() { if (!await flutterSoundHelper.hasPermissions()) {
super.onInit(); await flutterSoundHelper.requestPermissions();
initRecorder(); }
}
Future<void> initRecorder() async { if (!await flutterSoundHelper.hasPermissions()) {
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
if (status.isPermanentlyDenied) {
// Handle permission permanently denied
showPermissionDeniedDialog();
} else {
// Handle permission denied
showPermissionDeniedSnackbar();
}
return; return;
} }
await recorder.openRecorder();
recorder.setSubscriptionDuration(const Duration(minutes: 50));
}
Future<void> startRecording() async { await flutterSoundHelper.startRecorder();
final controller = Get.find<MapPassengerController>();
final filePath = 'audio_${controller.rideId}.wav'; // Specify the file name
await recorder.startRecorder(toFile: filePath);
isRecording = true; isRecording = true;
update();
} }
Future<void> stopRecording() async { Future<void> stopRecording() async {
final filePath = await recorder.stopRecorder(); if (!isRecording) {
final audioFile = File(filePath!); return;
print('Recorded file path: $audioFile'); }
// Now you can send this file to the server
await flutterSoundHelper.stopRecorder();
isRecording = false; isRecording = false;
update(); }
} }
@override class FlutterSoundHelper {
void onClose() { final flutterSound = FlutterSoundRecorder();
recorder.stopRecorder();
super.onClose(); Future<bool> hasPermissions() async {
} return await Permission.microphone.isGranted;
}
void showPermissionDeniedDialog() {
showDialog( Future<void> requestPermissions() async {
context: Get.context!, await Permission.microphone.request();
builder: (context) => AlertDialog( }
title: Text('Microphone Permission'),
content: Text('Microphone permission is required to record audio.'), Future<void> startRecorder() async {
actions: [ await flutterSound.openRecorder();
TextButton( await flutterSound.startRecorder(toFile: 'audio.wav');
onPressed: () { }
Navigator.of(context).pop();
openAppSettings(); Future<void> stopRecorder() async {
}, await flutterSound.stopRecorder();
child: Text('Open Settings'), await flutterSound.closeRecorder();
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Cancel'),
),
],
),
);
}
void showPermissionDeniedSnackbar() {
Get.snackbar(
'Microphone Permission',
'Microphone permission is required to record audio.',
snackPosition: SnackPosition.BOTTOM,
duration: Duration(seconds: 5),
mainButton: TextButton(
onPressed: () {
openAppSettings();
},
child: Text(
'Open Settings',
style: TextStyle(color: Colors.white),
),
),
);
} }
} }

View File

@@ -425,9 +425,11 @@ class MapDriverController extends GetxController {
isRideFinished = true; isRideFinished = true;
isRideStarted = false; isRideStarted = false;
isPriceWindow = false; isPriceWindow = false;
totalCost = carType == 'Comfort' || carType == 'Mashwari' totalCost = carType != 'Comfort' || carType != 'Mashwari'
? price.toStringAsFixed(1) ? totalPassenger
: totalPassenger; : price < double.parse(totalPassenger)
? totalPassenger
: price.toStringAsFixed(1);
paymentAmount = totalCost; paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off'); box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger(); // changeRideToBeginToPassenger();
@@ -466,7 +468,7 @@ class MapDriverController extends GetxController {
100; // for eygpt /100 100; // for eygpt /100
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: { var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId', 'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(), 'amount': (pointsSubstraction).toStringAsFixed(0),
'paymentMethod': paymentMethod, 'paymentMethod': paymentMethod,
'driverID': box.read(BoxName.driverID).toString(), 'driverID': box.read(BoxName.driverID).toString(),
}); });
@@ -474,68 +476,18 @@ class MapDriverController extends GetxController {
Future.delayed(const Duration(milliseconds: 300)); Future.delayed(const Duration(milliseconds: 300));
FirebaseMessagesController().sendNotificationToPassengerToken( FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Finish Trip', 'Driver Finish Trip',
'you will pay to Driver'.tr + '${'you will pay to Driver'.tr} $paymentAmount \$',
' ${carType == 'Comfort' || carType == 'Mashwari' ? price.toStringAsFixed(2) : totalPassenger} \$'
.tr,
tokenPassenger, tokenPassenger,
[ [
box.read(BoxName.driverID), box.read(BoxName.driverID),
rideId, rideId,
box.read(BoxName.tokenDriver), box.read(BoxName.tokenDriver),
carType == 'Comfort' || carType == 'Mashwari' // carType == 'Comfort' || carType == 'Mashwari'
? price.toStringAsFixed(2) // ? price.toStringAsFixed(2)
: totalPassenger // : totalPassenger
paymentAmount.toString()
], ],
); );
// } else {
// Get.defaultDialog(
// title: 'You don\'t arrive destenation yet .'.tr,
// middleText: '',
// confirm: MyElevatedButton(
// title: 'Ok'.tr,
// onPressed: () {
// Get.back();
// }));
// }
// } else {
// totalCost = price.toStringAsFixed(2);
// paymentAmount = totalCost;
// box.write(BoxName.statusDriverLocation, 'off');
// // changeRideToBeginToPassenger();
// await CRUD().post(link: AppLink.updateRides, payload: {
// 'id': rideId,
// 'rideTimeFinish': DateTime.now().toString(),
// 'status': 'Finished'
// });
// print('walletChecked is $walletChecked');
// if (walletChecked == 'true') {
// await CRUD().post(link: AppLink.addPassengersWallet, payload: {
// 'passenger_id': passengerId,
// 'balance': ((-1) * double.parse(paymentAmount)).toString()
// });
// }
// print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}');
// if (double.parse(passengerWalletBurc) < 0) {
// await CRUD().post(link: AppLink.addPassengersWallet, payload: {
// 'passenger_id': passengerId,
// 'balance': ((-1) * double.parse(passengerWalletBurc)).toString()
// });
// print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}');
// }
// Future.delayed(const Duration(milliseconds: 300));
// FirebaseMessagesController().sendNotificationToPassengerToken(
// 'Driver Finish Trip',
// 'you will pay to Driver'.tr + ' $totalCost \$'.tr,
// tokenPassenger,
// [
// box.read(BoxName.driverID),
// rideId,
// box.read(BoxName.tokenDriver),
// ],
// );
// }
// add wallet from passenger from driver
Get.to(() => RatePassenger(), arguments: { Get.to(() => RatePassenger(), arguments: {
'passengerId': passengerId, 'passengerId': passengerId,
'rideId': rideId, 'rideId': rideId,

View File

@@ -477,7 +477,9 @@ class MyTranslation extends Translations {
'Trip has Steps': "الرحلة تتكون من خطوات", 'Trip has Steps': "الرحلة تتكون من خطوات",
'Distance from Passenger to destination is ': 'Distance from Passenger to destination is ':
"المسافة من الراكب إلى الوجهة هي ", "المسافة من الراكب إلى الوجهة هي ",
'Cost Of Trip IS ': "تكلفة الرحلة هي ", 'price is': '‏التكلفة',
'distance is'
'Cost Of Trip IS ': "تكلفة الرحلة هي ",
"We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button.": "We noticed the speed is exceeding 100 km/h. Please slow down for your safety. If you feel unsafe, you can share your trip details with a contact or call the police using the red SOS button.":
"لقد لاحظنا أن السرعة تتجاوز ١٠٠ كم/ساعة. يرجى التباطؤ من أجل سلامتك. إذا كنت تشعر بعدم الأمان، يمكنك مشاركة تفاصيل رحلتك مع جهة اتصال أو الاتصال بالشرطة باستخدام زر SOS الأحمر.", "لقد لاحظنا أن السرعة تتجاوز ١٠٠ كم/ساعة. يرجى التباطؤ من أجل سلامتك. إذا كنت تشعر بعدم الأمان، يمكنك مشاركة تفاصيل رحلتك مع جهة اتصال أو الاتصال بالشرطة باستخدام زر SOS الأحمر.",
'Warning: Speeding detected!': "تحذير: تم رصد السرعة الزائدة!", 'Warning: Speeding detected!': "تحذير: تم رصد السرعة الزائدة!",

View File

@@ -17,7 +17,7 @@ import 'package:SEFER/views/widgets/elevated_btn.dart';
class RateController extends GetxController { class RateController extends GetxController {
double selectedRateItemId = -1; double selectedRateItemId = -1;
TextEditingController comment = TextEditingController(); TextEditingController comment = TextEditingController();
String? rideId, passengerId, driverId; String? rideId, passengerId, driverId, price;
late GlobalKey<FormState> formKey; late GlobalKey<FormState> formKey;
@override @override
void onInit() { void onInit() {
@@ -25,6 +25,7 @@ class RateController extends GetxController {
passengerId = Get.arguments['passengerId']; passengerId = Get.arguments['passengerId'];
rideId = Get.arguments['rideId']; rideId = Get.arguments['rideId'];
driverId = Get.arguments['driverId']; driverId = Get.arguments['driverId'];
price = Get.arguments['price'];
super.onInit(); super.onInit();
} }

View File

@@ -1,3 +1,5 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/home/map_passenger_controller.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -5,6 +7,7 @@ import 'package:get/get.dart';
import '../../constant/colors.dart'; import '../../constant/colors.dart';
import '../../constant/style.dart'; import '../../constant/style.dart';
import '../../controller/rate/rate_conroller.dart'; import '../../controller/rate/rate_conroller.dart';
import '../../main.dart';
import '../widgets/elevated_btn.dart'; import '../widgets/elevated_btn.dart';
import '../widgets/my_scafold.dart'; import '../widgets/my_scafold.dart';
@@ -21,9 +24,69 @@ class RateDriverFromPassenger extends StatelessWidget {
left: Get.width * .1, left: Get.width * .1,
right: Get.width * .1, right: Get.width * .1,
child: Container( child: Container(
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration1,
child: Column( child: Column(
children: [ children: [
Padding(
padding: const EdgeInsets.all(4),
child: Container(
height: Get.height * .25,
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${'Total price to '.tr}${Get.find<MapPassengerController>().firstName}',
style: AppStyle.title,
),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: AppColor.redColor,
)),
child: Padding(
padding: const EdgeInsets.all(4),
child: Text(
(double.parse(controller.price
.toString()) *
.12 +
double.parse(
controller.price.toString()))
.toStringAsFixed(2),
style: AppStyle.number.copyWith(
color: AppColor.redColor,
textBaseline:
TextBaseline.ideographic,
decoration:
TextDecoration.lineThrough,
decorationColor: AppColor.redColor),
),
),
),
const SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: AppColor.greenColor,
)),
child: Padding(
padding: const EdgeInsets.all(4),
child: Text(
controller.price.toString(),
style: AppStyle.number,
),
),
),
],
),
)),
),
Center( Center(
child: RatingBar.builder( child: RatingBar.builder(
initialRating: 0, initialRating: 0,

View File

@@ -21,8 +21,8 @@ GetBuilder<MapDriverController> driverEndRideBar() {
child: Container( child: Container(
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration,
height: mapDriverController.remainingTimeTimerRideBegin < 60 height: mapDriverController.remainingTimeTimerRideBegin < 60
? mapDriverController.driverEndPage = 180 ? mapDriverController.driverEndPage = 190
: 150, : 170,
width: 240, width: 240,
child: Column( child: Column(
children: [ children: [
@@ -70,7 +70,7 @@ GetBuilder<MapDriverController> driverEndRideBar() {
Text(mapDriverController.price.toStringAsFixed(2)), Text(mapDriverController.price.toStringAsFixed(2)),
], ],
), ),
(mapDriverController.carType == 'Free Ride' || (mapDriverController.carType == 'Mashwari' ||
mapDriverController.carType == 'Comfort') && mapDriverController.carType == 'Comfort') &&
mapDriverController.remainingTimeTimerRideBegin > 60 mapDriverController.remainingTimeTimerRideBegin > 60
? Row( ? Row(

View File

@@ -200,7 +200,7 @@ class OrderRequestPage extends StatelessWidget {
)), )),
), ),
Container( Container(
height: Get.height * .15, height: Get.height * .2,
width: Get.width * .9, width: Get.width * .9,
decoration: AppStyle.boxDecoration1, decoration: AppStyle.boxDecoration1,
child: Column( child: Column(
@@ -284,7 +284,10 @@ class OrderRequestPage extends StatelessWidget {
style: AppStyle.title, style: AppStyle.title,
children: [ children: [
TextSpan( TextSpan(
text: (mpg * double.parse(myList[5])) text: ((Get.find<HomeCaptainController>()
.fuelPrice /
12) *
double.parse(myList[5]))
.toStringAsFixed(2), .toStringAsFixed(2),
style: AppStyle.headTitle2), style: AppStyle.headTitle2),
], ],

View File

@@ -81,11 +81,11 @@ class OrderSpeedRequest extends StatelessWidget {
endIcon = value; endIcon = value;
}); });
// } // }
double mpg = 0; // double mpg = 0;
calculateConsumptionFuel() { // calculateConsumptionFuel() {
mpg = Get.find<HomeCaptainController>().fuelPrice / // mpg = Get.find<HomeCaptainController>().fuelPrice /
12; //todo in register car add mpg in box // 12; //todo in register car add mpg in box
} // }
return MyScafolld( return MyScafolld(
title: 'Order Details'.tr, title: 'Order Details'.tr,
@@ -199,7 +199,7 @@ class OrderSpeedRequest extends StatelessWidget {
)), )),
), ),
Container( Container(
height: Get.height * .15, height: Get.height * .2,
width: Get.width * .9, width: Get.width * .9,
decoration: AppStyle.boxDecoration1, decoration: AppStyle.boxDecoration1,
child: Column( child: Column(
@@ -292,8 +292,11 @@ class OrderSpeedRequest extends StatelessWidget {
style: AppStyle.title, style: AppStyle.title,
children: [ children: [
TextSpan( TextSpan(
text: (mpg * double.parse(myList[5])) text:
.toStringAsFixed(2), ((Get.find<HomeCaptainController>().fuelPrice /
12) *
double.parse(myList[5]))
.toStringAsFixed(2),
style: AppStyle.headTitle2), style: AppStyle.headTitle2),
], ],
), ),

View File

@@ -33,8 +33,8 @@ List<CarType> carTypes = [
carDetail: 'Delivery service'.tr, carDetail: 'Delivery service'.tr,
image: 'assets/images/moto.png'), image: 'assets/images/moto.png'),
CarType( CarType(
carType: 'Free Ride', carType: 'Mashwari',
carDetail: 'free ride without end point'.tr, carDetail: 'Mashwari without end point'.tr,
image: 'assets/images/freeRide.png'), image: 'assets/images/freeRide.png'),
]; ];

View File

@@ -84,8 +84,8 @@ class RideBeginPassenger extends StatelessWidget {
), ),
audioController.isRecording == false audioController.isRecording == false
? IconButton( ? IconButton(
onPressed: () { onPressed: () async {
audioController.startRecording(); await audioController.startRecording();
}, },
icon: const Icon( icon: const Icon(
Icons.play_circle_fill_outlined, Icons.play_circle_fill_outlined,
@@ -95,8 +95,8 @@ class RideBeginPassenger extends StatelessWidget {
' Add Note', // Optional tooltip for clarity ' Add Note', // Optional tooltip for clarity
) )
: IconButton( : IconButton(
onPressed: () { onPressed: () async {
audioController.stopRecording(); await audioController.stopRecording();
}, },
icon: const Icon( icon: const Icon(
Icons.stop_circle, Icons.stop_circle,