mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
Update player gesture
This commit is contained in:
parent
2cb849ad8e
commit
db46289813
@ -204,34 +204,7 @@ struct VideoPlayerView: View {
|
||||
hovering ? playerControls.show() : playerControls.hide()
|
||||
}
|
||||
#if !os(macOS)
|
||||
.gesture(
|
||||
DragGesture(minimumDistance: 0, coordinateSpace: .global)
|
||||
.onChanged { value in
|
||||
guard player.presentingPlayer,
|
||||
!playerControls.presentingControlsOverlay else { return }
|
||||
|
||||
let drag = value.translation.height
|
||||
|
||||
guard drag > 0 else { return }
|
||||
|
||||
viewVerticalOffset = drag
|
||||
}
|
||||
.onEnded { _ in
|
||||
if viewVerticalOffset > 100 {
|
||||
if player.playingFullScreen {
|
||||
viewVerticalOffset = 0
|
||||
player.exitFullScreen()
|
||||
} else {
|
||||
player.backend.setNeedsDrawing(false)
|
||||
player.hide()
|
||||
}
|
||||
} else {
|
||||
viewVerticalOffset = 0
|
||||
player.backend.setNeedsDrawing(true)
|
||||
player.show()
|
||||
}
|
||||
}
|
||||
)
|
||||
.gesture(playerDragGesture)
|
||||
#else
|
||||
.onAppear(perform: {
|
||||
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
||||
@ -343,6 +316,41 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
var playerDragGesture: some Gesture {
|
||||
DragGesture(minimumDistance: 0, coordinateSpace: .global)
|
||||
.onChanged { value in
|
||||
guard player.presentingPlayer,
|
||||
!playerControls.presentingControlsOverlay else { return }
|
||||
|
||||
let drag = value.translation.height
|
||||
|
||||
guard drag > 0 else { return }
|
||||
|
||||
if drag > 60, player.playingFullScreen {
|
||||
player.exitFullScreen()
|
||||
}
|
||||
|
||||
viewVerticalOffset = drag
|
||||
}
|
||||
.onEnded { _ in
|
||||
guard player.presentingPlayer,
|
||||
!playerControls.presentingControlsOverlay else { return }
|
||||
if viewVerticalOffset > 100 {
|
||||
if player.playingFullScreen {
|
||||
viewVerticalOffset = 0
|
||||
player.exitFullScreen()
|
||||
} else {
|
||||
player.backend.setNeedsDrawing(false)
|
||||
player.hide()
|
||||
}
|
||||
} else {
|
||||
viewVerticalOffset = 0
|
||||
player.backend.setNeedsDrawing(true)
|
||||
player.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var controlsTopPadding: Double {
|
||||
guard fullScreenLayout else { return 0 }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user