// A list's row as a slip: the page's paper — the row's title over its line — // whose tap opens what it names, so it carries the chevron (recordslips rule // 4; R3: no colour fill, no inline Add, no "All N"). Every measure is the // theme's (`slip_*`). import SwiftUI /// A slip's strip: the page's paper and its top and bottom edge. struct SlipPaper: View { @Environment(\.theme) private var theme var body: some View { let scale = theme.scale let shape = RoundedRectangle(cornerRadius: scale[.slipRadius], style: .continuous) shape .fill(theme.sheet(.cream)) .overlay(alignment: .top) { Rectangle().fill(theme.colors.hairline.color).frame(height: scale[.slipEdge]) } .overlay(alignment: .bottom) { Rectangle().fill(theme.colors.hairline.color).frame(height: scale[.slipEdge]) } .clipShape(shape) } } /// The one mark a slip carries at rest: a small pencil chevron at its right /// edge, on a slip whose tap leaves the page (a link, "and N more"). struct SlipChevron: View { @Environment(\.theme) private var theme var body: some View { let tall = theme.scale[.slipChevron] Path { path in path.move(to: .zero) path.addLine(to: CGPoint(x: tall / 2, y: tall / 2)) path.addLine(to: CGPoint(x: 0, y: tall)) } .stroke(theme.colors.inkTertiary.color, style: StrokeStyle(lineWidth: theme.scale[.stroke], lineCap: .round, lineJoin: .round)) .frame(width: tall / 2, height: tall) .accessibilityHidden(true) } /// The room a slip's words keep beside the chevron. static func room(_ theme: Theme) -> CGFloat { theme.scale[.slipChevron] / 2 + theme.scale[.slipPad] } } /// One row of a list, or the list's "and N more": a slip of the page's paper /// whose tap opens what it names. struct ListSlip: View { @Environment(\.theme) private var theme let title: String var line: String? = nil var onTap: () -> Void var body: some View { let scale = theme.scale Button(action: onTap) { VStack(alignment: .leading, spacing: scale[.slipGap] / 2) { Text(title) .paperBody(nil) .fixedSize(horizontal: false, vertical: true) if let line, !line.isEmpty { Text(line).paperHand(scale[.typeCaptionSize]) .fixedSize(horizontal: false, vertical: true) } } .padding(scale[.slipPad]) .padding(.trailing, SlipChevron.room(theme)) .frame(maxWidth: .infinity, alignment: .topLeading) .background { SlipPaper() } .overlay(alignment: .trailing) { SlipChevron().padding(.trailing, scale[.slipPad]) } .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityElement(children: .combine) .accessibilityAddTraits(.isLink) } }