Skip to content

Commit

Permalink
Remove RepaintBoundary on ProgressSlider
Browse files Browse the repository at this point in the history
Fixes a weird Impeller issue on iOS where the background glitches
  • Loading branch information
jmshrv committed Nov 24, 2023
1 parent 6b36228 commit 89fec62
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 59 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
116 changes: 57 additions & 59 deletions lib/components/PlayerScreen/progress_slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,69 +49,67 @@ class _ProgressSliderState extends State<ProgressSlider> {
trackHeight: 4.0,
trackShape: CustomTrackShape(),
),
child: RepaintBoundary(
child: StreamBuilder<ProgressState>(
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<ProgressState>(
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?");
}
},
),
),
);
Expand Down

0 comments on commit 89fec62

Please sign in to comment.