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;
default:
return null;
}
});
return HeroControllerScope(

View file

@ -121,61 +121,68 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
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),
),
),
],
);
},
),
],
),
),
],
);
},
),
],
),
),
),