@@ -9,54 +9,43 @@ import SnapKit
99import UIKit
1010
1111final class BitnagilAlert : UIViewController {
12- enum AlertType {
13- case withImage
14- case plainText
15- }
16-
1712 private enum Layout {
18- static let contentViewHorizontalSpacing : CGFloat = 39
19- static let contentViewHorizontalHeight : CGFloat = 154
20- static let imageSize : CGFloat = 55
21- static let imageTopSpacing : CGFloat = 24
22- static let titleTopSpacing : CGFloat = 18
23- static let titleHeight : CGFloat = 30
24- static let contentTopSpacing : CGFloat = 2
25- static let contentHeight : CGFloat = 18
13+ static let horizontalMargin : CGFloat = 24
14+ static let contentViewHorizontalSpacing : CGFloat = 44
15+ static let contentViewHorizontalHeight : CGFloat = 180
16+ static let titleTopSpacing : CGFloat = 20
17+ static let titleHeight : CGFloat = 28
18+ static let contentTopSpacing : CGFloat = 6
19+ static let contentHeight : CGFloat = 40
2620 static let buttonTopSpacing : CGFloat = 18
27- static let buttonHorizontalSpacing : CGFloat = 20
28- static let buttonHeight : CGFloat = 44
29- static let confirmButtonLeadingSpacing : CGFloat = 8
30- static let buttonBottomSpacing : CGFloat = 24
21+ static let buttonHeight : CGFloat = 48
22+ static let confirmButtonLeadingSpacing : CGFloat = 12
23+ static let buttonBottomSpacing : CGFloat = 20
3124 }
3225
3326 private let dimmedView = UIView ( )
3427 private let contentView = UIView ( )
35- private let alertImageView = UIImageView ( )
3628 private let titleLabel = UILabel ( )
3729 private let contentLabel = UILabel ( )
3830 private let cancelButton = UIButton ( )
3931 private let confirmButton = UIButton ( )
40- private let alertType : AlertType
4132 private var cancelHandler : ( ( ) -> Void ) ?
4233 private var confirmHandler : ( ( ) -> Void ) ?
4334
4435 init (
45- alertType: AlertType ,
4636 title: String ,
4737 content: String ,
4838 cancelButtonTitle: String ,
4939 confirmButtonTitle: String ,
5040 cancelHandler: ( ( ) -> Void ) ? ,
5141 confirmHandler: ( ( ) -> Void ) ?
5242 ) {
53- self . alertType = alertType
5443 super. init ( nibName: nil , bundle: nil )
5544
5645 self . cancelHandler = cancelHandler
5746 self . confirmHandler = confirmHandler
5847 titleLabel. text = title
59- contentLabel. text = content
48+ contentLabel. attributedText = BitnagilFont ( style : . body2 , weight : . medium ) . attributedString ( text : content)
6049 cancelButton. setTitle ( cancelButtonTitle, for: . normal)
6150 confirmButton. setTitle ( confirmButtonTitle, for: . normal)
6251
@@ -77,21 +66,22 @@ final class BitnagilAlert: UIViewController {
7766 dimmedView. alpha = 0.7
7867
7968 contentView. backgroundColor = . white
80- contentView. layer. cornerRadius = 20
69+ contentView. layer. cornerRadius = 12
8170 contentView. layer. masksToBounds = true
8271
83- alertImageView. image = BitnagilIcon . exclamationFilledIcon
84- titleLabel. font = BitnagilFont ( style: . title2, weight: . bold) . font
85- contentLabel. font = BitnagilFont ( style: . caption1, weight: . regular) . font
72+ titleLabel. font = BitnagilFont ( style: . subtitle1, weight: . semiBold) . font
73+ titleLabel. textColor = BitnagilColor . gray10
74+
75+ contentLabel. textColor = BitnagilColor . gray40
76+ contentLabel. numberOfLines = 2
8677
87- cancelButton. backgroundColor = . white
88- cancelButton. setTitleColor ( BitnagilColor . navy500 , for: . normal)
89- confirmButton. backgroundColor = BitnagilColor . navy500
78+ cancelButton. backgroundColor = BitnagilColor . gray97
79+ cancelButton. setTitleColor ( BitnagilColor . gray40 , for: . normal)
80+ confirmButton. backgroundColor = BitnagilColor . gray10
9081 confirmButton. setTitleColor ( . white, for: . normal)
9182 [ cancelButton, confirmButton] . forEach {
92- $0. titleLabel? . font = BitnagilFont ( style: . subtitle1, weight: . bold) . font
93- $0. layer. borderWidth = 1
94- $0. layer. cornerRadius = 8
83+ $0. titleLabel? . font = BitnagilFont ( style: . body2, weight: . medium) . font
84+ $0. layer. cornerRadius = 12
9585 $0. layer. masksToBounds = true
9686 }
9787
@@ -129,44 +119,29 @@ final class BitnagilAlert: UIViewController {
129119 make. height. equalTo ( Layout . contentViewHorizontalHeight) . priority ( . medium)
130120 }
131121
132- if alertType == . withImage {
133- contentView. addSubview ( alertImageView)
134- alertImageView. snp. makeConstraints { make in
135- make. top. equalToSuperview ( ) . offset ( Layout . imageTopSpacing)
136- make. centerX. equalToSuperview ( )
137- make. size. equalTo ( Layout . imageSize)
138- }
139-
140- titleLabel. snp. makeConstraints { make in
141- make. top. equalTo ( alertImageView. snp. bottom) . offset ( Layout . titleTopSpacing)
142- make. centerX. equalToSuperview ( )
143- make. height. equalTo ( Layout . titleHeight)
144- }
145- } else {
146- titleLabel. snp. makeConstraints { make in
147- make. top. equalToSuperview ( ) . offset ( Layout . titleTopSpacing)
148- make. centerX. equalToSuperview ( )
149- make. height. equalTo ( Layout . titleHeight)
150- }
122+ titleLabel. snp. makeConstraints { make in
123+ make. top. equalToSuperview ( ) . offset ( Layout . titleTopSpacing)
124+ make. horizontalEdges. equalToSuperview ( ) . inset ( Layout . horizontalMargin)
125+ make. height. equalTo ( Layout . titleHeight)
151126 }
152127
153128 contentLabel. snp. makeConstraints { make in
154129 make. top. equalTo ( titleLabel. snp. bottom) . offset ( Layout . contentTopSpacing)
155- make. centerX . equalToSuperview ( )
130+ make. horizontalEdges . equalToSuperview ( ) . inset ( Layout . horizontalMargin )
156131 make. height. equalTo ( Layout . contentHeight)
157132 }
158133
159134 cancelButton. snp. makeConstraints { make in
160135 make. top. equalTo ( contentLabel. snp. bottom) . offset ( Layout . buttonTopSpacing)
161- make. leading. equalToSuperview ( ) . offset ( Layout . buttonHorizontalSpacing )
136+ make. leading. equalToSuperview ( ) . offset ( Layout . horizontalMargin )
162137 make. height. equalTo ( Layout . buttonHeight)
163138 make. bottom. equalToSuperview ( ) . inset ( Layout . buttonBottomSpacing)
164139 }
165140
166141 confirmButton. snp. makeConstraints { make in
167142 make. top. equalTo ( contentLabel. snp. bottom) . offset ( Layout . buttonTopSpacing)
168143 make. leading. equalTo ( cancelButton. snp. trailing) . offset ( Layout . confirmButtonLeadingSpacing)
169- make. trailing. equalToSuperview ( ) . inset ( Layout . buttonHorizontalSpacing )
144+ make. trailing. equalToSuperview ( ) . inset ( Layout . horizontalMargin )
170145 make. height. equalTo ( Layout . buttonHeight)
171146 make. width. equalTo ( cancelButton)
172147 make. bottom. equalToSuperview ( ) . inset ( Layout . buttonBottomSpacing)
0 commit comments