// Capture as a layer: the capture surface (the picture path) or New thought's// overlay, whichever the raise asked for, drawn by the host it rose over.//// Home draws it in the board's place when capture rises over Home itself.// Over pushed screens the phone's stack host draws it OVER the whole stack and// pops nothing (mini RJ11, S2): capture used to pop to Home and put back only// the navigator's path, so every screen pushed by `navigationDestination(item:)`// — a Todos group, a todo opened from it, a linked record — was gone when the// capture was cancelled, and the person landed on the Todos root.importSwiftUIstructCaptureLayer: View {/// A thought the capture surface kept (the picture path), on the/// overlay's receipt until it is let go — the host's, so it outlives the/// surface that kept it. @Binding var kept: ThoughtFiled?/// The capture up is the picture path's (`CapturePictureLatch`).let pictureCapture: Bool/// Something was written or taken back: the host reads again.let onChanged: () -> Void @Environment(Navigator.self) privatevar navigator: Navigator? @Environment(DatabaseScene.self) privatevar scene: DatabaseScene? @Environment(DatabasesModel.self) privatevar databases: DatabasesModel? @Environment(\.records) privatevar recordsvar body: someView {iflet start = navigator?.capture, pictureCapture || navigator?.waitingPicture != nil { captureSurface(start) } else { thoughtOverlay(navigator?.capture) } }/// The capture surface, built from the core by `Hosted`; the navigator's/// flag comes down when it closes. @ViewBuilder privatefunc captureSurface(_ start: CaptureStart) -> someView {Hosted(unwired: { core, _ inCaptureSurfaceModel( read: ScreenRead(core: core, read: CaptureSurfaceModel.readName, families: [.core]), dictionary: { awaitVoiceBias.hints(core: core) } ) }) { surface inCaptureSurface( model: surface, start: start, onKept: { filed in kept = filed// The receipt shows first; its Done puts the screen back. navigator?.closeCapture(restoring: false) onChanged() }, onDiscarded: { navigator?.closeCapture() } ) } }/// New thought's own overlay (`NewThoughtOverlay.swift`): the pill's two/// paths and the receipt, over the same dock the capture surface mounts. @ViewBuilder privatefunc thoughtOverlay(_ start: CaptureStart?) -> someView {Hosted(unwired: { core, _ inCaptureSurfaceModel( read: ScreenRead(core: core, read: CaptureSurfaceModel.readName, families: [.core]), dictionary: { awaitVoiceBias.hints(core: core) } ) }) { surface inNewThoughtOverlay( model: surface, start: start, kept: kept, personalName: databases.flatMap { model in model.held.first(where: \.isPersonal).map { model.capName($0) } } ?? DatabaseCap.personal, pageDatabaseId: scene?.shownId, screen: CaptureScreen(navigator?.stack.last ?? .home), onDone: { kept = nil navigator?.closeCapture() onChanged() }) } }}/// The capture up is the picture path's: latched when the picture is held,/// because the capture surface TAKES the picture as it mounts and a body/// reading `waitingPicture` alone would swap the surface out under it. Worn/// by the always-mounted host, never by the layer itself.structCapturePictureLatch: ViewModifier { @Binding var pictureCapture: Boollet navigator: Navigator?func body(content: Content) -> someView { content .onChange(of: navigator?.waitingPicture != nil, initial: true) { _, held inif held { pictureCapture = true } } .onChange(of: navigator?.capture == nil) { _, closed inif closed { pictureCapture = false } } }}