Skip to content

Commit

Permalink
Avoid unnecessary layout work
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Jan 16, 2025
1 parent 70fbfaf commit 8ae81af
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ final class FormHeaderView: UIView {
}

func setIncentive(_ incentive: PaymentMethodIncentive?) {
guard incentive != self.incentive else {
return
}

if let promoBadgeView {
stackView.removeArrangedSubview(promoBadgeView)
promoBadgeView.removeFromSuperview()
Expand All @@ -101,6 +105,8 @@ final class FormHeaderView: UIView {
spacerView.removeFromSuperview()
}

self.incentive = incentive

if let incentive {
promoBadgeView = Self.makePromoBadge(for: incentive, with: appearance)
if let promoBadgeView {
Expand Down

0 comments on commit 8ae81af

Please sign in to comment.