From 263f0e63a63beac17b8ef6eeec8c1bc772d0207e Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 15 Aug 2022 00:14:28 +0200 Subject: [PATCH] Allow swipe down to open controls settings on tvOS --- Shared/Player/Controls/PlayerControls.swift | 10 ++++++++-- Shared/Player/Controls/TVControls.swift | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index 4d410b7d..e1c4ff46 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -142,8 +142,14 @@ struct PlayerControls: View { } } #if os(tvOS) - .onReceive(model.reporter) { _ in - model.show() + .onReceive(model.reporter) { value in + if value == "swipe down", !model.presentingControls, !model.presentingOverlays { + withAnimation(Self.animation) { + model.presentingControlsOverlay = true + } + } else { + model.show() + } model.resetTimer() } #endif diff --git a/Shared/Player/Controls/TVControls.swift b/Shared/Player/Controls/TVControls.swift index 500f2469..1c9b1b53 100644 --- a/Shared/Player/Controls/TVControls.swift +++ b/Shared/Player/Controls/TVControls.swift @@ -19,7 +19,7 @@ struct TVControls: UIViewRepresentable { let upSwipe = UISwipeGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.handleSwipe(sender:))) 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 controlsArea.addGestureRecognizer(leftSwipe) @@ -63,5 +63,9 @@ struct TVControls: UIViewRepresentable { let location = sender.location(in: view) model.reporter.send("swipe \(location)") } + + @objc func handleSwipeDown(sender _: UISwipeGestureRecognizer) { + model.reporter.send("swipe down") + } } }