Skip to content

EnvironmentValues

ohitsdaniel edited this page Apr 29, 2021 · 1 revision

Extensions on EnvironmentValues

Properties

navigator

The Navigator allowing navigation path mutations

var navigator: Navigator 

Can be used to directly navigate from a Vanilla SwiftUI.

struct RootView: View {
  @Environment(\.navigator) var navigator: Navigator
  @Environment(\.currentScreenID) var screenID: ScreenID

  var body: some View {
   Button(
     action: { navigator.go(to: DetailScreen(), on: screenID) },
     label: Text("Go to DetailScreen")
  }
}

treatSheetDismissAsAppearInPresenter

viewAppeared(animated:​) is not called in SwiftUI and UIKit when a ViewController dismisses a sheet. This environment value allows you to override this behaviour.

var treatSheetDismissAsAppearInPresenter: Bool 

Use .environment(\.treatSheetDismissAsAppearInPresenter, true) on your Root view to get onAppear events for sheet dismissals.

Example

 Root(
   dataSource: dataSource,
   pathBuilder: pathBuilder
 )
 .environment(\.treatSheetDismissAsAppearInPresenter, true)

parentScreenID

The ScreenID of the screen preceding the screen the view is embedded in

var parentScreenID: ScreenID? 

currentScreenID

The ScreenID of the screen the view is embedded in

var currentScreenID: ScreenID 

parentScreen

The Screen preceding the screen the view is embedded in

var parentScreen: AnyScreen? 

currentScreen

The Screen the view is embedded in

var currentScreen: AnyScreen 
Clone this wiki locally