Tap to dismiss on SwiftUI
hey, thanks for your awesome library, how can I dismiss the toast or notification in swiftUI form?
Dismissing a notification
NotificationPresenter.shared.dismiss()
// with completion
NotificationPresenter.shared.dismiss(after: 0.5) { presenter in
// ...
}
Thanks for the hint, but when I call it, it won't work, e.g. in onTagGesture{} in my SwiftUI view component. although I added the onTapDismiss functionality in my fork using UITapGestureRecognizer, but I wanted to check if it can be done directly or not.
Ah you want to handle custom user interaction? See this sample code you need to disable style.canTapToHold:
https://github.com/calimarkus/JDStatusBarNotification/blob/ffde0bab9fd0b47e426e696b5fe53deefc781452/ExampleProject/ExamplesScreen.swift#L268-L274
No no, I just want to simply dismiss the notification when the user taps anywhere on it
Yep, for that you need the above. Then you can use swift gesture handling as usual.
By default a user can only swipe to dismiss.