rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
926 stars 98 forks source link

EmptyView while push #95

Closed dmikots closed 2 years ago

dmikots commented 2 years ago

Hi! When I use push, I have empty view with back Botton on toolbar. But when I use .modal or .fullScreen - everything is ok

final class AccountCoordinator: NavigationCoordinatable {
    let stack = Stinsen.NavigationStack<AccountCoordinator>(initial: \AccountCoordinator.start)
    @Root var start = getAccount
    @Route(.push) var userProfile = getUserProfile

    @ViewBuilder func getAccount() -> some View {
        AccountView()
    }

    @ViewBuilder func getUserProfile() -> some View {
        UserProfileView()
    }
}

final class TabCoordinator: TabCoordinatable {
    lazy var child = TabChild(startingItems: [
        \TabCoordinator.dashBoards,
        \TabCoordinator.results,
        \TabCoordinator.bookings,
        \TabCoordinator.accounts
    ], activeTab: 0)

    @Route(tabItem: dashBoardTab) var dashBoards = getLocations
    @Route(tabItem: bookingTab) var bookings = getBooking
    @Route(tabItem: accountTab) var accounts = getAccount
    @Route(tabItem: resultsTab) var results = getResults

    let dashBoard: DashCoordinator
    let booking: BookingCoordinator
    let account: AccountCoordinator
    let result: ResultsCoordinator
image
LePips commented 2 years ago

Could you please provide the full TabCoordinator implementation?

dmikots commented 2 years ago

Could you please provide the full TabCoordinator implementation?

    var body: some Scene {
        WindowGroup {
            NavigationStack {
                MainCoordinator().view()
            }
        }
    }

My problem was in NavigationStack (16 iOS)

dmikots commented 2 years ago

But now, how can I disable navigationBar when push?

LePips commented 2 years ago

You're pushing a view inside a NavigationCoordinatable, a navigation bar is expected. You can hide the navigation bar on UserProfileView() with .navigationBarHidden(true). This isn't a Stinsen question, but a SwiftUI one.

dmikots commented 2 years ago

.navigationBarHidden(true)

thx u sir!