From 9c80dc8918452be320a6e4d07e41602305ca8a44 Mon Sep 17 00:00:00 2001 From: Hugo Lefrancois Date: Thu, 18 Apr 2024 11:06:14 -0400 Subject: [PATCH] iOS navigation: to supported embedded navigation manager, the parent route name is used when there is no child route --- navigation/ios/NavigationContainerView.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/navigation/ios/NavigationContainerView.swift b/navigation/ios/NavigationContainerView.swift index cf045278..f6717968 100644 --- a/navigation/ios/NavigationContainerView.swift +++ b/navigation/ios/NavigationContainerView.swift @@ -9,9 +9,13 @@ struct NavigationContainerView< ScreenView: View, NavModifier: ViewModifier >: View { - @ObservedObject var navigateState: NavigationState - @ViewBuilder let buildView: (ScreenData) -> ScreenView + @Environment(\.presentedPilotRouteName) private var presentedRouteName + + @ObservedObject private var navigateState: NavigationState + + @ViewBuilder private let buildView: (ScreenData) -> ScreenView + let content: () -> Content init(navigateState: NavigationState, buildView: @escaping (ScreenData) -> ScreenView, content: @escaping () -> Content) { @@ -70,7 +74,7 @@ struct NavigationContainerView< ) ) .environment(\.pilotNavigationDismissTriggered, navigateState.navigationDismissTriggered) - .environment(\.presentedPilotRouteName, navigateState.child?.route?.name) + .environment(\.presentedPilotRouteName, navigateState.child?.route?.name ?? presentedRouteName) } private var embedInNavigationView: Bool {