I have a custom TabBar view which consists of a Group
of UIViewControllerRepresentables that are presnted when the TabRouter
state changes accordingly.
The state is changed in the MenuView
which just changed an internal @Published
var within the TabRouter
that holds the viewState
struct TabBarView: View {
@EnvironmentObject var router: TabRouter
var body: some View {
GeometryReader { geo in
VStack(alignment: .center, spacing: 0) {
Group {
switch router.viewState {
case .state1:
LegacyVCRepresentable1()
case .state2:
LegacyVCRepresentable2()
case .state3:
LegacyVCRepresentable3()
case .state4:
LegacyVCRepresentable4()
}
}
.frame(maxHeight: .infinity)
MenuView()
.frame(width: geo.size.width, height: geo.size.height/12)
}
}
.ignoresSafeArea(edges: .top)
}
}
My problem here is that those legacy ViewControllers that I am presenting within this SwiftUI view is that they are storyboards and each one has different segues that navigate deeper within the navigation stack inside each one of them (UINavigationController transitions).
Is it possible for me to get some sort of callback when the views are being navigated deeper, so I can hide the MenuView
when it shouldn’t be seen?
OR shall I have to pass in some sort of callback variable like:
case .state1:
LegacyVCRepresentable1(onNavigated: onNavigated)
func onNavigated() {
self.hidesMenuView = true
}
And handle all those parts myself? Maybe someone has faced a similar issue and has a more elegant solution?
Thanks in advance!