-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPokitCaution.swift
More file actions
138 lines (121 loc) ยท 3.87 KB
/
PokitCaution.swift
File metadata and controls
138 lines (121 loc) ยท 3.87 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
//
// PokitCaution.swift
// DSKit
//
// Created by ๊น๋ํ on 8/10/24.
//
import SwiftUI
public enum CautionType {
case ์นดํ
๊ณ ๋ฆฌ์์
case ๋ฏธ๋ถ๋ฅ_๋งํฌ์์
case ํฌํท์์ธ_๋งํฌ์์
case ๋งํฌ์์
case ์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์์
case ๋งํฌ๋ถ์กฑ
case ์๋ฆผ์์
case ์ถ์ฒ_๋งํฌ์์
var image: PokitImage.Character {
switch self {
case .๋งํฌ๋ถ์กฑ:
return .sad
case .์๋ฆผ์์:
return .pooki
default: return .empty
}
}
var title: String {
switch self {
case .์นดํ
๊ณ ๋ฆฌ์์:
return "์ ์ฅ๋ ํฌํท์ด ์์ด์!"
case .๋ฏธ๋ถ๋ฅ_๋งํฌ์์:
return "๋ฏธ๋ถ๋ฅ ๋งํฌ๊ฐ ์์ด์!"
case .๋งํฌ์์, .ํฌํท์์ธ_๋งํฌ์์:
return "์ ์ฅ๋ ๋งํฌ๊ฐ ์์ด์!"
case .์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์์:
return "์ฆ๊ฒจ์ฐพ๊ธฐ ๋งํฌ๊ฐ ์์ด์!"
case .๋งํฌ๋ถ์กฑ:
return "๋งํฌ๊ฐ ๋ถ์กฑํด์!"
case .์๋ฆผ์์:
return "์๋ฆผ์ด ์์ด์"
case .์ถ์ฒ_๋งํฌ์์:
return "์์ง ์ถ์ฒ๋ ๋งํฌ๊ฐ ์์ด์!"
}
}
var message: String {
switch self {
case .์นดํ
๊ณ ๋ฆฌ์์:
return "ํฌํท์ ์์ฑํด ๋งํฌ๋ฅผ ์ ์ฅํด๋ณด์ธ์"
case .๋ฏธ๋ถ๋ฅ_๋งํฌ์์:
return "๋งํฌ๋ฅผ ํฌํท์ ๊น๋ํ๊ฒ ๋ถ๋ฅํ์
จ์ด์"
case .ํฌํท์์ธ_๋งํฌ์์:
return "ํฌํท์ ๋งํฌ๋ฅผ ์ ์ฅํด๋ณด์ธ์"
case .๋งํฌ์์:
return "๋ค์ํ ๋งํฌ๋ฅผ ํ ๊ณณ์ ์ ์ฅํด๋ณด์ธ์"
case .์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์์:
return "๋งํฌ๋ฅผ ์ฆ๊ฒจ์ฐพ๊ธฐ๋ก ๊ด๋ฆฌํด๋ณด์ธ์"
case .๋งํฌ๋ถ์กฑ:
return "๋งํฌ๋ฅผ 5๊ฐ ์ด์ ์ ์ฅํ๊ณ ์ถ์ฒ์ ๋ฐ์๋ณด์ธ์"
case .์๋ฆผ์์:
return "๋ฆฌ๋ง์ธ๋ ์๋ฆผ์ ์ค์ ํ์ธ์"
case .์ถ์ฒ_๋งํฌ์์:
return ""
}
}
var actionTitle: String? {
switch self {
case .์นดํ
๊ณ ๋ฆฌ์์:
return "ํฌํท ์ถ๊ฐํ๊ธฐ"
case .๋ฏธ๋ถ๋ฅ_๋งํฌ์์, .ํฌํท์์ธ_๋งํฌ์์:
return "๋งํฌ ์ถ๊ฐํ๊ธฐ"
default: return nil
}
}
}
public struct PokitCaution: View {
private let type: CautionType
private let action: (() -> Void)?
public init(
type: CautionType,
action: (() -> Void)? = nil
) {
self.type = type
self.action = action
}
public var body: some View {
HStack {
Spacer()
VStack(spacing: 0) {
Image(.character(type.image))
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 180, height: 180)
.padding(.bottom, 16)
Text(type.title)
.pokitFont(.title2)
.foregroundStyle(.pokit(.text(.secondary)))
.padding(.bottom, 8)
Text(type.message)
.pokitFont(.b2(.m))
.foregroundStyle(.pokit(.text(.secondary)))
.padding(.bottom, 16)
if let action,
let actionTitle = type.actionTitle {
PokitTextButton(
actionTitle,
state: .stroke(.secondary),
size: .medium,
shape: .rectangle,
action: action
)
}
}
Spacer()
}
}
}
#Preview {
PokitCaution(
type: .๋ฏธ๋ถ๋ฅ_๋งํฌ์์,
action: {}
)
}