Keep navigation state in a router shared by both iOS layouts

The tab bar and sidebar layouts each kept their own navigation paths and
selection, so swapping between them (resizing an iPad Stage Manager
window across the size-class breakpoint) lost every pushed screen and
re-applied the startup tab.

NavigationRouter now holds the selected section, a typed stack per
section keyed by SidebarItem.id, the search text and the sidebar
manager. Both layouts select with SidebarItem and render the router's
state; navigate(to:) pushes onto it directly instead of going through
an observed pendingNavigation, so a request made before a layout
appears is not lost, and a destination pushed before startup keeps its
section. When a layout can't show the selection (a sidebar channel in
the tab bar, a section hidden by customization) it lands on the section
that can host it with that screen pushed first.

This also fixes keyboard section commands in the tab bar layout and the
coordinator's stale tab on iPad. AppTab, pendingNavigation,
selectedSidebarItem and the unused SheetDestination/path API are gone,
and the iOS 18 and 26.1 root views are merged into AdaptiveTabView.
This commit is contained in:
Arkadiusz Fal
2026-10-03 23:24:50 +02:00
parent 79202667c0
commit b26b7d342f
9 changed files with 423 additions and 910 deletions

View File

@@ -1,53 +0,0 @@
//
// AppTab.swift
// Yattee
//
// Main app tab definitions.
//
import Foundation
enum AppTab: String, CaseIterable, Identifiable {
case home
case subscriptions
case search
#if os(tvOS)
case settings
#endif
var id: String { rawValue }
var title: String {
switch self {
case .home: return String(localized: "tabs.home")
case .subscriptions: return String(localized: "tabs.subscriptions")
case .search: return String(localized: "tabs.search")
#if os(tvOS)
case .settings: return String(localized: "tabs.settings")
#endif
}
}
var systemImage: String {
switch self {
case .home: return "house.fill"
case .subscriptions: return "play.square.stack.fill"
case .search: return "magnifyingglass"
#if os(tvOS)
case .settings: return "gearshape"
#endif
}
}
/// SidebarItem equivalent for UnifiedTabView navigation.
var sidebarItem: SidebarItem {
switch self {
case .home: return .home
case .subscriptions: return .subscriptionsFeed
case .search: return .search
#if os(tvOS)
case .settings: return .settings
#endif
}
}
}