Implemented Scott feedback.
This commit is contained in:
parent
a5186973ae
commit
f6c2935115
@ -114,7 +114,8 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func setupWithPrimaryButton() {
|
open func setupWithPrimaryButton() {
|
||||||
guard self.primaryButton == nil else {
|
// should not allow primaryButton addition, if secondaryButton exists
|
||||||
|
guard (self.primaryButton == nil && self.secondaryButton == nil) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createPrimaryButton()
|
createPrimaryButton()
|
||||||
@ -126,7 +127,8 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func setupWithSecondaryButton() {
|
open func setupWithSecondaryButton() {
|
||||||
guard self.secondaryButton == nil else {
|
// should not allow secondaryButton addition, if primaryButton exists
|
||||||
|
guard (self.secondaryButton == nil && self.primaryButton == nil) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createSecondaryButton()
|
createSecondaryButton()
|
||||||
@ -137,16 +139,14 @@ 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]?) {
|
||||||
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, legacy: Bool) {
|
|
||||||
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()
|
||||||
@ -166,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)
|
||||||
@ -194,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)
|
||||||
@ -202,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,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
|
||||||
}
|
}
|
||||||
@ -225,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
|
||||||
}
|
}
|
||||||
@ -237,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 {
|
||||||
@ -247,7 +247,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hideBothPrimaryButtons() {
|
public func hideBothButtons() {
|
||||||
primaryButton?.isHidden = true
|
primaryButton?.isHidden = true
|
||||||
secondaryButton?.isHidden = true
|
secondaryButton?.isHidden = true
|
||||||
}
|
}
|
||||||
@ -257,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)
|
||||||
@ -265,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