@@ -37,14 +37,7 @@ public struct PokitLinkPopup: View {
3737 ZStack {
3838 background
3939
40- Group {
41- switch self . type {
42- case let . link( url) :
43- linkPopup ( url)
44- case . text:
45- textPopup
46- }
47- }
40+ popup
4841 . padding ( . vertical, 12 )
4942 . padding ( . horizontal, 20 )
5043 }
@@ -59,44 +52,38 @@ public struct PokitLinkPopup: View {
5952 }
6053 }
6154
62- @ViewBuilder
63- private func linkPopup( _ url: String ) -> some View {
64- HStack {
55+ private var popup : some View {
56+ HStack ( spacing: 0 ) {
6557 Button {
6658 action ? ( )
6759 } label: {
6860 VStack ( alignment: . leading, spacing: 0 ) {
6961 Text ( titleKey)
70- . lineLimit ( 1 )
62+ . lineLimit ( 2 )
7163 . pokitFont ( . b2( . b) )
7264 . multilineTextAlignment ( . leading)
73- . foregroundStyle ( . pokit( . text( . inverseWh) ) )
65+ . foregroundStyle (
66+ type == . warning
67+ ? . pokit( . text( . primary) )
68+ : . pokit( . text( . inverseWh) )
69+ )
7470
75- Text ( url)
76- . lineLimit ( 1 )
77- . pokitFont ( . detail2)
78- . foregroundStyle ( . pokit( . text( . inverseWh) ) )
71+ if case . link( let url) = type {
72+ Text ( url)
73+ . lineLimit ( 1 )
74+ . pokitFont ( . detail2)
75+ . foregroundStyle ( . pokit( . text( . inverseWh) ) )
76+ }
7977 }
8078
81- Spacer ( minLength: 72 )
82- }
83-
84- closeButton
85- }
86- }
87-
88- private var textPopup : some View {
89- HStack {
90- Button {
91- action ? ( )
92- } label: {
93- Text ( titleKey)
94- . lineLimit ( 2 )
95- . pokitFont ( . b3( . b) )
96- . multilineTextAlignment ( . leading)
97- . foregroundStyle ( . pokit( . text( . inverseWh) ) )
79+ if case . success = type {
80+ Image ( . icon( . check) )
81+ . resizable ( )
82+ . frame ( width: 24 , height: 24 )
83+ . foregroundStyle ( . pokit( . icon( . inverseWh) ) )
84+ }
9885
99- Spacer ( minLength: 54 )
86+ Spacer ( minLength: 72 )
10087 }
10188
10289 closeButton
@@ -105,15 +92,19 @@ public struct PokitLinkPopup: View {
10592
10693 private var background : some View {
10794 RoundedRectangle ( cornerRadius: 9999 , style: . continuous)
108- . fill ( . pokit ( . bg ( . tertiary ) ) )
95+ . fill ( backgroundColor )
10996 }
11097
11198 private var closeButton : some View {
11299 Button ( action: closedPopup) {
113100 Image ( . icon( . x) )
114101 . resizable ( )
115102 . frame ( width: 24 , height: 24 )
116- . foregroundStyle ( . pokit( . icon( . inverseWh) ) )
103+ . foregroundStyle (
104+ type == . warning
105+ ? . pokit( . icon( . primary) )
106+ : . pokit( . icon( . inverseWh) )
107+ )
117108 }
118109 }
119110
@@ -123,12 +114,28 @@ public struct PokitLinkPopup: View {
123114 isPresented = false
124115 }
125116 }
117+
118+ private var backgroundColor : Color {
119+ switch type {
120+ case . link, . text:
121+ return . pokit( . bg( . tertiary) )
122+ case . success:
123+ return . pokit( . bg( . success) )
124+ case . error:
125+ return . pokit( . bg( . error) )
126+ case . warning:
127+ return . pokit( . bg( . warning) )
128+ }
129+ }
126130}
127131
128132public extension PokitLinkPopup {
129- enum PopupType {
133+ enum PopupType : Equatable {
130134 case link( url: String )
131135 case text
136+ case success
137+ case error
138+ case warning
132139 }
133140}
134141
@@ -145,5 +152,23 @@ public extension PokitLinkPopup {
145152 isPresented: . constant( true ) ,
146153 type: . text
147154 )
155+
156+ PokitLinkPopup (
157+ " 링크저장 완료 " ,
158+ isPresented: . constant( true ) ,
159+ type: . success
160+ )
161+
162+ PokitLinkPopup (
163+ " 링크저장 실패 " ,
164+ isPresented: . constant( true ) ,
165+ type: . error
166+ )
167+
168+ PokitLinkPopup (
169+ " 저장공간 부족 " ,
170+ isPresented: . constant( true ) ,
171+ type: . warning
172+ )
148173 }
149174}
0 commit comments