Cotton code
39 lines · 1.4 KB · SwiftRaw
import SwiftUI/// The record's one main act, sized by its words in the paper's own type.struct RecordInkPill: View {    @Environment(\.theme) private var theme    let label: String    let dye: PaperDye    let action: () -> Void    init(_ label: String, dye: PaperDye, action: @escaping () -> Void) {        self.label = label        self.dye = dye        self.action = action    }    var body: some View {        Button(action: action) {            Text(label)                .font(theme.type.body(theme.scale.bodySize + 2))                .foregroundStyle(dye.fill)                .fixedSize(horizontal: false, vertical: true)                .padding(.horizontal, RecordInkPillKnobs.faceInkPillHorizontalPadding)                .padding(.vertical, RecordInkPillKnobs.faceInkPillVerticalPadding)                .frame(minHeight: RecordInkPillKnobs.faceInkPillMinHeight)                .background(theme.print(.ink), in: Capsule())                .contentShape(Capsule())        }        .buttonStyle(MotionButtonStyle())    }}/// The sizes, counts and timings RecordInkPill draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enum RecordInkPillKnobs {    static let faceInkPillHorizontalPadding: CGFloat = 22    static let faceInkPillMinHeight: CGFloat = 48    static let faceInkPillVerticalPadding: CGFloat = 12}