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]]) {
|
if ([self.bottomView isKindOfClass:[TwoButtonView class]]) {
|
||||||
TwoButtonView *buttonView = (TwoButtonView *)self.bottomView;
|
TwoButtonView *buttonView = (TwoButtonView *)self.bottomView;
|
||||||
if (right && !left) {
|
if (right && !left) {
|
||||||
[buttonView hidePrimaryRightButton];
|
[buttonView hideRightButton];
|
||||||
} else if (!right && left) {
|
} else if (!right && left) {
|
||||||
[buttonView hidePrimaryLeftButton];
|
[buttonView hideLeftButton];
|
||||||
} else if (right && left) {
|
} else if (right && left) {
|
||||||
[buttonView hideBothPrimaryButtons];
|
[buttonView hideBothButtons];
|
||||||
} else if (!right && !left) {
|
} else if (!right && !left) {
|
||||||
[buttonView showBothPrimaryButtons];
|
[buttonView showBothButtons];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupWithTwoButtons() {
|
func setupWithTwoButtons() {
|
||||||
guard self.viewForButtons == nil else {
|
guard viewForButtons == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let viewForButtons = MVMCoreUICommonViewsUtility.commonView()
|
let viewForButtons = MVMCoreUICommonViewsUtility.commonView()
|
||||||
@ -114,7 +114,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func setupWithPrimaryButton() {
|
open func setupWithPrimaryButton() {
|
||||||
guard self.primaryButton == nil else {
|
guard primaryButton == nil && secondaryButton == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createPrimaryButton()
|
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...
|
open func setupWithSecondaryButton() {
|
||||||
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, legacy: Bool) {
|
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 {
|
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
if primaryButton == nil || secondaryButton == nil {
|
if primaryButton == nil || secondaryButton == nil {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
setupWithTwoButtons()
|
setupWithTwoButtons()
|
||||||
}
|
}
|
||||||
} else if primaryButtonMap != nil || (secondaryButtonMap != nil && legacy) {
|
} else if primaryButtonMap != nil {
|
||||||
// Only legacy sets up the primary button with a secondary map
|
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
if primaryButton == nil || secondaryButton != nil {
|
if primaryButton == nil || secondaryButton != nil {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
setupWithPrimaryButton()
|
setupWithPrimaryButton()
|
||||||
}
|
}
|
||||||
|
} else if secondaryButtonMap != nil {
|
||||||
|
heightConstraint?.isActive = false
|
||||||
|
if secondaryButton == nil || primaryButton != nil {
|
||||||
|
removeButtons()
|
||||||
|
setupWithSecondaryButton()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
if heightConstraint == nil {
|
if heightConstraint == nil {
|
||||||
@ -150,7 +166,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
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()
|
setDefaultCustom()
|
||||||
primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
secondaryButton?.setWithJSON(secondaryButtonJSON, 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]?) {
|
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 {
|
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||||
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
secondaryButton?.setWithActionMap(secondaryButtonMap, 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?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
primaryButton?.bordered = false
|
primaryButton?.bordered = false
|
||||||
} else if secondaryButtonMap != nil {
|
} else if secondaryButtonMap != nil {
|
||||||
primaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
primaryButton?.bordered = true
|
secondaryButton?.bordered = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +213,7 @@ import UIKit
|
|||||||
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hidePrimaryLeftButton() {
|
public func hideLeftButton() {
|
||||||
guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else {
|
guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -209,7 +225,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hidePrimaryRightButton() {
|
public func hideRightButton() {
|
||||||
guard let primaryButton = primaryButton, !primaryButton.isHidden else {
|
guard let primaryButton = primaryButton, !primaryButton.isHidden else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -221,7 +237,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func showBothPrimaryButtons() {
|
public func showBothButtons() {
|
||||||
primaryButton?.isHidden = false
|
primaryButton?.isHidden = false
|
||||||
secondaryButton?.isHidden = false
|
secondaryButton?.isHidden = false
|
||||||
if let primaryButton = primaryButton, let secondaryButton = secondaryButton {
|
if let primaryButton = primaryButton, let secondaryButton = secondaryButton {
|
||||||
@ -231,7 +247,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hideBothPrimaryButtons() {
|
public func hideBothButtons() {
|
||||||
primaryButton?.isHidden = true
|
primaryButton?.isHidden = true
|
||||||
secondaryButton?.isHidden = true
|
secondaryButton?.isHidden = true
|
||||||
}
|
}
|
||||||
@ -241,7 +257,7 @@ import UIKit
|
|||||||
extension TwoButtonView {
|
extension TwoButtonView {
|
||||||
@available(*, deprecated)
|
@available(*, deprecated)
|
||||||
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
|
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 {
|
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||||
primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
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)
|
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?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol)
|
||||||
primaryButton?.bordered = false
|
primaryButton?.bordered = false
|
||||||
} else if secondaryButtonMap != nil {
|
} else if secondaryButtonMap != nil {
|
||||||
primaryButton?.setWithActionMap(secondaryButtonMap, 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)
|
||||||
primaryButton?.bordered = true
|
secondaryButton?.bordered = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user