Skip to content

Commit cc059f1

Browse files
author
“Akshay
committed
Remove button stacking constriant
This change will remove the smart constraint added at one point to change the stackview alignment from horizontal to vertical if the size of two button exceed the width. This is not required in GA. Rather we are just keeping two buttons in one line and truncate the text if the text size exceeds the button width
1 parent 6794d55 commit cc059f1

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

swift-sdk/uicomponents/IterableEmbeddedView.swift

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -390,41 +390,8 @@ public class IterableEmbeddedView:UIView {
390390
return size.width
391391
}
392392

393-
public func updateButtonConstraints() {
394-
let bothButtonsVisible = !primaryBtn.isHidden && !secondaryBtn.isHidden
395-
396-
if !bothButtonsVisible {
397-
buttonStackView.axis = .horizontal
398-
horizontalButtonStackViewSpacer.isHidden = false
399-
return
400-
}
401-
402-
let doesTextWrapInPrimary = doesTextWrapInButton(primaryBtn)
403-
let doesTextWrapInSecondary = doesTextWrapInButton(secondaryBtn)
404-
405-
let shouldStackVertically = doesTextWrapInPrimary || doesTextWrapInSecondary
406-
407-
buttonStackView.axis = shouldStackVertically ? .vertical : .horizontal
408-
horizontalButtonStackViewSpacer.isHidden = shouldStackVertically
409-
}
410-
411-
private func doesTextWrapInButton(_ button: UIButton) -> Bool {
412-
guard let text = button.titleLabel?.text, let font = button.titleLabel?.font else {
413-
return false
414-
}
415-
416-
let maxSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: button.bounds.height)
417-
let textRect = text.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, attributes: [.font: font], context: nil)
418-
419-
return textRect.width > button.bounds.width
420-
}
421-
422-
423393
public override func layoutSubviews() {
424394
super.layoutSubviews()
425-
DispatchQueue.main.async {
426-
self.updateButtonConstraints()
427-
}
428395
}
429396
}
430397

@@ -515,6 +482,9 @@ public class IterableEMButton: UIButton {
515482
cornerRadii: CGSize(width: bounds.height / 2, height: bounds.height / 2))
516483
maskLayer.path = path.cgPath
517484
}
485+
486+
titleLabel?.numberOfLines = 1
487+
titleLabel?.lineBreakMode = .byTruncatingTail
518488
}
519489
}
520490

0 commit comments

Comments
 (0)