Merge branch 'feature/switches' into 'develop'

Feature/switches

See merge request BPHV_MIPS/mvm_core_ui!119
This commit is contained in:
Pfeil, Scott Robert 2019-08-29 12:44:53 -04:00
commit 740aaf09e0
24 changed files with 495 additions and 253 deletions

View File

@ -10,11 +10,10 @@
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; };
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; };
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; };
016A1071228122180009D605 /* SwitchLineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016A1070228122180009D605 /* SwitchLineItem.swift */; };
016A1071228122180009D605 /* HeadlineBodyTextButtonSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */; };
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
01CA51B5229716F60071A6EE /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CA51B4229716F60071A6EE /* Switch.swift */; };
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, ); }; };
@ -24,6 +23,10 @@
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 */; };
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; };
D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */; };
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */; };
D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */; };
D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; };
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */; };
D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -189,11 +192,10 @@
0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; };
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; };
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
016A1070228122180009D605 /* SwitchLineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchLineItem.swift; sourceTree = "<group>"; };
016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButtonSwitch.swift; sourceTree = "<group>"; };
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
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>"; };
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
@ -202,6 +204,10 @@
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>"; };
D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = "<group>"; };
D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodySwitch.swift; sourceTree = "<group>"; };
D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = "<group>"; };
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyTextButton.swift; sourceTree = "<group>"; };
D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckBox.h; sourceTree = "<group>"; };
D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckBox.m; sourceTree = "<group>"; };
D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckMarkView.h; sourceTree = "<group>"; };
@ -391,6 +397,61 @@
path = FormUIHelpers;
sourceTree = "<group>";
};
D224798823142BF2003FCCF9 /* SwitchMolecules */ = {
isa = PBXGroup;
children = (
D22479892314445E003FCCF9 /* LabelSwitch.swift */,
D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */,
016A1070228122180009D605 /* HeadlineBodyTextButtonSwitch.swift */,
);
path = SwitchMolecules;
sourceTree = "<group>";
};
D224798D2316A988003FCCF9 /* VerticalCombinationViews */ = {
isa = PBXGroup;
children = (
D2A638FC22CA98280052ED1F /* HeadlineBody.swift */,
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */,
);
path = VerticalCombinationViews;
sourceTree = "<group>";
};
D224798E2316A995003FCCF9 /* HorizontalCombinationViews */ = {
isa = PBXGroup;
children = (
D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */,
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
);
path = HorizontalCombinationViews;
sourceTree = "<group>";
};
D224798F2316A99F003FCCF9 /* LeftRightViews */ = {
isa = PBXGroup;
children = (
D224798823142BF2003FCCF9 /* SwitchMolecules */,
B8200E182281DC1A007245F4 /* CornerLabels.swift */,
);
path = LeftRightViews;
sourceTree = "<group>";
};
D22479902316A9CB003FCCF9 /* Organisms */ = {
isa = PBXGroup;
children = (
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
D2A6390022CBB1820052ED1F /* Carousel.swift */,
);
path = Organisms;
sourceTree = "<group>";
};
D22479912316A9EF003FCCF9 /* Items */ = {
isa = PBXGroup;
children = (
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */,
);
path = Items;
sourceTree = "<group>";
};
D22D1F582204D2590077CEC0 /* LegacyControllers */ = {
isa = PBXGroup;
children = (
@ -436,6 +497,7 @@
D29DF11E21E6851E003B2FB9 /* TopAlert */,
D29DF10D21E67A70003B2FB9 /* Atoms */,
D29DF10E21E67A77003B2FB9 /* Molecules */,
D22479902316A9CB003FCCF9 /* Organisms */,
D29DF0DF21E418B2003B2FB9 /* Templates */,
D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */,
D29DF0D021E404D4003B2FB9 /* Info.plist */,
@ -478,30 +540,19 @@
D29DF10E21E67A77003B2FB9 /* Molecules */ = {
isa = PBXGroup;
children = (
D22479912316A9EF003FCCF9 /* Items */,
D224798F2316A99F003FCCF9 /* LeftRightViews */,
D224798E2316A995003FCCF9 /* HorizontalCombinationViews */,
D224798D2316A988003FCCF9 /* VerticalCombinationViews */,
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */,
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */,
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */,
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
D282AACA2243C61700C46919 /* ButtonView.swift */,
016A1070228122180009D605 /* SwitchLineItem.swift */,
01CA51B4229716F60071A6EE /* Switch.swift */,
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
D2A514662213885800345BFB /* StandardHeaderView.swift */,
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
D274CA322236A78900B01B62 /* StandardFooterView.swift */,
D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */,
B8200E142280C4CF007245F4 /* ProgressBar.swift */,
B8200E182281DC1A007245F4 /* CornerLabels.swift */,
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
D2A638FC22CA98280052ED1F /* HeadlineBody.swift */,
D2A6390022CBB1820052ED1F /* Carousel.swift */,
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */,
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */,
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */,
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,
D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */,
);
path = Molecules;
sourceTree = "<group>";
@ -534,6 +585,7 @@
D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */,
D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */,
D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */,
D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */,
);
path = Categories;
sourceTree = "<group>";
@ -612,6 +664,7 @@
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */,
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
D282AACA2243C61700C46919 /* ButtonView.swift */,
D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */,
D29DF17221E69E1F003B2FB9 /* MFTextButton.m */,
);
@ -621,6 +674,10 @@
D29DF17D21E69E26003B2FB9 /* Views */ = {
isa = PBXGroup;
children = (
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */,
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */,
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */,
B8200E142280C4CF007245F4 /* ProgressBar.swift */,
DBC4391622442196001AB423 /* CaretView.swift */,
DBC4391722442197001AB423 /* DashLine.swift */,
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */,
@ -943,6 +1000,7 @@
D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */,
D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */,
DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */,
D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */,
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
@ -967,9 +1025,11 @@
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */,
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */,
D2E1FADD2268B25E00AEFD8C /* MoleculeTableViewCell.swift in Sources */,
D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */,
D29DF18121E69E50003B2FB9 /* MFView.m in Sources */,
@ -986,12 +1046,13 @@
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */,
016A1071228122180009D605 /* SwitchLineItem.swift in Sources */,
016A1071228122180009D605 /* HeadlineBodyTextButtonSwitch.swift in Sources */,
D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */,
D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */,
D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */,
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */,
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */,
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */,
D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */,
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
@ -1009,7 +1070,6 @@
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
01CA51B5229716F60071A6EE /* Switch.swift in Sources */,
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,

View File

@ -8,10 +8,11 @@
#import <UIKit/UIKit.h>
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
@import MVMCore.MVMCoreViewProtocol;
typedef void(^ValueChangeBlock)(void);
@interface MVMCoreUISwitch : UIControl <MVMCoreViewProtocol>
@interface MVMCoreUISwitch : UIControl <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
@property (assign, nonatomic, getter=isOn) BOOL on;
@property (nullable, strong, nonatomic) UIColor *onTintColor;
@ -23,8 +24,8 @@ typedef void(^ValueChangeBlock)(void);
@property (nonatomic) BOOL shouldTouchToSwitch;
@property (nullable, copy, nonatomic) ValueChangeBlock valueChangedBlock;
+ (nullable instancetype)mvmSwitchDefault;
+ (nullable instancetype)mvmSwitchDefaultWithValueChangeBlock:(nullable ValueChangeBlock)block;
+ (nonnull instancetype)mvmSwitchDefault;
+ (nonnull instancetype)mvmSwitchDefaultWithValueChangeBlock:(nullable ValueChangeBlock)block;
- (void)setState:(BOOL)state animated:(BOOL)animated;

View File

@ -14,6 +14,7 @@
#import <MVMCoreUI/UIColor+MFConvenience.h>
#import <MVMCoreUI/MVMCoreUICommonViewsUtility.h>
#import <MVMCoreUI/MVMCoreUIUtility.h>
#import <MVMCoreUI/MVMCoreUI-Swift.h>
const CGFloat SwitchWidth = 42;
const CGFloat SwitchHeight = 22;
@ -21,7 +22,7 @@ const CGFloat SwitchKnobWidth = 20;
const CGFloat SwitchKnobHeight = 20;
const CGFloat SwitchShakeIntensity = 2;
@interface MVMCoreUISwitch ()
@interface MVMCoreUISwitch () <FormValidationProtocol, MVMCoreUIViewConstrainingProtocol>
@property (weak, nonatomic) UIView *baseView;
@property (weak, nonatomic) UIView *knobView;
@ -37,6 +38,9 @@ const CGFloat SwitchShakeIntensity = 2;
@property (nonatomic) BOOL canChangeValue;
@property (strong, nonatomic, nullable) NSDictionary *json;
@property (nullable, strong, nonatomic) DelegateObject *delegate;
@end
@implementation MVMCoreUISwitch
@ -86,7 +90,7 @@ const CGFloat SwitchShakeIntensity = 2;
return mySwitch;
}
+ (nullable instancetype)mvmSwitchDefaultWithValueChangeBlock:(nullable ValueChangeBlock)block {
+ (nonnull instancetype)mvmSwitchDefaultWithValueChangeBlock:(nullable ValueChangeBlock)block {
MVMCoreUISwitch *mySwitch = [[self alloc] initWithFrame:CGRectZero];
mySwitch.valueChangedBlock = block;
return mySwitch;
@ -137,6 +141,50 @@ const CGFloat SwitchShakeIntensity = 2;
}
}
#pragma mark - MVMCoreUIMoleculeViewProtocol
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
self.json = json;
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
NSString *color = [json string:@"onTintColor"];
if (color) {
self.onTintColor = [UIColor mfGetColorForHex:color];
}
color = [json string:@"offTintColor"];
if (color) {
self.offTintColor = [UIColor mfGetColorForHex:color];
}
color = [json string:@"onKnobTintColor"];
if (color) {
self.onKnobTintColor = [UIColor mfGetColorForHex:color];
}
color = [json string:@"offKnobTintColor"];
if (color) {
self.offKnobTintColor = [UIColor mfGetColorForHex:color];
}
[self setState:[json boolForKey:@"state"] animated:false];
}
+ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject {
return [self getSwitchHeight];
}
#pragma mark - MVMCoreUIMoleculeViewProtocol
- (BOOL)needsToBeConstrained {
return YES;
}
- (UIStackViewAlignment)alignment {
return UIStackViewAlignmentTrailing;
}
#pragma mark - UIResponder overide
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
@ -280,6 +328,11 @@ const CGFloat SwitchShakeIntensity = 2;
if (self.valueChangedBlock) {
self.valueChangedBlock();
}
if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) {
FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)];
[formValidator enableByValidation];
}
}
- (void)setState:(BOOL)state withoutBlockAnimated:(BOOL)animated {
@ -308,7 +361,7 @@ const CGFloat SwitchShakeIntensity = 2;
}
- (BOOL)changeValue{
- (BOOL)changeValue {
self.on^=YES;
self.shouldTouchToSwitch = NO;
[self setState:self.on animated:YES];
@ -349,7 +402,8 @@ const CGFloat SwitchShakeIntensity = 2;
}
#pragma mark - Accessibility
- (BOOL)isAccessibilityElement{
- (BOOL)isAccessibilityElement {
return YES;
}
@ -361,4 +415,18 @@ const CGFloat SwitchShakeIntensity = 2;
return [MVMCoreUIUtility hardcodedStringWithKey:@"AccToggleHint"];
}
#pragma mark FormValidationProtocol
- (BOOL)isValidField {
return self.isOn && [self.json boolForKey:@"required"];
}
- (NSString *)formFieldName {
return [self.json string:KeyFieldKey];
}
- (id)formFieldValue {
return @(self.isOn);
}
@end

View File

@ -0,0 +1,44 @@
//
// NSLayoutConstraintExtension.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 8/28/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public extension NSLayoutConstraint {
static func pinSubviewsCenter(leftView: UIView, rightView: UIView) {
guard let superView = leftView.superview else {
return
}
leftView.centerYAnchor.constraint(equalTo: superView.centerYAnchor).isActive = true
leftView.leftAnchor.constraint(equalTo: superView.layoutMarginsGuide.leftAnchor).isActive = true
leftView.topAnchor.constraint(greaterThanOrEqualTo: superView.layoutMarginsGuide.topAnchor).isActive = true
superView.layoutMarginsGuide.bottomAnchor.constraint(greaterThanOrEqualTo: leftView.bottomAnchor).isActive = true
var constraint = leftView.topAnchor.constraint(equalTo: superView.layoutMarginsGuide.topAnchor)
constraint.priority = .defaultLow
constraint.isActive = true
constraint = superView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: leftView.bottomAnchor)
constraint.priority = .defaultLow
constraint.isActive = true
rightView.leftAnchor.constraint(greaterThanOrEqualTo: leftView.rightAnchor, constant: 16).isActive = true
rightView.centerYAnchor.constraint(equalTo: superView.centerYAnchor).isActive = true
superView.layoutMarginsGuide.rightAnchor.constraint(equalTo: rightView.rightAnchor).isActive = true
rightView.topAnchor.constraint(greaterThanOrEqualTo: superView.layoutMarginsGuide.topAnchor).isActive = true
superView.layoutMarginsGuide.bottomAnchor.constraint(greaterThanOrEqualTo: rightView.bottomAnchor).isActive = true
constraint = rightView.topAnchor.constraint(equalTo: superView.layoutMarginsGuide.topAnchor)
constraint.priority = .defaultLow
constraint.isActive = true
constraint = superView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: rightView.bottomAnchor)
constraint.priority = .defaultLow
constraint.isActive = true
}
}

View File

@ -8,12 +8,13 @@
import UIKit
@objcMembers open class TwoButtonView: ButtonView {
open var secondaryButton: PrimaryButton?
@objcMembers open class TwoButtonView: ViewConstrainingView {
open var primaryButton: PrimaryButton? = PrimaryButton.button()
open var secondaryButton: PrimaryButton? = PrimaryButton.button()
open var viewForButtons: UIView?
public var heightConstraint: NSLayoutConstraint?
public override init() {
public init() {
super.init(frame: .zero)
}
@ -34,25 +35,32 @@ import UIKit
open override func updateView(_ size: CGFloat) {
super.updateView(size)
MVMCoreDispatchUtility.performBlock(onMainThread: {
self.primaryButton?.updateView(size)
self.secondaryButton?.updateView(size)
})
}
open override func setupView() {
super.setupView()
setupButton()
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton")
let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton")
set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData)
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
}
open override func reset() {
super.reset()
primaryButton?.setAsStandardCustom()
secondaryButton?.setAsSecondaryCustom()
}
// MARK: - Constraining
override func setupButton() {
func setupButton() {
setupWithTwoButtons()
}

View File

@ -0,0 +1,57 @@
//
// HeadlineBodySwitch.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 8/26/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class HeadlineBodySwitch: ViewConstrainingView {
let headlineBody = HeadlineBody(frame: .zero)
let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault()
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
headlineBody.updateView(size)
mvmSwitch.updateView(size)
}
public override func setupView() {
super.setupView()
guard mvmSwitch.superview == nil else {
return
}
headlineBody.styleListItem()
addSubview(headlineBody)
addSubview(mvmSwitch)
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 30
}
public override func setAsMolecule() {
super.setAsMolecule()
headlineBody.setAsMolecule()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?()
headlineBody.styleListItem()
}
public override func reset() {
super.reset()
headlineBody.reset()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?()
headlineBody.styleListItem()
}
}

View File

@ -0,0 +1,59 @@
//
// SwitchLineItem.swift
// MVMCoreUI
//
// Created by Priya on 5/6/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class HeadlineBodyTextButtonSwitch: ViewConstrainingView {
let headlineBodyTextButton = HeadlineBodyTextButton(frame: .zero)
let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault()
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
headlineBodyTextButton.updateView(size)
mvmSwitch.updateView(size)
}
public override func setupView() {
super.setupView()
guard mvmSwitch.superview == nil else {
return
}
headlineBodyTextButton.headlineBody.styleListItem()
addSubview(headlineBodyTextButton)
addSubview(mvmSwitch)
NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBodyTextButton, rightView: mvmSwitch)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyTextButton"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return HeadlineBodyTextButton.estimatedHeight(forRow: json, delegateObject: delegateObject)
}
public override func setAsMolecule() {
super.setAsMolecule()
headlineBodyTextButton.setAsMolecule()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?()
headlineBodyTextButton.headlineBody.styleListItem()
}
public override func reset() {
super.reset()
headlineBodyTextButton.reset()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?()
headlineBodyTextButton.headlineBody.styleListItem()
}
}

View File

@ -0,0 +1,57 @@
//
// LabelSwitch.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 8/26/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class LabelSwitch: ViewConstrainingView {
let label = Label.commonLabelB1(true)
let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault()
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
label.updateView(size)
mvmSwitch.updateView(size)
}
public override func setupView() {
super.setupView()
guard mvmSwitch.superview == nil else {
return
}
addSubview(label)
addSubview(mvmSwitch)
label.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical)
NSLayoutConstraint.pinSubviewsCenter(leftView: label, rightView: mvmSwitch)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return MVMCoreUISwitch.estimatedHeight(forRow: json, delegateObject: delegateObject)
}
public override func setAsMolecule() {
super.setAsMolecule()
label.setAsMolecule()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?()
label.styleB1(true)
}
public override func reset() {
super.reset()
label.reset()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?()
label.styleB1(true)
}
}

View File

@ -1,91 +0,0 @@
//
// Switch.swift
// MVMCoreUI
//
// Created by Priya on 5/23/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class Switch: ViewConstrainingView, FormValidationProtocol{
public var mvmSwitch = MVMCoreUISwitch()
var isRequired = false
var delegateObject: DelegateObject?
@objc func switchChanged() {
let delegate = delegateObject as? MVMCoreUIDelegateObject
if let delegate = delegate {
let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
formValidator?.enableByValidation()
}
}
open override func setupView() {
super.setupView()
mvmSwitch.addTarget(self, action: #selector(Switch.switchChanged), for: .valueChanged)
self.clipsToBounds = true
addSubview(mvmSwitch)
mvmSwitch.translatesAutoresizingMaskIntoConstraints = false
setupContainerConstraints()
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
mvmSwitch.updateView(size)
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
isRequired = json?[KeyRequired] as? Bool ?? false
self.delegateObject = delegateObject
if let delegateObject = delegateObject {
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
}
if let onColorString = json?.optionalStringForKey("onTintColor") {
mvmSwitch.onTintColor = .mfGet(forHex: onColorString)
}
if let offColorString = json?.optionalStringForKey("offTintColor") {
mvmSwitch.offTintColor = .mfGet(forHex: offColorString)
}
if let onKnobColorString = json?.optionalStringForKey("onKnobTintColor") {
mvmSwitch.onKnobTintColor = .mfGet(forHex: onKnobColorString)
}
if let offKnobColorString = json?.optionalStringForKey("offKnobTintColor") {
mvmSwitch.offKnobTintColor = .mfGet(forHex: offKnobColorString)
}
mvmSwitch.setState(json?.optionalBoolForKey("state") ?? false, animated: true)
}
func setupContainerConstraints() {
mvmSwitch.topAnchor.constraint(equalTo: topAnchor).isActive = true
mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
mvmSwitch.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
mvmSwitch.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
}
public func isValidField() -> Bool {
return (isRequired == false) ? true : mvmSwitch.isOn
}
public func formFieldName() -> String? {
return json?.optionalStringForKey(KeyFieldKey)
}
public func formFieldValue() -> Any? {
return mvmSwitch.isOn
}
public override func needsToBeConstrained() -> Bool {
return true
}
public override func alignment() -> UIStackView.Alignment {
return UIStackView.Alignment.leading
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return MVMCoreUISwitch.getHeight()
}
}

View File

@ -1,121 +0,0 @@
//
// SwitchLineItem.swift
// MVMCoreUI
//
// Created by Priya on 5/6/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class SwitchLineItem: ViewConstrainingView, FormValidationProtocol{
public var mvmSwitch = Switch()
public var label = Label()
public var leftContainerView = UIView()
public var mfTextButton = MFTextButton(nil, constrainHeight: true, forWidth: 0)
var isRequired = false
var delegateObject: DelegateObject?
@objc func switchChanged() {
let delegate = delegateObject as? MVMCoreUIDelegateObject
if let delegate = delegate {
let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
formValidator?.enableByValidation()
}
}
open override func setupView() {
super.setupView()
leftContainerView.addSubview(label)
leftContainerView.addSubview(mfTextButton)
addSubview(leftContainerView)
addSubview(mvmSwitch)
leftContainerView.translatesAutoresizingMaskIntoConstraints = false
mvmSwitch.translatesAutoresizingMaskIntoConstraints = false
mfTextButton.translatesAutoresizingMaskIntoConstraints = false
label.translatesAutoresizingMaskIntoConstraints = false
setupContainerConstraints()
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
label.updateView(size)
mvmSwitch.updateView(size)
mfTextButton.updateView(size)
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
mfTextButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
if (label.text?.count ?? 0) <= 0 && (mfTextButton.titleLabel?.text?.count ?? 0) <= 0 {
mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0).isActive = true
}
}
func setupContainerConstraints() {
leftContainerView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
var constraint = leftContainerView.topAnchor.constraint(equalTo: topAnchor)
constraint.priority = UILayoutPriority(249)
constraint.isActive = true
mvmSwitch.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
constraint = mvmSwitch.topAnchor.constraint(equalTo: topAnchor)
constraint.priority = UILayoutPriority(249)
constraint.isActive = true
trailingAnchor.constraint(equalTo: mvmSwitch.trailingAnchor).isActive = true
constraint = bottomAnchor.constraint(equalTo: mvmSwitch.bottomAnchor)
constraint.priority = UILayoutPriority(249)
constraint.isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: mvmSwitch.bottomAnchor).isActive = true
constraint = bottomAnchor.constraint(equalTo: leftContainerView.bottomAnchor)
constraint.isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainerView.bottomAnchor).isActive = true
leftContainerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
NSLayoutConstraint.constraintPinSubview(leftContainerView, pinCenterX: false, pinCenterY: true)
constraint = mvmSwitch.leadingAnchor.constraint(greaterThanOrEqualTo: leftContainerView.trailingAnchor)
constraint.priority = UILayoutPriority(999)
constraint.isActive = true
NSLayoutConstraint.constraintPinSubview(mvmSwitch, pinCenterX: false, pinCenterY: true)
leftContainerView.topAnchor.constraint(equalTo: label.topAnchor).isActive = true
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true
constraint = leftContainerView.trailingAnchor.constraint(equalTo: label.trailingAnchor)
constraint.priority = UILayoutPriority(249)
constraint.isActive = true
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: mfTextButton.trailingAnchor).isActive = true
constraint = leftContainerView.trailingAnchor.constraint(equalTo: mfTextButton.trailingAnchor)
constraint.priority = UILayoutPriority(249)
constraint.isActive = true
leftContainerView.bottomAnchor.constraint(equalTo: mfTextButton.bottomAnchor).isActive = true
mfTextButton.leadingAnchor.constraint(equalTo: leftContainerView.leadingAnchor).isActive = true
label.leadingAnchor.constraint(equalTo: leftContainerView.leadingAnchor).isActive = true
mfTextButton.topAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
leftContainerView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
mvmSwitch.setContentHuggingPriority(.defaultLow, for: .horizontal)
}
public override func needsToBeConstrained() -> Bool {
return true
}
public override func alignment() -> UIStackView.Alignment {
return UIStackView.Alignment.leading
}
}

View File

@ -18,6 +18,28 @@ open class HeadlineBody: ViewConstrainingView {
var leftConstraintMessage: NSLayoutConstraint?
var rightConstraintMessage: NSLayoutConstraint?
func styleLandingPageHeader() {
headlineLabel.styleH1(true)
messageLabel.styleB2(true)
spaceBetweenLabelsConstant = PaddingTwo
}
func stylePageHeader() {
headlineLabel.styleH2(true)
messageLabel.styleB2(true)
spaceBetweenLabelsConstant = PaddingTwo
}
func styleListItem() {
headlineLabel.styleB1(true)
messageLabel.styleB2(true)
spaceBetweenLabelsConstant = 0
}
func hasText() -> Bool {
return headlineLabel.hasText || messageLabel.hasText
}
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
@ -95,9 +117,7 @@ open class HeadlineBody: ViewConstrainingView {
open override func reset() {
super.reset()
headlineLabel.styleH2(true)
messageLabel.styleB2(true)
spaceBetweenLabelsConstant = PaddingTwo
stylePageHeader()
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {

View File

@ -0,0 +1,78 @@
//
// HeadlineBodyTextButton.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 8/28/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class HeadlineBodyTextButton: ViewConstrainingView {
let headlineBody = HeadlineBody(frame: .zero)
let textButton = MFTextButton(nil, constrainHeight: true, forWidth: MVMCoreUIUtility.getWidth())
var spaceBetweenConstant: CGFloat = 0.0
var spaceBetween: NSLayoutConstraint?
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
headlineBody.updateView(size)
textButton.updateView(size)
setSpacing()
}
open override func setupView() {
super.setupView()
guard subviews.count == 0 else {
return
}
addSubview(headlineBody)
addSubview(textButton)
headlineBody.styleListItem()
headlineBody.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor, constant: 0).isActive = true
headlineBody.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
var constraint = layoutMarginsGuide.rightAnchor.constraint(equalTo: headlineBody.rightAnchor)
constraint.priority = .defaultHigh
constraint.isActive = true
spaceBetween = textButton.topAnchor.constraint(equalTo: headlineBody.bottomAnchor, constant: spaceBetweenConstant)
spaceBetween?.isActive = true
textButton.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
layoutMarginsGuide.bottomAnchor.constraint(equalTo: textButton.bottomAnchor).isActive = true
layoutMarginsGuide.rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor).isActive = true
constraint = layoutMarginsGuide.rightAnchor.constraint(equalTo: textButton.rightAnchor)
constraint.priority = .defaultHigh
constraint.isActive = true
}
// MARK: - Constraining
public func setSpacing() {
if headlineBody.hasText() && (textButton.titleLabel?.text?.count ?? 0) > 0 {
spaceBetween?.constant = spaceBetweenConstant
} else {
spaceBetween?.constant = 0
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData)
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
}
open override func reset() {
super.reset()
headlineBody.reset()
headlineBody.styleListItem()
textButton.reset()
}
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 60
}
}

View File

@ -41,11 +41,9 @@
@"checkbox" : MVMCoreUICheckBox.class,
@"cornerLabels" : CornerLabels.class,
@"progressBar": ProgressBar.class,
@"textField": MFTextField.class,
@"checkbox": MVMCoreUICheckBox.class,
@"listItem": MoleculeTableViewCell.class,
@"switchLineItem": SwitchLineItem.class,
@"switch": Switch.class,
@"switch": MVMCoreUISwitch.class,
@"leftRightLabelView": LeftRightLabelView.class,
@"actionDetailWithImage": ActionDetailWithImage.class,
@"image": MFLoadImageView.class,
@ -55,7 +53,11 @@
@"carouselItem": MoleculeCollectionViewCell.class,
@"barsPager": MVMCoreUIPageControl.class,
@"scroller": Scroller.class,
@"imageHeadlineBody": ImageHeadlineBody.class
@"imageHeadlineBody": ImageHeadlineBody.class,
@"labelSwitch": LabelSwitch.class,
@"headlineBodySwitch": HeadlineBodySwitch.class,
@"headlineBodyTextButton": HeadlineBodyTextButton.class,
@"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class
} mutableCopy];
});
return mapping;