Adding support for secondaryButton, if server dynamically sends only secondary button in TwoButtonView molecule.

This commit is contained in:
Khan, Arshad 2019-11-11 21:27:08 +05:30
parent 273da70f55
commit a5186973ae

View File

@ -125,6 +125,18 @@ import UIKit
} }
} }
open func setupWithSecondaryButton() {
guard self.secondaryButton == nil else {
return
}
createSecondaryButton()
if let secondaryButton = secondaryButton {
addSubview(secondaryButton)
pinView(toSuperView: secondaryButton)
alignCenterHorizontal()
}
}
// Sets up the number of buttons based on the maps. Doesn't set the buttons with the maps because legacy code handles differently from modern code... // Sets up the number of buttons based on the maps. Doesn't set the buttons with the maps because legacy code handles differently from modern code...
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, legacy: Bool) { func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, legacy: Bool) {
if primaryButtonMap != nil, secondaryButtonMap != nil { if primaryButtonMap != nil, secondaryButtonMap != nil {
@ -140,6 +152,10 @@ import UIKit
removeButtons() removeButtons()
setupWithPrimaryButton() setupWithPrimaryButton()
} }
} else if secondaryButtonMap != nil {
heightConstraint?.isActive = false
removeButtons()
setupWithSecondaryButton()
} else { } else {
removeButtons() removeButtons()
if heightConstraint == nil { if heightConstraint == nil {