Cotton code
34 lines · 1.1 KB · SwiftRaw
// The three states of a `ScreenRead` inside a `PaperScreen` — what// `ScreenPage` draws for the host chrome, drawn for the paper chrome instead.//// A refusal carries a retry (a read that fell over on a dropped connection// must not be terminal), the first wait is a skeleton, and every later re-read// leaves the last answer on the paper rather than blanking it.import CottonKitimport SwiftUIstruct PaperReadBody<Content: View>: View {    let read: ScreenRead    @ViewBuilder let content: (JSONValue) -> Content    var body: some View {        Group {            if let refusal = read.refusal {                QuietState(                    title: ShellLines.line("projects", "this_could_not_be"),                    message: refusal,                    actionLabel: CottonStrings.tryAgain,                    actionIdentifier: "work-read-retry",                    action: { Task { await read.load() } }                )            } else if let value = read.value {                content(value)            } else if read.firstAnswerPending {                SkeletonPage()            }        }        .task { await read.load() }    }}