Skip to content

Commit

Permalink
Perform UI changes in the main queue
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisNikolic committed Nov 21, 2024
1 parent 021b8f6 commit 233a650
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 15 additions & 14 deletions Sources/PrimerSDK/Classes/Extensions & Utilities/PrimerButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,28 @@ extension PrimerButton {

func startAnimating() {
if activityIndicator.isAnimating { return }
activityIndicator.startAnimating()
var buttonStates: [ActivityIndicatorButtonState] = []
for state in [UIControl.State.disabled] {
let buttonState = ActivityIndicatorButtonState(state: state, title: title(for: state), image: image(for: state))
buttonStates.append(buttonState)
setTitle("", for: state)
setImage(UIImage(), for: state)
}
self.activityIndicatorButtonStates = buttonStates
DispatchQueue.main.async {

self.activityIndicator.startAnimating()
var buttonStates: [ActivityIndicatorButtonState] = []
for state in [UIControl.State.disabled] {
let buttonState = ActivityIndicatorButtonState(state: state, title: self.title(for: state), image: self.image(for: state))
buttonStates.append(buttonState)
self.setTitle("", for: state)
self.setImage(UIImage(), for: state)
}
self.activityIndicatorButtonStates = buttonStates
self.isEnabled = false
}
}

func stopAnimating() {
activityIndicator.stopAnimating()
for buttonState in activityIndicatorButtonStates {
setTitle(buttonState.title, for: buttonState.state)
setImage(buttonState.image, for: buttonState.state)
}
DispatchQueue.main.async {
self.activityIndicator.stopAnimating()
for buttonState in self.activityIndicatorButtonStates {
self.setTitle(buttonState.title, for: buttonState.state)
self.setImage(buttonState.image, for: buttonState.state)
}
self.isEnabled = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,6 @@ class CardFormPaymentMethodTokenizationViewModel: PaymentMethodTokenizationViewM
}
}


// TODO: (BNI) This one is not being used, but it could be used for new UI
func configurePayButton(cardNetwork: CardNetwork?) {
var amount: Int = AppState.current.amount ?? 0

Expand Down

0 comments on commit 233a650

Please sign in to comment.