first i have NavigationView and dont working swipe back, how in UIKit NavigationController, why? Second, how to correctly create the navigation flow for my situation: I have AuthView(), SelectedLanguageView() and OnboardingView(). At first start user show SelectedLanguageView(), next OnboardingView() and in the end AuthView() User dont can with OnboardingView() return on SelectedLanguageView() and with AuthView() return AuthView() Just NavigationLink dont working without NavigationView, why? if this is not the first launch, and user not authorized, then show AuthView(), else if user authorize, then show MainView(), MainView() include tab bar for 4 items, every item have NavigationView
@State private var navBarHidden = true
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let languagSettings = UserLanguageSettings()
UserDefaults.standard.set(false, forKey: "isNotFirstLaunchApp")
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
if UserDefaults.standard.bool(forKey: "isNotFirstLaunchApp") == false {
window.rootViewController = UIHostingController(rootView: OnboardingView(navBarHidden: $navBarHidden).environmentObject(languagSettings))
} else {
window.rootViewController = UIHostingController(rootView: AuthorizationView(navBarHidden: $navBarHidden.not, isAddNavView: true).environmentObject(languagSettings))
}
self.window = window
window.makeKeyAndVisible()
}
}
condition if the user is authorized has not added yet
var isAddNavView: Bool = false
var body: some View {
if isAddNavBar {
return NavigationView {
ZStack {
VStack {
Text("")
}
}
}
} else {
return ZStack {
VStack {
Text("")
}
}
}
}
i have error, if return NavigationView, if delete NavigationView and return ZStack, then all right. I think there is a better solution. ideas?
NavigationLink(destination: SignInView(), isActive: $isShowingSignInView) {
EmptyView()
}
Button(action: {
self.isShowingSignInView.toggle()
}) {
Text("isShowingSignInView")
}
all navigation links in the project i use like this
next - i tried the following: in all project i delete all NavigationView and create modal show screens (.sheet) in AuthorizationView() i have variables @State Example, on AuthorizationView() i have
@State var isShowRegistration: Bool = false
and tap button Registration showing flow Registration include 4 screens which are shown with .sheet
RegistrationView(registrationView: $isShowRegistration)
//screens below include @Binding var registrationView: Bool
VerificationView(registrationView: $registrationView)
SetupPasswordView(registrationView: $registrationView)
EndRegistrationViewAndAuthorization(registrationView: $registrationView)
on EndRegistrationViewAndAuthorization i have button and in ideal me need closed all previous screens and call func Auth() Which will open me the main screen of the application with the tab bar each item of which includes NavigationView. Now my button action {self.registrationView.toogle()} return me RegistrationView() but should return to AuthorizationView()