This commit is contained in:
Hamza Aleghwairyeen
2024-04-12 00:52:03 +03:00
parent 0d0eaa6268
commit 0e91e389e5
6 changed files with 132 additions and 59 deletions

View File

@@ -1,3 +1,5 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:get/get.dart';
@@ -23,7 +25,9 @@ class TextToSpeechController extends GetxController {
Future<void> initTts() async {
String? lang =
WidgetsBinding.instance.platformDispatcher.locale.countryCode;
await flutterTts.setLanguage(lang!); //'en-US' Set language
await flutterTts.setLanguage(box.read(BoxName.lang)); //'en-US' Set language
// await flutterTts.setLanguage('ar-SA'); //'en-US' Set language
// await flutterTts.setLanguage(lang!); //'en-US' Set language
await flutterTts.setSpeechRate(0.5); // Adjust speech rate
await flutterTts.setVolume(1.0); // Set volume
}
@@ -31,7 +35,12 @@ class TextToSpeechController extends GetxController {
// Function to speak the given text
Future<void> speakText(String text) async {
try {
await flutterTts.speak(text);
await flutterTts.awaitSpeakCompletion(true);
var result = await flutterTts.speak(text);
if (result == 1) {
// TTS operation has started
// You can perform additional operations here, if needed
}
} catch (error) {
// Handle error gracefully, e.g., show a message
Get.snackbar('Error', 'Failed to speak text: $error');

View File

@@ -449,7 +449,7 @@ class MapDriverController extends GetxController {
? totalPassenger
: price < double.parse(totalPassenger)
? totalPassenger
: price.toStringAsFixed(1);
: price.toStringAsFixed(2);
paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger();

View File

@@ -833,6 +833,25 @@ class MapPassengerController extends GetxController {
update();
}
void getDialog(String title, midTitle, VoidCallback onPressed) {
Get.defaultDialog(
title: title,
titleStyle: AppStyle.title,
middleTextStyle: AppStyle.title,
content: IconButton(
onPressed: () async {
await textToSpeechController.speakText(midTitle);
},
icon: const Icon(Icons.headphones)),
middleText: midTitle,
confirm: MyElevatedButton(title: 'Ok'.tr, onPressed: onPressed),
cancel: MyElevatedButton(
title: 'Cancel',
onPressed: () {
Get.back();
}));
}
int currentTimeSearchingCaptainWindow = 0;
late String driverPhone = '';
late String driverRate = '';

View File

@@ -442,6 +442,8 @@ class MyTranslation extends Translations {
'Total points is ': "إجمالي النقاط هو",
'Total Connection Duration:': "إجمالي مدة الإتصال:",
' H and': "ساعة و",
'For Speed and Delivery trips, the price is calculated dynamically. For Comfort trips, the price is based on time and distance':
'بالنسبة لرحلات Speed والتوصيل، يتم حساب السعر بشكل ديناميكي. أما بالنسبة لرحلات الراحة، فيتم حساب السعر بناءً على الوقت والمسافة.',
'Hello this is Driver': "مرحبا هذا السائق",
'Is the Passenger in your Car ?': "هل الراكب في سيارتك؟",
'Please wait for the passenger to enter the car before starting the trip.':

View File

@@ -73,8 +73,11 @@ GetBuilder<MapDriverController> driverEndRideBar() {
child: Row(
children: [
const Icon(Icons.timer),
Text(mapDriverController
.stringRemainingTimeRideBegin1),
Text(
mapDriverController
.stringRemainingTimeRideBegin1,
style: AppStyle.number,
),
],
),
)),
@@ -87,7 +90,9 @@ GetBuilder<MapDriverController> driverEndRideBar() {
children: [
const Icon(Icons.location_on),
Text(
'${mapDriverController.recentDistanceToDash.toStringAsFixed(0)} ${'KM'.tr}'),
'${mapDriverController.recentDistanceToDash.toStringAsFixed(0)} ${'KM'.tr}',
style: AppStyle.number,
),
],
),
),
@@ -100,8 +105,10 @@ GetBuilder<MapDriverController> driverEndRideBar() {
child: Row(
children: [
const Icon(Icons.attach_money),
Text(mapDriverController.price
.toStringAsFixed(2)),
Text(
mapDriverController.price.toStringAsFixed(2),
style: AppStyle.number,
),
],
),
),

View File

@@ -1,10 +1,12 @@
import 'package:SEFER/views/home/profile/feed_back_page.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/profile/profile_controller.dart';
import 'package:SEFER/main.dart';
import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
@@ -44,16 +46,32 @@ class RideBeginPassenger extends StatelessWidget {
backgroundImage: NetworkImage(
'https://ride.mobile-app.store/portrate_captain_image/${controller.driverId}.jpg'),
),
Container(
decoration: AppStyle.boxDecoration1,
child: Column(
children: [
Text(
Column(
children: [
Container(
decoration: AppStyle.boxDecoration1,
child: Text(
controller.firstName,
style: AppStyle.title,
),
],
),
),
Container(
decoration: AppStyle.boxDecoration1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
controller.make,
style: AppStyle.title,
),
Text(
controller.model,
style: AppStyle.title,
),
],
),
),
],
),
Column(
children: [
@@ -97,56 +115,74 @@ class RideBeginPassenger extends StatelessWidget {
],
),
),
InkWell(
onTap: () {
controller.getDialog(
'Price of trip'.tr,
'For Speed and Delivery trips, the price is calculated dynamically. For Comfort trips, the price is based on time and distance'
.tr, () {
Get.back();
});
},
child: Container(
width: Get.width * .15,
decoration: AppStyle.boxDecoration1,
child: Column(
children: [
Text(
'💵 ',
style: AppStyle.title,
),
Text(
controller.totalPassenger.toStringAsFixed(2),
style: AppStyle.title,
),
],
),
),
),
Container(
width: Get.width * .15,
decoration: AppStyle.boxDecoration1,
child: Column(
children: [
Text(
'💵 ',
style: AppStyle.title,
),
Text(
controller.totalPassenger.toStringAsFixed(2),
style: AppStyle.title,
),
],
child: IconButton(
onPressed: () => Get.to(
() => FeedBackPage(),
transition: Transition.downToUp,
),
icon: const Icon(
Icons.note_add,
color: AppColor.redColor,
),
tooltip: ' Add Note', // Optional tooltip for clarity
),
),
IconButton(
onPressed: () => Get.to(
() => FeedBackPage(),
transition: Transition.downToUp,
),
icon: const Icon(
Icons.note_add,
color: AppColor.redColor,
),
tooltip: ' Add Note', // Optional tooltip for clarity
Container(
width: Get.width * .15,
decoration: AppStyle.boxDecoration1,
child: 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
),
],
),
Stack(