-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement a generic AsyncButton with support for throwing closures #8
Conversation
@PSchmiedmayer SpeziViews seems to have an outdated list of required status checks in the branch protection rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is a great addition! 🚀
Love the usage of environment values to configure the behaviour, really follows the trend of the latest SwiftUI APIs out there.
Only had a few smaller comments. Feel free to make the conversations as resolved when they are addressed and merge the PR after that 🚀
Fixed the merge check requirements @Supereg 👍 |
The |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
==========================================
- Coverage 78.11% 76.74% -1.36%
==========================================
Files 19 22 +3
Lines 612 748 +136
==========================================
+ Hits 478 574 +96
- Misses 134 174 +40
Continue to review full report in Codecov by Sentry.
|
@PSchmiedmayer Do you remember how we fixed the issue of a 0% code coverage 🙈 EDIT: nevermind. Codecov was still outdated. |
Was there an easy way to exclude PreviewProviders from code coverage reporting? |
Thanks for the tipps regarding code coverage. feel free to merge 👍 |
Implement a generic AsyncButton with support for throwing closures
♻️ Current situation & Problem
Currently, Spezi Views (nor SwiftUI) provide a way to easily manage buttons with asynchronous action closures. We have several use cases where a reusable button with an async (throwing) action closure would be helpful (e.g. SpeziAccount for Login/Signup/Password Reset buttons).
💡 Proposed solution
This PR introduces a the new, reusable component
AsyncButton
that allows to supplyasync
andasync throwing
action closures. It handles disabling the button and rendering of a processing indicator automatically. To deal with thrown errors of the action closure, we reuse theViewState
abstraction already available in SpeziViews. This can easily be combined with theviewStateAlert(state:)
modifier to display a simple error alert.⚙️ Release Notes
AsyncButton
component forasync
andasync throwing
action closures.processingDebounceDuration
EnvironmentKey for a generalized configuration of debounce durations.processingOverlay(isProcessing:overlay)
modifier to easily replace a view with a processing indicator.➕ Additional Information
Related PRs
This PR refines the
AsyncDataEntrySubmitButton
implementation currently used in the upcoming SpeziAccount PR StanfordSpezi/SpeziAccount#7 and moves it to SpeziViews.Testing
Additional UI tests were added.
Reviewer Nudging
Ideally, have a look at the added UI tests and then at the
AsyncButton
implementation itself. It might be helpful to play around with the Previews ofAsyncButton
as well.Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: