Apple TvOS detect swipe gesture in SwiftUI on remote control

I'm new in SwiftUI and Apple TV applications and I was wondering how to detect swipe gesture on remote control for TvOS in SwiftUI for the ContentView. Every time I search I just found solutions for UIKit or for iPhone/iPad since the drag gesture is not available to tvOS.
The plan for this gesture when swipe left or right present menus/side panels on the screen and focus on theses views.
Can anyone give some advice/tutorial or demo?

Thanks in advance and KR,
rpessoa
Post not yet marked as solved Up vote post of linuxrp Down vote post of linuxrp
2.5k views
  • Hey @linuxrp I would love to know if you ever found a good solution for this. If I find one I'll be sure to post it here.

  • I would recommend using GameController framework and GCController class. I have implemented RemoteController class which detects Siri Remote (1st and 2nd generation), iOS Remote (tvOS remote controller on iPhone) and Nimbus+ and PS game controllers. GCController has the advantage of programmatically add such tweaks as handling arrows on old remote with touch pad in a similar way as on new remote with arrow buttons - user must press touch pad down on old remote to trigger arro press.

Add a Comment

Replies

Did you find any solution to this? Facing same hurdles

Has anyone found a solution to this? CardButtonStyle applies the well-known "parallax effect" (its documentation refers to it as a motion effect) that wiggles the focused element when moving the finger on the Apple TV Remote touch area but I haven't found out how to replicate that effect without the styling that comes with CardButtonStyle.

The WWDC session Build SwiftUI apps for tvOS is a little odd in that at 1:42 it shows .buttonStyle(CardButtonStyle()) as the solution for when you'd want that that motion effect, and goes on to say that if you're looking for different styling than the one CardButtonStyle gives you, you can just create your own custom button style... without explaining how you can then get back the motion effect.

Looking at the Gestures, it seems that neither DragGesture nor anything else that might be used to implement this effect yourself is available on tvOS. 🤔

If anybody has an idea I'd greatly appreciate your advice.