Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
32 lines
1.1 KiB
Swift
Executable File
32 lines
1.1 KiB
Swift
Executable File
// ShellNavigator — the shell's selection, reachable from the screens inside it.
|
|
//
|
|
// AppShell's tab selection used to be a private @State Int. That is fine for
|
|
// the drawer, which sits above the content, but not for anything INSIDE a tab
|
|
// that needs to change tabs — the header avatar being the case in point: a
|
|
// NavigationLink to AppDestination.profile would build a SECOND ProfileView
|
|
// inside the current tab's stack instead of switching to the real one.
|
|
//
|
|
// Kept deliberately small: selection only. Pushes stay value-based through
|
|
// NavigationLink/AppDestination.
|
|
|
|
import Foundation
|
|
import Observation
|
|
|
|
@MainActor
|
|
@Observable
|
|
public final class ShellNavigator {
|
|
/// The shell's selected index. RwShell binds to this.
|
|
public var index: Int
|
|
/// Where Profile sits in RwShell's index space (footerDestinations continue
|
|
/// the main count), passed in by AppShell so this type stays ignorant of
|
|
/// the tab enum.
|
|
private let profileIndex: Int
|
|
|
|
public init(profileIndex: Int, index: Int = 0) {
|
|
self.profileIndex = profileIndex
|
|
self.index = index
|
|
}
|
|
|
|
public func selectProfile() { index = profileIndex }
|
|
}
|