243 lines
10 KiB
Dart
243 lines
10 KiB
Dart
import 'package:SEFER/controller/functions/tts.dart';
|
|
import 'package:SEFER/controller/home/home_page_controller.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:SEFER/constant/colors.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/views/lang/languages.dart';
|
|
import 'package:SEFER/views/widgets/my_scafold.dart';
|
|
import 'package:path/path.dart' as path;
|
|
import 'package:share/share.dart';
|
|
|
|
import '../../controller/functions/audio_record1.dart';
|
|
import 'HomePage/about_page.dart';
|
|
import 'HomePage/frequentlyQuestionsPage.dart';
|
|
import 'profile/passenger_profile_page.dart';
|
|
|
|
class HomePage extends StatelessWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Get.put(HomePageController());
|
|
return MyScafolld(
|
|
isleading: true,
|
|
title: 'Home Page'.tr,
|
|
body: [
|
|
Column(
|
|
children: [
|
|
ListTile(
|
|
onTap: () {
|
|
Get.to(() => const Language());
|
|
},
|
|
title: Text(
|
|
'Language'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
subtitle: Text(
|
|
'To change Language the App'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
trailing: const Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 30,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
leading: const Icon(
|
|
Icons.language_sharp,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.location_city_outlined),
|
|
title: Text(
|
|
'Change Country'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
subtitle: Text(
|
|
'You can change the Country to get all features'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
onTap: () => Get.to(MyScafolld(
|
|
title: 'Change Country'.tr,
|
|
body: [CountryPickerFromSetting()],
|
|
isleading: true)),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.question_answer),
|
|
title: Text(
|
|
'Frequently Questions'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
subtitle: Text(
|
|
'You can change the Country to get all features'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
onTap: () => Get.to(() => const FrequentlyQuestionsPage()),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.vibration),
|
|
title: GetBuilder<HomePageController>(builder: (controller) {
|
|
return SwitchListTile(
|
|
title: Text(
|
|
'Vibration'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
value: controller.isVibrate,
|
|
onChanged: controller.changeVibrateOption,
|
|
activeColor: AppColor.primaryColor,
|
|
);
|
|
}),
|
|
subtitle: Text(
|
|
'You can change the Vibration for all butttons'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
onTap: () => Get.to(() => const FrequentlyQuestionsPage()),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.record_voice_over_outlined),
|
|
title: Text(
|
|
'Trips recorded'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
subtitle: Text(
|
|
'Here recorded trips audio'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
onTap: () async {
|
|
Get.defaultDialog(
|
|
title: 'Select recorded trip'.tr,
|
|
titleStyle: AppStyle.title,
|
|
content:
|
|
GetBuilder<AudioRecorderController>(builder: (audio) {
|
|
return Column(
|
|
children: [
|
|
FutureBuilder<List<String>>(
|
|
future: audio.getRecordedFiles(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState ==
|
|
ConnectionState.waiting) {
|
|
return const CircularProgressIndicator();
|
|
} else if (snapshot.hasData) {
|
|
final recordedFiles = snapshot.data!;
|
|
return DropdownButton<String>(
|
|
value: audio.selectedFilePath,
|
|
onChanged: (value) {
|
|
audio.selectedFilePath = value;
|
|
audio.playRecordedFile(value!);
|
|
audio.update();
|
|
},
|
|
items: recordedFiles
|
|
.map((file) => DropdownMenuItem<String>(
|
|
value: file,
|
|
child: Text(path.basename(file)),
|
|
))
|
|
.toList(),
|
|
);
|
|
} else {
|
|
return Text('Error: ${snapshot.error}');
|
|
}
|
|
},
|
|
),
|
|
Slider(
|
|
value: audio.currentPosition,
|
|
max: audio.totalDuration,
|
|
inactiveColor: AppColor.accentColor,
|
|
label: audio.currentPosition.toString(),
|
|
onChanged: (value) {
|
|
audio.currentPosition = value;
|
|
// audio.update();
|
|
audio.audioPlayer
|
|
.seek(Duration(seconds: value.toInt()));
|
|
},
|
|
),
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(16.0),
|
|
color: Colors.grey[200],
|
|
child: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
audio.selectedFilePath != null
|
|
? '${'Selected file:'.tr} ${path.basename(audio.selectedFilePath!)}'
|
|
: 'No file selected'.tr,
|
|
style: AppStyle.subtitle,
|
|
),
|
|
if (audio.selectedFilePath != null)
|
|
IconButton(
|
|
icon: const Icon(Icons.share),
|
|
onPressed: () {
|
|
Share.shareFiles(
|
|
[audio.selectedFilePath!]);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
IconButton(
|
|
onPressed: () async {
|
|
Get.defaultDialog(
|
|
title: 'Are you sure to delete recorded files'
|
|
.tr,
|
|
content: Column(
|
|
children: [
|
|
IconButton(
|
|
onPressed: () {
|
|
Get.find<TextToSpeechController>()
|
|
.speakText(
|
|
'this will delete all files from your device'
|
|
.tr);
|
|
},
|
|
icon: const Icon(Icons.headphones),
|
|
),
|
|
Text(
|
|
'this will delete all files from your device'
|
|
.tr,
|
|
textAlign: TextAlign.center,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
titleStyle: AppStyle.title,
|
|
confirm: MyElevatedButton(
|
|
title: 'Delete'.tr,
|
|
kolor: AppColor.redColor,
|
|
onPressed: () async {
|
|
await audio
|
|
// .deleteRecordedFile(audio.selectedFilePath!);
|
|
.deleteAllRecordedFiles();
|
|
Get.back();
|
|
Get.back();
|
|
}));
|
|
},
|
|
icon: const Icon(Icons.delete),
|
|
),
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
}),
|
|
ListTile(
|
|
leading: const Icon(Icons.account_balance_outlined),
|
|
title: Text(
|
|
'About Us'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
subtitle: Text(
|
|
'You can change the Country to get all features'.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
onTap: () => Get.to(() => const AboutPage()),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|