|
| 1 | +// |
| 2 | +// ScheduleCell.swift |
| 3 | +// DesignSystem |
| 4 | +// |
| 5 | +// Created by eunpyo on 4/22/25. |
| 6 | +// |
| 7 | + |
| 8 | +import SwiftUI |
| 9 | + |
| 10 | +public struct ScheduleCell: View { |
| 11 | + private let month: Int |
| 12 | + private let day: Int |
| 13 | + private let title: String |
| 14 | + private let description: String |
| 15 | + private let style: ScheduleCellStyle |
| 16 | + |
| 17 | + public init( |
| 18 | + month: Int, |
| 19 | + day: Int, |
| 20 | + title: String, |
| 21 | + description: String, |
| 22 | + style: ScheduleCellStyle |
| 23 | + ) { |
| 24 | + self.month = month |
| 25 | + self.day = day |
| 26 | + self.title = title |
| 27 | + self.description = description |
| 28 | + self.style = style |
| 29 | + } |
| 30 | + |
| 31 | + public var body: some View { |
| 32 | + HStack(alignment: .center, spacing: .zero) { |
| 33 | + VStack(alignment: .center, spacing: 4) { |
| 34 | + Text("\(month)월") |
| 35 | + .pretendardFont(family: .Medium, size: 14) |
| 36 | + .foregroundStyle(.staticBlack) |
| 37 | + |
| 38 | + Text("\(day)") |
| 39 | + .pretendardFont(family: .Medium, size: 20) |
| 40 | + .foregroundStyle(.staticBlack) |
| 41 | + } |
| 42 | + .frame(width: 54, height: 54) |
| 43 | + .background(.blue20) |
| 44 | + .opacity(style.monthDayOpacity) |
| 45 | + .clipShape(.rect(cornerRadius: 12)) |
| 46 | + |
| 47 | + VStack(alignment: .leading, spacing: .zero) { |
| 48 | + Text(title) |
| 49 | + .pretendardFont(family: .Bold, size: 18) |
| 50 | + .foregroundStyle(.backgroundInverse) |
| 51 | + |
| 52 | + Text(description) |
| 53 | + .pretendardFont(family: .Regular, size: 14) |
| 54 | + .foregroundStyle(.textSecondary) |
| 55 | + } |
| 56 | + .padding(.leading, 12) |
| 57 | + .opacity(style.titleDescriptionOpacity) |
| 58 | + |
| 59 | + Spacer() |
| 60 | + } |
| 61 | + .overlay { |
| 62 | + if let stampImage = style.stampImage { |
| 63 | + GeometryReader { proxy in |
| 64 | + let xPosition = proxy.size.width * 0.82205128 |
| 65 | + let yPosition = proxy.size.height * 0.92953488 |
| 66 | + |
| 67 | + stampImage |
| 68 | + .resizable() |
| 69 | + .scaledToFit() |
| 70 | + .rotationEffect(.degrees(-15)) |
| 71 | + .position(x: xPosition, y: yPosition) |
| 72 | + .frame(width: 120, height: 120) |
| 73 | + .opacity(0.8) |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + .padding(16) |
| 78 | + .background(style.backgroundColor) |
| 79 | + .clipShape(.rect(cornerRadius: 16)) |
| 80 | + .overlay { |
| 81 | + if style.dashBorder { |
| 82 | + RoundedRectangle(cornerRadius: 16) |
| 83 | + .stroke(.gray60, style: StrokeStyle(lineWidth: 1, dash: [4, 4])) |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments