@@ -9,6 +9,27 @@ import SnapKit
99import Then
1010import UIKit
1111
12+ public struct PopUpModel {
13+ let title : String
14+ let description : String ?
15+ let actionButtonTitle : String
16+ let outButtonTitle : String
17+
18+ public init ( title: String , description: String ? , actionButtonTitle: String , outButtonTitle: String ) {
19+ self . title = title
20+ self . description = description
21+ self . actionButtonTitle = actionButtonTitle
22+ self . outButtonTitle = outButtonTitle
23+ }
24+
25+ public init ( title: String , actionButtonTitle: String , outButtonTitle: String ) {
26+ self . title = title
27+ self . description = nil
28+ self . actionButtonTitle = actionButtonTitle
29+ self . outButtonTitle = outButtonTitle
30+ }
31+ }
32+
1233public final class PopUp : UIView {
1334
1435 public enum Style : CaseIterable {
@@ -29,7 +50,7 @@ public final class PopUp: UIView {
2950 $0. alignment = . center
3051 }
3152
32- private( set) lazy var deleteButton = UIButton ( ) . then {
53+ public private( set) lazy var deleteButton = UIButton ( ) . then {
3354 $0. setImage ( STImages . xMark. image, for: . normal)
3455 }
3556
@@ -111,17 +132,14 @@ public final class PopUp: UIView {
111132 }
112133 }
113134
114- public func update(
115- titile: String , description: String ? = nil , actionButtonTitle: String ,
116- outButtonTitle: String = " 취소 "
117- ) {
118- titleLabel. styledText = titile
119- descriptionLabel. styledText = description
135+ public func update( popUpModel: PopUpModel ) {
136+ titleLabel. styledText = popUpModel. title
137+ descriptionLabel. styledText = popUpModel. description
120138 let style = Typography . Body_16_B
121139 style. color = STColors . white. color
122- actionButton. setAttributedTitle ( actionButtonTitle. set ( style: style) , for: . normal)
140+ actionButton. setAttributedTitle ( popUpModel . actionButtonTitle. set ( style: style) , for: . normal)
123141 style. color = STColors . gray1. color
124- outButton. setAttributedTitle ( outButtonTitle. set ( style: style) , for: . normal)
142+ outButton. setAttributedTitle ( popUpModel . outButtonTitle. set ( style: style) , for: . normal)
125143 }
126144
127145 public func update( style: Style ) {
@@ -139,13 +157,12 @@ public final class PopUp: UIView {
139157 }
140158
141159 let popup = PopUp ( ) . then {
142- $0. update ( titile : " 제목 " , description: " 설명 텍스트입니다. " , actionButtonTitle: " 확인 " )
160+ $0. update ( popUpModel : PopUpModel ( title : " 제목 " , description: " 설명 텍스트입니다. " , actionButtonTitle: " 확인 " , outButtonTitle : " 취소 " ) )
143161 $0. update ( style: . one)
144162 }
145163
146164 let popupTwo = PopUp ( ) . then {
147- $0. update (
148- titile: " 제목 " , description: " 설명 \n 텍스트입니다. " , actionButtonTitle: " 확인 " , outButtonTitle: " 취소 " )
165+ $0. update ( popUpModel : PopUpModel ( title: " 제목 " , description: " 설명 텍스트입니다. " , actionButtonTitle: " 확인 " , outButtonTitle: " 취소 " ) )
149166 $0. update ( style: . two)
150167 }
151168
0 commit comments