// The phone's host: Home, as one page surface (lane inplace, 16 Oct 2026). // // The phone pushes nothing over the whole screen. Every page opens in place // on a page surface's own stack (`Navigator.tileStacks`, `TilePage`): the // shown fan tile's while Home draws its fan, and this one — the root's // (`Navigator.rootTile`) — when it draws none. The owner saw inside pages // still sliding in from the right with a back button and ruled that every // page opens as a record does; the NavigationStack this host was is gone. // // The Mac needs a DIFFERENT host over the same navigator // (`Boot/ColumnsHost.swift`), and the one branch that chooses between them is // `RootView`'s (the design spec's §5.2). Everything else `RootView` hands the // host — the navigator in the environment, the alarms, the toasts, the taps, // the route deps, the shake sheet — still wraps whichever host it built, so // both take the identical environment. // // **The navigator is passed, not read from the environment.** `RootView` // applies `.environment(navigator)` OUTSIDE the host, so inside it there is // nothing to read yet. import CottonKit import SwiftUI public struct StackHost: View { @Bindable private var navigator: Navigator private let deps: RouteDeps private let project: String? private let root: Root /// Capture drawn over the stack (`Navigator.captureOverStack`): its kept /// thought and picture latch live here, under the layer. @State private var kept: ThoughtFiled? @State private var pictureCapture = false /// Shared across the UIKit root and every fan tile's hosting controller. @State private var fanCover = FanCover() /// - Parameter project: the cap switcher's project, which every surface in /// the stack reads as `\.currentProject` — the board, and every list and /// page pushed over it, as the Mac's windows do (rebuild note 7b95efa4: /// "the switcher sets the current project for every board, list and page"). public init(navigator: Navigator, deps: RouteDeps, project: String? = nil, @ViewBuilder root: () -> Root) { self.navigator = navigator self.deps = deps self.project = project self.root = root() } public var body: some View { let ground = fanCover.ground return rootSurface // Every page — Home's fan tiles' and the root's own — is drawn by // the ONE route table (`RouteScreen`), through `RoutePage`. .environment(\.routePage, RoutePage(deps: deps)) // Capture raised over the root's pages is drawn over them, on the // page's own ground; nothing under it is closed (S2). .overlay { if navigator.captureOverStack { CaptureLayer(kept: $kept, pictureCapture: pictureCapture) {} .background { PageGroundFill().ignoresSafeArea() } } } .modifier(CapturePictureLatch(pictureCapture: $pictureCapture, navigator: navigator)) // The shell's writing editors over every page: the short-text input, // the full-screen editor (`DeckWritingLayer`). .deckWriting() // UIKit lays the root and tile hosts inside the safe area. Paint the // window's paper or the live deck's own ground here, outside every // host, through the status bar and under the home indicator. The // same cover box crosses those hosts through their environment. .background { ZStack { PageGroundFill() DeckGroundLaid(ground: ground) if ground == .blank, let plain = fanCover.plainGround { plain } }.ignoresSafeArea() } .environment(\.fanCover, fanCover) // A live fan tile reports from its own host. The root beneath it // must not answer "paper" for a preference that stops at that host. .environment(\.fanLaysGround, navigator.tile == nil) .cottonPageGround(.groundMuted) .cottonPageTexture(.plaster) // The one current project, for the root and every pushed screen alike. .environment(\.currentProject, project) } /// Home under the root's own pages: a page opened while Home draws no /// fan stands on this surface, never pushed. @ViewBuilder private var rootSurface: some View { #if os(iOS) TilePage( key: Navigator.rootTile, root: AnyView(root.cottonScreenFrame()), rootTitle: FanWords.home, navigator: navigator) #else root.cottonScreenFrame() #endif } }