Cotton code
60 lines · 2.2 KB · SwiftRaw
import SwiftUI/// Each source's glyph, 22 points, stroked like the mock's (24-unit viewBox,/// stroke 1.6, round caps and joins). WhatsApp, Mail and Photos are the mock's/// own paths; Calls and Texts are drawn in the same hand.struct SourceIcon: View {    let source: Source    var color: Color = Palette.ink    var body: some View {        shape            .stroke(color, style: StrokeStyle(lineWidth: 1.6 * 22 / 24, lineCap: .round, lineJoin: .round))            .frame(width: 22, height: 22)            .accessibilityHidden(true)    }    private var shape: SVGPath {        switch source {        case .whatsapp:            SVGPath("M4 20l1.3-3.9A8 8 0 1 1 8.4 18.9Z")        case .mail:            SVGPath(SVGPath.rect(3, 5, 18, 14, rx: 2), "M3 7l9 6 9-6")        case .photos:            SVGPath(SVGPath.rect(3, 4, 18, 16, rx: 2), SVGPath.circle(9, 10, r: 2), "M21 16l-5-5-9 9")        case .calls:            SVGPath(                "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92Z"            )        case .texts:            SVGPath("M21 12a8 8 0 0 1-8 8H5l-2 2V12a8 8 0 0 1 8-8h2a8 8 0 0 1 8 8Z", "M8 11h8", "M8 15h5")        }    }}/// The running card's round pause control, and the paused card's resume.struct RoundGlyph: View {    enum Kind { case pause, resume }    let kind: Kind    var body: some View {        ZStack {            Circle().fill(Palette.paper)            switch kind {            case .pause:                HStack(spacing: 2) {                    Rectangle().frame(width: 2, height: 8)                    Rectangle().frame(width: 2, height: 8)                }                .foregroundStyle(Palette.ink)            case .resume:                SVGPath("M7 4l12 8-12 8Z")                    .fill(Palette.ink)                    .frame(width: 12, height: 12)                    .offset(x: 1)            }        }        .frame(width: 28, height: 28)        .contentShape(Circle())    }}