Merge pull request #814 from yattee/fullscreen-gesture-toggle

allow users to disable fullscreen swipe gesture
This commit is contained in:
Arkadiusz Fal 2024-11-08 15:01:06 +01:00 committed by GitHub
commit f69ccb6bd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 6 deletions

View File

@ -5,6 +5,7 @@ final class ConstrolsSettingsGroupExporter: SettingsGroupExporter {
override var globalJSON: JSON { override var globalJSON: JSON {
[ [
"avPlayerUsesSystemControls": Defaults[.avPlayerUsesSystemControls], "avPlayerUsesSystemControls": Defaults[.avPlayerUsesSystemControls],
"fullscreenPlayerGestureEnabled": Defaults[.fullscreenPlayerGestureEnabled],
"horizontalPlayerGestureEnabled": Defaults[.horizontalPlayerGestureEnabled], "horizontalPlayerGestureEnabled": Defaults[.horizontalPlayerGestureEnabled],
"seekGestureSensitivity": Defaults[.seekGestureSensitivity], "seekGestureSensitivity": Defaults[.seekGestureSensitivity],
"seekGestureSpeed": Defaults[.seekGestureSpeed], "seekGestureSpeed": Defaults[.seekGestureSpeed],

View File

@ -9,6 +9,10 @@ struct ConstrolsSettingsGroupImporter {
Defaults[.avPlayerUsesSystemControls] = avPlayerUsesSystemControls Defaults[.avPlayerUsesSystemControls] = avPlayerUsesSystemControls
} }
if let fullscreenPlayerGestureEnabled = json["fullscreenPlayerGestureEnabled"].bool {
Defaults[.fullscreenPlayerGestureEnabled] = fullscreenPlayerGestureEnabled
}
if let horizontalPlayerGestureEnabled = json["horizontalPlayerGestureEnabled"].bool { if let horizontalPlayerGestureEnabled = json["horizontalPlayerGestureEnabled"].bool {
Defaults[.horizontalPlayerGestureEnabled] = horizontalPlayerGestureEnabled Defaults[.horizontalPlayerGestureEnabled] = horizontalPlayerGestureEnabled
} }

View File

@ -116,6 +116,7 @@ extension Defaults.Keys {
static let avPlayerUsesSystemControls = Key<Bool>("avPlayerUsesSystemControls", default: Constants.isTvOS) static let avPlayerUsesSystemControls = Key<Bool>("avPlayerUsesSystemControls", default: Constants.isTvOS)
static let horizontalPlayerGestureEnabled = Key<Bool>("horizontalPlayerGestureEnabled", default: true) static let horizontalPlayerGestureEnabled = Key<Bool>("horizontalPlayerGestureEnabled", default: true)
static let fullscreenPlayerGestureEnabled = Key<Bool>("fullscreenPlayerGestureEnabled", default: true)
static let seekGestureSensitivity = Key<Double>("seekGestureSensitivity", default: 30.0) static let seekGestureSensitivity = Key<Double>("seekGestureSensitivity", default: 30.0)
static let seekGestureSpeed = Key<Double>("seekGestureSpeed", default: 0.5) static let seekGestureSpeed = Key<Double>("seekGestureSpeed", default: 0.5)

View File

@ -63,7 +63,7 @@ extension VideoPlayerView {
} }
// Toggle fullscreen on upward drag only when not disabled // Toggle fullscreen on upward drag only when not disabled
if verticalDrag < -50 { if fullscreenPlayerGestureEnabled, verticalDrag < -50 {
player.toggleFullScreenAction() player.toggleFullScreenAction()
disableGestureTemporarily() disableGestureTemporarily()
return return

View File

@ -66,6 +66,7 @@ struct VideoPlayerView: View {
#endif #endif
@Default(.horizontalPlayerGestureEnabled) var horizontalPlayerGestureEnabled @Default(.horizontalPlayerGestureEnabled) var horizontalPlayerGestureEnabled
@Default(.fullscreenPlayerGestureEnabled) var fullscreenPlayerGestureEnabled
@Default(.seekGestureSpeed) var seekGestureSpeed @Default(.seekGestureSpeed) var seekGestureSpeed
@Default(.seekGestureSensitivity) var seekGestureSensitivity @Default(.seekGestureSensitivity) var seekGestureSensitivity
@Default(.playerSidebar) var playerSidebar @Default(.playerSidebar) var playerSidebar

View File

@ -8,6 +8,7 @@ struct PlayerControlsSettings: View {
@Default(.playerControlsLayout) private var playerControlsLayout @Default(.playerControlsLayout) private var playerControlsLayout
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout @Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
@Default(.horizontalPlayerGestureEnabled) private var horizontalPlayerGestureEnabled @Default(.horizontalPlayerGestureEnabled) private var horizontalPlayerGestureEnabled
@Default(.fullscreenPlayerGestureEnabled) private var fullscreenPlayerGestureEnabled
@Default(.seekGestureSpeed) private var seekGestureSpeed @Default(.seekGestureSpeed) private var seekGestureSpeed
@Default(.seekGestureSensitivity) private var seekGestureSensitivity @Default(.seekGestureSensitivity) private var seekGestureSensitivity
@Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration @Default(.buttonBackwardSeekDuration) private var buttonBackwardSeekDuration
@ -64,9 +65,10 @@ struct PlayerControlsSettings: View {
@ViewBuilder var sections: some View { @ViewBuilder var sections: some View {
#if !os(tvOS) #if !os(tvOS)
Section(header: SettingsHeader(text: "Controls".localized()), footer: controlsLayoutFooter) { Section(header: SettingsHeader(text: "Player Controls".localized()), footer: controlsLayoutFooter) {
#if !os(tvOS) avPlayerUsesSystemControlsToggle
avPlayerUsesSystemControlsToggle #if os(iOS)
fullscreenPlayerGestureEnabledToggle
#endif #endif
horizontalPlayerGestureEnabledToggle horizontalPlayerGestureEnabledToggle
SettingsHeader(text: "Seek gesture sensitivity".localized(), secondary: true) SettingsHeader(text: "Seek gesture sensitivity".localized(), secondary: true)
@ -112,7 +114,7 @@ struct PlayerControlsSettings: View {
} }
var controlsButtonsSection: some View { var controlsButtonsSection: some View {
Section(header: SettingsHeader(text: "Controls Buttons".localized())) { Section(header: SettingsHeader(text: "Player Control Buttons".localized())) {
controlButtonToggles controlButtonToggles
} }
} }
@ -157,8 +159,12 @@ struct PlayerControlsSettings: View {
#endif #endif
} }
private var fullscreenPlayerGestureEnabledToggle: some View {
Toggle("Swipe up toggles fullscreen", isOn: $fullscreenPlayerGestureEnabled)
}
private var horizontalPlayerGestureEnabledToggle: some View { private var horizontalPlayerGestureEnabledToggle: some View {
Toggle("Seek with horizontal swipe on video", isOn: $horizontalPlayerGestureEnabled) Toggle("Seek with horizontal swipe", isOn: $horizontalPlayerGestureEnabled)
} }
private var avPlayerUsesSystemControlsToggle: some View { private var avPlayerUsesSystemControlsToggle: some View {