Skip to content
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

didActivateItem missing from SwiftUI implementation #1

Closed
hiddenmountain opened this issue Sep 17, 2022 · 2 comments
Closed

didActivateItem missing from SwiftUI implementation #1

hiddenmountain opened this issue Sep 17, 2022 · 2 comments

Comments

@hiddenmountain
Copy link

I might be missing something obvious, but I can't find how to use didActivateItem, didCancel etc. when following the Swift UI implementation.

How do I tell DSFQuickActionBar what to do when an item is activated?

@dagronf
Copy link
Owner

dagronf commented Sep 17, 2022

Hey mate, in the call to QuickActionBar<>, you pass in a binding to selectedItem. When that value changes, the item was activated.

For example, in the SwiftUI Demo in the Demos/SwiftUI Demo folder, if you look at ContentView.swift, line 50 is the call for the quick action bar.

You can see at line 54 we pass in a binding to a selectedItem object (in this case selectedFilter).

When selectedFilter changes, the user has activated the item. If you need a callback you could add an onChange modifier to the quick action bar to detect the change, like so :-

.onChange(of: selectedFilter) { newValue in
   Swift.print("Selected filter \(newValue)")
}

I didn't add a 'didCancel' as for the initial version I didn't need it for what I was doing, but it wouldn't be overly difficult to add.

Hope that helps!

@hiddenmountain
Copy link
Author

Thanks a lot; that makes total sense and it's working as intended now. Great work on this, by the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants