Cotton code
47 lines · 2.1 KB · SwiftRaw
// A page painted for its picture runs in picture mode (architect, 17 Oct 2026,// 292): the fan's painter mounts a neighbour's page off screen to keep its// picture, and that page did its work — the camera's permission prompt rose// while Subscriptions was open, two cards from Camera. A page in picture mode// draws its face and does nothing else: no permission asked, no capture// session, no timer. Camera's picture is its face.import CottonKitimport SwiftUIextension EnvironmentValues {    /// This page is being painted for its picture, off screen.    @Entry var paintsPicture = false    /// Whether this page's appearing is an open the person made. A fan's    /// pages are mounted by its turns and its painter, so the fan says its    /// own open — the settled card's page, once — and its pages say none    /// (294, walker293: 423 opens in 37 min, none of them made).    @Entry var countsOpens = true}extension RouteScreen {    /// Whether this route's appearing logs an open: a list the person sees,    /// never a page painted for its picture or mounted by a fan's turn.    static func countsOpen(_ route: Route, paintsPicture: Bool, countsOpens: Bool) -> Bool {        !paintsPicture && countsOpens && route.tier == .list && route.recordId == nil    }}/// What a page painted for its picture is told when it asks for a device/// capability: where it stands now, never a prompt.struct PictureCapabilities: CapabilityAuthority {    let real: any CapabilityAuthority    func status(_ capability: DeviceCapability) async -> CapabilityAccess { await real.status(capability) }    func ask(_ capability: DeviceCapability) async -> CapabilityAccess { await real.status(capability) }}/// Picture mode, set inside whatever environment the page is given.struct PictureMode: ViewModifier {    @Environment(\.cottonCapabilities) private var capabilities    func body(content: Content) -> some View {        content            .environment(\.paintsPicture, true)            .environment(\.cottonCapabilities, PictureCapabilities(real: capabilities))    }}