joogps / SlideOverCard

A SwiftUI card view, made great for setup interactions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Close on Tap Outside

Mcrich23 opened this issue · comments

Is there a way you can make it, so a tap outside of the card dismisses it. Thanks!

Seems to me like this could be implemented into here, as well as further down in the code:

public init(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, dragEnabled: Binding<Bool> = .constant(true), dragToDismiss: Binding<Bool> = .constant(true), displayExitButton: Binding<Bool> = .constant(true), content: @escaping () -> Content) {

Using struct TouchGesture from SwiftUI, detect when a tap gesture that's outside the card's view and close it from there. Looking into SlideOverCard.swift's logic, it appears that there's logic already in place to detect dragging so shouldn't be too hard!

I can start work on this @joogps if you're okay with that 🙂

@Mcrich23 @corbin-r thank you for your support!