// One opened object and its acts. A deck's record opens IN PLACE// (`OpenedInPlace`); the page (`OpenedCardPage`) is what a new record's// blank card stands on, with the same container Settings' Backup card uses.importCottonFacesimportCottonKitimportCottonPaperimportCottonValuesimportSwiftUIstructOpenedCardContent<Face: View, Acts: View>: View { @ViewBuilder let face: () -> Face @ViewBuilder let acts: () -> Actsvar body: someView { VStack(alignment: .leading, spacing: BackupCardKnobs.gap) { face() .environment(\.faceOpened, true) .frame(maxWidth: .infinity) acts() } }}structOpenedCardPage<Face: View, Acts: View>: View {var ground: FaceGround? = nillet close: () -> Void @ViewBuilder let face: () -> Face @ViewBuilder let acts: () -> Actsvar body: someView {GeometryReader { room inPaperScreen(faceGround: ground, showsBack: false, onBack: close) {OpenedCardContent { face() .aspectRatio(CardPaperKnobs.aspect, contentMode: .fit) .frame(maxHeight: max(0, room.size.height - DeckWholeCardKnobs.top)) .clipped() } acts: { acts() } } } .simultaneousGesture(MagnifyGesture().onEnded { pinch inif pinch.magnification < DeckWholeCardKnobs.closes { close() } }) .environment(\.openedCardGround, ground) .accessibilityElement(children: .contain) .accessibilityIdentifier("opened-card") }}/// AN OPENED CARD STAYS WHERE IT IS (owner, 3 Nov 2026: "Do we need to/// shift the todo out of the box of todos when the actions menu comes up?/// ... The objects are designed in such a way that the action menu won't/// overlap then anyways"; and of every kind: "None of them should change or/// shift on long press. Just the action menu should come up."). A tap that/// opens a record at rest, and every hold, open the card IN PLACE on its/// deck: the same frame, size, ground and neighbours, the face drawn as at/// rest (never its `faceOpened` look). The acts tier fans at the hub/// (`presentOpened`), the face's tagged parts go live (`deckEditable`), and/// the deck holds every move while it stands (each deck's own `opened`)./// Closing — the hub, Close, a pinch in, or the card leaving the screen —/// returns the deck to plain; nothing moved, so nothing animates back. One/// implementation for every deck's card, Home's sync card included.structOpenedInPlace: ViewModifier {let opened: Boollet definition: TableDefinitionlet record: TableRecordlet close: () -> Void/// The face the card wears now: Face on the acts rests on it.let worn: String @Environment(\.deckEditor) privatevar editor @Environment(\.cottonCore) privatevar core @Environment(\.deckViewName) privatevar viewprivatevar target: DeckEditTarget {DeckEditTarget(table: definition.id, record: record.id, date: definition.whenColumn) }func body(content: Content) -> someView { content .deckEditable(definition: definition, record: record, live: opened) .simultaneousGesture(MagnifyGesture().onEnded { pinch inif pinch.magnification < DeckWholeCardKnobs.closes { close() } }, including: opened ? .all : .subviews) .onChange(of: opened, initial: true) { was, now inif now {// Its tool's acts beside its own, as they stand on this view's deck. editor?.presentOpened(target, record: record, worn: worn, view: view, core: core, close: close) } elseif was { dismiss() } }// Another card's opening (or a new record's) took the editor:// this one stands down. .onChange(of: editor?.openedTarget) { was, now inif opened, was == target, now != target { close() } } .onChange(of: record) { _, record inif opened { editor?.hold(record) } } .onDisappear { if opened { dismiss(); close() } } }/// The editor lets go of this card, unless another has it already.privatefunc dismiss() {guard editor?.openedTarget == nil || editor?.openedTarget == target else { return } editor?.dismissOpened() }}extensionView {/// The deck's card, opened in place while `opened` (`OpenedInPlace`).func opensInPlace(_ opened: Bool, definition: TableDefinition, record: TableRecord, worn: String, close: @escaping () -> Void) -> someView { modifier(OpenedInPlace(opened: opened, definition: definition, record: record, close: close, worn: worn)) }}privatestructOpenedCardGroundKey: EnvironmentKey {staticlet defaultValue: FaceGround? = nil}extensionEnvironmentValues {var openedCardGround: FaceGround? { get { self[OpenedCardGroundKey.self] } set { self[OpenedCardGroundKey.self] = newValue } }}/// The plus card uses the same face and part editors, above the same fan.structOpenedDraftCard: View {let draft: DeckDraftlet editor: DeckEditorvar body: someView {OpenedCardPage(ground: DeckGround.of(draft.card), close: { editor.close() }) {DeckFace.view(for: draft.card, record: draft.record) {} .deckEditable(definition: draft.definition, record: draft.record) .onTapGesture {// Its title untyped, a tap asks it again (`shell.input`'s new).guard draft.isNew, let target = editor.openedTarget,let column = editor.part("title", on: target.record)?.column, draft.record[column].text?.isEmpty != falseelse { return } editor.write(target, column: column, store: nil, core: nil) } } acts: { EmptyView() } }}