This commit is contained in:
Hamza-Ayed
2024-09-04 14:49:36 +03:00
parent 04c47d3431
commit e23709c924
19 changed files with 568 additions and 266 deletions

View File

@@ -1,18 +1,14 @@
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 'HomePage/trip_record_page.dart';
import 'profile/passenger_profile_page.dart';
class HomePage extends StatelessWidget {
@@ -106,121 +102,7 @@ class HomePage extends StatelessWidget {
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),
),
],
);
}),
);
Get.to(() => TripsRecordedPage());
}),
ListTile(
leading: const Icon(Icons.account_balance_outlined),