Replies: 2 comments
-
|
Given the many ways presentation values can be dismissed, I'm not sure how you'd listen to the route. Nor do I think that listening in is that great an implementation, as it depends on some process knowing and depending upon the specific internal mechanisms of another. Better to drive UI directly from the dependent state. struct SomeOtherView: View {
@Environment(\.currentUser) var currentUser
var body: some View {
if let user = currentUser {
Text("User \(user.name)")
} else {
Text("What I'd show for a non-logged in user..")
}
}
} |
Beta Was this translation helpful? Give feedback.
-
|
I think your suggestion is correct, I created a property and then achieved the effect I wanted by listening to this property. However, I still feel that in actual use, there is still a need to listen to routes. For example, I have a global floating button, but I want to hide this button if the page that is opened is in a whitelist. We can currently create a global property, listen to it, and change the value of this property after opening the property page. However, if we can easily listen to routes, or route top child, all this will be easier. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
My App has a requirement. When the user's login status fails, the log page needs to be presented. When the login is successful, the page needs to be refreshed automatically after the login page is dismissed. Therefore, I need to listen to the status of the page route. Is there any good way?
Beta Was this translation helpful? Give feedback.
All reactions