feat(Desktop): Added double tap full-screen support (#178)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2024-12-12 23:25:07 +01:00 committed by GitHub
parent e0e06e0064
commit 5acce21261
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 53 deletions

View file

@ -69,8 +69,6 @@ class HomeScreen extends ConsumerWidget {
); );
} }
return null; return null;
default:
return null;
} }
}); });
return HeroControllerScope( return HeroControllerScope(

View file

@ -121,61 +121,68 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
closePlayer(); closePlayer();
} }
}, },
child: GestureDetector( child: MouseRegion(
onTap: () => toggleOverlay(), cursor: showOverlay ? SystemMouseCursors.basic : SystemMouseCursors.none,
child: MouseRegion( onExit: (event) => toggleOverlay(value: false),
cursor: showOverlay ? SystemMouseCursors.basic : SystemMouseCursors.none, onEnter: (event) => toggleOverlay(value: true),
onExit: (event) => toggleOverlay(value: false), onHover: AdaptiveLayout.of(context).isDesktop ? (event) => toggleOverlay(value: true) : null,
onEnter: (event) => toggleOverlay(value: true), child: Stack(
onHover: AdaptiveLayout.of(context).isDesktop ? (event) => toggleOverlay(value: true) : null, children: [
child: Stack( Positioned.fill(
children: [ child: GestureDetector(
if (subtitleWidget != null) subtitleWidget, onTap: AdaptiveLayout.of(context).inputDevice == InputDevice.pointer
if (AdaptiveLayout.of(context).isDesktop) ? () => player.playOrPause()
Consumer(builder: (context, ref, child) { : () => toggleOverlay(),
final playing = ref.watch(mediaPlaybackProvider.select((value) => value.playing)); onDoubleTap: AdaptiveLayout.of(context).inputDevice == InputDevice.pointer
final buffering = ref.watch(mediaPlaybackProvider.select((value) => value.buffering)); ? () => toggleFullScreen(ref)
return playButton(playing, buffering); : null,
}), ),
IgnorePointer( ),
ignoring: !showOverlay, if (subtitleWidget != null) subtitleWidget,
child: AnimatedOpacity( if (AdaptiveLayout.of(context).isDesktop)
duration: fadeDuration, Consumer(builder: (context, ref, child) {
opacity: showOverlay ? 1 : 0, final playing = ref.watch(mediaPlaybackProvider.select((value) => value.playing));
child: Column( final buffering = ref.watch(mediaPlaybackProvider.select((value) => value.buffering));
children: [ return playButton(playing, buffering);
topButtons(context), }),
const Spacer(), IgnorePointer(
bottomButtons(context), ignoring: !showOverlay,
], child: AnimatedOpacity(
), duration: fadeDuration,
opacity: showOverlay ? 1 : 0,
child: Column(
children: [
topButtons(context),
const Spacer(),
bottomButtons(context),
],
), ),
), ),
const VideoPlayerSeekIndicator(), ),
Consumer( const VideoPlayerSeekIndicator(),
builder: (context, ref, child) { Consumer(
final position = ref.watch(mediaPlaybackProvider.select((value) => value.position)); builder: (context, ref, child) {
MediaSegment? segment = mediaSegments?.atPosition(position); final position = ref.watch(mediaPlaybackProvider.select((value) => value.position));
bool forceShow = segment?.forceShow(position) ?? false; MediaSegment? segment = mediaSegments?.atPosition(position);
return Stack( bool forceShow = segment?.forceShow(position) ?? false;
children: [ return Stack(
Align( children: [
alignment: Alignment.centerRight, Align(
child: Padding( alignment: Alignment.centerRight,
padding: const EdgeInsets.all(32), child: Padding(
child: SkipSegmentButton( padding: const EdgeInsets.all(32),
segment: segment, child: SkipSegmentButton(
isOverlayVisible: forceShow ? true : showOverlay, segment: segment,
pressedSkip: () => skipToSegmentEnd(segment), isOverlayVisible: forceShow ? true : showOverlay,
), pressedSkip: () => skipToSegmentEnd(segment),
), ),
), ),
], ),
); ],
}, );
), },
], ),
), ],
), ),
), ),
), ),