This commit is contained in:
Hamza Aleghwairyeen
2024-04-07 23:59:49 +03:00
parent 5d9538f744
commit 6a4a549211
48 changed files with 129 additions and 70 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -1,13 +1,16 @@
import 'dart:io'; import 'dart:io';
import 'package:SEFER/controller/home/map_passenger_controller.dart'; import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:get/get.dart'; import 'package:get/get.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 recorder = FlutterSoundRecorder();
bool isRecoding = false; bool isRecording = false;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@@ -17,7 +20,13 @@ class AudioController extends GetxController {
Future<void> initRecorder() async { Future<void> initRecorder() async {
final status = await Permission.microphone.request(); final status = await Permission.microphone.request();
if (status != PermissionStatus.granted) { if (status != PermissionStatus.granted) {
if (status.isPermanentlyDenied) {
// Handle permission permanently denied
showPermissionDeniedDialog();
} else {
// Handle permission denied // Handle permission denied
showPermissionDeniedSnackbar();
}
return; return;
} }
await recorder.openRecorder(); await recorder.openRecorder();
@@ -25,10 +34,10 @@ class AudioController extends GetxController {
} }
Future<void> startRecording() async { Future<void> startRecording() async {
await recorder.startRecorder( final controller = Get.find<MapPassengerController>();
toFile: final filePath = 'audio_${controller.rideId}.wav'; // Specify the file name
'audio_${Get.find<MapPassengerController>().rideId}.wav'); // Specify the file name await recorder.startRecorder(toFile: filePath);
isRecoding = true; isRecording = true;
update(); update();
} }
@@ -37,13 +46,56 @@ class AudioController extends GetxController {
final audioFile = File(filePath!); final audioFile = File(filePath!);
print('Recorded file path: $audioFile'); print('Recorded file path: $audioFile');
// Now you can send this file to the server // Now you can send this file to the server
isRecoding = false; isRecording = false;
update(); update();
} }
@override @override
void onClose() { void onClose() {
recorder.closeRecorder(); recorder.stopRecorder();
super.onClose(); super.onClose();
} }
void showPermissionDeniedDialog() {
showDialog(
context: Get.context!,
builder: (context) => AlertDialog(
title: Text('Microphone Permission'),
content: Text('Microphone permission is required to record audio.'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
openAppSettings();
},
child: Text('Open Settings'),
),
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

@@ -28,7 +28,7 @@ class HomeCaptainController extends GetxController {
late double kazan; late double kazan;
double latePrice = 0; double latePrice = 0;
double heavyPrice = 0; double heavyPrice = 0;
double comfortPrice = 0, speedPrice = 0, deliveryPrice = 0, freePrice = 0; double comfortPrice = 0, speedPrice = 0, deliveryPrice = 0, mashwariPrice = 0;
double naturePrice = 0; double naturePrice = 0;
bool isCallOn = false; bool isCallOn = false;
String totalMoneyToday = '0'; String totalMoneyToday = '0';
@@ -255,7 +255,7 @@ class HomeCaptainController extends GetxController {
speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']); speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']);
deliveryPrice = deliveryPrice =
double.parse(jsonDecode(res)['message'][0]['deliveryPrice']); double.parse(jsonDecode(res)['message'][0]['deliveryPrice']);
freePrice = double.parse(jsonDecode(res)['message'][0]['freePrice']); mashwariPrice = double.parse(jsonDecode(res)['message'][0]['freePrice']);
} }
} }

View File

@@ -298,30 +298,12 @@ class MapDriverController extends GetxController {
'rideTimeStart': DateTime.now().toString(), 'rideTimeStart': DateTime.now().toString(),
'status': 'Begin', 'status': 'Begin',
}); });
await CRUD().post(link: AppLink.addDriverpayment, payload: {
'rideId': rideId,
'amount': paymentAmount,
'payment_method': paymentMethod,
'passengerID': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
});
FirebaseMessagesController().sendNotificationToAnyWithoutData( FirebaseMessagesController().sendNotificationToAnyWithoutData(
'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger); 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
rideIsBeginPassengerTimer(); rideIsBeginPassengerTimer();
double pointsSubstraction = 0;
pointsSubstraction = double.parse(paymentAmount) * // var d = jsonDecode(res);
(-1) *
double.parse(kazan) /
100; // for eygpt /100
var res =
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(),
'paymentMethod': paymentMethod,
'driverID': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
update(); update();
// Start updating location and moving camera // Start updating location and moving camera
@@ -443,7 +425,7 @@ class MapDriverController extends GetxController {
isRideFinished = true; isRideFinished = true;
isRideStarted = false; isRideStarted = false;
isPriceWindow = false; isPriceWindow = false;
totalCost = carType == 'Comfort' || carType == 'Free Ride' totalCost = carType == 'Comfort' || carType == 'Mashwari'
? price.toStringAsFixed(1) ? price.toStringAsFixed(1)
: totalPassenger; : totalPassenger;
paymentAmount = totalCost; paymentAmount = totalCost;
@@ -461,6 +443,13 @@ class MapDriverController extends GetxController {
'balance': ((-1) * double.parse(paymentAmount)).toString() 'balance': ((-1) * double.parse(paymentAmount)).toString()
}); });
} }
await CRUD().post(link: AppLink.addDriverpayment, payload: {
'rideId': rideId,
'amount': paymentAmount,
'payment_method': paymentMethod,
'passengerID': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
});
print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}'); print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}');
if (double.parse(passengerWalletBurc) < 0) { if (double.parse(passengerWalletBurc) < 0) {
await CRUD().post(link: AppLink.addPassengersWallet, payload: { await CRUD().post(link: AppLink.addPassengersWallet, payload: {
@@ -469,11 +458,22 @@ class MapDriverController extends GetxController {
}); });
print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}'); print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}');
} }
double pointsSubstraction = 0;
pointsSubstraction = double.parse(paymentAmount) *
(-1) *
double.parse(kazan) /
100; // for eygpt /100
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(),
'paymentMethod': paymentMethod,
'driverID': box.read(BoxName.driverID).toString(),
});
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 +
' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$' ' ${carType == 'Comfort' || carType == 'Mashwari' ? price.toStringAsFixed(2) : totalPassenger} \$'
.tr, .tr,
tokenPassenger, tokenPassenger,
[ [
@@ -597,7 +597,7 @@ class MapDriverController extends GetxController {
: (i ~/ 60) + : (i ~/ 60) +
(recentDistanceToDash * (recentDistanceToDash *
Get.find<HomeCaptainController>() Get.find<HomeCaptainController>()
.freePrice); // $1 for each minute + $4 for each km .mashwariPrice); // $1 for each minute + $4 for each km
price = (price * .10) + price; // Add 10% tax price = (price * .10) + price; // Add 10% tax
speed = Get.find<LocationController>().speed * 3.6; speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide; progressTimerRideBegin = i / durationOfRide;

View File

@@ -700,12 +700,16 @@ class MapPassengerController extends GetxController {
//print(res); //print(res);
} }
var decode = jsonDecode(res); var decode = jsonDecode(res);
print(decode['data']);
if (decode['data']['status'] == 'Begin') { if (decode['data'] == 'Begin') {
statusRide = 'Begin';
update();
// todo from sql or get storage // todo from sql or get storage
List<dynamic> pol = box.read(BoxName.tripData); // List<dynamic> pol = box.read(BoxName.tripData);
// print(pol);
Map<String, dynamic> tripData = Map<String, dynamic> tripData =
box.read(BoxName.tripData) as Map<String, dynamic>; box.read(BoxName.tripData) as Map<String, dynamic>;
print(tripData);
final points = decodePolyline( final points = decodePolyline(
tripData["routes"][0]["overview_polyline"]["points"]); tripData["routes"][0]["overview_polyline"]["points"]);
@@ -729,8 +733,9 @@ class MapPassengerController extends GetxController {
rideTimerBegin = true; rideTimerBegin = true;
isDriverInPassengerWay = false; isDriverInPassengerWay = false;
isDriverArrivePassenger = false; isDriverArrivePassenger = false;
update(); // update();
// isCancelRidePageShown = true; // isCancelRidePageShown = true;
durationToAdd = tripData['routes'][0]['legs'][0]['duration']['value'];
rideIsBeginPassengerTimer(); rideIsBeginPassengerTimer();
runWhenRideIsBegin(); runWhenRideIsBegin();
update(); update();
@@ -1144,7 +1149,7 @@ class MapPassengerController extends GetxController {
late double headingList; late double headingList;
Future getCarsLocationByPassengerAndReloadMarker() async { Future getCarsLocationByPassengerAndReloadMarker() async {
// if (rideConfirm == false) { if (statusRide == 'wait') {
carsLocationByPassenger = []; carsLocationByPassenger = [];
LatLngBounds bounds = calculateBounds( LatLngBounds bounds = calculateBounds(
passengerLocation.latitude, passengerLocation.longitude, 7000); passengerLocation.latitude, passengerLocation.longitude, 7000);
@@ -1165,11 +1170,12 @@ class MapPassengerController extends GetxController {
dataCarsLocationByPassenger = jsonDecode(res); dataCarsLocationByPassenger = jsonDecode(res);
//print(dataCarsLocationByPassenger); //print(dataCarsLocationByPassenger);
// if (dataCarsLocationByPassenger.length > carsOrder) { // if (dataCarsLocationByPassenger.length > carsOrder) {
driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id'] driverId = dataCarsLocationByPassenger['message'][carsOrder]
['driver_id']
.toString(); .toString();
gender = dataCarsLocationByPassenger['message'][carsOrder]['gender'] gender = dataCarsLocationByPassenger['message'][carsOrder]['gender']
.toString(); .toString();
// } }
// //print('driverId==============$driverId'); // //print('driverId==============$driverId');
@@ -1964,6 +1970,7 @@ class MapPassengerController extends GetxController {
var response = await CRUD().getGoogleApi(link: url, payload: {}); var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs']; data = response['routes'][0]['legs'];
// //print(data); // //print(data);
box.remove(BoxName.tripData);
box.write(BoxName.tripData, response); box.write(BoxName.tripData, response);
startNameAddress = data[0]['start_address']; startNameAddress = data[0]['start_address'];
endNameAddress = data[0]['end_address']; endNameAddress = data[0]['end_address'];

View File

@@ -31,7 +31,7 @@ class DrawerCaptain extends StatelessWidget {
} }
return Drawer( return Drawer(
child: Column( child: ListView(
children: [ children: [
// Other drawer items // Other drawer items
UserAccountsDrawerHeader( UserAccountsDrawerHeader(

View File

@@ -154,7 +154,7 @@ class ApplyOrderWidget extends StatelessWidget {
), ),
), ),
controller.isDriverArrivePassenger controller.isDriverArrivePassenger
? DriverArrivePassengerAndWaitMinute() ? const DriverArrivePassengerAndWaitMinute()
: const TimeDriverToPassenger() : const TimeDriverToPassenger()
], ],
), ),

View File

@@ -290,10 +290,10 @@ class CarDetailsTypeToChoose extends StatelessWidget {
} else if (mapPassengerController } else if (mapPassengerController
.selectedIndex == .selectedIndex ==
3) { 3) {
box.write(BoxName.carType, 'FreeRide'); box.write(BoxName.carType, 'Mashwari');
mapPassengerController.totalPassenger = 50; mapPassengerController.totalPassenger = 50;
Get.defaultDialog( Get.defaultDialog(
title: 'FreeRide', title: 'Mashwari',
titleStyle: AppStyle.title, titleStyle: AppStyle.title,
content: CarDialogue( content: CarDialogue(
textToSpeechController: textToSpeechController:

View File

@@ -21,7 +21,7 @@ class RideBeginPassenger extends StatelessWidget {
ProfileController profileController = Get.put(ProfileController()); ProfileController profileController = Get.put(ProfileController());
AudioController audioController = Get.put(AudioController()); AudioController audioController = Get.put(AudioController());
return GetBuilder<MapPassengerController>(builder: (controller) { return GetBuilder<MapPassengerController>(builder: (controller) {
if (controller.rideTimerBegin) { if (controller.rideTimerBegin || controller.statusRide == 'Begin') {
return Positioned( return Positioned(
left: 10, left: 10,
right: 10, right: 10,
@@ -73,7 +73,7 @@ class RideBeginPassenger extends StatelessWidget {
), ),
tooltip: ' Add Note', // Optional tooltip for clarity tooltip: ' Add Note', // Optional tooltip for clarity
), ),
audioController.isRecoding audioController.isRecoding == false
? IconButton( ? IconButton(
onPressed: () { onPressed: () {
audioController.startRecording(); audioController.startRecording();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB