UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

problems with navigation in SwiftUI (1.0)

Forums > SwiftUI

Hi, 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 NavigationBar, if delete NavigationBar 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

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

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.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.