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 'package:SEFER/controller/home/map_passenger_controller.dart';
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 isRecoding = false;
bool isRecording = false;
@override
void onInit() {
super.onInit();
@@ -17,7 +20,13 @@ class AudioController extends GetxController {
Future<void> initRecorder() async {
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
// Handle permission denied
if (status.isPermanentlyDenied) {
// Handle permission permanently denied
showPermissionDeniedDialog();
} else {
// Handle permission denied
showPermissionDeniedSnackbar();
}
return;
}
await recorder.openRecorder();
@@ -25,10 +34,10 @@ class AudioController extends GetxController {
}
Future<void> startRecording() async {
await recorder.startRecorder(
toFile:
'audio_${Get.find<MapPassengerController>().rideId}.wav'); // Specify the file name
isRecoding = true;
final controller = Get.find<MapPassengerController>();
final filePath = 'audio_${controller.rideId}.wav'; // Specify the file name
await recorder.startRecorder(toFile: filePath);
isRecording = true;
update();
}
@@ -37,13 +46,56 @@ class AudioController extends GetxController {
final audioFile = File(filePath!);
print('Recorded file path: $audioFile');
// Now you can send this file to the server
isRecoding = false;
isRecording = false;
update();
}
@override
void onClose() {
recorder.closeRecorder();
recorder.stopRecorder();
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;
double latePrice = 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;
bool isCallOn = false;
String totalMoneyToday = '0';
@@ -255,7 +255,7 @@ class HomeCaptainController extends GetxController {
speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']);
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(),
'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(
'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
rideIsBeginPassengerTimer();
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(),
});
var d = jsonDecode(res);
// var d = jsonDecode(res);
update();
// Start updating location and moving camera
@@ -443,7 +425,7 @@ class MapDriverController extends GetxController {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
totalCost = carType == 'Comfort' || carType == 'Free Ride'
totalCost = carType == 'Comfort' || carType == 'Mashwari'
? price.toStringAsFixed(1)
: totalPassenger;
paymentAmount = totalCost;
@@ -461,6 +443,13 @@ class MapDriverController extends GetxController {
'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)}');
if (double.parse(passengerWalletBurc) < 0) {
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
@@ -469,11 +458,22 @@ class MapDriverController extends GetxController {
});
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));
FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Finish Trip',
'you will pay to Driver'.tr +
' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$'
' ${carType == 'Comfort' || carType == 'Mashwari' ? price.toStringAsFixed(2) : totalPassenger} \$'
.tr,
tokenPassenger,
[
@@ -597,7 +597,7 @@ class MapDriverController extends GetxController {
: (i ~/ 60) +
(recentDistanceToDash *
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
speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide;

View File

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

View File

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

View File

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

View File

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

View File

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