// The slip-list tile: a table's records at tile size as a column of the// table's own slips (`SlipFace`) — the same slip its list draws, one face on// every list (recordface row 1, 21 Oct 2026).//// HOW MANY FIT is the layout's (`SlipTileColumn`): the slips are taken in// order while each stands whole, and what does not fit is counted as "+N// more" beside the table's name — counted from what was placed, never// guessed from a typeface.//// Which records: the list's own order and sections (Today first for Todos),// leaving out what the list reads as finished — a struck slip (a done todo)// is not work for the home screen.importCottonKitimportCottonValuesimportSwiftUI/// Which records a slip-list tile shows, and how many it asks for. Pure.publicenumSlipTileLayout {/// The most slips a size asks its read for: more than a tile holds, so/// the column fills and the rest are counted.publicstaticfunc capacity(_ size: TileSize) -> Int { size == .large ? SlipTileKnobs.largeCapacity : SlipTileKnobs.capacity }}/// A slip-list table at tile size: its name with "+N more" when some do/// not fit, and its slips.structSlipListFace: View { @Environment(\.theme) privatevar themelet definition: TableDefinitionlet records: [TableRecord]let now: Date/// The tile says its table's name and what it left out; a section's/// heading says both, so its slips stand alone, as tall as they are.var named = true/// Where a tapped slip opens; nil draws the slips inert.var onOpenRecord: ((TableRecord) -> Void)? = nilvar body: someView {let shown = recordsif shown.isEmpty { VStack(alignment: .leading, spacing: SlipTileKnobs.nameGap) {if named { TileHeading(title: definition.plural) }TileQuietSlip(line: definition.empty?.title ?? ShellLines.line("faces", "tile.empty"))if named { Spacer(minLength: 0) } } } elseif named {// One heading per count the column may land on; it shows the one// that says what it left out.SlipTileColumn(rows: shown.count, gap: SlipTileKnobs.rowGap, headingGap: SlipTileKnobs.nameGap) {ForEach(0...shown.count, id: \.self) { placed inTileHeading(title: definition.plural, note: placed < shown.count ? "+\(shown.count - placed) more" : nil) }ForEach(shown) { slip($0) } } } else { VStack(alignment: .leading, spacing: SlipTileKnobs.rowGap) {ForEach(shown) { slip($0) } } } } @ViewBuilder privatefunc slip(_ record: TableRecord) -> someView {iflet onOpenRecord {Button { onOpenRecord(record) } label: { SlipFace(definition: definition, record: record, compact: true) } .buttonStyle(MotionButtonStyle()) .accessibilityIdentifier("tile-\(definition.id)-\(record.id)") } else {SlipFace(definition: definition, record: record, compact: true) .accessibilityIdentifier("tile-\(definition.id)-\(record.id)") } }}/// The tile's column: `rows + 1` headings (the one for each count that may/// fit) then the rows. It places the rows that stand whole under the/// heading, then the heading for that count; the rest stand outside the/// tile, which clips them.structSlipTileColumn: Layout {let rows: Intlet gap: CGFloatlet headingGap: CGFloatfunc sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { proposal.replacingUnspecifiedDimensions() }/// How many rows stand whole in `height` under a heading `heading` tall.staticfunc fitting(_ heights: [CGFloat], height: CGFloat, heading: CGFloat, gap: CGFloat, headingGap: CGFloat) -> Int {var used = heading + headingGapvar placed = 0for row in heights {let next = used + (placed == 0 ? 0 : gap) + rowif next > height { break } used = next placed += 1 }return placed }func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {let headings = Array(subviews.prefix(rows + 1))let slips = Array(subviews.dropFirst(rows + 1))let width = ProposedViewSize(width: bounds.width, height: nil)let heights = slips.map { $0.sizeThatFits(width).height }let heading = headings.first?.sizeThatFits(width).height ?? 0let placed = Self.fitting(heights, height: bounds.height, heading: heading, gap: gap, headingGap: headingGap)let away = CGPoint(x: bounds.minX, y: bounds.maxY + bounds.height)for (count, view) in headings.enumerated() { view.place(at: count == placed ? bounds.origin : away, proposal: width) }var y = bounds.minY + heading + headingGapfor (index, view) in slips.enumerated() {if index < placed { view.place(at: CGPoint(x: bounds.minX, y: y), proposal: width) y += heights[index] + gap } else { view.place(at: away, proposal: width) } } }}/// The sizes and counts the slip-list tile draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumSlipTileKnobs {staticlet capacity = 6staticlet largeCapacity = 12staticlet nameGap: CGFloat = 8staticlet rowGap: CGFloat = 6}