@@ -79,16 +79,15 @@ open class UKButton: UIView, UKComponent {
7979 private func setup( ) {
8080 self . addSubview ( self . stackView)
8181
82+ self . stackView. addArrangedSubview ( self . loaderView)
83+ self . stackView. addArrangedSubview ( self . titleLabel)
8284 switch self . model. imageLocation {
8385 case . leading:
8486 self . stackView. insertArrangedSubview ( self . imageView, at: 0 )
8587 case . trailing:
8688 self . stackView. addArrangedSubview ( self . imageView)
8789 }
8890
89- self . stackView. addArrangedSubview ( self . loaderView)
90- self . stackView. addArrangedSubview ( self . titleLabel)
91-
9291 if #available( iOS 17 . 0 , * ) {
9392 self . registerForTraitChanges ( [ UITraitUserInterfaceStyle . self] ) { ( view: Self , _: UITraitCollection ) in
9493 view. handleTraitChanges ( )
@@ -101,14 +100,9 @@ open class UKButton: UIView, UKComponent {
101100 private func style( ) {
102101 Self . Style. mainView ( self , model: self . model)
103102 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)
108105 Self . Style. imageView ( self . imageView, model: self . model)
109-
110- self . loaderView. model = self . model. preferredLoadingVM
111- self . loaderView. isVisible = self . model. isLoading
112106 }
113107
114108 // MARK: Layout
@@ -135,9 +129,6 @@ open class UKButton: UIView, UKComponent {
135129
136130 self . style ( )
137131
138- self . loaderView. isVisible = self . model. isLoading
139- self . titleLabel. isHidden = self . model. title. isEmpty
140-
141132 if self . model. shouldUpdateImagePosition ( oldModel) {
142133 self . stackView. removeArrangedSubview ( self . imageView)
143134 switch self . model. imageLocation {
@@ -240,6 +231,7 @@ extension UKButton {
240231 label. text = model. title
241232 label. font = model. preferredFont. uiFont
242233 label. textColor = model. foregroundColor. uiColor
234+ label. isHidden = model. title. isEmpty
243235 }
244236 static func configureStackView(
245237 _ stackView: UIStackView ,
@@ -250,7 +242,10 @@ extension UKButton {
250242 stackView. alignment = . center
251243 stackView. spacing = model. contentSpacing
252244 }
253-
245+ static func loaderView( _ view: UKLoading , model: Model ) {
246+ view. model = model. preferredLoadingVM
247+ view. isVisible = model. isLoading
248+ }
254249 static func imageView( _ imageView: UIImageView , model: Model ) {
255250 imageView. image = model. image
256251 imageView. contentMode = . scaleAspectFit
0 commit comments