From d423053603fbf56d5dbb4934f5fea53d674dc3e4 Mon Sep 17 00:00:00 2001 From: Seyed Amir Hossein Mosavi Date: Wed, 25 Sep 2024 15:40:45 +0330 Subject: [PATCH] fix masalan --- ios/Runner/Info.plist | 6 ++++++ lib/views/ai/widgets/audio_wave.dart | 21 ++++++++++++--------- lib/views/direct/direct_state.dart | 2 +- lib/views/webview/web_view.dart | 13 +++++++------ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 3e7a40e..65f0b71 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -69,5 +69,11 @@ dev.flutter.background.refresh + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + \ No newline at end of file diff --git a/lib/views/ai/widgets/audio_wave.dart b/lib/views/ai/widgets/audio_wave.dart index 68e42e7..702eb2e 100644 --- a/lib/views/ai/widgets/audio_wave.dart +++ b/lib/views/ai/widgets/audio_wave.dart @@ -52,7 +52,16 @@ class _AudioWaveState extends State { totalDuration = widget.totalDuration; } }); - // listeners(); + listeners(); + } + + void listeners() async { + VoiceService.audioPlayer.playerStateStream.listen((event) async { + if (event.processingState == ProcessingState.completed) { + await VoiceService.audioPlayer.pause(); + await VoiceService.audioPlayer.seek(Duration.zero); + } + }); } @override @@ -71,18 +80,12 @@ class _AudioWaveState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - StreamBuilder( - stream: VoiceService.audioPlayer.playbackEventStream, + StreamBuilder( + stream: VoiceService.audioPlayer.playerStateStream, builder: (context, snapshot) { if (!snapshot.hasData) { return const SizedBox(); } - - if (snapshot.data!.processingState == - ProcessingState.completed) { - VoiceService.audioPlayer.pause(); - VoiceService.audioPlayer.seek(Duration.zero); - } if ((snapshot.data!.processingState == ProcessingState.loading || snapshot.data!.processingState == diff --git a/lib/views/direct/direct_state.dart b/lib/views/direct/direct_state.dart index c618350..2e5ca51 100644 --- a/lib/views/direct/direct_state.dart +++ b/lib/views/direct/direct_state.dart @@ -67,7 +67,7 @@ class DirectState extends CoreProvier { isRecording = true; Directory? tempDir; if (!kIsWeb) { - tempDir = await getDownloadsDirectory(); + tempDir = await getApplicationDocumentsDirectory(); } _recorder.start(const RecordConfig(), path: kIsWeb diff --git a/lib/views/webview/web_view.dart b/lib/views/webview/web_view.dart index c6619b0..84ac7d8 100644 --- a/lib/views/webview/web_view.dart +++ b/lib/views/webview/web_view.dart @@ -1,6 +1,7 @@ // ignore_for_file: library_private_types_in_public_api, deprecated_member_use import 'package:didvan/constants/assets.dart'; +import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -74,12 +75,12 @@ class _WebViewState extends State { } }, child: Scaffold( - // appBar: AppBar( - // title: const DidvanText( - // 'بازگشت به دیدوان', - // ), - // leading: const BackButton(), - // ), + appBar: AppBar( + title: const DidvanText( + 'بازگشت به دیدوان', + ), + leading: const BackButton(), + ), body: loading ? Center( child: Image.asset(