Merge branch 'feature/twobuttonview_secondary_button_fix' into 'develop'
Adding support for displaying only secondaryButton on server dynamic response See merge request BPHV_MIPS/mvm_core_ui!172
This commit is contained in:
commit
835eb3a43b
@ -427,13 +427,13 @@
|
||||
if ([self.bottomView isKindOfClass:[TwoButtonView class]]) {
|
||||
TwoButtonView *buttonView = (TwoButtonView *)self.bottomView;
|
||||
if (right && !left) {
|
||||
[buttonView hidePrimaryRightButton];
|
||||
[buttonView hideRightButton];
|
||||
} else if (!right && left) {
|
||||
[buttonView hidePrimaryLeftButton];
|
||||
[buttonView hideLeftButton];
|
||||
} else if (right && left) {
|
||||
[buttonView hideBothPrimaryButtons];
|
||||
[buttonView hideBothButtons];
|
||||
} else if (!right && !left) {
|
||||
[buttonView showBothPrimaryButtons];
|
||||
[buttonView showBothButtons];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ import UIKit
|
||||
}
|
||||
|
||||
func setupWithTwoButtons() {
|
||||
guard self.viewForButtons == nil else {
|
||||
guard viewForButtons == nil else {
|
||||
return
|
||||
}
|
||||
let viewForButtons = MVMCoreUICommonViewsUtility.commonView()
|
||||
@ -114,7 +114,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open func setupWithPrimaryButton() {
|
||||
guard self.primaryButton == nil else {
|
||||
guard primaryButton == nil && secondaryButton == nil else {
|
||||
return
|
||||
}
|
||||
createPrimaryButton()
|
||||
@ -125,21 +125,37 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
open func setupWithSecondaryButton() {
|
||||
guard secondaryButton == nil && primaryButton == nil else {
|
||||
return
|
||||
}
|
||||
createSecondaryButton()
|
||||
if let secondaryButton = secondaryButton {
|
||||
addSubview(secondaryButton)
|
||||
pinView(toSuperView: secondaryButton)
|
||||
alignCenterHorizontal()
|
||||
}
|
||||
}
|
||||
|
||||
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?) {
|
||||
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||
heightConstraint?.isActive = false
|
||||
if primaryButton == nil || secondaryButton == nil {
|
||||
removeButtons()
|
||||
setupWithTwoButtons()
|
||||
}
|
||||
} else if primaryButtonMap != nil || (secondaryButtonMap != nil && legacy) {
|
||||
// Only legacy sets up the primary button with a secondary map
|
||||
} else if primaryButtonMap != nil {
|
||||
heightConstraint?.isActive = false
|
||||
if primaryButton == nil || secondaryButton != nil {
|
||||
removeButtons()
|
||||
setupWithPrimaryButton()
|
||||
}
|
||||
} else if secondaryButtonMap != nil {
|
||||
heightConstraint?.isActive = false
|
||||
if secondaryButton == nil || primaryButton != nil {
|
||||
removeButtons()
|
||||
setupWithSecondaryButton()
|
||||
}
|
||||
} else {
|
||||
removeButtons()
|
||||
if heightConstraint == nil {
|
||||
@ -150,7 +166,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON, legacy: false)
|
||||
setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON)
|
||||
setDefaultCustom()
|
||||
primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
secondaryButton?.setWithJSON(secondaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
@ -178,7 +194,7 @@ import UIKit
|
||||
}
|
||||
|
||||
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true)
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap)
|
||||
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
@ -186,8 +202,8 @@ import UIKit
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.bordered = false
|
||||
} else if secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.bordered = true
|
||||
secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
secondaryButton?.bordered = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +213,7 @@ import UIKit
|
||||
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public func hidePrimaryLeftButton() {
|
||||
public func hideLeftButton() {
|
||||
guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else {
|
||||
return
|
||||
}
|
||||
@ -209,7 +225,7 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public func hidePrimaryRightButton() {
|
||||
public func hideRightButton() {
|
||||
guard let primaryButton = primaryButton, !primaryButton.isHidden else {
|
||||
return
|
||||
}
|
||||
@ -221,7 +237,7 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public func showBothPrimaryButtons() {
|
||||
public func showBothButtons() {
|
||||
primaryButton?.isHidden = false
|
||||
secondaryButton?.isHidden = false
|
||||
if let primaryButton = primaryButton, let secondaryButton = secondaryButton {
|
||||
@ -231,7 +247,7 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public func hideBothPrimaryButtons() {
|
||||
public func hideBothButtons() {
|
||||
primaryButton?.isHidden = true
|
||||
secondaryButton?.isHidden = true
|
||||
}
|
||||
@ -241,7 +257,7 @@ import UIKit
|
||||
extension TwoButtonView {
|
||||
@available(*, deprecated)
|
||||
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true)
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap)
|
||||
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||
secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||
@ -249,8 +265,8 @@ extension TwoButtonView {
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||
primaryButton?.bordered = false
|
||||
} else if secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||
primaryButton?.bordered = true
|
||||
secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||
secondaryButton?.bordered = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user