修复 Tab 导航栈路径绑定,确保子页面 push 后立即响应。
直接观察 RouterPath 并绑定 NavigationStack,移除未使用的 AppTab/AppRouter 辅助 API。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -141,7 +141,17 @@ private struct TabNavigationStackHost: View {
|
||||
let tab: AppTab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: appRouter.binding(for: tab)) {
|
||||
TabNavigationStackContent(tab: tab, router: appRouter.router(for: tab))
|
||||
}
|
||||
}
|
||||
|
||||
/// 直接观察单个 Tab 的路由路径,确保子页面修改 RouterPath 后导航栈能立即响应。
|
||||
private struct TabNavigationStackContent: View {
|
||||
let tab: AppTab
|
||||
@ObservedObject var router: RouterPath
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $router.path) {
|
||||
tab.rootView
|
||||
.navigationTitle(tab.title)
|
||||
.navigationDestination(for: AppRoute.self) { route in
|
||||
@ -149,7 +159,7 @@ private struct TabNavigationStackHost: View {
|
||||
.toolbar(route.hidesTabBarWhenPushed ? .hidden : .visible, for: .tabBar)
|
||||
}
|
||||
}
|
||||
.environmentObject(appRouter.router(for: tab))
|
||||
.environmentObject(router)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user