Comments (5)
Hey,
How and when do you reset your routing states?
If we're talking about a real "reset" of the state, there is one place I do this to essentially restart the app after appearance settings are changed by EnvironmentOverrides
panel (a UI/UX testing tool I built, which is also demoed as part of this project).
Normally you don't want a full reset, but toggle a few flags at once to pop back to your AuthenticationView
. That is, there should be a flag that presented SignUpView and another one that displayed HomeView, so as soon as you toggle both off you should be good.
If this tip does not help, please do provide the code of how you're changing the routing state to pop back and the routing state structure itself.
from clean-architecture-swiftui.
@nalexn Would you please take a look at this project?
https://gitlab.com/MohsenKhosravinia/cleanarchvaiyo
from clean-architecture-swiftui.
Ok, after a quick glance I think you should remove NavigationLink
here and leave just the Button
:
NavigationLink(destination: AuthenticationView(), isActive: routingBinding.shouldNavigateToAuthetication) {
Button {
logout()
} label: {
Image(systemName: "power")
//...
}
}
then, I'd removed the var shouldNavigateToAuthetication: Bool = false
in the HomeView.Routing
. In your logout
, instead of
injected.appState[\.routing.home.shouldNavigateToAuthetication] = true
you should toggle the container.interactors.splashInteractor.isLogin
, since I can see it toggles between AuthenticationView
and HomeView
:
if container.interactors.splashInteractor.isLogin {
NavigationLink(
destination: HomeView(),
isActive: $showHomeView) { EmptyView() }
} else {
NavigationLink(
destination: AuthenticationView(),
isActive: $showAuthenticationView) { EmptyView() }
}
from clean-architecture-swiftui.
Thank you for the effort but I want to go forward (after log out I want to instantiate new authentication view). I did follow your steps but the log out button does nothing without navigation link. When we instantiate a view twice (based on a UX situation) we don't get the proper result because the app state holds the routing last states and the automatic navigation happens afterward. Do you have any suggestion on that? I was trying to reset the AppState.Routing struct on the .onAppear or .onDisappear but the result was messy and not satisfying.
from clean-architecture-swiftui.
Ok, then if you actually need to show another AuthenticationView and not pop back to the original, the second one has to rely on separate routing parameters. Introduce a secondary set of routing params for AuthenticationView, and then control which set to use by providing an enum or a bool value as init parameter for the AuthenticationView
from clean-architecture-swiftui.
Related Issues (20)
- Typo: TextField spelling HOT 1
- Cannot connect to REST API HOT 4
- How to save related CoreData objects? HOT 1
- Something wrong with @Builder and @resultBuilder !!! HOT 1
- How to get value from LoadableSubject? HOT 1
- Why does the '.onReceive(routingUpdate)' perform twice? HOT 1
- Project does not build in Xcode 13.2; Internal error: missingPackageDescriptionModule HOT 2
- Question: why `case .isLoading` is not called even we got `.isLoading` on didSet? HOT 1
- Find by AccessibilityIdentifier HOT 3
- app crash after select some countires HOT 1
- Would be cool to have the same using SwiftUI Lifecycle
- safearea is not correct HOT 2
- How do I add pagination?
- Question regarding Value: Decodable and Closures
- How do i add interceptor? HOT 1
- Few questions
- CancelBag Strong Reference Cycle HOT 7
- Decouple `Respository` logic HOT 1
- DIContainer conforming EnvironmentKey - can't find its usage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clean-architecture-swiftui.