Merge branch 'develop' into feature/kevin
# Conflicts: # MVMCoreUI.xcodeproj/project.pbxproj # MVMCoreUI/Atoms/Views/MFLabel.h # MVMCoreUI/Atoms/Views/MFLabel.m
This commit is contained in:
commit
17decc6602
@ -155,6 +155,7 @@
|
||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; };
|
||||
D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; };
|
||||
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; };
|
||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; };
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
|
||||
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; };
|
||||
@ -316,6 +317,7 @@
|
||||
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; };
|
||||
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = "<group>"; };
|
||||
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
||||
D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = "<group>"; };
|
||||
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
|
||||
DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; };
|
||||
DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; };
|
||||
@ -634,6 +636,7 @@
|
||||
D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */,
|
||||
D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */,
|
||||
D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */,
|
||||
D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */,
|
||||
@ -864,6 +867,7 @@
|
||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */,
|
||||
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
|
||||
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
||||
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
|
||||
|
||||
@ -106,15 +106,15 @@ open class CaretButton: MFCustomButton {
|
||||
//------------------------------------------------------
|
||||
|
||||
// Default values for view.
|
||||
@objc open override func setAsMolecule() {
|
||||
@objc open func setAsMolecule() {
|
||||
|
||||
backgroundColor = .clear
|
||||
setTitleColor(enabledColor, for: .normal)
|
||||
setTitleColor(disabledColor, for: .disabled)
|
||||
}
|
||||
|
||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData)
|
||||
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
guard let dictionary = json else { return }
|
||||
|
||||
|
||||
@ -11,14 +11,14 @@
|
||||
#import <MVMCoreUI/ButtonDelegateProtocol.h>
|
||||
#import <MVMCoreUI/MFButtonProtocol.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
@import MVMCore.MVMCoreViewProtocol;
|
||||
@class DelegateObject;
|
||||
|
||||
typedef void (^ButtonTapBlock)(id _Nonnull sender);
|
||||
|
||||
extern CGFloat const CloseButtonHeight;
|
||||
extern CGFloat const CloseButtonWidth;
|
||||
|
||||
@interface MFCustomButton : UIButton <MFButtonProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
@interface MFCustomButton : UIButton <MFButtonProtocol>
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *actionMap;
|
||||
@property (nullable, nonatomic, weak) id <ButtonDelegateProtocol> buttonDelegate;
|
||||
@ -28,14 +28,19 @@ extern CGFloat const CloseButtonWidth;
|
||||
- (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event;
|
||||
|
||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler.
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
//accessibility
|
||||
- (void)addAccessibilityForCameraControl;
|
||||
|
||||
- (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction;
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler.
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData __deprecated;
|
||||
|
||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate __deprecated;
|
||||
|
||||
@end
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
#import "MVMCoreUIUtility.h"
|
||||
#import "MVMCoreUIConstants.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
CGFloat const CloseButtonHeight = 40.0f;
|
||||
CGFloat const CloseButtonWidth = 40.0f;
|
||||
@ -37,6 +38,54 @@ CGFloat const CloseButtonWidth = 40.0f;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData {
|
||||
|
||||
self.actionMap = actionMap;
|
||||
self.titleLabel.numberOfLines = 0;
|
||||
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
[self setTitle:[actionMap stringForKey:KeyTitle] forState:UIControlStateNormal];
|
||||
|
||||
[self setEnabled:![actionMap[KeyDisableButton]boolValue]];
|
||||
|
||||
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
|
||||
self.buttonDelegate = ((MVMCoreUIDelegateObject *)delegateObject).buttonDelegate;
|
||||
}
|
||||
__weak MFCustomButton *weakSelf = self;
|
||||
[self addBlock:^(id _Nonnull sender) {
|
||||
|
||||
BOOL performAction = YES;
|
||||
if (weakSelf.buttonDelegate && [weakSelf.buttonDelegate respondsToSelector:@selector(button:shouldPerformActionWithMap:additionalData:)]) {
|
||||
performAction = [weakSelf.buttonDelegate button:weakSelf shouldPerformActionWithMap:actionMap additionalData:additionalData];
|
||||
}
|
||||
|
||||
if (performAction) {
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject];
|
||||
}
|
||||
} forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
|
||||
//accessibility
|
||||
-(void)addAccessibilityForCameraControl{
|
||||
self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"];
|
||||
self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"];
|
||||
self.accessibilityTraits = UIAccessibilityTraitNone;
|
||||
}
|
||||
|
||||
|
||||
- (UIAccessibilityCustomAction *)accessibilityCustomAction {
|
||||
NSString *name = self.accessibilityLabel ?: self.titleLabel.text;
|
||||
return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)];
|
||||
}
|
||||
|
||||
- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action {
|
||||
if (self.buttonTapBlock) {
|
||||
self.buttonTapBlock(self);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
|
||||
self.actionMap = actionMap;
|
||||
@ -53,11 +102,11 @@ CGFloat const CloseButtonWidth = 40.0f;
|
||||
}
|
||||
|
||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
||||
|
||||
|
||||
if (!buttonDelegate) {
|
||||
[self setWithActionMap:actionMap delegate:actionDelegate additionalData:additionalData];
|
||||
} else {
|
||||
|
||||
|
||||
self.actionMap = actionMap;
|
||||
self.titleLabel.numberOfLines = 0;
|
||||
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
@ -86,24 +135,4 @@ CGFloat const CloseButtonWidth = 40.0f;
|
||||
}
|
||||
}
|
||||
|
||||
//accessibility
|
||||
-(void)addAccessibilityForCameraControl{
|
||||
self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"];
|
||||
self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"];
|
||||
self.accessibilityTraits = UIAccessibilityTraitNone;
|
||||
}
|
||||
|
||||
|
||||
- (UIAccessibilityCustomAction *)accessibilityCustomAction {
|
||||
NSString *name = self.accessibilityLabel ?: self.titleLabel.text;
|
||||
return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)];
|
||||
}
|
||||
|
||||
- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action {
|
||||
if (self.buttonTapBlock) {
|
||||
self.buttonTapBlock(self);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -128,12 +128,12 @@
|
||||
|
||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
NSString *color = [json string:KeyTextColor];
|
||||
if (color) {
|
||||
[self setTitleColor:[UIColor mfGetColorForHex:color] forState:UIControlStateNormal];
|
||||
}
|
||||
[self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject <MVMCoreActionDelegateProtocol>*)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id <ButtonDelegateProtocol>)delegate : nil)];
|
||||
[self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData];
|
||||
if ([self titleForState:UIControlStateNormal].length == 0) {
|
||||
self.heightConstraint.constant = 0;
|
||||
} else {
|
||||
|
||||
@ -648,10 +648,11 @@
|
||||
[self setAsStandardCustom];
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
|
||||
[FormValidator setupValidationWithMolecule:self delegate:(id<FormValidationProtocol>)delegate];
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
|
||||
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
|
||||
}
|
||||
|
||||
self.primaryButtonType = PrimaryButtonTypeCustom;
|
||||
NSString *color = [json string:@"fillColor"];
|
||||
if (color) {
|
||||
@ -676,7 +677,7 @@
|
||||
self.validationRequired = [json boolForKey:@"validationRequired"];
|
||||
|
||||
[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)];
|
||||
[self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData];
|
||||
}
|
||||
|
||||
#pragma mark - Handling Validations
|
||||
|
||||
@ -114,7 +114,7 @@
|
||||
+ (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate {
|
||||
MFTextField *textField = [self mfTextField];
|
||||
textField.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[textField setWithJSON:map delegate:delegate additionalData:nil];
|
||||
[textField setWithMap:map bothDelegates:delegate];
|
||||
return textField;
|
||||
}
|
||||
|
||||
@ -556,10 +556,12 @@
|
||||
self.isMolecule = YES;
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate additionalData:(NSDictionary *)additionalData {
|
||||
[FormValidator setupValidationWithMolecule:self delegate:(id<FormValidationProtocol>)delegate];
|
||||
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id<FormValidationProtocol>)delegate];
|
||||
[self setWithMap:json bothDelegates:formValidator];
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
|
||||
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
|
||||
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
|
||||
[self setWithMap:json bothDelegates:formValidator];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FormValidationProtocol
|
||||
|
||||
@ -94,10 +94,9 @@ open class CaretView: MFView {
|
||||
|
||||
defaultState()
|
||||
}
|
||||
|
||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
// Configure class properties with JSON values
|
||||
guard let jsonDictionary = json else { return }
|
||||
|
||||
|
||||
@ -68,8 +68,8 @@ open class DashLine: MFView {
|
||||
isHidden = false
|
||||
}
|
||||
|
||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
// Configure class properties with JSON values
|
||||
guard let jsonDictionary = json else { return }
|
||||
|
||||
@ -73,9 +73,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
|
||||
[super setWithJSON:json delegate:delegate additionalData:additionalData];
|
||||
[self.label setWithJSON:json delegate:delegate additionalData:additionalData];
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||
[self.label setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||
}
|
||||
|
||||
- (void)alignLeft {
|
||||
|
||||
@ -556,8 +556,7 @@ extension LabelWithInternalButton: MVMCoreUIMoleculeViewProtocol {
|
||||
|
||||
}
|
||||
|
||||
@objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
@objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
// Configure class properties with JSON values
|
||||
guard let dictionary = json else { return }
|
||||
|
||||
|
||||
64
MVMCoreUI/Atoms/Views/MFLabel.h
Normal file
64
MVMCoreUI/Atoms/Views/MFLabel.h
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// MFLabel.h
|
||||
// mobilefirst
|
||||
//
|
||||
// Created by Scott Pfeil on 3/22/17.
|
||||
// Copyright © 2017 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
@class MFSizeObject;
|
||||
@class DelegateObject;
|
||||
|
||||
@interface MFLabel : UILabel <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
- (nullable instancetype)initWithStandardFontSize:(CGFloat)size;
|
||||
|
||||
// Set this property if you want updateView to update the font based on this standard and the size passed in.
|
||||
@property (nonatomic) CGFloat standardFontSize;
|
||||
|
||||
// Set this to use a custom sizing object during updateView instead of the standard.
|
||||
@property (nonatomic, strong, nullable) MFSizeObject *sizeObject;
|
||||
|
||||
// Set the font and set to scale
|
||||
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale;
|
||||
|
||||
// Convenience checker for text or attributed text.
|
||||
- (BOOL)hasText;
|
||||
|
||||
#pragma mark - 2.0
|
||||
//75Bd 40pt
|
||||
+ (nonnull MFLabel *)commonLabelH1:(BOOL)scale;
|
||||
//75Bd 25pt
|
||||
+ (nonnull MFLabel *)commonLabelH2:(BOOL)scale;
|
||||
//75Bd 18pt
|
||||
+ (nonnull MFLabel *)commonLabelH3:(BOOL)scale;
|
||||
//75Bd 32pt
|
||||
+ (nonnull MFLabel *)commonLabelH32:(BOOL)scale;
|
||||
//75Bd 13pt
|
||||
+ (nonnull MFLabel *)commonLabelB1:(BOOL)scale;
|
||||
//55Rg 13pt
|
||||
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale;
|
||||
//55Rg 11pt gray
|
||||
+ (nonnull MFLabel *)commonLabelB3:(BOOL)scale;
|
||||
//55Rg 20pt
|
||||
+ (nonnull MFLabel *)commonLabelB20:(BOOL)scale;
|
||||
|
||||
// Getters
|
||||
+ (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel());
|
||||
|
||||
// Setters
|
||||
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html;
|
||||
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
- (void)styleH1:(BOOL)scale;
|
||||
- (void)styleH2:(BOOL)scale;
|
||||
- (void)styleH3:(BOOL)scale;
|
||||
- (void)styleH32:(BOOL)scale;
|
||||
- (void)styleB1:(BOOL)scale;
|
||||
- (void)styleB2:(BOOL)scale;
|
||||
- (void)styleB3:(BOOL)scale;
|
||||
- (void)styleB20:(BOOL)scale;
|
||||
|
||||
@end
|
||||
291
MVMCoreUI/Atoms/Views/MFLabel.m
Normal file
291
MVMCoreUI/Atoms/Views/MFLabel.m
Normal file
@ -0,0 +1,291 @@
|
||||
//
|
||||
// MFLabel.m
|
||||
// mobilefirst
|
||||
//
|
||||
// Created by Scott Pfeil on 3/22/17.
|
||||
// Copyright © 2017 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MFLabel.h"
|
||||
#import <MVMCoreUI/MFStyler.h>
|
||||
#import <MVMCoreUI/MFSizeObject.h>
|
||||
#import <MVMCoreUI/MVMCoreUIConstants.h>
|
||||
#import "UIColor+MFConvenience.h"
|
||||
#import "MFFonts.h"
|
||||
#import "MVMCoreUISplitViewController.h"
|
||||
#import "MVMCoreUILoggingHandler.h"
|
||||
@import MVMCore.MVMCoreGetterUtility;
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
@import MVMCore.MVMCoreJSONConstants;
|
||||
|
||||
@interface MFLabel ()
|
||||
|
||||
@property (strong, nonatomic) NSNumber *scaleSize;
|
||||
|
||||
// Used for scaling the font in updateView.
|
||||
@property (strong, nonatomic) NSAttributedString *originalAttributedString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MFLabel
|
||||
|
||||
- (void)setupView {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.numberOfLines = 0;
|
||||
self.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
self.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder {
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStandardFontSize:(CGFloat)size {
|
||||
if ([self init]) {
|
||||
self.standardFontSize = size;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
self.scaleSize = @(size);
|
||||
if (self.originalAttributedString) {
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:self.originalAttributedString];
|
||||
[attributedString removeAttribute:NSFontAttributeName range:NSMakeRange(0, attributedString.length)];
|
||||
[self.originalAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, self.originalAttributedString.length) options:0 usingBlock:^(UIFont *value, NSRange range, BOOL * _Nonnull stop) {
|
||||
// Loop the original attributed string, resize the fonts.
|
||||
UIFont *font = [value fontWithSize:[[MFStyler sizeObjectGenericForCurrentDevice:value.pointSize] getValueBasedOnSize:size]];
|
||||
[attributedString addAttribute:NSFontAttributeName value:font range:range];
|
||||
}];
|
||||
self.attributedText = attributedString;
|
||||
} else if (!fequal(self.standardFontSize, 0)) {
|
||||
MFSizeObject *sizeObject = self.sizeObject;
|
||||
if (!sizeObject) {
|
||||
sizeObject = [MFStyler sizeObjectGenericForCurrentDevice:self.standardFontSize];
|
||||
}
|
||||
self.font = [self.font fontWithSize:[sizeObject getValueBasedOnSize:size]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale {
|
||||
self.font = font;
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)setScale:(BOOL)scale {
|
||||
if (scale) {
|
||||
self.standardFontSize = self.font.pointSize;
|
||||
[self updateView:(self.scaleSize ? self.scaleSize.floatValue : [MVMCoreUISplitViewController getApplicationViewWidth])];
|
||||
} else {
|
||||
self.standardFontSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasText {
|
||||
return self.text.length > 0 || self.attributedText.length > 0;
|
||||
}
|
||||
|
||||
#pragma mark - 2.0
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelH1:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleH1:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelH2:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleH2:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelH3:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleH3:scale];
|
||||
return label;
|
||||
}
|
||||
+ (nonnull MFLabel *)commonLabelH32:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleH32:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelB1:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleB1:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleB2:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelB3:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleB3:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)commonLabelB20:(BOOL)scale {
|
||||
MFLabel *label = [MFLabel label];
|
||||
[label styleB20:scale];
|
||||
return label;
|
||||
}
|
||||
|
||||
+ (nonnull MFLabel *)label {
|
||||
return [[MFLabel alloc] initWithFrame:CGRectZero];
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html {
|
||||
NSData *data = [html dataUsingEncoding:kCFStringEncodingUTF8];
|
||||
if (data) {
|
||||
NSError *error = nil;
|
||||
label.attributedText = [[NSAttributedString alloc] initWithData:data options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:&error];
|
||||
if (error) {
|
||||
[[MVMCoreUILoggingHandler sharedLoggingHandler] addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"LabelHTMLParse"]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData {
|
||||
if (label) {
|
||||
label.text = [json string:KeyText];
|
||||
[self setLabel:label withHTML:[json string:@"html"]];
|
||||
NSString *textColor = [json string:KeyTextColor];
|
||||
if (textColor) {
|
||||
label.textColor = [UIColor mfGetColorForHex:textColor];
|
||||
}
|
||||
NSString *backgroundColor = [json string:KeyBackgroundColor];
|
||||
if (backgroundColor) {
|
||||
label.backgroundColor = [UIColor mfGetColorForHex:backgroundColor];
|
||||
}
|
||||
NSString *accessibilityText = [json string:@"accessibilityText"];
|
||||
if (accessibilityText) {
|
||||
label.accessibilityLabel = accessibilityText;
|
||||
}
|
||||
NSString *fontName = [json string:@"fontName"];
|
||||
NSNumber *fontSize = [json optionalNumberForKey:@"fontSize"];
|
||||
if (fontName) {
|
||||
label.font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
|
||||
} else if (fontSize) {
|
||||
label.font = [label.font fontWithSize:fontSize.doubleValue];
|
||||
}
|
||||
|
||||
NSArray *attributes = [json array:@"attributes"];
|
||||
if (attributes) {
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}];
|
||||
for (NSDictionary *attribute in attributes) {
|
||||
NSNumber *location = [attribute optionalNumberForKey:@"location"];
|
||||
NSNumber *length = [attribute optionalNumberForKey:@"length"];
|
||||
if (location && length) {
|
||||
NSRange range = NSMakeRange(location.unsignedIntegerValue, length.unsignedIntegerValue);
|
||||
NSString *type = [attribute string:KeyType];
|
||||
if ([type isEqualToString:@"underline"]) {
|
||||
[attributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
|
||||
} else if ([type isEqualToString:@"strikethrough"]) {
|
||||
[attributedString addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleThick) range:range];
|
||||
} else if ([type isEqualToString:@"color"]) {
|
||||
NSString *color = [attribute string:KeyTextColor];
|
||||
if (color) {
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor mfGetColorForHex:color] range:range];
|
||||
}
|
||||
} else if ([type isEqualToString:@"font"]) {
|
||||
NSString *fontName = [attribute string:@"name"];
|
||||
NSNumber *fontSize = [attribute optionalNumberForKey:@"size"];
|
||||
UIFont *font = nil;
|
||||
if (fontName) {
|
||||
font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
|
||||
} else if (fontSize) {
|
||||
font = [label.font fontWithSize:fontSize.doubleValue];
|
||||
}
|
||||
if (font) {
|
||||
[attributedString addAttribute:NSFontAttributeName value:font range:range];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label.attributedText = attributedString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
[MFLabel setUILabel:self withJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||
self.originalAttributedString = self.attributedText;
|
||||
}
|
||||
|
||||
- (void)styleH1:(BOOL)scale {
|
||||
[MFStyler styleLabelH1:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleH2:(BOOL)scale {
|
||||
[MFStyler styleLabelH2:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleH3:(BOOL)scale {
|
||||
[MFStyler styleLabelH3:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleH32:(BOOL)scale {
|
||||
[MFStyler styleLabelH32:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleB1:(BOOL)scale {
|
||||
[MFStyler styleLabelB1:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleB2:(BOOL)scale {
|
||||
[MFStyler styleLabelB2:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleB3:(BOOL)scale {
|
||||
[MFStyler styleLabelB3:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)styleB20:(BOOL)scale {
|
||||
[MFStyler styleLabelB20:self genericScaling:NO];
|
||||
[self setScale:scale];
|
||||
}
|
||||
|
||||
- (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits {
|
||||
|
||||
if (accessibilityTraits& UIAccessibilityTraitHeader) {
|
||||
UIAccessibilityTraits noHeaderTraits = accessibilityTraits - UIAccessibilityTraitHeader;
|
||||
[super setAccessibilityTraits:noHeaderTraits];
|
||||
} else {
|
||||
[super setAccessibilityTraits:accessibilityTraits];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@ -203,8 +203,8 @@ import UIKit
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol functions
|
||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MFView.h"
|
||||
@import MVMCore.Swift;
|
||||
|
||||
@implementation MFView
|
||||
|
||||
@ -43,7 +44,7 @@
|
||||
|
||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
self.json = json;
|
||||
}
|
||||
|
||||
|
||||
@ -95,8 +95,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
|
||||
[super setWithJSON:json delegate:delegate additionalData:additionalData];
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||
if (json) {
|
||||
self.hidden = NO;
|
||||
NSString *type = [json string:KeyType];
|
||||
|
||||
@ -93,7 +93,7 @@ static NSTimeInterval const HandScrollAnimationTiming = 7.f;
|
||||
|
||||
BOOL automaticInset = NO;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
automaticInset = self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic;
|
||||
automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic;
|
||||
}
|
||||
|
||||
// Takes into account the navigation bar.
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
@class MainMenuViewController;
|
||||
@class MVMCoreUITabBarPageControlViewController;
|
||||
@class MVMAnimationManager;
|
||||
@class DelegateObject;
|
||||
|
||||
@interface MFViewController : UIViewController <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate, ButtonDelegateProtocol, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MVMCoreUIDetailViewProtocol>
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
|
||||
// Creates an initial load object if needed.
|
||||
if (!self.loadObject) {
|
||||
self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegate:self];
|
||||
self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegateObject:[self delegateObject]];
|
||||
}
|
||||
|
||||
// Avoid the setter so we are only setting the bool and wait for view will appear to update the navigation bar.
|
||||
@ -180,6 +180,10 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable DelegateObject *)delegateObject {
|
||||
return [MVMCoreUIDelegateObject createWithDelegateForAll:self];
|
||||
}
|
||||
|
||||
#pragma mark - Response Handling
|
||||
|
||||
- (void)observeForResponseJSONUpdates {
|
||||
@ -304,6 +308,8 @@
|
||||
|| self.manager
|
||||
|| self.loadObject.requestParameters.tabWasPressed);
|
||||
}
|
||||
} else {
|
||||
[[MVMCoreUISession sharedGlobal].splitViewController.parentViewController setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +345,7 @@
|
||||
if (rightPanelLinkDict) {
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict
|
||||
additionalData:nil
|
||||
delegate:self];
|
||||
delegateObject:[self delegateObject]];
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
@ -494,6 +500,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
//this method is needed for getting status bar style from present viewcotnroller
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle {
|
||||
if ([self respondsToSelector:@selector(defaultStatusBarStyle)]) {
|
||||
return [self defaultStatusBarStyle];
|
||||
} else {
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
@ -603,7 +618,7 @@
|
||||
[self.formValidator addFormParamsWithRequestParameters:requestParameters];
|
||||
requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"];
|
||||
|
||||
[[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegate:self];
|
||||
[[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]];
|
||||
}
|
||||
|
||||
- (void)handleBackAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData {
|
||||
@ -658,7 +673,7 @@
|
||||
|
||||
- (void)handleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData {
|
||||
|
||||
[MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegate:self];
|
||||
[MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:[self delegateObject]];
|
||||
}
|
||||
|
||||
- (void)handleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData {
|
||||
@ -685,7 +700,7 @@
|
||||
}
|
||||
|
||||
- (nullable MVMCoreAlertObject *)alertObjectToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject {
|
||||
return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject actionDelegate:self];
|
||||
return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject delegateObject:[self delegateObject]];
|
||||
}
|
||||
|
||||
- (void)handleFieldErrors:(nullable NSArray *)fieldErrors loadObject:(nonnull MVMCoreLoadObject *)loadObject {
|
||||
|
||||
@ -30,6 +30,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// View Controller can override this method and do custom action instead of opening the left panel
|
||||
- (BOOL)isOverridingLeftButton;
|
||||
|
||||
//return desired status bar style based on different View Controller
|
||||
- (UIStatusBarStyle)defaultStatusBarStyle;
|
||||
- (nullable UIColor *)defaultStatusBarBackgroundColor;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -105,6 +105,10 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
+ (CGFloat)getApplicationViewWidth;
|
||||
+ (CGFloat)getApplicationViewMaxSize;
|
||||
|
||||
// return subviewcontrollers' prefer status bar style
|
||||
- (UIStatusBarStyle)getDefaultStatusBarStyle;
|
||||
- (nullable UIColor *)getDefaultStatusBarBackgroundColor;
|
||||
|
||||
#pragma mark - Main Subclassables
|
||||
|
||||
// Can subclass to set threshold for when the drawers are permanently extended. Default is 1000 for the left panel and 2000 for both.
|
||||
|
||||
@ -877,7 +877,33 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle {
|
||||
return self.topAlertView.statusBarStyle;
|
||||
if (self.topAlertView.topAlertObject) {
|
||||
return self.topAlertView.statusBarStyle;
|
||||
} else {
|
||||
UIStatusBarStyle style = [self getDefaultStatusBarStyle];
|
||||
[self.topAlertView resetDefaultBackgroundColor:[self getDefaultStatusBarBackgroundColor] basedOnStatusBarStyle:style];
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)getDefaultStatusBarStyle {
|
||||
UIViewController *viewController = [self getCurrentDetailViewController];
|
||||
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
|
||||
&& [viewController respondsToSelector:@selector(defaultStatusBarStyle)]
|
||||
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle]) {
|
||||
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle];
|
||||
}
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (UIColor *)getDefaultStatusBarBackgroundColor {
|
||||
UIViewController *viewController = [self getCurrentDetailViewController];
|
||||
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
|
||||
&& [viewController respondsToSelector:@selector(defaultStatusBarBackgroundColor)]
|
||||
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarBackgroundColor]) {
|
||||
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarBackgroundColor];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
@ -394,7 +394,7 @@
|
||||
if (customAdditionalData) {
|
||||
[additionalData addEntriesFromDictionary:customAdditionalData];
|
||||
}
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:self];
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[self delegateObject]];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
import Foundation
|
||||
|
||||
@objc public extension FormValidator {
|
||||
@objc public func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
||||
@objc func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
||||
requestParameters.add(self.getFormParams())
|
||||
}
|
||||
|
||||
@objc public func getFormParams() -> [String: Any] {
|
||||
@objc func getFormParams() -> [String: Any] {
|
||||
var extraParam: [String: Any] = [:]
|
||||
MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
|
||||
for molecule in self.molecules {
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
// Sets up the buttons/button.
|
||||
NSDictionary *primaryButtonDictionary = [self primaryButtonMap];
|
||||
NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap];
|
||||
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
|
||||
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil];
|
||||
self.secondaryButton = buttonView.secondaryButton;
|
||||
self.primaryButton = buttonView.primaryButton;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
@property (nullable, weak, nonatomic) UIView *viewInScroll;
|
||||
@property (nullable, weak, nonatomic) UIView *viewOutOfScroll;
|
||||
@property (nullable, strong, nonatomic) UIView *safeAreaView;
|
||||
@property (nullable, weak, nonatomic) ViewConstrainingView *bottomAccessoryView;
|
||||
|
||||
// Set to overwrite which view is the top edge and/or bottom edge of the between view. must be added to the ui and constrained before buildViewsBetweenLabelsAndButtons.
|
||||
// Use these to create views that are pinned near the labels or buttons and are separate from any centered content. Add and set in buildInAdditionalViewsBeforeCenteredContent.
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
@property (nullable, weak, nonatomic) NSArray *middleViews;
|
||||
|
||||
@property (nullable, weak, nonatomic) UIView *betweenView;
|
||||
@property (nullable, weak, nonatomic) ViewConstrainingView *bottomAccessoryView;
|
||||
|
||||
// Adds the button view to the screen. Out of the scroll or in.
|
||||
- (void)addViewOutsideOfScrollView:(UIView *)bottomView;
|
||||
@ -127,7 +126,7 @@
|
||||
// Sets up the buttons/button.
|
||||
NSDictionary *primaryButtonDictionary = [self primaryButtonMap];
|
||||
NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap];
|
||||
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self];
|
||||
TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil];
|
||||
self.secondaryButton = buttonView.secondaryButton;
|
||||
self.primaryButton = buttonView.primaryButton;
|
||||
bottomView = buttonView;
|
||||
|
||||
@ -33,9 +33,9 @@ import UIKit
|
||||
primaryButton?.isEnabled = enabled
|
||||
}
|
||||
|
||||
public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate: NSObject?, buttonDelegate: Any?) {
|
||||
public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
|
||||
super.init(frame: .zero)
|
||||
setWithJSON(json, delegate: actionDelegate, additionalData: additionalData)
|
||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
@ -58,9 +58,9 @@ import UIKit
|
||||
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)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
// MARK: - Constraining
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@class DelegateObject;
|
||||
|
||||
@protocol MVMCoreUIMoleculeViewProtocol <NSObject>
|
||||
|
||||
// Sets up the ui based on the json
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData;
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
@ -17,13 +17,13 @@ public class MoleculeStackView: MFView {
|
||||
super.init(frame: frame)
|
||||
}
|
||||
|
||||
public init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
public init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.init(frame: CGRect.zero)
|
||||
setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) {
|
||||
self.init(withJSON: json, delegate: delegate, additionalData: nil)
|
||||
public convenience init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) {
|
||||
self.init(withJSON: json, delegateObject: delegateObject, additionalData: nil)
|
||||
self.spacingBlock = spacingBlock
|
||||
}
|
||||
|
||||
@ -48,8 +48,8 @@ public class MoleculeStackView: MFView {
|
||||
}
|
||||
}
|
||||
|
||||
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
guard let molecules = json?.arrayForKey("molecules") as? [[String: Any]] else {
|
||||
return
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class MoleculeStackView: MFView {
|
||||
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, additionalData: additionalData)
|
||||
molecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
moleculesArray.append(molecule)
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ public class StandardFooterView: ViewConstrainingView {
|
||||
rightConstraintTextButton?.constant = constant
|
||||
}
|
||||
|
||||
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||
backgroundColor = .mfGet(forHex: colorString)
|
||||
}
|
||||
twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegate: delegate, additionalData: additionalData)
|
||||
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegate: delegate, additionalData: additionalData)
|
||||
twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +110,8 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
separatorView?.rightPin?.constant = constant
|
||||
}
|
||||
|
||||
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||
backgroundColor = .mfGet(forHex: colorString)
|
||||
}
|
||||
@ -123,11 +123,11 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
}
|
||||
|
||||
let headlineJSON = json?.optionalDictionaryForKey("headline")
|
||||
headlineLabel.setWithJSON(headlineJSON, delegate: delegate, additionalData: additionalData)
|
||||
headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let bodyJSON = json?.optionalDictionaryForKey("body")
|
||||
messageLabel.setWithJSON(bodyJSON, delegate: delegate, additionalData: additionalData)
|
||||
messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let separatorJSON = json?.optionalDictionaryForKey("separator")
|
||||
separatorView?.setWithJSON(separatorJSON, delegate: delegate, additionalData: additionalData)
|
||||
separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
if separatorView?.isHidden ?? true {
|
||||
bottomPin?.constant = 0
|
||||
|
||||
@ -39,14 +39,14 @@ import UIKit
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
|
||||
}
|
||||
let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton")
|
||||
let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton")
|
||||
set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, actionDelegate: delegate, additionalData: additionalData, buttonDelegate: delegate)
|
||||
set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
// MARK: - Constraining
|
||||
@ -142,32 +142,24 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
|
||||
open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON, legacy: false)
|
||||
setDefaultCustom()
|
||||
primaryButton?.setWithJSON(primaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData)
|
||||
secondaryButton?.setWithJSON(secondaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData)
|
||||
primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
secondaryButton?.setWithJSON(secondaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
// 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)
|
||||
public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
self.init()
|
||||
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
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, buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: AnyHashable]?) {
|
||||
self.init()
|
||||
setup(withButtonMap: buttonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.setAsSmall(small)
|
||||
secondaryButton?.setAsSmall(small)
|
||||
}
|
||||
|
||||
public convenience init(buttonSmall small: Bool, enabled: Bool) {
|
||||
@ -178,16 +170,24 @@ import UIKit
|
||||
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: buttonDelegate)
|
||||
primaryButton?.setAsSmall(small)
|
||||
secondaryButton?.setAsSmall(small)
|
||||
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true)
|
||||
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
} else if primaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.bordered = false
|
||||
} else if secondaryButtonMap != nil {
|
||||
primaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
primaryButton?.bordered = true
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton)
|
||||
let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton)
|
||||
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public func hidePrimaryLeftButton() {
|
||||
@ -229,3 +229,42 @@ import UIKit
|
||||
secondaryButton?.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Deprecate
|
||||
extension TwoButtonView {
|
||||
@available(*, deprecated)
|
||||
open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) {
|
||||
setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
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)
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
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: buttonDelegate)
|
||||
primaryButton?.setAsSmall(small)
|
||||
secondaryButton?.setAsSmall(small)
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
20
MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift
Normal file
20
MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// DelegateObject.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 4/12/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class MVMCoreUIDelegateObject: DelegateObject {
|
||||
public weak var formValidationProtocol: FormValidationProtocol?
|
||||
public weak var buttonDelegate: ButtonDelegateProtocol?
|
||||
|
||||
open override func setAll(withDelegate delegate: Any) {
|
||||
super.setAll(withDelegate: delegate)
|
||||
formValidationProtocol = delegate as? FormValidationProtocol
|
||||
buttonDelegate = delegate as? ButtonDelegateProtocol
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
@import MVMCore.MVMCoreLoggingHandler;
|
||||
@class MVMCoreTopAlertObject;
|
||||
@class MFViewController;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
@class DelegateObject;
|
||||
|
||||
@interface MVMCoreUIMoleculeMappingObject : NSObject
|
||||
|
||||
@ -19,6 +20,6 @@
|
||||
|
||||
// Returns the molecule for the given name.
|
||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)getMoleculeForName:(nonnull NSString *)name;
|
||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate;
|
||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
@end
|
||||
|
||||
@ -55,13 +55,13 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate {
|
||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject {
|
||||
NSString *moleculeName = [json string:@"moleculeName"];
|
||||
if (!moleculeName) {
|
||||
return nil;
|
||||
}
|
||||
UIView <MVMCoreUIMoleculeViewProtocol>*molecule = [self getMoleculeForName:moleculeName];
|
||||
[molecule setWithJSON:json delegate:delegate additionalData:nil];
|
||||
[molecule setWithJSON:json delegateObject:delegateObject additionalData:nil];
|
||||
return molecule;
|
||||
}
|
||||
|
||||
|
||||
@ -12,13 +12,13 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController {
|
||||
|
||||
public override func viewForMiddle() -> UIView? {
|
||||
let molecule = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack")
|
||||
let moleculeStack = MoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil)
|
||||
let moleculeStack = MoleculeStackView(withJSON: molecule, delegateObject: delegateObject(), additionalData: nil)
|
||||
return moleculeStack
|
||||
}
|
||||
|
||||
public override func viewForTop() -> UIView? {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"),
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else {
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else {
|
||||
return nil
|
||||
}
|
||||
return molecule
|
||||
@ -26,7 +26,7 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController {
|
||||
|
||||
override public func viewForBottom() -> UIView? {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"),
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else {
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else {
|
||||
return nil
|
||||
}
|
||||
return molecule
|
||||
|
||||
@ -16,7 +16,7 @@ public class MoleculeStackTemplate: ThreeLayerViewController {
|
||||
}
|
||||
|
||||
public override func viewForTop() -> UIView? {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else {
|
||||
return nil
|
||||
}
|
||||
return molecule
|
||||
@ -26,11 +26,11 @@ public class MoleculeStackTemplate: ThreeLayerViewController {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") else {
|
||||
return nil
|
||||
}
|
||||
return MoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil)
|
||||
return MoleculeStackView(withJSON: moleculeJSON, delegateObject: delegateObject(), additionalData: nil)
|
||||
}
|
||||
|
||||
override public func viewForBottom() -> UIView? {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else {
|
||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else {
|
||||
return nil
|
||||
}
|
||||
return molecule
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#import <MVMCore/MVMCoreTopAlertAnimationDelegateProtocol.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
|
||||
@class MVMCoreTopAlertObject;
|
||||
@class MFCustomButton;
|
||||
|
||||
@interface MVMCoreUITopAlertBaseView : MFView
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#import "MVMCoreUICommonViewsUtility.h"
|
||||
#import "MFStyler.h"
|
||||
#import "MVMCoreUISession.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
@import MVMCore.MVMCoreTopAlertDelegateProtocol;
|
||||
|
||||
@implementation MVMCoreUITopAlertBaseView
|
||||
@ -35,7 +37,7 @@
|
||||
}
|
||||
|
||||
if (performAction) {
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:[MVMCoreUISession sharedGlobal].topAlertView];
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]];
|
||||
}
|
||||
} forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#import <MVMCore/MVMCoreTopAlertAnimationDelegateProtocol.h>
|
||||
|
||||
@class PrimaryButton;
|
||||
@class MVMCoreTopAlertObject;
|
||||
|
||||
@interface MVMCoreUITopAlertMainView : MVMCoreUITopAlertBaseView
|
||||
|
||||
|
||||
@ -41,6 +41,9 @@
|
||||
- (void)expandStatusBarView;
|
||||
- (void)collapseStatusBarView;
|
||||
|
||||
/// reset status bar background color, when backgroundColor is nil corresponding background color will be set based on style
|
||||
- (void)resetDefaultBackgroundColor:(nullable UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style;
|
||||
|
||||
// Can be subclassed for custom views.
|
||||
- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor;
|
||||
|
||||
|
||||
@ -189,7 +189,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
||||
[weakSelf.superview layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
[weakSelf.animationDelegate topAlertViewFinishAnimation];
|
||||
[weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault];
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
|
||||
UIView *view = weakSelf.currentAlert;
|
||||
@ -204,6 +203,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
||||
[operation markAsFinished];
|
||||
completionHandler(finished);
|
||||
weakSelf.topAlertObject = nil;
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
[weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
@ -242,4 +244,18 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resetDefaultBackgroundColor:(UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style {
|
||||
if (!self.topAlertObject) {
|
||||
UIColor *defaultStatusBarBackgroundColor = backgroundColor;
|
||||
if (!defaultStatusBarBackgroundColor) {
|
||||
defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor];
|
||||
}
|
||||
|
||||
//color doesn't match the current default value
|
||||
if (!CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) {
|
||||
self.statusBarView.backgroundColor = defaultStatusBarBackgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user