primary button set as molecule
unto legacy top labels change
This commit is contained in:
parent
81375ab196
commit
bd3757048e
@ -154,7 +154,6 @@
|
||||
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */; };
|
||||
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */; };
|
||||
D2A514672213885800345BFB /* MVMCoreUIHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */; };
|
||||
D2A514692213B5FB00345BFB /* PrimaryButtonViewMoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514682213B5FB00345BFB /* PrimaryButtonViewMoleculeProtocolExtension.swift */; };
|
||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; };
|
||||
D2A5146D2214C1E400345BFB /* LegacyLargeHeaderSingleLabelTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146C2214C1E400345BFB /* LegacyLargeHeaderSingleLabelTemplate.swift */; };
|
||||
D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -315,7 +314,6 @@
|
||||
D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackTemplate.swift; sourceTree = "<group>"; };
|
||||
D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackCenteredTemplate.swift; sourceTree = "<group>"; };
|
||||
D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIHeaderView.swift; sourceTree = "<group>"; };
|
||||
D2A514682213B5FB00345BFB /* PrimaryButtonViewMoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryButtonViewMoleculeProtocolExtension.swift; sourceTree = "<group>"; };
|
||||
D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = "<group>"; };
|
||||
D2A5146C2214C1E400345BFB /* LegacyLargeHeaderSingleLabelTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyLargeHeaderSingleLabelTemplate.swift; sourceTree = "<group>"; };
|
||||
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; };
|
||||
@ -426,7 +424,6 @@
|
||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
|
||||
D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */,
|
||||
D29770F721F7C73800B2F0D0 /* PrimaryButtonView.m */,
|
||||
D2A514682213B5FB00345BFB /* PrimaryButtonViewMoleculeProtocolExtension.swift */,
|
||||
D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */,
|
||||
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
|
||||
D2A5145E2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift */,
|
||||
@ -870,7 +867,6 @@
|
||||
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
|
||||
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
||||
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
||||
D2A514692213B5FB00345BFB /* PrimaryButtonViewMoleculeProtocolExtension.swift in Sources */,
|
||||
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
|
||||
D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */,
|
||||
D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */,
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#import <MVMCoreUI/MFCustomButton.h>
|
||||
#import <MVMCoreUI/MFTextField.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
PrimaryButtonTypeRed,
|
||||
@ -19,15 +20,24 @@ typedef enum : NSUInteger {
|
||||
// 2.0
|
||||
PrimaryButtonTypeBlack,
|
||||
PrimaryButtonTypeWhite,
|
||||
|
||||
PrimaryButtonTypeCustom
|
||||
} PrimaryButtonType;
|
||||
|
||||
static CGFloat const PrimaryButtonHeight = 42.0;
|
||||
static CGFloat const PrimaryButtonSmallHeight = 30.0;
|
||||
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol>
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set
|
||||
|
||||
// For custom type.
|
||||
@property (nonatomic, strong, nullable) UIColor *fillColor;
|
||||
@property (nonatomic, strong, nullable) UIColor *borderColor;
|
||||
@property (nonatomic, strong, nullable) UIColor *textColor;
|
||||
@property (nonatomic, strong, nullable) UIColor *disabledFillColor;
|
||||
@property (nonatomic, strong, nullable) UIColor *disabledBorderColor;
|
||||
@property (nonatomic, strong, nullable) UIColor *disabledTextColor;
|
||||
|
||||
@property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set
|
||||
@property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void);
|
||||
|
||||
// Set as no to make button filled, set as yes to make button bordered.
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#import "UIColor+MFConvenience.h"
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
@import MVMCore.MVMCoreGetterUtility;
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
|
||||
@interface PrimaryButton ()
|
||||
|
||||
@ -32,6 +33,8 @@
|
||||
|
||||
@implementation PrimaryButton
|
||||
|
||||
#pragma mark - Sizing
|
||||
|
||||
- (MFSizeObject *)innerPadding {
|
||||
return [MFSizeObject sizeObjectWithStandardSize:24.0 standardiPadPortraitSize:32.0 iPadProLandscapeSize:36.0];
|
||||
}
|
||||
@ -110,7 +113,11 @@
|
||||
} else {
|
||||
[self setAsInactiveGray];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PrimaryButtonTypeCustom:
|
||||
[self setAsCustom];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -215,6 +222,10 @@
|
||||
} else {
|
||||
[self setAsInactiveGray];
|
||||
}
|
||||
break;
|
||||
case PrimaryButtonTypeCustom:
|
||||
[self setAsCustom];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -394,9 +405,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setAsCustom {
|
||||
if (self.enabled) {
|
||||
self.backgroundColor = self.fillColor ?: [UIColor clearColor];
|
||||
if (self.bordered) {
|
||||
self.layer.borderWidth = 1;
|
||||
self.layer.borderColor = self.borderColor.CGColor ?: [UIColor blackColor].CGColor;
|
||||
[self setTitleColor:(self.textColor ?: [UIColor colorWithCGColor:self.layer.borderColor]) forState:UIControlStateNormal];
|
||||
} else {
|
||||
self.layer.borderWidth = 0;
|
||||
self.layer.borderColor = [UIColor clearColor].CGColor;
|
||||
[self setTitleColor:(self.textColor ?: [UIColor blackColor]) forState:UIControlStateNormal];
|
||||
}
|
||||
} else {
|
||||
if (self.disabledBorderColor || self.bordered) {
|
||||
self.layer.borderWidth = 1;
|
||||
self.layer.borderColor = self.disabledBorderColor.CGColor ?: [UIColor mfPrimaryWhiteButtonDisableColor].CGColor;
|
||||
self.backgroundColor = self.disabledFillColor ?: [UIColor clearColor];
|
||||
[self setTitleColor:(self.disabledTextColor ?: [UIColor colorWithCGColor:self.layer.borderColor]) forState:UIControlStateNormal];
|
||||
} else {
|
||||
self.layer.borderWidth = 0;
|
||||
self.layer.borderColor = [UIColor clearColor].CGColor;
|
||||
self.backgroundColor = self.disabledFillColor ?: [UIColor mfPrimaryWhiteButtonDisableColor];
|
||||
[self setTitleColor:(self.disabledTextColor ?: [UIColor blackColor]) forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBordered:(BOOL)bordered {
|
||||
if (bordered != _bordered) {
|
||||
if (bordered) {
|
||||
if (self.buttonType == PrimaryButtonTypeCustom) {
|
||||
_bordered = bordered;
|
||||
[self setAsCustom];
|
||||
} else if (bordered) {
|
||||
self.layer.borderWidth = 1;
|
||||
[self setTitleColor:self.backgroundColor forState:UIControlStateNormal];
|
||||
self.layer.borderColor = self.backgroundColor.CGColor;
|
||||
@ -521,6 +562,25 @@
|
||||
|
||||
#pragma mark - For Subclassing
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
self.primaryButtonType = PrimaryButtonTypeCustom;
|
||||
NSString *color = [json string:@"fillColor"];
|
||||
self.fillColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
color = [json string:@"textColor"];
|
||||
self.textColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
color = [json string:@"borderColor"];
|
||||
self.borderColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
_bordered = self.borderColor != nil;
|
||||
color = [json string:@"disabledFillColor"];
|
||||
self.disabledFillColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
color = [json string:@"disabledTextColor"];
|
||||
self.disabledTextColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
color = [json string:@"disabledBorderColor"];
|
||||
self.disabledBorderColor = (color ? [UIColor mfGetColorForHex:color] : nil);
|
||||
[self setAsSmallButton:[json boolForKey:@"small"]];
|
||||
[self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject <MVMCoreActionDelegateProtocol>*)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id <ButtonDelegateProtocol>)delegate : nil)];
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
if (self = [super initWithCoder:aDecoder]) {
|
||||
[self pinHeight];
|
||||
|
||||
@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
@import MVMCore.MVMCoreViewProtocol;
|
||||
|
||||
@interface MFView : UIView <MVMCoreViewProtocol>
|
||||
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
// Called in the initialization functions. Can setup ui here.
|
||||
- (void)setupView;
|
||||
|
||||
@ -41,5 +41,7 @@
|
||||
- (void)updateView:(CGFloat)size {
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
public class MVMCoreUIHeaderView: ViewConstrainingView, MVMCoreUIMoleculeViewProtocol {
|
||||
public class MVMCoreUIHeaderView: ViewConstrainingView {
|
||||
let headlineLabel = MFLabel.commonLabelH2(true)
|
||||
let messageLabel = MFLabel.commonLabelB2(true)
|
||||
var separatorView: SeparatorView?
|
||||
@ -86,7 +86,8 @@ public class MVMCoreUIHeaderView: ViewConstrainingView, MVMCoreUIMoleculeViewPro
|
||||
separatorView?.rightPin?.constant = constant
|
||||
}
|
||||
|
||||
public func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?) {
|
||||
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
headlineLabel.text = json?.optionalStringForKey(KeyTitle)
|
||||
messageLabel.text = json?.optionalStringForKey(KeyMessage)
|
||||
separatorView?.isHidden = !(json?.boolForKey("showSeparator") ?? false)
|
||||
|
||||
@ -8,17 +8,17 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
public class MVMCoreUIMoleculeStackView: MFView, MVMCoreUIMoleculeViewProtocol {
|
||||
public class MVMCoreUIMoleculeStackView: MFView {
|
||||
var spacingBlock: ((Any) -> UIEdgeInsets)?
|
||||
var moleculesArray: [UIView]?
|
||||
|
||||
init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?) {
|
||||
init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.init(frame: CGRect.zero)
|
||||
setWithJSON(json, delegate: delegate)
|
||||
setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
}
|
||||
|
||||
convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) {
|
||||
self.init(withJSON: json, delegate: delegate)
|
||||
self.init(withJSON: json, delegate: delegate, additionalData: nil)
|
||||
self.spacingBlock = spacingBlock
|
||||
}
|
||||
|
||||
@ -43,7 +43,8 @@ public class MVMCoreUIMoleculeStackView: MFView, MVMCoreUIMoleculeViewProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
public func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?) {
|
||||
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
guard let molecules = json?.arrayForKey("molecules") as? [[String: Any]] else {
|
||||
return
|
||||
}
|
||||
@ -52,7 +53,7 @@ public class MVMCoreUIMoleculeStackView: MFView, MVMCoreUIMoleculeViewProtocol {
|
||||
var moleculesArray = [] as [UIView]
|
||||
for moleculeJSON in molecules {
|
||||
if let name = moleculeJSON.optionalStringForKey("moleculeName"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForName(name) {
|
||||
molecule.setWithJSON(moleculeJSON, delegate: delegate)
|
||||
molecule.setWithJSON(moleculeJSON, delegate: delegate, additionalData: additionalData)
|
||||
moleculesArray.append(molecule)
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
@protocol MVMCoreUIMoleculeViewProtocol <NSObject>
|
||||
|
||||
// Sets up the ui based on the json
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate;
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -28,7 +28,10 @@
|
||||
- (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;
|
||||
|
||||
// Sets up with whatever is in the passed in button map. (could be 0, 1, or 2 buttons)
|
||||
// Sets up with whatever is in the passed in. (could be 0, 1, or 2 buttons)
|
||||
- (void)setupWithFirstButtonJSON:(nullable NSDictionary *)firstButtonJSON secondButtonJSON:(nullable NSDictionary *)secondButtonJSON additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
|
||||
|
||||
// Legacy: Sets up with whatever is in the passed in button map. (could be 0, 1, or 2 buttons)
|
||||
- (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;
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#import <MVMCore/MVMCoreJSONConstants.h>
|
||||
#import "MVMCoreUICommonViewsUtility.h"
|
||||
#import "MVMCoreUIConstants.h"
|
||||
#import "UIColor+MFConvenience.h"
|
||||
|
||||
@interface PrimaryButtonView ()
|
||||
|
||||
@ -26,6 +27,25 @@
|
||||
@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];
|
||||
}
|
||||
[self setupWithFirstButtonJSON:[json dict:@"FirstButton"] secondButtonJSON:[json dict:@"SecondButton"] additionalData:nil actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject <MVMCoreActionDelegateProtocol>*)delegate : nil) buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id <ButtonDelegateProtocol>)delegate : nil)];
|
||||
}
|
||||
|
||||
#pragma mark - Inits
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
@ -85,6 +105,8 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Setup
|
||||
|
||||
- (void)setupWithButtonMap:(nullable NSDictionary *)buttonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
||||
|
||||
NSDictionary *secondaryButtonMap = [buttonMap dict:KeySecondaryButton];
|
||||
@ -92,8 +114,15 @@
|
||||
[self setupWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
}
|
||||
|
||||
- (void)setupWithFirstButtonJSON:(nullable NSDictionary *)firstButtonJSON secondButtonJSON:(nullable NSDictionary *)secondButtonJSON additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
||||
[self setupWithPrimaryButtonMap:firstButtonJSON secondaryButtonMap:secondButtonJSON additionalData:additionalData actionDelegate:actionDelegate buttonDelegate:buttonDelegate legacyJSON:NO];
|
||||
}
|
||||
|
||||
- (void)setupWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
||||
|
||||
[self setupWithPrimaryButtonMap:primaryButtonMap secondaryButtonMap:secondaryButtonMap additionalData:additionalData actionDelegate:actionDelegate buttonDelegate:buttonDelegate legacyJSON:YES];
|
||||
}
|
||||
|
||||
- (void)setupWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate legacyJSON:(BOOL)legacyJSON {
|
||||
if (primaryButtonMap && secondaryButtonMap) {
|
||||
self.height.active = NO;
|
||||
|
||||
@ -103,11 +132,16 @@
|
||||
self.twoButtonView = nil;
|
||||
[self setupWithTwoButtons];
|
||||
}
|
||||
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
[self.secondaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
if (legacyJSON) {
|
||||
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
[self.secondaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
} else {
|
||||
[self.primaryButton setWithJSON:primaryButtonMap delegate:actionDelegate additionalData:additionalData];
|
||||
[self.secondaryButton setWithJSON:secondaryButtonMap delegate:actionDelegate additionalData:additionalData];
|
||||
}
|
||||
} else if (primaryButtonMap || secondaryButtonMap) {
|
||||
self.height.active = NO;
|
||||
|
||||
|
||||
// Setup with one button.
|
||||
if (!self.primaryButton || self.secondaryButton) {
|
||||
[self removeSubviews];
|
||||
@ -117,16 +151,20 @@
|
||||
}
|
||||
[self alignCenter];
|
||||
|
||||
if (primaryButtonMap) {
|
||||
|
||||
// Only primary button
|
||||
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
self.primaryButton.bordered = NO;
|
||||
if (legacyJSON) {
|
||||
if (primaryButtonMap) {
|
||||
|
||||
// Only primary button
|
||||
[self.primaryButton setWithActionMap:primaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
self.primaryButton.bordered = NO;
|
||||
} else {
|
||||
|
||||
// Only secondary button
|
||||
[self.primaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
self.primaryButton.bordered = YES;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Only secondary button
|
||||
[self.primaryButton setWithActionMap:secondaryButtonMap actionDelegate:actionDelegate additionalData:additionalData buttonDelegate:buttonDelegate];
|
||||
self.primaryButton.bordered = YES;
|
||||
[self.primaryButton setWithJSON:primaryButtonMap delegate:actionDelegate additionalData:additionalData];
|
||||
}
|
||||
} else {
|
||||
[self removeSubviews];
|
||||
@ -230,13 +268,7 @@
|
||||
centerRightPin.active = YES;
|
||||
}
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
[super updateView:size];
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
[self.primaryButton updateView:size];
|
||||
[self.secondaryButton updateView:size];
|
||||
}];
|
||||
}
|
||||
#pragma mark - Configuring
|
||||
|
||||
- (void)alignLeft {
|
||||
self.alignCenterPin.active = NO;
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
//
|
||||
// PrimaryButtonViewMoleculeProtocolExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 2/12/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension PrimaryButtonView: MVMCoreUIMoleculeViewProtocol {
|
||||
public func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?) {
|
||||
let firstButtonMap = json?.optionalDictionaryForKey("FirstButton")
|
||||
let secondButtonMap = json?.optionalDictionaryForKey("SecondButton")
|
||||
if let backgroundColor = json?.optionalStringForKey("backgroundColor") {
|
||||
self.backgroundColor = UIColor.mfGet(forHex: backgroundColor)
|
||||
}
|
||||
let actionDelegate = delegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol
|
||||
let buttonDelegate = delegate as? ButtonDelegateProtocol
|
||||
setup(withPrimaryButtonMap: firstButtonMap, secondaryButtonMap: secondButtonMap, actionDelegate: actionDelegate, additionalData: nil, buttonDelegate: buttonDelegate)
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,4 @@
|
||||
- (void)setLeftConstant:(CGFloat)leftConstant;
|
||||
- (void)setRightConstant:(CGFloat)rightConstant;
|
||||
|
||||
// Sets up the ui based on the json
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json;
|
||||
|
||||
@end
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#import <MVMCoreUI/MFStyler.h>
|
||||
#import <MVMCore/MVMCoreConstants.h>
|
||||
#import <MVMCoreUI/NSLayoutConstraint+MFConvenience.h>
|
||||
#import <MVMCoreUI/UIColor+MFConvenience.h>
|
||||
|
||||
@interface TopLabelsView ()
|
||||
|
||||
@ -215,34 +214,4 @@
|
||||
self.rightConstraintSeparator.constant = rightConstant;
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json {
|
||||
[self setHeadlineString:[json stringForKey:KeyTitle] messageString:[json stringForKey:KeyMessage]];
|
||||
UIColor *textColor = [self colorForTopLabelsWithJSON:json];
|
||||
self.headlineLabel.textColor = textColor;
|
||||
self.messageLabel.textColor = textColor;
|
||||
self.backgroundColor = [self colorForBackgroundWithJSON:json];
|
||||
NSNumber *showBottomLine = [json objectForKey:@"showBottomLine" ofType:[NSNumber class]];
|
||||
if (showBottomLine) {
|
||||
self.separatorView.hidden = ![showBottomLine boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
- (nonnull UIColor *)colorForTopLabelsWithJSON:(nullable NSDictionary *)json {
|
||||
NSString *titleColor = [json string:@"titleBgColor"];
|
||||
if (titleColor) {
|
||||
return [UIColor mfGetColorForHex:titleColor];
|
||||
} else {
|
||||
return [UIColor blackColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (nonnull UIColor *)colorForBackgroundWithJSON:(nullable NSDictionary *)json {
|
||||
NSString *color = [json string:@"backgroundColor"];
|
||||
if (color) {
|
||||
return [UIColor mfGetColorForHex:color];
|
||||
} else {
|
||||
return [UIColor clearColor];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
return nil;
|
||||
}
|
||||
UIView <MVMCoreUIMoleculeViewProtocol>*molecule = [self getMoleculeForName:moleculeName];
|
||||
[molecule setWithJSON:json delegate:delegate];
|
||||
[molecule setWithJSON:json delegate:delegate additionalData:nil];
|
||||
return molecule;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController {
|
||||
|
||||
public override func viewForMiddle() -> UIView? {
|
||||
let molecule = loadObject?.pageJSON?.optionalDictionaryForKey("MoleculeStack")
|
||||
let moleculeStack = MVMCoreUIMoleculeStackView(withJSON: molecule, delegate: self)
|
||||
let moleculeStack = MVMCoreUIMoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil)
|
||||
return moleculeStack
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ public class MoleculeStackTemplate: ThreeLayerViewController {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("MoleculeStack") else {
|
||||
return nil
|
||||
}
|
||||
return MVMCoreUIMoleculeStackView(withJSON: moleculeJSON, delegate: self)
|
||||
return MVMCoreUIMoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil)
|
||||
}
|
||||
|
||||
override public func viewForBottom() -> UIView? {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user