-
Notifications
You must be signed in to change notification settings - Fork 61
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
Conditional ViewModifier issue #12
Comments
vladyslavsosiuk
pushed a commit
to vladyslavsosiuk/SwiftUI-Shimmer
that referenced
this issue
Nov 6, 2023
vladyslavsosiuk
pushed a commit
to vladyslavsosiuk/SwiftUI-Shimmer
that referenced
this issue
Nov 7, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. Thank you for a great code sample.
I found that it uses a conditional view modifier which is an incorrect implementation in SwiftUI and causes hard-to-track bugs.
The antipattern described in more details here: https://www.objc.io/blog/2021/08/24/conditional-view-modifiers/
Unfortunately, I don't have a possibility to open a PR with a fix, but I can provide suggestions.
Instead of returning modified view if the active argument is true we should pass that argument down to the ShimmerView and compute the duration of the animation based on that argument:
We will also need to retrigger the animation if view didn't reappear but the isActive property flipped from false to true
We should pass down the
isActive
argument down to theAnimatedMask
modifier and down to the GradientMaskModifier so that we can computeedgeColor
opacity and return 1 ifisActive
is false.Let me know if you need more details.
The text was updated successfully, but these errors were encountered: