Allow swipe down to open controls settings on tvOS

This commit is contained in:
Arkadiusz Fal 2022-08-15 00:14:28 +02:00
parent 4ec9791467
commit 263f0e63a6
2 changed files with 13 additions and 3 deletions

View File

@ -142,8 +142,14 @@ struct PlayerControls: View {
} }
} }
#if os(tvOS) #if os(tvOS)
.onReceive(model.reporter) { _ in .onReceive(model.reporter) { value in
model.show() if value == "swipe down", !model.presentingControls, !model.presentingOverlays {
withAnimation(Self.animation) {
model.presentingControlsOverlay = true
}
} else {
model.show()
}
model.resetTimer() model.resetTimer()
} }
#endif #endif

View File

@ -19,7 +19,7 @@ struct TVControls: UIViewRepresentable {
let upSwipe = UISwipeGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.handleSwipe(sender:))) let upSwipe = UISwipeGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.handleSwipe(sender:)))
upSwipe.direction = .up upSwipe.direction = .up
let downSwipe = UISwipeGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.handleSwipe(sender:))) let downSwipe = UISwipeGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.handleSwipeDown(sender:)))
downSwipe.direction = .down downSwipe.direction = .down
controlsArea.addGestureRecognizer(leftSwipe) controlsArea.addGestureRecognizer(leftSwipe)
@ -63,5 +63,9 @@ struct TVControls: UIViewRepresentable {
let location = sender.location(in: view) let location = sender.location(in: view)
model.reporter.send("swipe \(location)") model.reporter.send("swipe \(location)")
} }
@objc func handleSwipeDown(sender _: UISwipeGestureRecognizer) {
model.reporter.send("swipe down")
}
} }
} }