Cotton code
43 lines · 1.6 KB · SwiftRaw
// `/device/[page]` — one of THIS device's pages that only its host can draw.//// THIS device's own record page offers them (`native Device records`'s host acts);// the host names and draws each through `HostSettingsSlot`// (`Platform/HostSettingsSlot.swift`). This screen knows only the id: it puts// the host's page on the paper under the words its act was offered with, and// says plainly that there is nothing here when the host has no such page —// which is every id on the phone, whose host hands in none.import CottonKitimport SwiftUIstruct HostPageScreen: View {    let id: String    @Environment(HostSettingsSlot.self) private var host: HostSettingsSlot?    /// The words the page's act was offered with; none for a page that is    /// only opened in place.    private var title: String? {        host?.deviceActs.first { $0.id == id }?.label    }    var body: some View {        PaperScreen(title: title) {            Group {                if let page = host?.page(id) {                    page.content()                } else {                    Text(Self.nothingHere)                        .paperHand(17)                        .accessibilityIdentifier("host-page-missing")                }            }            .settingsFormWidth()            .frame(maxWidth: .infinity, alignment: .topLeading)        }        .accessibilityElement(children: .contain)        .accessibilityIdentifier("host-page-\(id)")    }    /// What an id no host page answers says.    static var nothingHere: String { ShellLines.line("empty", "host_page", ["host": "\(HostNoun.lowerCase)"]) }}