fix controls when swiping between image and video

This commit is contained in:
mertalev
2024-11-09 00:31:10 -05:00
parent 190dbb0042
commit 0010eda67f
6 changed files with 51 additions and 45 deletions
@@ -17,10 +17,15 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final showControls = ref.watch(showControlsProvider);
// A timer to hide the controls
final hideTimer = useTimer(
hideTimerDuration,
() {
if (!context.mounted) {
return;
}
final state = ref.read(videoPlaybackValueProvider).state;
// Do not hide on paused
if (state != VideoPlaybackState.paused) {
@@ -66,7 +71,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
behavior: HitTestBehavior.opaque,
onTap: showControlsAndStartHideTimer,
child: AbsorbPointer(
absorbing: !ref.watch(showControlsProvider),
absorbing: !showControls,
child: Stack(
children: [
if (showBuffering)
@@ -84,7 +89,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
iconColor: Colors.white,
isFinished: state == VideoPlaybackState.completed,
isPlaying: state == VideoPlaybackState.playing,
show: ref.watch(showControlsProvider),
show: showControls,
onPressed: togglePlay,
),
),