From a5186973ae93d0cb2c174cb9986cfa7ad317a865 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Mon, 11 Nov 2019 21:27:08 +0530 Subject: [PATCH] Adding support for secondaryButton, if server dynamically sends only secondary button in TwoButtonView molecule. --- .../TwoButtonView.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 28ad6dc4..592abb36 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -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... func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, legacy: Bool) { if primaryButtonMap != nil, secondaryButtonMap != nil { @@ -140,6 +152,10 @@ import UIKit removeButtons() setupWithPrimaryButton() } + } else if secondaryButtonMap != nil { + heightConstraint?.isActive = false + removeButtons() + setupWithSecondaryButton() } else { removeButtons() if heightConstraint == nil {