-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing object and allowing dismiss? #7
Comments
Hello @ozumado. Sorry for the delay with answer, just saw your message. ModalLink(destination: { dismiss in DetailedView(item: "Item", dismiss: dismiss)}) {
Text("Present")
} Or you can rewrite the same in a next way depending on the syntax preferences: ModalLink(
destination: { DetailedView(item: "Item", dismiss: $0) },
label: { Text("Present") }
) Please, let me know if you have some other questions or improvements suggestions about the library. |
Thanks for your reply, I decided to use native way to close a View instead ( |
Ok, so I overcome this issue by using .onTapGesture() instead of Button() while using native .sheet(). It looks like Button is the issue here. I'm not an expert, but maybe this change could fix the issue in the library: public var body: some View {
Button(action: presentModalView){ label }
} To this: public var body: some View {
label.onTapGesture() { self.presentModalView() }
} But now the "fake button" doesn't have the same feel as real one - not changing opacity while pressed down, so I currently overcome this issue by creating a Button that does nothing, and applying .onTapGesture() that trigger the action: public var body: some View {
Button(action: { }) { label.onTapGesture() { self.presentModalView() } }
} |
Hello there,
I'm just learning SwiftUI and I faced a problem while using this library (which is awesome and simple btw.). Is it possible to pass an object to modal view and enable dismiss action?
ModalLink(destination: DetailedView(item:item).init(dismiss:))
Doesn't seem to work... I'm either able to only pass an object or enable dismiss action.
ModalLink(destination: DetailedView(item:item)
ModalLink(destination: DetailedView.init(dismiss:))
Any clues?
The text was updated successfully, but these errors were encountered: