|
I'm dealing with my login screen. For that, I've defined an @AppStorage property. On change of scenePhase, I toggle it to false, and call FaceIDAuthentication method when it comes to active:
On my MainView (second on the hiearchy), I condition all shown content to this value:
I change this value on Login view (password, just in case FaceId fails, or is not on) with:
And on FaceIdAthentication with:
Both login methods (password and FaceId) work like a charm. But animations don't: no animation (opacity of MainView, or the other two on changing the value) at all is used when "unpresenting" LoginView. Is this the correct way of doing so? Explained here: https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-and-remove-views-with-a-transition Is it correct monitoring @AppStore (UserDefaults) for animations to fire? Have I to add any aditional modifier to my LoginView() on MainView call, maybe? |
|
An idea..I don't know if it would work.. but what if you change
to
The animation will be triggerred once the the appBlocked value will change.. |
|
Thanks, @Bnerd. Efectively: passing the value to be directly monitored... But still not working. Could it be related to the fact that I use this way as well on @main view? must animation be there? (marked whith ** above)? But this case is only related to FaceID call. It must work with password, not being used then. |
|
As per my understanding the .animation goes to what you want to animate. Login -> Main .animaiton goes to Main Main -> Login .animaiton goes to Login Give it a try |
|
I've moved the method from MainView...
...to @main App struct:
Thus, one level higher, to the top of app hiearchy. Thinking with your idea that, as appBlocked toggle is received before on "top" @main app structure, I cannot see it on "lower" MainView(). But still no animation. Any further ideas? |
|
Finally, after much google research, I've found a workaround to make it work. I've moved LoginView showing logic from @main app struct to the second hierarchical view, MainView. I've placed there the two views –regular behind, and login at front– on a ZStack, adding conditional for LoginView to be shown, and a modifier .zIndex(1) to keep its position on the stack when hiding/showing it. Finally, .animation modifier attached to ZStack itself:
This way, animation works perfectly. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.