WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

NavigationStack Help

Forums > SwiftUI

Hi, I'm trying to grasp how the new navigation stacks and links work. Before NavigationLinks had an isActive parameter and you could create an emptyview as its label so that if there were some condition to be met, the boolean would be set to true and you would navigate to the next screen. However, I am not able to recreate anything like that. Scenario I have right now: an amition that goes on while an API call is made. Once the animation is done, it sets a boolean value to true (ill call it doneLoading). Before: i would just have an emptyView navigationLink where that bool value would be in the isActive param and once the animation and call were over, i would be brought to the next screen. This time around, i've tried setting the navigationDestination(isPresented: doneLoading){ nextScreen() } but the animation just starts over.

 @State var show = false
    @State var isDone: Bool = false
    @State var doneLoading = false
    @StateObject var viewModel: BumperScreenViewModel
    @StateObject var sheetManager = SheetManager()

    init(viewModel: @autoclosure @escaping () -> BumperScreenViewModel) {
        self._viewModel = .init(wrappedValue: viewModel())

    var body: some View {
        NavigationStack {
            VStack {
                ZStack {
                    VStack {
                        if show {
                                .frame(width: 150, height: 150)
                                .task {
                                    try? await viewModel.getDataFromAPI()
                                    try? await Task.sleep(for: Duration.seconds(1))
                        } else {
        .navigationDestination(isPresented: $doneLoading) {


Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

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.