This commit is contained in:
Suresh, Kamlesh 2019-06-10 11:44:08 -04:00
commit b216f7da43
32 changed files with 334 additions and 65 deletions

View File

@ -20,6 +20,8 @@
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; };
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E142280C4CF007245F4 /* ProgressBar.swift */; };
B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8200E182281DC1A007245F4 /* ProgressBarView.swift */; };
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; };
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
@ -40,6 +42,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 */; };
@ -186,6 +189,8 @@
01CA51B4229716F60071A6EE /* Switch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Switch.swift; sourceTree = "<group>"; };
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
B8200E142280C4CF007245F4 /* ProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = "<group>"; };
B8200E182281DC1A007245F4 /* ProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarView.swift; sourceTree = "<group>"; };
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = "<group>"; };
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
@ -206,6 +211,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>"; };
@ -466,6 +472,8 @@
D274CA322236A78900B01B62 /* StandardFooterView.swift */,
01004F2F22721C3800991ECC /* RadioButton.swift */,
D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */,
B8200E142280C4CF007245F4 /* ProgressBar.swift */,
B8200E182281DC1A007245F4 /* ProgressBarView.swift */,
0116A4E4228B19640094F3ED /* RadioButtonModel.swift */,
);
path = Molecules;
@ -670,6 +678,7 @@
D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */,
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */,
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */,
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */,
D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */,
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */,
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
@ -774,6 +783,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 */,
@ -919,6 +929,7 @@
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
B8200E152280C4CF007245F4 /* ProgressBar.swift in Sources */,
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
DBEFFA04225A829700230692 /* Label.swift in Sources */,
@ -972,6 +983,7 @@
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
B8200E192281DC1A007245F4 /* ProgressBarView.swift in Sources */,
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -10,7 +10,7 @@
import MVMCore
@objc open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
@objc open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
//------------------------------------------------------
// MARK: - Properties
//------------------------------------------------------
@ -295,14 +295,29 @@ import MVMCore
// MARK: - Atomization
//------------------------------------------------------
public func reset() {
text = nil
attributedText = nil
originalAttributedString = nil
styleB2(true)
}
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
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
}
}
extension Label {

View File

@ -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;

View File

@ -54,7 +54,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
return YES;
}
- (UIStackViewAlignment)moleculeAlignment {
- (UIStackViewAlignment)alignment {
return UIStackViewAlignmentLeading;
}

View File

@ -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];
}
}

View File

@ -145,6 +145,12 @@
}
}
- (void)reset {
if ([self.constrainedView respondsToSelector:@selector(reset)]) {
[self.constrainedView performSelector:@selector(reset)];
}
}
#pragma mark - MVMCoreUIMoleculeViewProtocol
- (void)setAsMolecule {

View File

@ -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

View File

@ -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];
}

View File

@ -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>

View File

@ -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: {

View File

@ -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

View File

@ -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),

View File

@ -0,0 +1,49 @@
//
// ProgressBar.swift
// MVMCoreUI
//
// Created by Panth Patel on 5/3/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public class ProgressBar: UIProgressView {
var isRounded = Bool()
var thickness : Float = 0.0 {
willSet(newValue) {
heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true
switch isRounded {
case true:
layer.cornerRadius = CGFloat(newValue/2)
clipsToBounds = true
default:
progressViewStyle = .bar
}
}
}
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
isRounded = json?.optionalBoolForKey("roundedRect") ?? false
thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0)
let percentage = json?.floatFromStringForKey("percent")
progress = (percentage ?? Float(0.0))/100
progressTintColor = UIColor.mfBattleshipGrey()
trackTintColor = UIColor.mfLighterGray()
if let progresscolor = json?.optionalStringForKey("progressColor") {
if !progresscolor.isEmpty {
progressTintColor = UIColor.mfGet(forHex: progresscolor)
}
}
if let backgroundcolor = json?.optionalStringForKey("backgroundColor") {
if !backgroundcolor.isEmpty {
trackTintColor = UIColor.mfGet(forHex: backgroundcolor)
}
}
}
}

View File

@ -0,0 +1,99 @@
//
// ProgressBarView.swift
// MVMCoreUI
//
// Created by Panth Patel on 5/3/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class ProgressBarView: ViewConstrainingView {
var progress = ProgressBar()
var topleftlabel = Label()
var toprightlabel = Label()
var bottomleftlabel = Label()
var bottomrightlabel = Label()
open override func needsToBeConstrained() -> Bool {
return true
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
progress.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
let topleftlabeljson = json?.optionalDictionaryForKey("label")
let toprightlabeljson = json?.optionalDictionaryForKey("toprightlabel")
let bottomleftlabeljson = json?.optionalDictionaryForKey("bottomleftlabel")
let bottomrightlabeljson = json?.optionalDictionaryForKey("bottomrightlabel")
topleftlabel.setWithJSON(topleftlabeljson, delegateObject: delegateObject, additionalData: additionalData)
toprightlabel.setWithJSON(toprightlabeljson, delegateObject: delegateObject, additionalData: additionalData)
bottomleftlabel.setWithJSON(bottomleftlabeljson, delegateObject: delegateObject, additionalData: additionalData)
bottomrightlabel.setWithJSON(bottomrightlabeljson, delegateObject: delegateObject, additionalData: additionalData)
}
override open func setupView() {
super.setupView()
addSubview(topleftlabel)
addSubview(toprightlabel)
addSubview(bottomleftlabel)
addSubview(bottomrightlabel)
addSubview(progress)
progress.translatesAutoresizingMaskIntoConstraints = false
topleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
topleftlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
let topleftwidthconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
topleftwidthconstraint.priority = UILayoutPriority(100)
topleftwidthconstraint.isActive = true
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal)
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical)
NSLayoutConstraint(item: toprightlabel, attribute: .leading, relatedBy: .equal, toItem: topleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true
toprightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
toprightlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
toprightlabel.textAlignment = .right
toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal)
toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical)
var topconstraint = progress.topAnchor.constraint(equalTo: topleftlabel.bottomAnchor, constant: PaddingTwo)
topconstraint.priority = UILayoutPriority(249)
topconstraint.isActive = true
progress.topAnchor.constraint(greaterThanOrEqualTo: topleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true
topconstraint = progress.topAnchor.constraint(equalTo: toprightlabel.bottomAnchor, constant: PaddingTwo)
topconstraint.priority = UILayoutPriority(249)
topconstraint.isActive = true
progress.topAnchor.constraint(greaterThanOrEqualTo: toprightlabel.bottomAnchor, constant: PaddingTwo).isActive = true
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
bottomleftlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
bottomleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
let bottomleftwidthconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
bottomleftwidthconstraint.priority = UILayoutPriority(100)
bottomleftwidthconstraint.isActive = true
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal)
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical)
NSLayoutConstraint(item: bottomrightlabel, attribute: .leading, relatedBy: .equal, toItem: bottomleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true
bottomrightlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
bottomrightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
bottomrightlabel.textAlignment = .right
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal)
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical)
var bottomconstraint = bottomAnchor.constraint(equalTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo)
bottomconstraint.priority = UILayoutPriority(249)
bottomconstraint.isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo).isActive = true
bottomconstraint = bottomAnchor.constraint(equalTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo)
bottomconstraint.priority = UILayoutPriority(249)
bottomconstraint.isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: bottomrightlabel.bottomAnchor, constant: PaddingTwo).isActive = true
}
}

View File

@ -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()
}
}

View File

@ -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

View File

@ -80,7 +80,7 @@ import UIKit
return true
}
public override func moleculeAlignment() -> UIStackView.Alignment {
public override func alignment() -> UIStackView.Alignment {
return UIStackView.Alignment.leading
}
}

View File

@ -113,7 +113,7 @@ import UIKit
return true
}
public override func moleculeAlignment() -> UIStackView.Alignment {
public override func alignment() -> UIStackView.Alignment {
return UIStackView.Alignment.leading
}
}

View File

@ -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()

View File

@ -13,6 +13,7 @@
#import "MVMCoreUIObject.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>
#import "MFTextField.h"
#import "MVMCoreUIViewConstrainingProtocol.h"
@implementation MVMCoreUIMoleculeMappingObject
@ -27,12 +28,16 @@
@"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,
@"checkbox" : MVMCoreUICheckBox.class,
@"progressBarView" : ProgressBarView.class,
@"progressBar": ProgressBar.class,
@"textField": MFTextField.class,
@"checkbox": MVMCoreUICheckBox.class,
@"radioButton": RadioButton.class,
@ -83,8 +88,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;

View 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

View File

@ -94,6 +94,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

View File

@ -92,12 +92,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);
}
}];
}

View File

@ -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)
}