You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have one question, Do I have to create individual route for each tab?
If yes, then suppose there is one view which is part of 3rd tab but I want to push that view in 2nd tab. How can I push 3rd routes view to using 2nd route.
The text was updated successfully, but these errors were encountered:
Hello @iosYash, Yes we have to create individual routes for each tab.
The main route for the whole app, and other routes for individual tabs.
It's also very easy to show the view of one tab in another tab as we have a different router for each tab, we can create a new case in the enum switch of the one tab's router to open the view of the other tab's view, and just use the same view for both tab in the switch case.
Let me explain it with an example,
I have used 2 tabs, and we want to open 1 same screen from both tabs,
public enum AppRoute: Equatable {
public static func == (lhs: AppRoute, rhs: AppRoute) -> Bool {
return lhs.key == rhs.key
}
// MARK: - Home tab
case Home
// MARK: - Settings tab
case Setting
case ReportProblem
public var key: String {
switch self {
case .Home:
return "homeView"
case .Setting:
return "settingView"
case .ReportProblem:
return "reportProblemView"
}
}
}
struct HomeTabRouteView: View {
@StateObject var tabPilot = UIPilot(initial: AppRoute.Home)
var body: some View {
VStack(spacing: 0) {
UIPilotHost(tabPilot) { route in
switch route {
case .Home:
HomeView()
case .ReportProblem:
ReportProblemView()
default:
EmptyView()
}
}
}
}
}
struct SettingTabRouteView: View {
@StateObject var tabPilot = UIPilot(initial: AppRoute.Home)
var body: some View {
VStack(spacing: 0) {
UIPilotHost(tabPilot) { route in
switch route {
case .Setting:
SettingView()
case .ReportProblem:
ReportProblemView()
default:
EmptyView()
}
}
}
}
}
Using this we can open the report problem screen (which is part of the 2nd tab) in the 1st tab. Note:- We can not switch the tab programmatically to use the same view in a different tab.
I have one question, Do I have to create individual route for each tab?
If yes, then suppose there is one view which is part of 3rd tab but I want to push that view in 2nd tab. How can I push 3rd routes view to using 2nd route.
The text was updated successfully, but these errors were encountered: