-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDesignSystem.swift
More file actions
376 lines (325 loc) · 12 KB
/
DesignSystem.swift
File metadata and controls
376 lines (325 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
import SwiftUI
// MARK: - Design System
struct DesignSystem {
// MARK: - Colors
struct Colors {
// Primary Colors
static let primary = Color("AppPrimaryColor")
static let secondary = Color("AppSecondaryColor")
// Background Colors
static let background = Color(.systemBackground)
static let secondaryBackground = Color(.secondarySystemBackground)
static let cardBackground = Color(.tertiarySystemBackground)
// Semantic Colors
static let wait = Color("WaitColor")
static let answered = Color("AnsweredColor")
static let notAnswered = Color("NotAnsweredColor")
// Category Colors
static let personal = Color("PersonalColor")
static let family = Color("FamilyColor")
static let health = Color("HealthColor")
static let work = Color("WorkColor")
static let relationship = Color("RelationshipColor")
static let thanksgiving = Color("ThanksgivingColor")
static let vision = Color("VisionColor")
static let other = Color("OtherColor")
// Text Colors
static let primaryText = Color(.label)
static let secondaryText = Color(.secondaryLabel)
static let tertiaryText = Color(.tertiaryLabel)
}
// MARK: - Typography
struct Typography {
static let largeTitle = Font.largeTitle.weight(.bold)
static let title1 = Font.title.weight(.bold)
static let title2 = Font.title2.weight(.semibold)
static let title3 = Font.title3.weight(.semibold)
static let headline = Font.headline.weight(.semibold)
static let body = Font.body.weight(.regular)
static let callout = Font.callout.weight(.medium)
static let subheadline = Font.subheadline.weight(.medium)
static let footnote = Font.footnote.weight(.regular)
static let caption = Font.caption.weight(.medium)
static let caption2 = Font.caption2.weight(.regular)
}
// MARK: - Spacing
struct Spacing {
static let xxs: CGFloat = 2
static let xs: CGFloat = 4
static let sm: CGFloat = 8
static let md: CGFloat = 12
static let lg: CGFloat = 16
static let xl: CGFloat = 20
static let xxl: CGFloat = 24
static let xxxl: CGFloat = 32
static let huge: CGFloat = 40
}
// MARK: - Corner Radius
struct CornerRadius {
static let small: CGFloat = 8
static let medium: CGFloat = 12
static let large: CGFloat = 16
static let extraLarge: CGFloat = 20
}
// MARK: - Shadows
struct Shadow {
static let small = (color: Color.black.opacity(0.05), radius: CGFloat(2), x: CGFloat(0), y: CGFloat(1))
static let medium = (color: Color.black.opacity(0.1), radius: CGFloat(8), x: CGFloat(0), y: CGFloat(2))
static let large = (color: Color.black.opacity(0.15), radius: CGFloat(16), x: CGFloat(0), y: CGFloat(4))
}
// MARK: - Animation
struct Animation {
static let quick = SwiftUI.Animation.easeInOut(duration: 0.2)
static let standard = SwiftUI.Animation.easeInOut(duration: 0.3)
static let slow = SwiftUI.Animation.easeInOut(duration: 0.5)
}
// MARK: - Adaptive Layout (iPad Support)
struct AdaptiveLayout {
static func spacing(_ base: CGFloat, for sizeClass: UserInterfaceSizeClass?) -> CGFloat {
sizeClass == .regular ? base * 1.25 : base
}
static let sidebarWidth: CGFloat = 320
static let contentColumnWidth: CGFloat = 400
static let maxFormWidth: CGFloat = 600
static let maxDetailWidth: CGFloat = 700
}
}
// MARK: - Adaptive Frame Modifier
extension View {
@ViewBuilder
func adaptiveFrame(sizeClass: UserInterfaceSizeClass?, maxWidth: CGFloat) -> some View {
if sizeClass == .regular {
self.frame(maxWidth: maxWidth)
} else {
self
}
}
@ViewBuilder
func adaptivePadding(sizeClass: UserInterfaceSizeClass?, base: CGFloat = DesignSystem.Spacing.lg) -> some View {
self.padding(.horizontal, DesignSystem.AdaptiveLayout.spacing(base, for: sizeClass))
}
}
// MARK: - Storage Utilities
extension PrayerStorage {
var color: Color {
switch self {
case .wait: return DesignSystem.Colors.wait
case .yes: return DesignSystem.Colors.answered
case .no: return DesignSystem.Colors.notAnswered
}
}
var description: String {
switch self {
case .wait: return "하나님의 응답을 기다리는 기도들"
case .yes: return "응답받은 감사한 기도들"
case .no: return "다른 계획이 있으셨던 기도들"
}
}
var icon: String {
switch self {
case .wait: return "clock.fill"
case .yes: return "checkmark.circle.fill"
case .no: return "xmark.circle.fill"
}
}
}
// MARK: - Category Utilities
extension PrayerCategory {
var color: Color {
switch self {
case .personal: return DesignSystem.Colors.personal
case .family: return DesignSystem.Colors.family
case .health: return DesignSystem.Colors.health
case .work: return DesignSystem.Colors.work
case .relationship: return DesignSystem.Colors.relationship
case .thanksgiving: return DesignSystem.Colors.thanksgiving
case .vision: return DesignSystem.Colors.vision
case .other: return DesignSystem.Colors.other
}
}
}
// MARK: - Date Formatters
extension DateFormatter {
static let compact: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yy.MM.dd"
return formatter
}()
static let full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yy.MM.dd HH:mm"
return formatter
}()
static let detailed: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
return formatter
}()
}
// MARK: - Core UI Components
// 모던한 카드 컴포넌트
struct ModernCard<Content: View>: View {
let content: Content
let backgroundColor: Color
let cornerRadius: CGFloat
let shadowStyle: (color: Color, radius: CGFloat, x: CGFloat, y: CGFloat)
init(
backgroundColor: Color = DesignSystem.Colors.cardBackground,
cornerRadius: CGFloat = DesignSystem.CornerRadius.large,
shadowStyle: (color: Color, radius: CGFloat, x: CGFloat, y: CGFloat) = DesignSystem.Shadow.medium,
@ViewBuilder content: () -> Content
) {
self.content = content()
self.backgroundColor = backgroundColor
self.cornerRadius = cornerRadius
self.shadowStyle = shadowStyle
}
var body: some View {
content
.background(backgroundColor)
.cornerRadius(cornerRadius)
.shadow(
color: shadowStyle.color,
radius: shadowStyle.radius,
x: shadowStyle.x,
y: shadowStyle.y
)
}
}
// 모던한 버튼 컴포넌트
struct ModernButton: View {
let title: String
let style: ButtonStyle
let size: ButtonSize
let action: () -> Void
enum ButtonStyle {
case primary, secondary, tertiary, success, destructive
var backgroundColor: Color {
switch self {
case .primary: return DesignSystem.Colors.primary
case .secondary: return DesignSystem.Colors.secondary
case .tertiary: return DesignSystem.Colors.cardBackground
case .success: return DesignSystem.Colors.answered
case .destructive: return DesignSystem.Colors.notAnswered
}
}
var textColor: Color {
switch self {
case .primary, .secondary, .success, .destructive: return .white
case .tertiary: return DesignSystem.Colors.primaryText
}
}
}
enum ButtonSize {
case small, medium, large
var padding: (vertical: CGFloat, horizontal: CGFloat) {
switch self {
case .small: return (DesignSystem.Spacing.sm, DesignSystem.Spacing.md)
case .medium: return (DesignSystem.Spacing.md, DesignSystem.Spacing.lg)
case .large: return (DesignSystem.Spacing.lg, DesignSystem.Spacing.xl)
}
}
var font: Font {
switch self {
case .small: return DesignSystem.Typography.caption
case .medium: return DesignSystem.Typography.callout
case .large: return DesignSystem.Typography.headline
}
}
}
var body: some View {
Button(action: action) {
Text(title)
.font(size.font)
.fontWeight(.semibold)
.foregroundColor(style.textColor)
.padding(.vertical, size.padding.vertical)
.padding(.horizontal, size.padding.horizontal)
.frame(maxWidth: .infinity)
.background(style.backgroundColor)
.cornerRadius(DesignSystem.CornerRadius.medium)
.shadow(
color: style.backgroundColor.opacity(0.3),
radius: DesignSystem.Shadow.medium.radius,
x: DesignSystem.Shadow.medium.x,
y: DesignSystem.Shadow.medium.y
)
}
.buttonStyle(PlainButtonStyle())
}
}
// 카테고리 태그 컴포넌트
struct CategoryTag: View {
let category: PrayerCategory
let size: TagSize
enum TagSize {
case small, medium
var padding: (vertical: CGFloat, horizontal: CGFloat) {
switch self {
case .small: return (DesignSystem.Spacing.xs, DesignSystem.Spacing.sm)
case .medium: return (DesignSystem.Spacing.sm, DesignSystem.Spacing.md)
}
}
var font: Font {
switch self {
case .small: return DesignSystem.Typography.caption2
case .medium: return DesignSystem.Typography.caption
}
}
}
var body: some View {
Text(category.displayName)
.font(size.font)
.fontWeight(.semibold)
.foregroundColor(.white)
.padding(.vertical, size.padding.vertical)
.padding(.horizontal, size.padding.horizontal)
.background(category.color)
.cornerRadius(DesignSystem.CornerRadius.small)
}
}
// 상태 인디케이터 컴포넌트
struct StatusIndicator: View {
let storage: PrayerStorage
let size: IndicatorSize
var style: IndicatorStyle = .colored
enum IndicatorSize {
case small, medium, large
var iconSize: CGFloat {
switch self {
case .small: return 24
case .medium: return 32
case .large: return 40
}
}
}
enum IndicatorStyle {
case colored // 색상 아이콘만 표시 (기도 목록용)
case circleWhite // 색상 원형 배경 + 흰색 아이콘 (보관소 카드용)
}
// filled 버전 아이콘 이름
private var filledIconName: String {
switch storage {
case .wait: return "clock.fill"
case .yes: return "checkmark.circle.fill"
case .no: return "xmark.circle.fill"
}
}
var body: some View {
switch style {
case .colored:
Image(systemName: filledIconName)
.font(.system(size: size.iconSize, weight: .medium))
.foregroundColor(storage.color)
.symbolRenderingMode(.hierarchical)
case .circleWhite:
Image(systemName: storage.icon)
.font(.system(size: size.iconSize * 0.5, weight: .semibold))
.foregroundColor(.white)
.frame(width: size.iconSize, height: size.iconSize)
.background(storage.color)
.clipShape(Circle())
}
}
}