@@ -79,16 +79,15 @@ open class UKButton: UIView, UKComponent {
79
79
private func setup( ) {
80
80
self . addSubview ( self . stackView)
81
81
82
+ self . stackView. addArrangedSubview ( self . loaderView)
83
+ self . stackView. addArrangedSubview ( self . titleLabel)
82
84
switch self . model. imageLocation {
83
85
case . leading:
84
86
self . stackView. insertArrangedSubview ( self . imageView, at: 0 )
85
87
case . trailing:
86
88
self . stackView. addArrangedSubview ( self . imageView)
87
89
}
88
90
89
- self . stackView. addArrangedSubview ( self . loaderView)
90
- self . stackView. addArrangedSubview ( self . titleLabel)
91
-
92
91
if #available( iOS 17 . 0 , * ) {
93
92
self . registerForTraitChanges ( [ UITraitUserInterfaceStyle . self] ) { ( view: Self , _: UITraitCollection ) in
94
93
view. handleTraitChanges ( )
@@ -101,14 +100,9 @@ open class UKButton: UIView, UKComponent {
101
100
private func style( ) {
102
101
Self . Style. mainView ( self , model: self . model)
103
102
Self . Style. titleLabel ( self . titleLabel, model: self . model)
104
- Self . Style. configureStackView (
105
- self . stackView,
106
- model: self . model
107
- )
103
+ Self . Style. configureStackView ( self . stackView, model: self . model)
104
+ Self . Style. loaderView ( self . loaderView, model: self . model)
108
105
Self . Style. imageView ( self . imageView, model: self . model)
109
-
110
- self . loaderView. model = self . model. preferredLoadingVM
111
- self . loaderView. isVisible = self . model. isLoading
112
106
}
113
107
114
108
// MARK: Layout
@@ -135,9 +129,6 @@ open class UKButton: UIView, UKComponent {
135
129
136
130
self . style ( )
137
131
138
- self . loaderView. isVisible = self . model. isLoading
139
- self . titleLabel. isHidden = self . model. title. isEmpty
140
-
141
132
if self . model. shouldUpdateImagePosition ( oldModel) {
142
133
self . stackView. removeArrangedSubview ( self . imageView)
143
134
switch self . model. imageLocation {
@@ -240,6 +231,7 @@ extension UKButton {
240
231
label. text = model. title
241
232
label. font = model. preferredFont. uiFont
242
233
label. textColor = model. foregroundColor. uiColor
234
+ label. isHidden = model. title. isEmpty
243
235
}
244
236
static func configureStackView(
245
237
_ stackView: UIStackView ,
@@ -250,7 +242,10 @@ extension UKButton {
250
242
stackView. alignment = . center
251
243
stackView. spacing = model. contentSpacing
252
244
}
253
-
245
+ static func loaderView( _ view: UKLoading , model: Model ) {
246
+ view. model = model. preferredLoadingVM
247
+ view. isVisible = model. isLoading
248
+ }
254
249
static func imageView( _ imageView: UIImageView , model: Model ) {
255
250
imageView. image = model. image
256
251
imageView. contentMode = . scaleAspectFit
0 commit comments