From 5acce212611bdad23000baaf7f334cafb2aadaf6 Mon Sep 17 00:00:00 2001 From: PartyDonut <42371342+PartyDonut@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:25:07 +0100 Subject: [PATCH] feat(Desktop): Added double tap full-screen support (#178) Co-authored-by: PartyDonut --- lib/screens/home_screen.dart | 2 - .../video_player/video_player_controls.dart | 109 ++++++++++-------- 2 files changed, 58 insertions(+), 53 deletions(-) diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index a72d969..8db6f38 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -69,8 +69,6 @@ class HomeScreen extends ConsumerWidget { ); } return null; - default: - return null; } }); return HeroControllerScope( diff --git a/lib/screens/video_player/video_player_controls.dart b/lib/screens/video_player/video_player_controls.dart index d2bcbc5..1c45765 100644 --- a/lib/screens/video_player/video_player_controls.dart +++ b/lib/screens/video_player/video_player_controls.dart @@ -121,61 +121,68 @@ class _DesktopControlsState extends ConsumerState { closePlayer(); } }, - child: GestureDetector( - onTap: () => toggleOverlay(), - child: MouseRegion( - cursor: showOverlay ? SystemMouseCursors.basic : SystemMouseCursors.none, - onExit: (event) => toggleOverlay(value: false), - onEnter: (event) => toggleOverlay(value: true), - onHover: AdaptiveLayout.of(context).isDesktop ? (event) => toggleOverlay(value: true) : null, - child: Stack( - children: [ - if (subtitleWidget != null) subtitleWidget, - if (AdaptiveLayout.of(context).isDesktop) - Consumer(builder: (context, ref, child) { - final playing = ref.watch(mediaPlaybackProvider.select((value) => value.playing)); - final buffering = ref.watch(mediaPlaybackProvider.select((value) => value.buffering)); - return playButton(playing, buffering); - }), - IgnorePointer( - ignoring: !showOverlay, - child: AnimatedOpacity( - duration: fadeDuration, - opacity: showOverlay ? 1 : 0, - child: Column( - children: [ - topButtons(context), - const Spacer(), - bottomButtons(context), - ], - ), + child: MouseRegion( + cursor: showOverlay ? SystemMouseCursors.basic : SystemMouseCursors.none, + onExit: (event) => toggleOverlay(value: false), + onEnter: (event) => toggleOverlay(value: true), + onHover: AdaptiveLayout.of(context).isDesktop ? (event) => toggleOverlay(value: true) : null, + child: Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: AdaptiveLayout.of(context).inputDevice == InputDevice.pointer + ? () => player.playOrPause() + : () => toggleOverlay(), + onDoubleTap: AdaptiveLayout.of(context).inputDevice == InputDevice.pointer + ? () => toggleFullScreen(ref) + : null, + ), + ), + if (subtitleWidget != null) subtitleWidget, + if (AdaptiveLayout.of(context).isDesktop) + Consumer(builder: (context, ref, child) { + final playing = ref.watch(mediaPlaybackProvider.select((value) => value.playing)); + final buffering = ref.watch(mediaPlaybackProvider.select((value) => value.buffering)); + return playButton(playing, buffering); + }), + IgnorePointer( + ignoring: !showOverlay, + child: AnimatedOpacity( + duration: fadeDuration, + opacity: showOverlay ? 1 : 0, + child: Column( + children: [ + topButtons(context), + const Spacer(), + bottomButtons(context), + ], ), ), - const VideoPlayerSeekIndicator(), - Consumer( - builder: (context, ref, child) { - final position = ref.watch(mediaPlaybackProvider.select((value) => value.position)); - MediaSegment? segment = mediaSegments?.atPosition(position); - bool forceShow = segment?.forceShow(position) ?? false; - return Stack( - children: [ - Align( - alignment: Alignment.centerRight, - child: Padding( - padding: const EdgeInsets.all(32), - child: SkipSegmentButton( - segment: segment, - isOverlayVisible: forceShow ? true : showOverlay, - pressedSkip: () => skipToSegmentEnd(segment), - ), + ), + const VideoPlayerSeekIndicator(), + Consumer( + builder: (context, ref, child) { + final position = ref.watch(mediaPlaybackProvider.select((value) => value.position)); + MediaSegment? segment = mediaSegments?.atPosition(position); + bool forceShow = segment?.forceShow(position) ?? false; + return Stack( + children: [ + Align( + alignment: Alignment.centerRight, + child: Padding( + padding: const EdgeInsets.all(32), + child: SkipSegmentButton( + segment: segment, + isOverlayVisible: forceShow ? true : showOverlay, + pressedSkip: () => skipToSegmentEnd(segment), ), ), - ], - ); - }, - ), - ], - ), + ), + ], + ); + }, + ), + ], ), ), ),