// What every tile face is drawn at and with: its size, its measurements, its// heading on the plaster and the slip it shows when it has nothing to draw.//// A tile is a table's face at a fixed size (`BoardTile`, `SlipTileFace`), drawn// on a board and on a database page's section. Every face is a fixed-size// drawing, like the paper voices: print on an object scales with the object,// never with Dynamic Type.importSwiftUI/// The three sizes a tile comes in, each a fixed canvas.publicenumTileSize: String, Sendable, CaseIterable {case small, medium, large/// The tile's canvas on a 393-point phone.publicvar canvas: CGSize {switchself {case .small: return CGSize(width: 158, height: 158)case .medium: return CGSize(width: 338, height: 158)case .large: return CGSize(width: 338, height: 354) } }}/// The tile faces' shared measurements.publicenumTileMetrics {/// The air every face keeps from its tile's edge: paper needs the room,/// and a sheet whose shadow is clipped by a margin reads as a sticker.publicstaticlet padding: CGFloat = 12/// The gap between objects on a face.publicstaticlet gap: CGFloat = 10/// A face's own heading on the plaster.publicstaticlet titleSize: CGFloat = 20/// A handwritten note on the plaster — a count, the weather, "tomorrow".publicstaticlet noteSize: CGFloat = 15/// The side of each of `columns` × `rows` objects of `aspect` (width ÷/// height) laid with `gap` into `space` — the largest that fits BOTH ways.publicstaticfunc side( fitting space: CGSize, columns: Int, rows: Int, aspect: CGFloat, gap: CGFloat = gap ) -> CGFloat {guard columns > 0, rows > 0, aspect > 0else { return0 }let across = (space.width - gap * CGFloat(columns - 1)) / CGFloat(columns)let down = (space.height - gap * CGFloat(rows - 1)) / CGFloat(rows) * aspectreturn max(0, min(across, down)) }}/// A face's heading, set on the plaster: the serif title and a handwritten note/// beside it. Ink on plaster is not multiplied — plaster is not paper.structTileHeading: View { @Environment(\.theme) privatevar themelet title: Stringvar note: String?var noteInk: PaperInk = .pencilvar trailing: String?var body: someView { HStack(alignment: .firstTextBaseline, spacing: 8) {Text(title) .font(theme.type.title(TileMetrics.titleSize)) .foregroundStyle(theme.print(.ink)) .lineLimit(1) .layoutPriority(1)iflet note {Text(note) .font(theme.type.hand(TileMetrics.noteSize)) .foregroundStyle(theme.print(noteInk)) .lineLimit(1) }Spacer(minLength: 4)iflet trailing {Text(trailing) .font(theme.type.hand(TileMetrics.noteSize)) .foregroundStyle(theme.print(.pencil)) .lineLimit(1) } } }}/// What a face shows when it has nothing to draw: one torn slip with the/// sentence typed on it — the empty object, at tile size.publicstructTileQuietSlip: View {privatelet line: Stringpublicinit(line: String) {self.line = line }publicvar body: someView {// The seed is the torn edge's: it keeps the spelling every quiet slip// has always been drawn with, so the edge does not move.Paper(dye: .cream, edge: .torn, seed: "widget-quiet-\(line)") {Text(line) .paperBody(12.5, ink: .pencil) .lineLimit(3) .multilineTextAlignment(.leading) .fixedSize(horizontal: false, vertical: true) .frame(maxWidth: .infinity, alignment: .leading) } }}