// A screen's menu, as the tray.//// The architect's ruling of 13 Oct 2026: the three-dots menu is removed from// every page. The stack of cards at the top corner (`TrayStackButton`) is the// one page menu, and what a screen offers besides its records — Select, a// related list, its settings, an export — is a card in the tray it raises,// coloured by what it does like every act. A screen keeps its menu as the// list of `PopoverMenuItem`s it always built; this turns them into cards and// runs the one that fires.importSwiftUI/// One line of a screen's menu, which the tray draws as an act card.publicstructPopoverMenuItem: Identifiable {publiclet id: String/// The object its card stands, by name (`shell.list`'s `menu`, or the/// screen that built the line); a link where it names none.publiclet object: String?/// What the line does, which its card is coloured by.publiclet does: CommandDoes?publiclet label: Stringpubliclet isDestructive: Boolpubliclet isDisabled: Boolpubliclet action: () -> Voidpublicinit( id: String, object: String? = nil, does: CommandDoes? = .moves, label: String, destructive: Bool = false, disabled: Bool = false, action: @escaping () -> Void ) {self.id = idself.object = objectself.does = doesself.label = labelself.isDestructive = destructiveself.isDisabled = disabledself.action = action }}extensionActCardReading {/// A menu line as an act card: the object and colour the line says, a/// bin held to fire where it takes something away.staticfunc item(_ item: PopoverMenuItem, prefix: String = MenuTray.prefix) -> ActCardReading {ActCardReading( id: prefix + item.id, verb: item.label.replacingOccurrences(of: "\u{2026}", with: ""), object: .enamel(item.isDestructive ? .bin : CardEnamel.named(item.object) ?? .link), gesture: item.isDestructive ? .holds : .fires, does: item.isDestructive ? .destroys : item.does) }}enumMenuTray {staticlet prefix = "menu-"/// The menu line a fired card stands for.staticfunc line(_ card: ActCardReading, in items: [PopoverMenuItem], prefix: String = prefix) -> PopoverMenuItem? { items.first { prefix + $0.id == card.id && !$0.isDisabled } }}extensionView {/// The screen's menu as the tray the stack button raises.func menuTray(state: Binding<TrayState>, items: [PopoverMenuItem], title: String? = nil) -> someView { tray(state: state) {Tray( state: state, acts: items.filter { !$0.isDisabled }.map { ActCardReading.item($0) }, title: title, onFire: { card inMenuTray.line(card, in: items)?.action() }) } }}extensionView {/// The screen's menu as the tray, held open by a flag: the stack button/// sets it, and the tray clears it as it drops.func menuTray(isOpen: Binding<Bool>, items: [PopoverMenuItem], title: String? = nil) -> someView { modifier(FlagMenuTray(isOpen: isOpen, items: items, title: title)) }}/// What a tray held open by a flag stands at. The flag says raised or not;/// a row that must be held raises its card alone (`.offering`), which a flag/// cannot say, so the offer is kept here.structTrayFlagState: Equatable {var offer: TrayOffer?func state(isOpen: Bool) -> TrayState { offer.map(TrayState.offering) ?? (isOpen ? .pulled : .rest) }mutatingfunc set(_ state: TrayState, isOpen: inoutBool) {ifcase .offering(let offered) = state { offer = offered } else { offer = nil } isOpen = state.isRaised }}privatestructFlagMenuTray: ViewModifier { @Binding var isOpen: Boollet items: [PopoverMenuItem]let title: String? @State privatevar flag = TrayFlagState()func body(content: Content) -> someView { content.menuTray( state: Binding(get: { flag.state(isOpen: isOpen) }, set: { flag.set($0, isOpen: &isOpen) }), items: items, title: title) }}