// DISAPPEARING MESSAGES on a person's or a group's page (CONTRACT.md// "Disappearing messages", as Android's warm/Timer.kt draws it): one row near// the top of the page, its name and the length it stands at (or Off); tapped,// a sheet with the core's title, its four lengths (the one on ticked) and its// note on what disappearing cannot stop. A choice sends `chat.act timer`; the// chat's line and the header's status are the core's. Where the core answers// no choices (the person cannot write there), the row is drawn without the// sheet. A chat the core answers no `timer` for has no row.#if os(iOS)importCottonKitimportSwiftUIstructChatTimerRow: View {let card: ChatTimerCardletopen: () -> Void @Environment(\.chatLook) privatevar look/// The length as its choice says it; with no choices to read it from, the kit's own word for that length.privatevar length: String {iflet on = card.choices.first(where: \.on) { return on.label }returnswitch card.seconds {case86_400: ShellLines.line("chat", "app.timer.h24")case604_800: ShellLines.line("chat", "app.timer.d7")case7_776_000: ShellLines.line("chat", "app.timer.d90")default: ShellLines.line("chat", "app.timer.off") } }var body: someView {if card.choices.isEmpty { line.accessibilityElement(children: .combine).accessibilityIdentifier("chat-timer") } else {Button(action: open) { line } .buttonStyle(.plain) .accessibilityIdentifier("chat-timer") } }/// One line with the length at its end; where that does not fit (the largest text), the length under the name,/// so the name never breaks inside a word.privatevar line: someView {ViewThatFits(in: .horizontal) { HStack(spacing: 12) { mark titleSpacer(minLength: 8) said } VStack(alignment: .leading, spacing: 2) { title said } .padding(.vertical, 6) } .frame(maxWidth: .infinity, minHeight: 48, alignment: .leading) .contentShape(Rectangle()) }privatevar mark: someView {Image(systemName: "timer") .font(.system(size: 16 * min(look.scale, 1.3))) .foregroundStyle(look.colours.dim) .frame(width: 24) .accessibilityHidden(true) }privatevar title: someView {Text(verbatim: card.title).font(look.font(16)).foregroundStyle(look.colours.text) }privatevar said: someView {Text(verbatim: length) .font(look.font(14)) .foregroundStyle(card.seconds > 0 ? look.colours.accent : look.colours.dim) }}/// The lengths (the one on ticked) and the core's note under them; a choice is handed back unless it is the one standing.structChatTimerSheet: View {let card: ChatTimerCardlet set: (Int) -> Voidlet close: () -> Void @Environment(\.chatLook) privatevar lookvar body: someView { VStack(alignment: .leading, spacing: 4) {Text(verbatim: card.title) .font(look.font(20, .bold)).foregroundStyle(look.colours.text) .padding(.bottom, 6) .accessibilityAddTraits(.isHeader)ForEach(card.choices) { choice inButton { close()if !choice.on { set(choice.seconds) } } label: { HStack(spacing: 12) {Text(verbatim: choice.label).font(look.font(16)).foregroundStyle(look.colours.text)Spacer(minLength: 8)if choice.on {Image(systemName: "checkmark").font(.system(size: 15 * min(look.scale, 1.3), weight: .semibold)) .foregroundStyle(look.colours.accent) .accessibilityHidden(true) } } .frame(maxWidth: .infinity, minHeight: 48, alignment: .leading) .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityAddTraits(choice.on ? [.isButton, .isSelected] : .isButton) .accessibilityIdentifier("chat-timer-\(choice.seconds)") }Text(verbatim: card.note) .font(look.font(13)) .foregroundStyle(look.colours.dim) .fixedSize(horizontal: false, vertical: true) .padding(.top, 8) .padding(.bottom, 6) .accessibilityIdentifier("chat-timer-note") } .padding(.horizontal, Warm.side) .padding(.vertical, 18) .accessibilityElement(children: .contain) .accessibilityIdentifier("chat-timer-sheet") }}#endif