Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full screen route in nested coordinators doesn't get performed in iOS 14.4 #79

Open
vadimbelyaev opened this issue Jul 11, 2022 · 0 comments

Comments

@vadimbelyaev
Copy link

Consider an iOS SwiftUI project that has the following coordinator structure:

App
    MainCoordinator
        ContentViewCoordinator (@Root of MainCoordinator)
            SecondaryCoordinator (@Route(.fullScreen) from ContentViewCoordinator)

In iOS 14.4, performing route(to:) from ContentViewCoordinator to SecondaryCoordinator by some reason has no effect (just nothing happens, no crashes, no console logs), while it works perfectly fine in iOS 14.5 and iOS 15. The issue is reproducible on simulators with Xcode 13.4.

Here's a full source code of an app that illustrates the issue:

import Stinsen
import SwiftUI

@main
struct StinsenNavigationIssueExampleApp: App {
    var body: some Scene {
        WindowGroup {
            MainCoordinator().view()
        }
    }
}

final class MainCoordinator: NavigationCoordinatable {
    var stack = NavigationStack(initial: \MainCoordinator.start)

    @Root private var start = makeStart

    private func makeStart() -> ContentViewCoordinator {
        ContentViewCoordinator()
    }
}

final class ContentViewCoordinator: NavigationCoordinatable {
    var stack = NavigationStack(initial: \ContentViewCoordinator.start)

    @Root private var start = makeContentView
    @Route(.fullScreen) private var secondary = makeSecondaryCoordinator

    private func makeContentView() -> some View {
        ContentView(buttonAction: { [weak self] in
            self?.route(to: \.secondary)
        })
    }

    private func makeSecondaryCoordinator() -> SecondaryCoordinator {
        SecondaryCoordinator()
    }
}

final class SecondaryCoordinator: NavigationCoordinatable {
    var stack = NavigationStack(initial: \SecondaryCoordinator.start)

    @Root private var start = makeSecondaryView

    private func makeSecondaryView() -> some View {
        SecondaryView()
    }
}

struct ContentView: View {
    var buttonAction: (() -> Void)?
    var body: some View {
        Button {
            buttonAction?()
        } label: {
            Text("Open secondary view")
        }
    }
}

struct SecondaryView: View {
    var body: some View {
        ZStack {
            Color.yellow.ignoresSafeArea()
            Text("Secondary")
        }
    }
}

Tapping on the "Open secondary view" button has no effect in iOS 14.4 simulator, but works well in iOS 14.5 and iOS 15. I was not able to confirm if it's reproducible on a physical device because I don't have any devices running that particular iOS version.

Interestingly enough, if I just get rid of the MainCoordinator and instantiate ContentViewCoordinator right in the App's body, it starts working fine on iOS 14.4.

The full source code of the example app is also available on GitHub: https://github.com/vadimbelyaev/StinsenNavigationIssueExample

Let me know if I can provide any additional info that can help resolving the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant