修复 Tab 导航栈路径绑定,确保子页面 push 后立即响应。
直接观察 RouterPath 并绑定 NavigationStack,移除未使用的 AppTab/AppRouter 辅助 API。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -29,19 +29,6 @@ enum AppTab: String, CaseIterable, Identifiable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
var systemImage: String {
|
||||
switch self {
|
||||
case .home:
|
||||
"house"
|
||||
case .orders:
|
||||
"doc.text"
|
||||
case .statistics:
|
||||
"chart.bar"
|
||||
case .profile:
|
||||
"person"
|
||||
}
|
||||
}
|
||||
|
||||
/// 当前 Tab 处于选中状态时使用的本地图片资源名。
|
||||
var selectedImageName: String {
|
||||
switch self {
|
||||
@ -83,9 +70,4 @@ enum AppTab: String, CaseIterable, Identifiable, Hashable {
|
||||
ProfileRootView()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var label: some View {
|
||||
Label(title, systemImage: systemImage)
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,16 +100,6 @@ final class AppRouter: ObservableObject {
|
||||
return router
|
||||
}
|
||||
|
||||
/// 生成 SwiftUI NavigationStack 可使用的路径绑定。
|
||||
func binding(for tab: AppTab) -> Binding<[AppRoute]> {
|
||||
let router = router(for: tab)
|
||||
|
||||
return Binding(
|
||||
get: { router.path },
|
||||
set: { router.path = $0 }
|
||||
)
|
||||
}
|
||||
|
||||
/// 切换到指定主 Tab。
|
||||
func select(_ tab: AppTab) {
|
||||
selectedTab = tab
|
||||
|
||||
Reference in New Issue
Block a user