Skip to content
ohitsdaniel edited this page Apr 29, 2021 · 3 revisions

Root

Root View of any ComposableNavigator driven application

public struct Root<Builder: PathBuilder>: View 

Embeds the content in a NavigationView and builds the navigation path, whenever it changes.

Usage

import ComposableNavigator
import SwiftUI

struct AppNavigationTree: NavigationTree {
  let homeViewModel: HomeViewModel
  let detailViewModel: DetailViewModel
  let settingsViewModel: SettingsViewModel

  var builder: some PathBuilder {
    Screen(
      HomeScreen.self,
      content: {
        HomeView(viewModel: homeViewModel)
      },
      nesting: {
        DetailScreen.Builder(viewModel: detailViewModel),
        SettingsScreen.Builder(viewModel: settingsViewModel)
      }
    )
  }
}

@main
struct ExampleApp: App {
  let dataSource = Navigator.Datasource(root: HomeScreen())

  var body: some Scene {
    WindowGroup {
      Root(
       dataSource: dataSource,
       pathBuilder: AppNavigationTree(...)
     )
    }
  }
}

Inheritance

View

Initializers

init(dataSource:navigator:pathBuilder:)

public init(
    dataSource: Navigator.Datasource,
    navigator: Navigator,
    pathBuilder: Builder
  ) 

init(dataSource:pathBuilder:)

init(
    dataSource: Navigator.Datasource,
    pathBuilder: Builder
  ) 

Properties

body

public var body: some View 

Methods

debug()

Enable logging function calls to the Navigator object and path changes.

func debug() -> Root 
Clone this wiki locally