From 89fec629833c8daf49c0362c821bd9c42276ac54 Mon Sep 17 00:00:00 2001 From: James Harvey <44349936+jmshrv@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:22:33 +0000 Subject: [PATCH] Remove RepaintBoundary on ProgressSlider Fixes a weird Impeller issue on iOS where the background glitches --- ios/Podfile.lock | 6 + .../PlayerScreen/progress_slider.dart | 116 +++++++++--------- 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7f42d89d9..086f153b5 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -61,6 +61,8 @@ PODS: - Flutter (1.0.0) - flutter_downloader (0.0.1): - Flutter + - flutter_vibrate (0.0.1): + - Flutter - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) @@ -91,6 +93,7 @@ DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) - flutter_downloader (from `.symlinks/plugins/flutter_downloader/ios`) + - flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`) - just_audio (from `.symlinks/plugins/just_audio/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) @@ -121,6 +124,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_downloader: :path: ".symlinks/plugins/flutter_downloader/ios" + flutter_vibrate: + :path: ".symlinks/plugins/flutter_vibrate/ios" just_audio: :path: ".symlinks/plugins/just_audio/ios" package_info_plus: @@ -145,6 +150,7 @@ SPEC CHECKSUMS: file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_downloader: b7301ae057deadd4b1650dc7c05375f10ff12c39 + flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e diff --git a/lib/components/PlayerScreen/progress_slider.dart b/lib/components/PlayerScreen/progress_slider.dart index 232506bb0..65be27c7e 100644 --- a/lib/components/PlayerScreen/progress_slider.dart +++ b/lib/components/PlayerScreen/progress_slider.dart @@ -49,69 +49,67 @@ class _ProgressSliderState extends State { trackHeight: 4.0, trackShape: CustomTrackShape(), ), - child: RepaintBoundary( - child: StreamBuilder( - stream: progressStateStream, - builder: (context, snapshot) { - if (snapshot.data?.mediaItem == null) { - // If nothing is playing or the AudioService isn't connected, return a - // greyed out slider with some fake numbers. We also do this if - // currentPosition is null, which sometimes happens when the app is - // closed and reopened. - return widget.showPlaceholder - ? Column( - children: [ - const Slider( - value: 0, - max: 1, - onChanged: null, - ), - if (widget.showDuration) - const _ProgressSliderDuration( - position: Duration(), - ) - ], - ) - : const SizedBox.shrink(); - } else if (snapshot.hasData) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Stack( + child: StreamBuilder( + stream: progressStateStream, + builder: (context, snapshot) { + if (snapshot.data?.mediaItem == null) { + // If nothing is playing or the AudioService isn't connected, return a + // greyed out slider with some fake numbers. We also do this if + // currentPosition is null, which sometimes happens when the app is + // closed and reopened. + return widget.showPlaceholder + ? Column( children: [ - // Slider displaying buffer status. - if (widget.showBuffer) - _BufferSlider( - mediaItem: snapshot.data?.mediaItem, - playbackState: snapshot.data!.playbackState, - ), - // Slider displaying playback progress. - _PlaybackProgressSlider( - allowSeeking: widget.allowSeeking, - playbackState: snapshot.data!.playbackState, - position: snapshot.data!.position, - mediaItem: snapshot.data!.mediaItem, - onDrag: (value) => setState(() { - _dragValue = value; - }), + const Slider( + value: 0, + max: 1, + onChanged: null, ), + if (widget.showDuration) + const _ProgressSliderDuration( + position: Duration(), + ) ], - ), - if (widget.showDuration) - _ProgressSliderDuration( - position: _dragValue == null - ? snapshot.data!.position - : Duration(microseconds: _dragValue!.toInt()), - itemDuration: snapshot.data!.mediaItem?.duration, + ) + : const SizedBox.shrink(); + } else if (snapshot.hasData) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + children: [ + // Slider displaying buffer status. + if (widget.showBuffer) + _BufferSlider( + mediaItem: snapshot.data?.mediaItem, + playbackState: snapshot.data!.playbackState, + ), + // Slider displaying playback progress. + _PlaybackProgressSlider( + allowSeeking: widget.allowSeeking, + playbackState: snapshot.data!.playbackState, + position: snapshot.data!.position, + mediaItem: snapshot.data!.mediaItem, + onDrag: (value) => setState(() { + _dragValue = value; + }), ), - ], - ); - } else { - return const Text( - "Snapshot doesn't have data and MediaItem isn't null and AudioService is connected?"); - } - }, - ), + ], + ), + if (widget.showDuration) + _ProgressSliderDuration( + position: _dragValue == null + ? snapshot.data!.position + : Duration(microseconds: _dragValue!.toInt()), + itemDuration: snapshot.data!.mediaItem?.duration, + ), + ], + ); + } else { + return const Text( + "Snapshot doesn't have data and MediaItem isn't null and AudioService is connected?"); + } + }, ), ), );