fix(nav): resolve routing bug when target tab is hidden inside 'More' tab
- Fix an issue where navigating to Records via long-press stops at the 'More' tab menu - Update navigation logic to automatically route through the 'More' tab and land directly on the target screen - Ensure action filters are correctly applied when deep-linking to nested tabs
This commit is contained in:
parent
5475590a47
commit
acdddbb670
Binary file not shown.
@ -90,11 +90,19 @@ final class AppRouter {
|
||||
/// 기록 탭이 열릴 때 적용할 행동 필터 (기록 탭에서 소비 후 nil로 되돌림)
|
||||
var pendingHistoryActionID: PersistentIdentifier?
|
||||
|
||||
/// 기록 탭으로 이동하며 행동 필터를 예약. 기록 탭이 노출 탭에 없으면 더보기로 이동.
|
||||
/// 더보기 탭 내부 내비게이션 경로. 더보기에 숨은 탭으로 바로 진입할 때 라우터가 채워 넣는다.
|
||||
var morePath: [AppTab] = []
|
||||
|
||||
/// 기록 탭으로 이동하며 행동 필터를 예약. 기록 탭이 노출 탭에 없으면 더보기 안의 기록 화면까지 바로 진입.
|
||||
func openHistory(filtering actionID: PersistentIdentifier, visibleTabsRaw: String) {
|
||||
pendingHistoryActionID = actionID
|
||||
let visible = AppTab.visibleTabs(from: visibleTabsRaw)
|
||||
tabSelection = visible.contains(.history) ? AppTab.history.rawValue : AppTab.moreTabValue
|
||||
if visible.contains(.history) {
|
||||
tabSelection = AppTab.history.rawValue
|
||||
} else {
|
||||
morePath = [.history]
|
||||
tabSelection = AppTab.moreTabValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,9 +198,12 @@ struct MainTabView: View {
|
||||
}
|
||||
.onAppear {
|
||||
#if DEBUG
|
||||
// 검증용: -startTab이 노출 탭에 없으면 더보기 대신 그 탭 화면으로 안내되도록 보정
|
||||
// 검증용: -startTab이 노출 탭에 없으면 더보기 안의 그 화면까지 바로 진입
|
||||
let valid = visibleTabs.map(\.rawValue) + [AppTab.moreTabValue]
|
||||
if !valid.contains(router.tabSelection) {
|
||||
if let hidden = AppTab(rawValue: router.tabSelection) {
|
||||
router.morePath = [hidden]
|
||||
}
|
||||
router.tabSelection = AppTab.moreTabValue
|
||||
}
|
||||
#endif
|
||||
@ -203,14 +214,14 @@ struct MainTabView: View {
|
||||
// MARK: - 더보기 탭
|
||||
|
||||
struct MoreTabView: View {
|
||||
@Environment(AppRouter.self) private var router
|
||||
let tabs: [AppTab]
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
@Bindable var router = router
|
||||
NavigationStack(path: $router.morePath) {
|
||||
List(tabs) { tab in
|
||||
NavigationLink {
|
||||
tab.rootView
|
||||
} label: {
|
||||
NavigationLink(value: tab) {
|
||||
Label {
|
||||
Text(tab.label)
|
||||
} icon: {
|
||||
@ -222,6 +233,9 @@ struct MoreTabView: View {
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(AppTheme.background)
|
||||
.navigationTitle("더보기")
|
||||
.navigationDestination(for: AppTab.self) { tab in
|
||||
tab.rootView
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user