Merge branch 'develop' into feature/kevin

# Conflicts:
#	MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m
This commit is contained in:
Christiano, Kevin 2019-03-26 16:43:47 -04:00
commit f154befabf
12 changed files with 379 additions and 431 deletions

View File

@ -11,6 +11,7 @@
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; };
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; };
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; };
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */; };
D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -22,6 +23,7 @@
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; };
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; };
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; };
D28B4F8A21FF967C00712C7A /* MVMCoreUIObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */; };
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
@ -30,8 +32,6 @@
D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */; };
D29770F821F7C73800B2F0D0 /* PrimaryButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770F921F7C73800B2F0D0 /* PrimaryButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770F721F7C73800B2F0D0 /* PrimaryButtonView.m */; };
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */; };
D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -162,6 +162,7 @@
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = "<group>"; };
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckBox.h; sourceTree = "<group>"; };
D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckBox.m; sourceTree = "<group>"; };
D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckMarkView.h; sourceTree = "<group>"; };
@ -173,6 +174,7 @@
D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = "<group>"; };
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = "<group>"; };
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = "<group>"; };
D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = "<group>"; };
D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIObject.h; sourceTree = "<group>"; };
D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIObject.m; sourceTree = "<group>"; };
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
@ -181,8 +183,6 @@
D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsAndBottomButtonsTableViewController.h; sourceTree = "<group>"; };
D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsAndBottomButtonsViewController.h; sourceTree = "<group>"; };
D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsViewController.m; sourceTree = "<group>"; };
D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryButtonView.h; sourceTree = "<group>"; };
D29770F721F7C73800B2F0D0 /* PrimaryButtonView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryButtonView.m; sourceTree = "<group>"; };
D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITextFieldView.m; sourceTree = "<group>"; };
D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITextFieldView.h; sourceTree = "<group>"; };
D29DF0CC21E404D4003B2FB9 /* MVMCoreUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MVMCoreUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -411,8 +411,8 @@
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */,
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */,
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */,
D29770F721F7C73800B2F0D0 /* PrimaryButtonView.m */,
D282AACA2243C61700C46919 /* ButtonView.swift */,
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
D2A514662213885800345BFB /* StandardHeaderView.swift */,
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
@ -734,7 +734,6 @@
D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */,
D28B4F8A21FF967C00712C7A /* MVMCoreUIObject.h in Headers */,
D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */,
D29770F821F7C73800B2F0D0 /* PrimaryButtonView.h in Headers */,
D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */,
D29DF2BD21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h in Headers */,
D29DF2EE21ECEADF003B2FB9 /* MFFonts.h in Headers */,
@ -845,7 +844,6 @@
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */,
D29770F921F7C73800B2F0D0 /* PrimaryButtonView.m in Sources */,
D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */,
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
@ -867,6 +865,7 @@
D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */,
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */,
D29DF18121E69E50003B2FB9 /* MFView.m in Sources */,
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
@ -889,6 +888,7 @@
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */,
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */,

View File

@ -51,7 +51,7 @@ static CGFloat const PrimaryButtonSmallHeight = 30.0;
+ (nullable instancetype)primarySmallButton:(BOOL)enabled;
+ (nullable instancetype)primaryTinyButton:(BOOL)enabled;
+ (nullable instancetype)primaryButton;
+ (nonnull instancetype)primaryButton NS_SWIFT_NAME(button());
+ (nullable instancetype)primarySmallButton;
+ (nullable instancetype)primaryWhiteButton:(BOOL)small;

View File

@ -547,7 +547,7 @@
return button;
}
+ (nullable instancetype)primaryButton {
+ (nonnull instancetype)primaryButton {
PrimaryButton *button = [self getButton];
button.primaryButtonType = PrimaryButtonTypeBlack;
[button setAsBlack];

View File

@ -7,7 +7,6 @@
//
#import "TopLabelsAndBottomButtonsTableViewController.h"
#import <MVMCoreUI/PrimaryButtonView.h>
#import <MVMCoreUI/MVMCoreUIUtility.h>
#import <MVMCoreUI/StackableViewController.h>
#import <MVMCoreUI/MVMCoreUICommonViewsUtility.h>
@ -18,6 +17,7 @@
#import <MVMCore/NSDictionary+MFConvenience.h>
#import <MVMCore/MVMCoreLoadObject.h>
#import <MVMCore/MVMCoreJSONConstants.h>
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@import MVMAnimationFramework;
@ -117,7 +117,7 @@
// Sets up the buttons/button.
NSDictionary *primaryButtonDictionary = [self primaryButtonMap];
NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap];
PrimaryButtonView *buttonView = [[PrimaryButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
self.secondaryButton = buttonView.secondaryButton;
self.primaryButton = buttonView.primaryButton;
@ -430,8 +430,8 @@
- (void)setPrimaryLeftButtonHidden:(BOOL)left rightButtonHidden:(BOOL)right {
if ([self.bottomView isKindOfClass:[PrimaryButtonView class]]) {
PrimaryButtonView *buttonView = (PrimaryButtonView *)self.bottomView;
if ([self.bottomView isKindOfClass:[TwoButtonView class]]) {
TwoButtonView *buttonView = (TwoButtonView *)self.bottomView;
if (right && !left) {
[buttonView hidePrimaryRightButton];
} else if (!right && left) {

View File

@ -7,7 +7,6 @@
//
#import "TopLabelsAndBottomButtonsViewController.h"
#import <MVMCoreUI/PrimaryButtonView.h>
#import <MVMCoreUI/MFSizeObject.h>
#import <MVMCoreUI/MVMCoreUICommonViewsUtility.h>
#import <MVMCoreUI/UIColor+MFConvenience.h>
@ -18,6 +17,7 @@
#import <MVMCore/MVMCoreLoadObject.h>
#import <MVMCore/MVMCoreJSONConstants.h>
#import <MVMCore/MVMCoreConstants.h>
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@import MVMAnimationFramework;
@ -80,18 +80,18 @@
}
if (!self.customBottemView) {
PrimaryButtonView *buttonView = (PrimaryButtonView *)self.bottomView;
TwoButtonView *buttonView = (TwoButtonView *)self.bottomView;
if (self.secondaryButton || self.primaryButton) {
UIEdgeInsets paddingForBottomButtons = [self paddingForBottomButtons];
buttonView.leftPin.constant = paddingForBottomButtons.left;
buttonView.rightPin.constant = paddingForBottomButtons.right;
[buttonView setLeftPinConstant:paddingForBottomButtons.left];
[buttonView setRightPinConstant:paddingForBottomButtons.right];
buttonView.topPin.constant = paddingForBottomButtons.top;
buttonView.bottomPin.constant = paddingForBottomButtons.bottom;
} else {
buttonView.topPin.constant = 0;
buttonView.bottomPin.constant = 0;
buttonView.leftPin.constant = 0;
buttonView.rightPin.constant = 0;
[buttonView setLeftPinConstant:0];
[buttonView setRightPinConstant:0];
}
}
}
@ -127,7 +127,7 @@
// Sets up the buttons/button.
NSDictionary *primaryButtonDictionary = [self primaryButtonMap];
NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap];
PrimaryButtonView *buttonView = [[PrimaryButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
self.secondaryButton = buttonView.secondaryButton;
self.primaryButton = buttonView.primaryButton;
bottomView = buttonView;

View File

@ -106,7 +106,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
#pragma mark - Molecules
#import <MVMCoreUI/TopLabelsView.h>
#import <MVMCoreUI/PrimaryButtonView.h>
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
#pragma mark - Templates

View File

@ -0,0 +1,127 @@
//
// ButtonView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/21/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers open class ButtonView: ViewConstrainingView {
open var primaryButton: PrimaryButton? = PrimaryButton.button()
open var alignCenterPin: NSLayoutConstraint?
open var alignCenterLeftPin: NSLayoutConstraint?
open var alignCenterRightPin: NSLayoutConstraint?
// MARK: - Inits
public init() {
super.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public convenience init(buttonSmall small: Bool, enabled: Bool) {
self.init()
primaryButton?.setAsSmall(small)
primaryButton?.isEnabled = enabled
}
public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate: NSObject?, buttonDelegate: Any?) {
super.init(frame: .zero)
setWithJSON(json, delegate: actionDelegate, additionalData: additionalData)
}
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
MVMCoreDispatchUtility.performBlock(onMainThread: {
self.primaryButton?.updateView(size)
})
}
open override func setupView() {
super.setupView()
setupButton()
alignCenter()
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setAsMolecule() {
super.setAsMolecule()
primaryButton?.setAsMolecule()
}
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
primaryButton?.setWithJSON(json, delegate: delegate, additionalData: additionalData)
}
// MARK: - Constraining
func setupButton() {
if let primaryButton = primaryButton, !subviews.contains(primaryButton) {
addSubview(primaryButton)
setupConstraints(forView: primaryButton)
}
}
func setupConstraints(forView view: UIView) {
leftPin = view.leftAnchor.constraint(equalTo: leftAnchor)
topPin = view.topAnchor.constraint(equalTo: topAnchor)
rightPin = rightAnchor.constraint(equalTo: view.rightAnchor)
bottomPin = bottomAnchor.constraint(equalTo: view.bottomAnchor)
leftPin?.isActive = true
topPin?.isActive = true
rightPin?.isActive = true
bottomPin?.isActive = true
alignCenterPin = view.centerXAnchor.constraint(equalTo: centerXAnchor)
alignCenterLeftPin = view.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor)
alignCenterRightPin = rightAnchor.constraint(greaterThanOrEqualTo: view.rightAnchor)
}
open func alignLeft() {
alignCenterPin?.isActive = false
alignCenterLeftPin?.isActive = false
alignCenterRightPin?.isActive = true
leftPin?.isActive = true
rightPin?.isActive = false
}
open func alignCenter() {
alignCenterPin?.isActive = true
alignCenterLeftPin?.isActive = true
alignCenterRightPin?.isActive = true
leftPin?.isActive = false
rightPin?.isActive = false
}
open func alignRight() {
alignCenterPin?.isActive = false
alignCenterLeftPin?.isActive = true
alignCenterRightPin?.isActive = false
leftPin?.isActive = false
rightPin?.isActive = true
}
open override func setLeftPinConstant(_ constant: CGFloat) {
super.setLeftPinConstant(constant)
alignCenterLeftPin?.constant = constant
}
open override func setRightPinConstant(_ constant: CGFloat) {
super.setRightPinConstant(constant)
alignCenterRightPin?.constant = constant
}
open override func resetConstraints() {
super.resetConstraints()
primaryButton?.isEnabled = false
}
}

View File

@ -1,53 +0,0 @@
//
// PrimaryButtonView.h
// myverizon
//
// Created by Scott Pfeil on 12/11/15.
// Copyright © 2015 Verizon Wireless. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MVMCoreUI/ViewConstrainingView.h>
#import <MVMCoreUI/PrimaryButton.h>
@interface PrimaryButtonView : ViewConstrainingView
// Set when there is one button or it is the right button when there are two.
@property (nullable, weak, nonatomic) PrimaryButton *primaryButton;
// The left button when there are two buttons.
@property (nullable, weak, nonatomic) PrimaryButton *secondaryButton;
// Inits with a single button.
- (nonnull instancetype)initButtonSmall:(BOOL)small enabled:(BOOL)enabled;
// Inits with two buttons.
- (nonnull instancetype)initWithTwoButtons;
// Legacy: Sets up with whatever is in the passed in button map. (could be 0, 1, or 2 buttons)
- (nonnull instancetype)initButtonSmall:(BOOL)small buttonMap:(nullable NSDictionary *)buttonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
- (nonnull instancetype)initWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
- (void)setupWithButtonMap:(nullable NSDictionary *)buttonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
- (void)setupWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
// Sets up with two buttons.
- (void)setupWithTwoButtons;
// For subclassing, just returns the button.
- (nonnull id)createButton;
// Change the alignment of the button
- (void)alignLeft;
- (void)alignCenter;
- (void)alignRight;
- (void)alignFill;//default behavior
// Show/hide left and right primary buttons. This does not impact the vertical space of the view.
- (void)hidePrimaryLeftButton;
- (void)hidePrimaryRightButton;
- (void)showBothPrimaryButtons;
- (void)hideBothPrimaryButtons;
- (void)removeSubviews;
@end

View File

@ -1,350 +0,0 @@
//
// PrimaryButtonView.m
// myverizon
//
// Created by Scott Pfeil on 12/11/15.
// Copyright © 2015 Verizon Wireless. All rights reserved.
//
#import "PrimaryButtonView.h"
#import <MVMCore/NSDictionary+MFConvenience.h>
#import <MVMCore/MVMCoreDispatchUtility.h>
#import <MVMCore/MVMCoreJSONConstants.h>
#import "MVMCoreUICommonViewsUtility.h"
#import "MVMCoreUIConstants.h"
#import "UIColor+MFConvenience.h"
@interface PrimaryButtonView ()
@property (weak, nonatomic) UIView *twoButtonView;
@property (weak, nonatomic) NSLayoutConstraint *alignCenterPin;
@property (weak, nonatomic) NSLayoutConstraint *alignCenterLeftPin;
@property (weak, nonatomic) NSLayoutConstraint *alignCenterRightPin;
@property (weak, nonatomic) NSLayoutConstraint *height;
@property (nonatomic, strong) NSArray<NSLayoutConstraint *> *horizontalConstraints;
@end
@implementation PrimaryButtonView
- (void)updateView:(CGFloat)size {
[super updateView:size];
[MVMCoreDispatchUtility performBlockOnMainThread:^{
[self.primaryButton updateView:size];
[self.secondaryButton updateView:size];
}];
}
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
[super setWithJSON:json delegate:delegate additionalData:additionalData];
NSString *backgroundColorString = [json string:@"backgroundColor"];
if (backgroundColorString) {
self.backgroundColor = [UIColor mfGetColorForHex:backgroundColorString];
}
NSDictionary *primaryButtonMap = [json dict:@"primaryButton"];
NSDictionary *secondaryButtonMap = [json dict:@"secondaryButton"];
[self setupUIWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap];
[self.primaryButton setAsStandardCustom];
[self.secondaryButton setAsSecondaryCustom];
[self.primaryButton setWithJSON:primaryButtonMap delegate:delegate additionalData:additionalData];
[self.secondaryButton setWithJSON:secondaryButtonMap delegate:delegate additionalData:additionalData];
}
#pragma mark - Inits
- (instancetype)init {
if (self = [super init]) {
self.backgroundColor = [UIColor clearColor];
self.translatesAutoresizingMaskIntoConstraints = NO;
[self setupWithSingleButton];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
self.backgroundColor = [UIColor clearColor];
self.translatesAutoresizingMaskIntoConstraints = NO;
[self setupWithSingleButton];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor clearColor];
self.translatesAutoresizingMaskIntoConstraints = NO;
[self setupWithSingleButton];
}
return self;
}
- (nonnull instancetype)initButtonSmall:(BOOL)small enabled:(BOOL)enabled {
if (self = [self init]) {
[self.primaryButton setAsSmallButton:small];
[self.primaryButton setEnabled:enabled];
}
return self;
}
- (nonnull instancetype)initWithTwoButtons {
if (self = [self init]) {
[self setupWithTwoButtons];
}
return self;
}
#pragma mark - Legacy Setup
- (nonnull instancetype)initButtonSmall:(BOOL)small buttonMap:(nullable NSDictionary *)buttonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
if (self = [self init]) {
[self setupWithButtonMap:buttonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
[self.primaryButton setAsSmallButton:small];
[self.secondaryButton setAsSmallButton:small];
}
return self;
}
- (nonnull instancetype)initWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
if (self = [self init]) {
[self setupWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
}
return self;
}
- (void)setupWithButtonMap:(nullable NSDictionary *)buttonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
NSDictionary *secondaryButtonMap = [buttonMap dict:KeySecondaryButton];
NSDictionary *primaryButtonMap = [buttonMap dict:KeyPrimaryButton];
[self setupWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
}
- (void)setupWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
[self setupUIWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap];
if (self.primaryButton && self.secondaryButton) {
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
[self.secondaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
} else if (self.primaryButton) {
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
self.primaryButton.bordered = NO;
} else {
[self.primaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
self.primaryButton.bordered = YES;
}
}
#pragma mark - Setup
- (void)setupUIWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap {
if (primaryButtonMap && secondaryButtonMap) {
self.height.active = NO;
// Setup with two buttons
if (!self.primaryButton || !self.secondaryButton) {
[self removeSubviews];
self.twoButtonView = nil;
[self setupWithTwoButtons];
}
} else if (primaryButtonMap || secondaryButtonMap) {
self.height.active = NO;
// Setup with one button.
if (!self.primaryButton || self.secondaryButton) {
[self removeSubviews];
self.primaryButton = nil;
self.secondaryButton = nil;
[self setupWithSingleButton];
}
} else {
[self removeSubviews];
if (!self.height) {
NSLayoutConstraint *height = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0];
height.active = YES;
self.height = height;
}
}
}
- (id)createButton {
return [PrimaryButton primaryButton:NO];
}
- (void)setupWithTwoButtons {
if (self.primaryButton) {
[self.primaryButton removeFromSuperview];
self.primaryButton = nil;
}
if (!self.twoButtonView) {
self.backgroundColor = [UIColor clearColor];
self.translatesAutoresizingMaskIntoConstraints = NO;
UIView *buttonView = [MVMCoreUICommonViewsUtility commonView];
PrimaryButton *leftButton = [PrimaryButton primaryButton];
leftButton.bordered = YES;
leftButton.translatesAutoresizingMaskIntoConstraints = NO;
[buttonView addSubview:leftButton];
self.secondaryButton = leftButton;
PrimaryButton *rightButton = [PrimaryButton primaryButton];
rightButton.translatesAutoresizingMaskIntoConstraints = NO;
[buttonView addSubview:rightButton];
self.primaryButton = rightButton;
[rightButton.widthAnchor constraintEqualToAnchor:leftButton.widthAnchor multiplier:1].active = YES;
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[leftButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(leftButton)]];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[rightButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(rightButton)]];
self.horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[leftButton]-10-[rightButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(leftButton,rightButton)];
[NSLayoutConstraint activateConstraints:self.horizontalConstraints];
[self addSubview:buttonView];
[self setupAlignmentsWithView:buttonView];
self.twoButtonView = buttonView;
[self alignCenter];
}
}
- (void)setupWithSingleButton {
if (!self.primaryButton) {
self.backgroundColor = [UIColor clearColor];
self.translatesAutoresizingMaskIntoConstraints = NO;
PrimaryButton *button = [self createButton];
button.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:button];
self.primaryButton = button;
[self setupAlignmentsWithView:button];
[self alignCenter];
}
}
- (void)setupAlignmentsWithView:(UIView *)view {
// Align left and right constants.
NSLayoutConstraint *leftPin = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
self.leftPin = leftPin;
leftPin.active = YES;
NSLayoutConstraint *topPin = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
self.topPin = topPin;
topPin.active = YES;
NSLayoutConstraint *bottomPin = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
self.bottomPin = bottomPin;
bottomPin.active = YES;
NSLayoutConstraint *rightPin = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
self.rightPin = rightPin;
rightPin.active = YES;
// Center alignments
NSLayoutConstraint *alignCenter = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0];
self.alignCenterPin = alignCenter;
alignCenter.active = YES;
NSLayoutConstraint *centerLeftPin = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
self.alignCenterLeftPin = centerLeftPin;
centerLeftPin.active = YES;
NSLayoutConstraint *centerRightPin = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
self.alignCenterRightPin = centerRightPin;
centerRightPin.active = YES;
}
#pragma mark - Configuring
- (void)alignLeft {
self.alignCenterPin.active = NO;
self.alignCenterLeftPin.active = NO;
self.alignCenterRightPin.active = YES;
self.leftPin.active = YES;
self.rightPin.active = NO;
}
- (void)alignCenter {
self.alignCenterPin.active = YES;
self.alignCenterLeftPin.active = YES;
self.alignCenterRightPin.active = YES;
self.leftPin.active = NO;
self.rightPin.active = NO;
}
- (void)alignFill {
self.alignCenterPin.active = NO;
self.alignCenterLeftPin.active = NO;
self.alignCenterRightPin.active = NO;
self.leftPin.active = YES;
self.rightPin.active = YES;
}
- (void)alignRight {
self.alignCenterPin.active = NO;
self.alignCenterLeftPin.active = YES;
self.alignCenterRightPin.active = NO;
self.leftPin.active = NO;
self.rightPin.active = YES;
}
- (void)setLeftPinConstant:(CGFloat)constant {
[super setLeftPinConstant:constant];
self.alignCenterLeftPin.constant = constant;
}
- (void)setRightPinConstant:(CGFloat)constant {
[super setRightPinConstant:constant];
self.alignCenterRightPin.constant = constant;
}
- (void)resetConstraints {
[super resetConstraints];
self.primaryButton.enabled = NO;
}
- (void)hidePrimaryLeftButton {
if (!self.secondaryButton.hidden) {
self.secondaryButton.hidden = YES;
PrimaryButton *rightButton = self.primaryButton;
[NSLayoutConstraint deactivateConstraints:self.horizontalConstraints];
self.horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[rightButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(rightButton)];
[NSLayoutConstraint activateConstraints:self.horizontalConstraints];
}
}
- (void)hidePrimaryRightButton {
if (!self.primaryButton.hidden) {
self.primaryButton.hidden = YES;
PrimaryButton *leftButton = self.secondaryButton;
[NSLayoutConstraint deactivateConstraints:self.horizontalConstraints];
self.horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[leftButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(leftButton)];
[NSLayoutConstraint activateConstraints:self.horizontalConstraints];
}
}
- (void)showBothPrimaryButtons {
self.primaryButton.hidden = NO;
self.secondaryButton.hidden = NO;
PrimaryButton *rightButton = self.primaryButton;
PrimaryButton *leftButton = self.secondaryButton;
[NSLayoutConstraint deactivateConstraints:self.horizontalConstraints];
self.horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[leftButton]-10-[rightButton]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:NSDictionaryOfVariableBindings(leftButton,rightButton)];
[NSLayoutConstraint activateConstraints:self.horizontalConstraints];
}
- (void)hideBothPrimaryButtons {
self.primaryButton.hidden = YES;
self.secondaryButton.hidden = YES;
}
- (void)removeSubviews {
for (UIView *view in self.subviews) {
[view removeFromSuperview];
}
}
@end

View File

@ -9,7 +9,7 @@
import UIKit
public class StandardFooterView: ViewConstrainingView {
let twoButtonView = PrimaryButtonView(frame: .zero)
let twoButtonView = TwoButtonView(frame: .zero)
var textButton = MFTextButton(nil, constrainHeight: true, forWidth: MVMCoreUIUtility.getWidth())
var spaceBetweenButtons: NSLayoutConstraint?
var leftConstraintTwoButton: NSLayoutConstraint?
@ -34,7 +34,9 @@ public class StandardFooterView: ViewConstrainingView {
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
clipsToBounds = true
setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
setContentCompressionResistancePriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
addSubview(twoButtonView)
addSubview(textButton)
@ -66,10 +68,10 @@ public class StandardFooterView: ViewConstrainingView {
}
public func setSpacing() {
if twoButtonView.subviews.count > 0 && textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 {
if !(twoButtonView.heightConstraint?.isActive ?? false) && textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 {
spaceBetweenButtons?.constant = PaddingTwo
show()
} else if twoButtonView.subviews.count > 0 || textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 {
} else if !(twoButtonView.heightConstraint?.isActive ?? false) || textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 {
spaceBetweenButtons?.constant = 0
show()
} else {

View File

@ -0,0 +1,223 @@
//
// TwoButtonView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/21/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers open class TwoButtonView: ButtonView {
open var secondaryButton: PrimaryButton?
open var viewForButtons: UIView?
public var heightConstraint: NSLayoutConstraint?
public override init() {
super.init(frame: .zero)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
MVMCoreDispatchUtility.performBlock(onMainThread: {
self.secondaryButton?.updateView(size)
})
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
}
let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton")
let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton")
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: false)
primaryButton?.setAsStandardCustom()
secondaryButton?.setAsSecondaryCustom()
primaryButton?.setWithJSON(primaryButtonMap, delegate: delegate, additionalData: additionalData)
secondaryButton?.setWithJSON(secondaryButtonMap, delegate: delegate, additionalData: additionalData)
}
// MARK: - Constraining
override func setupButton() {
setupWithTwoButtons()
}
func createPrimaryButton() {
if primaryButton == nil {
primaryButton = PrimaryButton.button()
}
}
func createSecondaryButton() {
if secondaryButton == nil {
secondaryButton = PrimaryButton.button()
secondaryButton?.bordered = true
}
}
func removeButtons() {
viewForButtons?.removeFromSuperview()
primaryButton?.removeFromSuperview()
secondaryButton?.removeFromSuperview()
viewForButtons = nil
secondaryButton = nil
primaryButton = nil
}
open func setupConstraintsForViewWithButtons() {
guard let viewForButtons = viewForButtons, let primaryButton = primaryButton, let secondaryButton = secondaryButton else {
return
}
viewForButtons.addSubview(primaryButton)
viewForButtons.addSubview(secondaryButton)
secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true
secondaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true
primaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true
viewForButtons.bottomAnchor.constraint(equalTo: secondaryButton.bottomAnchor).isActive = true
viewForButtons.bottomAnchor.constraint(equalTo: primaryButton.bottomAnchor).isActive = true
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[leftButton]-10-[rightButton]-0-|", options: NSLayoutConstraint.FormatOptions.alignAllCenterY, metrics: nil, views: ["leftButton": secondaryButton, "rightButton": primaryButton]))
}
func setupWithTwoButtons() {
guard self.viewForButtons == nil else {
return
}
let viewForButtons = MVMCoreUICommonViewsUtility.commonView()
addSubview(viewForButtons)
self.viewForButtons = viewForButtons
setupConstraints(forView: viewForButtons)
alignCenter()
createPrimaryButton()
createSecondaryButton()
setupConstraintsForViewWithButtons()
}
open func setupWithPrimaryButton() {
guard self.primaryButton == nil else {
return
}
createPrimaryButton()
if let primaryButton = primaryButton {
addSubview(primaryButton)
setupConstraints(forView: primaryButton)
alignCenter()
}
}
// 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 {
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
heightConstraint?.isActive = false
if primaryButton == nil || secondaryButton != nil {
removeButtons()
setupWithPrimaryButton()
}
} else {
removeButtons()
if heightConstraint == nil {
heightConstraint = heightAnchor.constraint(equalToConstant: 0)
heightConstraint?.isActive = true
}
}
}
// MARK: - Legacy
open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton)
let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton)
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate)
}
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true)
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)
} else if primaryButtonMap != nil {
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
}
}
public convenience init(buttonSmall small: Bool, enabled: Bool) {
self.init()
removeButtons()
setupWithPrimaryButton()
primaryButton?.setAsSmall(small)
primaryButton?.isEnabled = enabled
}
public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) {
self.init()
setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonMap)
primaryButton?.setAsSmall(small)
secondaryButton?.setAsSmall(small)
}
public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
self.init()
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate)
}
public func hidePrimaryLeftButton() {
guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else {
return
}
secondaryButton.isHidden = true
if let primaryButton = primaryButton {
primaryButton.removeFromSuperview()
viewForButtons?.addSubview(primaryButton)
NSLayoutConstraint.constraintPinSubview(toSuperview: primaryButton)
}
}
public func hidePrimaryRightButton() {
guard let primaryButton = primaryButton, !primaryButton.isHidden else {
return
}
primaryButton.isHidden = true
if let secondaryButton = secondaryButton {
secondaryButton.removeFromSuperview()
viewForButtons?.addSubview(secondaryButton)
NSLayoutConstraint.constraintPinSubview(toSuperview: secondaryButton)
}
}
public func showBothPrimaryButtons() {
primaryButton?.isHidden = false
secondaryButton?.isHidden = false
if let primaryButton = primaryButton, let secondaryButton = secondaryButton {
primaryButton.removeFromSuperview()
secondaryButton.removeFromSuperview()
setupConstraintsForViewWithButtons()
}
}
public func hideBothPrimaryButtons() {
primaryButton?.isHidden = true
secondaryButton?.isHidden = true
}
}

View File

@ -23,11 +23,11 @@
mapping = [@{
@"label": LabelView.class,
@"separator": SeparatorView.class,
@"button": MFCustomButton.class,
@"button": ButtonView.class,
@"textButton": MFTextButton.class,
@"standardHeader": StandardHeaderView.class,
@"moleculeStack": MoleculeStackView.class,
@"twoButtonView": PrimaryButtonView.class,
@"twoButtonView": TwoButtonView.class,
@"standardFooter": StandardFooterView.class,
@"dashLine": DashLine.class,
@"caretView": CaretView.class,