// The TOOLS deck (row B of the deck faces): the Tools card on the dial opens// a deck with one card per installed tool, never a grid or a list, each// drawn by CottonFaces' `ToolFace` with its tool's object (`ToolObject`) and// what its home table holds, read here. A tap opens the tool; a hold lifts// the card with its acts.importCottonPaperimportCottonValuesimportSwiftUI/// Every installed tool as a deck of `ToolFace` cards, in the person's order.structToolsDeck: View {let tiles: [GridTile]letopen: (GridTile) -> Void @Environment(\.records) privatevar store @Environment(\.tableDefinitions) privatevar definitions/// Each tool's home-table figures, by tool key, as they are read. @State privatevar figures: [String: String] = [:]var body: someView {CardDeck( items: tiles,open: open, acts: { tile in [LiftedAct(id: "open", word: ShellLines.line("faces", "link.open", ["name": tile.name]), object: nil, destroys: false) { open(tile) }] }, words: { tile in [tile.name, purpose(of: tile)].compactMap { $0 }.joined(separator: " ") } ) { tile inToolFace(name: tile.name, purpose: purpose(of: tile), figure: figures[tile.key]) { side inToolObject(name: tile.name, picture: tile.picture, printing: .contentOnly, side: side) } } .task(id: tiles.map(\.key)) { await readFigures() } }privatefunc purpose(of tile: GridTile) -> String? {guardcase .dataTool(let tool) = tile.opens else { returnnil }return tool.purpose?.trimmingCharacters(in: .whitespacesAndNewlines).nilIfEmpty }/// Each tool's home table summed up in the core's words, one at a time.privatefunc readFigures() async {guardlet store else { return }for tile in tiles {guard figures[tile.key] == nil, case .dataTool(let tool) = tile.opens,let home = BoardLayout.home(for: tool, in: definitions),let read = try? await store.summarize(table: home.id),let line = SummaryFigure.line(read, in: home) else { continue } figures[tile.key] = line } }}privateextensionString {var nilIfEmpty: String? { isEmpty ? nil : self }}