Merge branch 'develop' into feature/kevin
# Conflicts: # MVMCoreUI/Atoms/Views/Label.swift
This commit is contained in:
commit
8ebcef3a60
@ -38,6 +38,7 @@
|
||||
D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D296E143229729C30051EBE7 /* MoleculeMappingObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */; };
|
||||
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
|
||||
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */; };
|
||||
@ -203,6 +204,7 @@
|
||||
D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = "<group>"; };
|
||||
D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = "<group>"; };
|
||||
D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MoleculeMappingObject+Extension.swift"; sourceTree = "<group>"; };
|
||||
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
|
||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
|
||||
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
|
||||
D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsTableViewController.m; sourceTree = "<group>"; };
|
||||
@ -667,6 +669,7 @@
|
||||
D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */,
|
||||
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */,
|
||||
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */,
|
||||
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */,
|
||||
D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */,
|
||||
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */,
|
||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
|
||||
@ -771,6 +774,7 @@
|
||||
D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */,
|
||||
D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */,
|
||||
D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */,
|
||||
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */,
|
||||
D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */,
|
||||
D29DF25721E6A177003B2FB9 /* MFTextField.h in Headers */,
|
||||
D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */,
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
|
||||
open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
|
||||
open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Constants
|
||||
@ -136,7 +136,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
|
||||
return true
|
||||
}
|
||||
|
||||
open func moleculeAlignment() -> UIStackView.Alignment {
|
||||
open func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
@class MFSizeObject;
|
||||
|
||||
@interface MFTextButton : MFCustomButton <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
@interface MFTextButton : MFCustomButton <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||
|
||||
@property (nonnull, strong, nonatomic) MFSizeObject *sizeObject;
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#import "UIColor+MFConvenience.h"
|
||||
#import "MVMCoreUISplitViewController.h"
|
||||
#import "MVMCoreUIConstants.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
@import MVMCore.MVMCoreGetterUtility;
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
@ -54,7 +55,7 @@
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.contentMode = UIViewContentModeRedraw;
|
||||
[self setTitleColor:[UIColor mfTextButtonColor] forState:UIControlStateNormal];
|
||||
[self setTitleColor:[UIColor mfTextButtonColorHighlighted] forState:UIControlStateHighlighted];
|
||||
[self setTitleColor:[UIColor mfCharcoalColor] forState:UIControlStateHighlighted];
|
||||
// left alignment by default
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
||||
@ -128,6 +129,10 @@
|
||||
|
||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
- (void)reset {
|
||||
[self setTitleColor:[UIColor mfTextButtonColor] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
NSString *color = [json string:KeyTextColor];
|
||||
if (color) {
|
||||
@ -141,11 +146,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MVMCoreUIViewConstrainingProtocol
|
||||
|
||||
- (BOOL)needsToBeConstrained {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (UIStackViewAlignment)moleculeAlignment {
|
||||
- (UIStackViewAlignment)alignment {
|
||||
return UIStackViewAlignmentLeading;
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ typedef enum : NSUInteger {
|
||||
static CGFloat const PrimaryButtonHeight = 42.0;
|
||||
static CGFloat const PrimaryButtonSmallHeight = 30.0;
|
||||
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||
|
||||
@property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set
|
||||
|
||||
|
||||
@ -328,7 +328,18 @@
|
||||
if (self.skipHighlighted) {
|
||||
return;
|
||||
}
|
||||
if (self.primaryButtonType == PrimaryButtonTypeRed) {
|
||||
if (self.primaryButtonType == PrimaryButtonTypeCustom) {
|
||||
if (highlighted && self.enabled) {
|
||||
CALayer *mask = [[CALayer alloc] init];
|
||||
mask.backgroundColor = [UIColor whiteColor].CGColor;
|
||||
mask.opacity = 0.7;
|
||||
mask.frame = self.bounds;
|
||||
self.layer.mask = mask;
|
||||
self.layer.opaque = true;
|
||||
} else if (!highlighted) {
|
||||
self.layer.mask = nil;
|
||||
}
|
||||
} if (self.primaryButtonType == PrimaryButtonTypeRed) {
|
||||
if (self.bordered) {
|
||||
if (highlighted) {
|
||||
self.backgroundColor = [UIColor mfRedColor];
|
||||
@ -485,11 +496,12 @@
|
||||
[self setTitleColor:(self.disabledTextColor ?: [UIColor blackColor]) forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
[self setTitleColor:[self titleColorForState:UIControlStateNormal] forState:UIControlStateHighlighted];
|
||||
}
|
||||
|
||||
- (void)setBordered:(BOOL)bordered {
|
||||
if (bordered != _bordered) {
|
||||
if (self.buttonType == PrimaryButtonTypeCustom) {
|
||||
if (self.primaryButtonType == PrimaryButtonTypeCustom) {
|
||||
_bordered = bordered;
|
||||
[self setAsCustom];
|
||||
} else if (bordered) {
|
||||
@ -626,11 +638,16 @@
|
||||
|
||||
#pragma mark - Molecule protocol
|
||||
|
||||
- (void)reset {
|
||||
[self setAsStandardCustom];
|
||||
}
|
||||
|
||||
- (void)setAsStandardCustom {
|
||||
// Default to standard look.
|
||||
self.primaryButtonType = PrimaryButtonTypeCustom;
|
||||
self.fillColor = [UIColor blackColor];
|
||||
self.textColor = [UIColor whiteColor];
|
||||
self.disabledTextColor = self.textColor;
|
||||
self.borderColor = nil;
|
||||
_bordered = false;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
#import <MVMCoreUI/ViewConstrainingView.h>
|
||||
|
||||
@class PrimaryButton;
|
||||
@class MFTextField;
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface MFTextField : MFView <MVMCoreUIMoleculeViewProtocol>
|
||||
@interface MFTextField : ViewConstrainingView <MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nullable, weak, nonatomic) UIView *view;
|
||||
|
||||
|
||||
@ -40,17 +40,12 @@
|
||||
#pragma mark - setup
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
[super updateView:size];
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
self.formLabel.font = [MFStyler fontB3];
|
||||
self.label.font = [MFStyler fontForTextFieldUnderLabel];
|
||||
[MFStyler styleTextField:self.textField];
|
||||
[self.dashLine updateView:size];
|
||||
|
||||
if (self.isMolecule) {
|
||||
[self setHorizontalPadding:[MFStyler defaultHorizontalPaddingForSize:size]];
|
||||
} else {
|
||||
[self setHorizontalPadding:0];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -373,14 +368,16 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setHorizontalPadding:(CGFloat)padding {
|
||||
self.textContainerLeftPin.constant = padding;
|
||||
self.errorLableLeftPin.constant = padding;
|
||||
self.formLabelLeftPin.constant = padding;
|
||||
|
||||
self.textContainerRightPin.constant = padding;
|
||||
self.errorLableRightPin.constant = padding;
|
||||
self.formLabelRightPin.constant = padding;
|
||||
- (void)setLeftPinConstant:(CGFloat)constant {
|
||||
self.textContainerLeftPin.constant = constant;
|
||||
self.errorLableLeftPin.constant = constant;
|
||||
self.formLabelLeftPin.constant = constant;
|
||||
}
|
||||
|
||||
- (void)setRightPinConstant:(CGFloat)constant {
|
||||
self.textContainerRightPin.constant = constant;
|
||||
self.errorLableRightPin.constant = constant;
|
||||
self.formLabelRightPin.constant = constant;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
|
||||
@ -133,7 +133,7 @@ open class CaretView: MFView {
|
||||
return true
|
||||
}
|
||||
|
||||
open override func moleculeAlignment() -> UIStackView.Alignment {
|
||||
open override func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ import MVMCore
|
||||
public typealias ActionBlock = () -> Void
|
||||
|
||||
|
||||
@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MFButtonProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
|
||||
//------------------------------------------------------
|
||||
// MARK: - General Properties
|
||||
//------------------------------------------------------
|
||||
@ -26,7 +26,7 @@ public typealias ActionBlock = () -> Void
|
||||
public var sizeObject: MFSizeObject?
|
||||
public var scaleSize: NSNumber?
|
||||
|
||||
/// Used for scaling the font in updateView.
|
||||
// Used for scaling the font in updateView.
|
||||
private var originalAttributedString: NSAttributedString?
|
||||
|
||||
public var hasText: Bool {
|
||||
@ -334,15 +334,30 @@ public typealias ActionBlock = () -> Void
|
||||
// MARK: - Atomization
|
||||
extension Label {
|
||||
|
||||
public func reset() {
|
||||
text = nil
|
||||
attributedText = nil
|
||||
originalAttributedString = nil
|
||||
styleB2(true)
|
||||
}
|
||||
|
||||
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
clauses = []
|
||||
Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData)
|
||||
originalAttributedString = attributedText
|
||||
}
|
||||
|
||||
public func setAsMolecule() {
|
||||
setContentHuggingPriority(.required, for: .vertical)
|
||||
}
|
||||
|
||||
public func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
public func alignment() -> UIStackView.Alignment {
|
||||
return .leading
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Multi-Action Functionality
|
||||
|
||||
@ -8,9 +8,10 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
#import <MVMCoreUI/MVMCoreUIViewConstrainingProtocol.h>
|
||||
@import MVMCore.MVMCoreViewProtocol;
|
||||
|
||||
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *json;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (UIStackViewAlignment)moleculeAlignment {
|
||||
- (UIStackViewAlignment)alignment {
|
||||
return UIStackViewAlignmentLeading;
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +70,10 @@
|
||||
|
||||
#pragma mark - set up
|
||||
|
||||
- (void)reset {
|
||||
[self setAsLight];
|
||||
}
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
[super updateView:size];
|
||||
self.height.constant = [self.heightSizeObject getValueBasedOnSize:size];
|
||||
@ -107,7 +111,7 @@
|
||||
[self setAsMedium];
|
||||
} else if ([type isEqualToString:@"heavy"]) {
|
||||
[self setAsHeavy];
|
||||
} else {
|
||||
} else if ([type isEqualToString:@"standard"]) {
|
||||
[self setAsLight];
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,6 +145,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reset {
|
||||
if ([self.constrainedView respondsToSelector:@selector(reset)]) {
|
||||
[self.constrainedView performSelector:@selector(reset)];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
- (void)setAsMolecule {
|
||||
|
||||
@ -12,11 +12,9 @@
|
||||
|
||||
#pragma mark - 2.0
|
||||
|
||||
+ (nonnull UIColor *)mfNegativeOrangeColor;
|
||||
+ (nonnull UIColor *)mfSwitchOnTintColor;
|
||||
+ (nonnull UIColor *)mfSwitchOffTintColor;
|
||||
+ (nonnull UIColor *)mfSilver;
|
||||
+ (nonnull UIColor *)mfSilverTwo;
|
||||
+ (nonnull UIColor *)mfBattleshipGrey;
|
||||
+ (nonnull UIColor *)mfPrimaryButtonHighlightBlackColor;
|
||||
+ (nonnull UIColor *)mfPrimaryWhiteButtonDisableColor;
|
||||
@ -26,7 +24,6 @@
|
||||
+ (nonnull UIColor *)mfPumpkinColor;
|
||||
+ (nonnull UIColor *)mfShamrock;
|
||||
+ (nonnull UIColor *)mfCerulean;
|
||||
+ (nonnull UIColor *)mfLightBlackColor;
|
||||
+ (nonnull UIColor *)mfWhiteTwo;
|
||||
|
||||
#pragma mark - legacy
|
||||
|
||||
@ -13,10 +13,6 @@
|
||||
|
||||
#pragma mark - 2.0
|
||||
|
||||
+ (nonnull UIColor *)mfNegativeOrangeColor {
|
||||
return [UIColor mfPumpkinColor];
|
||||
}
|
||||
|
||||
+ (nonnull UIColor *)mfSwitchOnTintColor {
|
||||
return [UIColor mfShamrock];
|
||||
}
|
||||
@ -29,10 +25,6 @@
|
||||
return [UIColor mfColor8bitsWithRed:216 green:218 blue:218 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (nonnull UIColor *)mfSilverTwo {
|
||||
return [UIColor mfColor8bitsWithRed:217 green:219 blue:219 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (nonnull UIColor *)mfBattleshipGrey {
|
||||
return [UIColor mfColor8bitsWithRed:116 green:118 blue:118 alpha:1.0];
|
||||
}
|
||||
@ -70,10 +62,6 @@
|
||||
return [UIColor mfColor8bitsWithRed:0 green:122 blue:184 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (nonnull UIColor *)mfLightBlackColor {
|
||||
return [UIColor mfColor8bitsWithRed:95 green:95 blue:95 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (nonnull UIColor *)mfWhiteTwo {
|
||||
return [UIColor mfColor8bitsWithRed:246 green:246 blue:246 alpha:1.0];
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
|
||||
#import <MVMCoreUI/MVMCoreUISession.h>
|
||||
#import <MVMCoreUI/MVMCoreUILoggingHandler.h>
|
||||
#import <MVMCoreUI/MVMCoreUIViewControllerMappingObject.h>
|
||||
#import <MVMCoreUI/MVMCoreUIViewConstrainingProtocol.h>
|
||||
#import <MVMCoreUI/MoleculeDelegateProtocol.h>
|
||||
#import <MVMCoreUI/MoleculeListCellProtocol.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeMappingObject.h>
|
||||
|
||||
@ -39,6 +39,10 @@ import UIKit
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
open override func reset() {
|
||||
primaryButton?.reset()
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||
|
||||
@ -12,21 +12,19 @@
|
||||
|
||||
@protocol MVMCoreUIMoleculeViewProtocol <NSObject, MVMCoreViewProtocol>
|
||||
|
||||
// Sets up the ui based on the json
|
||||
/// Sets up the ui based on the json
|
||||
- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||
|
||||
@optional
|
||||
|
||||
// Called after init to provide an early setter for any molecule specific logic
|
||||
/// Called after init to provide an early setter for any molecule specific logic
|
||||
- (void)setAsMolecule;
|
||||
|
||||
// Notifies the creator that the view needs to be constrained in a view.
|
||||
- (BOOL)needsToBeConstrained;
|
||||
/// Resets to default state before set with json is called again.
|
||||
- (void)reset;
|
||||
|
||||
// The alignment for the molecule if constrained.
|
||||
- (UIStackViewAlignment)moleculeAlignment;
|
||||
|
||||
// For the molecule list to load more efficiently.
|
||||
/// For the molecule list to load more efficiently.
|
||||
+ (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json;
|
||||
|
||||
@end
|
||||
|
||||
@ -41,7 +41,7 @@ import UIKit
|
||||
|
||||
// MARK: - MFViewProtocol
|
||||
public func updateView(_ size: CGFloat) {
|
||||
MFStyler.setDefaultMarginsFor(self, size: size)
|
||||
MFStyler.setDefaultMarginsFor(self, size: size, horizontal: true, vertical: true)
|
||||
if #available(iOS 11.0, *) {
|
||||
contentView.directionalLayoutMargins = directionalLayoutMargins
|
||||
topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
|
||||
@ -75,7 +75,16 @@ import UIKit
|
||||
if molecule == nil {
|
||||
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) {
|
||||
contentView.addSubview(moleculeView)
|
||||
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: moleculeView.needsToBeConstrained?() ?? false).values))
|
||||
let standardConstraints = (moleculeView as? MVMCoreUIViewConstrainingProtocol)?.useStandardConstraints?() ?? true
|
||||
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: standardConstraints).values))
|
||||
if standardConstraints {
|
||||
let constraint = contentView.heightAnchor.constraint(equalToConstant: 80)
|
||||
constraint.priority = .defaultLow
|
||||
constraint.isActive = true
|
||||
if let moleculeView = moleculeView as? ViewConstrainingView {
|
||||
moleculeView.updateViewHorizontalDefaults = false
|
||||
}
|
||||
}
|
||||
molecule = moleculeView
|
||||
}
|
||||
} else {
|
||||
@ -97,6 +106,10 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public func reset() {
|
||||
molecule?.reset?()
|
||||
}
|
||||
|
||||
public static func estimatedHeight(forRow json: [AnyHashable : Any]?) -> CGFloat {
|
||||
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule),
|
||||
let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON, delegateObject: nil),
|
||||
|
||||
@ -101,4 +101,9 @@ public class StandardFooterView: ViewConstrainingView {
|
||||
twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public override func reset() {
|
||||
twoButtonView.reset()
|
||||
textButton.reset()
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
var rightConstraintMessage: NSLayoutConstraint?
|
||||
private var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
headlineLabel.updateView(size)
|
||||
@ -41,7 +42,7 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
messageLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||
setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
|
||||
|
||||
topPin = headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFive)
|
||||
topPin = headlineLabel.topAnchor.constraint(equalTo: topAnchor, constant: PaddingDefaultVerticalSpacing)
|
||||
topPin?.isActive = true
|
||||
|
||||
spaceBetweenLabels = messageLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: PaddingTwo)
|
||||
@ -74,6 +75,7 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Constraining
|
||||
public func setSpacing() {
|
||||
if headlineLabel.hasText && messageLabel.hasText {
|
||||
spaceBetweenLabels?.constant = PaddingTwo
|
||||
@ -110,6 +112,15 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
separatorView?.rightPin?.constant = constant
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
backgroundColor = .clear
|
||||
headlineLabel.styleH2(true)
|
||||
messageLabel.styleB2(true)
|
||||
separatorView?.setAsHeavy()
|
||||
separatorView?.show()
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let colorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||
@ -126,8 +137,9 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let bodyJSON = json?.optionalDictionaryForKey("body")
|
||||
messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let separatorJSON = json?.optionalDictionaryForKey("separator")
|
||||
separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
|
||||
separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
if separatorView?.isHidden ?? true {
|
||||
bottomPin?.constant = 0
|
||||
|
||||
@ -80,7 +80,7 @@ import UIKit
|
||||
return true
|
||||
}
|
||||
|
||||
public override func moleculeAlignment() -> UIStackView.Alignment {
|
||||
public override func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ import UIKit
|
||||
return true
|
||||
}
|
||||
|
||||
public override func moleculeAlignment() -> UIStackView.Alignment {
|
||||
public override func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,11 @@ import UIKit
|
||||
set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
secondaryButton?.setAsSecondaryCustom()
|
||||
}
|
||||
|
||||
// MARK: - Constraining
|
||||
override func setupButton() {
|
||||
setupWithTwoButtons()
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#import "MVMCoreUIObject.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
#import "MFTextField.h"
|
||||
#import "MVMCoreUIViewConstrainingProtocol.h"
|
||||
|
||||
@implementation MVMCoreUIMoleculeMappingObject
|
||||
|
||||
@ -27,10 +28,10 @@
|
||||
@"separator": SeparatorView.class,
|
||||
@"button": ButtonView.class,
|
||||
@"textButton": MFTextButton.class,
|
||||
@"standardHeader": StandardHeaderView.class,
|
||||
@"header": StandardHeaderView.class,
|
||||
@"moleculeStack": MoleculeStackView.class,
|
||||
@"twoButtonView": TwoButtonView.class,
|
||||
@"standardFooter": StandardFooterView.class,
|
||||
@"footer": StandardFooterView.class,
|
||||
@"caretView": CaretView.class,
|
||||
@"caretButton": CaretButton.class,
|
||||
@"textField": MFTextField.class,
|
||||
@ -82,8 +83,11 @@
|
||||
return nil;
|
||||
}
|
||||
UIView <MVMCoreUIMoleculeViewProtocol>*molecule = [self createMoleculeForName:moleculeName];
|
||||
if (constrainIfNeeded && [molecule respondsToSelector:@selector(needsToBeConstrained)] && [molecule needsToBeConstrained]) {
|
||||
molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[molecule respondsToSelector:@selector(moleculeAlignment)] ? [molecule moleculeAlignment] : UIStackViewAlignmentFill];
|
||||
|
||||
// Check if we need to constrain this view.
|
||||
UIView <MVMCoreUIViewConstrainingProtocol> *castMolecule = [molecule conformsToProtocol:@protocol(MVMCoreUIViewConstrainingProtocol)] ? (UIView <MVMCoreUIViewConstrainingProtocol> *)molecule : nil;
|
||||
if (constrainIfNeeded && [castMolecule respondsToSelector:@selector(needsToBeConstrained)] && [castMolecule needsToBeConstrained]) {
|
||||
molecule = [[ViewConstrainingView alloc] initWithMolecule:molecule alignment:[castMolecule respondsToSelector:@selector(alignment)] ? [castMolecule alignment] : UIStackViewAlignmentFill];
|
||||
}
|
||||
[molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:nil];
|
||||
return molecule;
|
||||
|
||||
24
MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h
Normal file
24
MVMCoreUI/OtherHandlers/MVMCoreUIViewConstrainingProtocol.h
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// MVMCoreUIViewConstrainingProtocol.h
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 6/3/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@protocol MVMCoreUIViewConstrainingProtocol <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/// Notifies the creator that the view may not be suitable to be shown on its own and it needs to be added to a view to help with layout.
|
||||
- (BOOL)needsToBeConstrained;
|
||||
|
||||
/// The alignment if constrained.
|
||||
- (UIStackViewAlignment)alignment;
|
||||
|
||||
/// Can be used to override any standard constraints that may be added.
|
||||
- (BOOL)useStandardConstraints;
|
||||
|
||||
@end
|
||||
@ -91,6 +91,7 @@ B3 -> Legal
|
||||
+ (CGFloat)defaultHorizontalPaddingForSize:(CGFloat)size;
|
||||
+ (CGFloat)defaultVerticalPaddingForSize:(CGFloat)size;
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size;
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size horizontal:(BOOL)horizontal vertical:(BOOL)vertical;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Returns the fonts for these styles. Scales them as needed by default
|
||||
|
||||
@ -91,12 +91,17 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size {
|
||||
[self setDefaultMarginsForView:view size:size horizontal:YES vertical:NO];
|
||||
}
|
||||
|
||||
+ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size horizontal:(BOOL)horizontal vertical:(BOOL)vertical {
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
CGFloat padding = [MFStyler defaultHorizontalPaddingForSize:size];
|
||||
CGFloat horizontalPadding = horizontal ? [MFStyler defaultHorizontalPaddingForSize:size] : 0;
|
||||
CGFloat verticalPadding = vertical ? PaddingDefaultVerticalSpacing : 0;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(0, padding, 0, padding);
|
||||
view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(verticalPadding, horizontalPadding, verticalPadding, horizontalPadding);
|
||||
} else {
|
||||
view.layoutMargins = UIEdgeInsetsMake(0, padding, 0, padding);
|
||||
view.layoutMargins = UIEdgeInsetsMake(verticalPadding, horizontalPadding, verticalPadding, horizontalPadding);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -85,6 +85,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController {
|
||||
protocolCell.setSeparatorWithJSON?(loadObject?.pageJSON?.optionalDictionaryForKey("separator"), delegateObject: delegate, additionalData: nil, indexPath: indexPath)
|
||||
}
|
||||
if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol {
|
||||
protocolCell.reset?()
|
||||
protocolCell.setWithJSON(molecule.molecule, delegateObject: delegate, additionalData: nil)
|
||||
protocolCell.updateView(tableView.bounds.width)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user