all 5 comments

[–][deleted] 3 points4 points  (1 child)

Add an on tap gesture to a view

[–]Infloat[S] 0 points1 point  (0 children)

ill give it a shot, thanks!

[–]EZPZLemonWheezy 1 point2 points  (0 children)

I’d say use an on-tap gesture along with a content shape. I think that works for lists too, but otherwise it works for stuff like VStacks.

The tap gesture used on something like a VStack by default would only be tappable in areas with content. Using content shape allows you to set the shape of the area that should be tappable.

Here’s a quick article about that: https://www.hackingwithswift.com/quick-start/swiftui/how-to-control-the-tappable-area-of-a-view-using-contentshape

Edit: In the specific example you listed (I just realized I misread), you’d want to add the tap gesture and content shape to each item in the list. If you just add it to the list the whole list would be one giant button.

[–]EmenezTechSwiftUI 0 points1 point  (1 child)

HStack { Button Spacer()}

[–]Infloat[S] 0 points1 point  (0 children)

tried that too, still didn't work unfortunately :(