From 69309cf3b170be028580e732f13338857e440fa7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 26 Mar 2019 13:51:33 -0400 Subject: [PATCH 01/35] molecule testfields --- MVMCoreUI.xcodeproj/project.pbxproj | 46 +++++++ MVMCoreUI/Atoms/Buttons/PrimaryButton.h | 3 +- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 62 +++++++-- MVMCoreUI/Atoms/TextFields/MFTextField.h | 6 +- MVMCoreUI/Atoms/TextFields/MFTextField.m | 124 +++++++++++++----- MVMCoreUI/Atoms/TextFields/MFTextField.xib | 14 +- MVMCoreUI/BaseControllers/MFViewController.m | 39 ++++-- .../ThreeLayerViewController.swift | 24 ++-- MVMCoreUI/MVMCoreUI.h | 5 + MVMCoreUI/Models/FormValidator.swift | 14 ++ .../MVMCoreUIFormValidator+FormParams.swift | 33 +++++ .../MVMCoreUIFormValidator+TextFields.swift | 46 +++++++ MVMCoreUI/Models/MVMCoreUIFormValidator.h | 31 +++++ MVMCoreUI/Models/MVMCoreUIFormValidator.m | 79 +++++++++++ MVMCoreUI/Molecules/MFTextFieldListView.swift | 14 +- MVMCoreUI/Molecules/MoleculeStackView.swift | 6 +- .../MVMCoreUIMoleculeMappingObject.m | 7 +- .../MVMCoreUIFormMoleculesProtocol.h | 18 +++ .../MVMCoreUIFormValidationProtocol.h | 27 ++++ .../MoleculeStackCenteredTemplate.swift | 6 +- 20 files changed, 521 insertions(+), 83 deletions(-) create mode 100644 MVMCoreUI/Models/FormValidator.swift create mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift create mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift create mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator.h create mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator.m create mode 100644 MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h create mode 100644 MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a222046d..23cb82de 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -7,8 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */; }; + 01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */; }; + 01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */; }; + 01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C0B249224A9C2000F89DF2 /* FormValidator.swift */; }; + 01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */; }; + 01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 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, ); }; }; 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 */; }; D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -161,6 +169,13 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+TextFields.swift"; sourceTree = ""; }; + 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+FormParams.swift"; sourceTree = ""; }; + 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormMoleculesProtocol.h; sourceTree = ""; }; + 01C0B249224A9C2000F89DF2 /* FormValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; + 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidator.h; sourceTree = ""; }; + 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIFormValidator.m; sourceTree = ""; }; + 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidationProtocol.h; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; @@ -331,6 +346,27 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 01C74D86224298C3009C25A3 /* Protocols */ = { + isa = PBXGroup; + children = ( + 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */, + 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */, + ); + path = Protocols; + sourceTree = ""; + }; + 01C74D87224298E2009C25A3 /* Models */ = { + isa = PBXGroup; + children = ( + 01C0B249224A9C2000F89DF2 /* FormValidator.swift */, + 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */, + 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */, + 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */, + 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */, + ); + path = Models; + sourceTree = ""; + }; D22D1F582204D2590077CEC0 /* LegacyControllers */ = { isa = PBXGroup; children = ( @@ -364,6 +400,8 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( + 01C74D87224298E2009C25A3 /* Models */, + 01C74D86224298C3009C25A3 /* Protocols */, D29DF31421ECECA7003B2FB9 /* SupportingFiles */, D29DF27021E79B2C003B2FB9 /* OtherHandlers */, D29DF13A21E68682003B2FB9 /* Utility */, @@ -701,6 +739,7 @@ D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */, D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */, D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */, + 01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */, D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */, D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */, D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, @@ -740,6 +779,7 @@ D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */, D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */, D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */, + 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */, D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */, D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */, D29DF2C421E7BF57003B2FB9 /* MFTabBarSwipeAnimator.h in Headers */, @@ -755,9 +795,11 @@ D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */, D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */, + 01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */, D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */, D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */, + 01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */, D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */, D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */, D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, @@ -850,6 +892,7 @@ files = ( D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, + 01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, @@ -884,6 +927,7 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, + 01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */, D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, @@ -906,10 +950,12 @@ D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + 01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */, + 01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h index 182a527b..5947c634 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h @@ -11,6 +11,7 @@ #import #import #import +#import "MVMCoreUIFormValidationProtocol.h" typedef enum : NSUInteger { PrimaryButtonTypeRed, @@ -26,7 +27,7 @@ typedef enum : NSUInteger { static CGFloat const PrimaryButtonHeight = 42.0; static CGFloat const PrimaryButtonSmallHeight = 30.0; -@interface PrimaryButton : MFCustomButton +@interface PrimaryButton : MFCustomButton @property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 960e29e7..718f5b7f 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -12,23 +12,26 @@ #import "MVMCoreUISplitViewController.h" #import "MFStyler.h" #import "UIColor+MFConvenience.h" + +#import "MVMCoreUIFormValidator.h" + @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; -@interface PrimaryButton () - +@interface PrimaryButton() +@property (nonatomic) BOOL validationRequired; @property (nonatomic) BOOL smallButton; @property (assign, nonatomic) BOOL tinyButton; +@property (nonatomic) CGFloat sizeForSizing; + @property (weak, nonatomic) NSLayoutConstraint *height; @property (weak, nonatomic) NSLayoutConstraint *width; -@property (strong, nonatomic) NSArray *textFields; - +@property (strong, nonatomic) NSMutableArray *textFields; @property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType; - -@property (nonatomic) CGFloat sizeForSizing; +@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; @end @@ -645,6 +648,9 @@ } - (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { + + [MVMCoreUIFormValidator setupValidationFor:self delegate:delegate]; + self.primaryButtonType = PrimaryButtonTypeCustom; NSString *color = [json string:@"fillColor"]; if (color) { @@ -666,6 +672,8 @@ if ((color = [json string:@"disabledBorderColor"])) { self.disabledBorderColor = [UIColor mfGetColorForHex:color]; } + self.validationRequired = [json boolForKey:@"validationRequired"]; + [self setAsSmallButton:[json boolForKey:@"small"]]; [self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; } @@ -673,6 +681,8 @@ #pragma mark - Handling Validations - (void)setEnabledByValidity { + + __block BOOL valid = YES; [self.textFields enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (!((MFTextField *)obj).valid) { @@ -680,7 +690,7 @@ *stop = YES; } }]; - + [MVMCoreDispatchUtility performBlockOnMainThread:^{ self.enabled = valid && (self.extraValidationBlock ? self.extraValidationBlock() : YES); }]; @@ -692,7 +702,22 @@ field.mfTextFieldDelegate = nil; } } - self.textFields = textFields; + self.textFields = [textFields mutableCopy]; + + for (MFTextField *field in self.textFields) { + field.mfTextFieldDelegate = self; + [field setDefaultValidationBlock]; + } + [self setEnabledByValidity]; +} + +- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField{ + if (self.textFields == nil) { + self.textFields = [NSMutableArray array]; + } + if (textField) { + [self.textFields addObject:textField]; + } for (MFTextField *field in self.textFields) { field.mfTextFieldDelegate = self; @@ -708,7 +733,7 @@ field.mfTextFieldDelegate = nil; } } - self.textFields = textFields; + self.textFields = [textFields mutableCopy]; for (MFTextField *field in self.textFields) { field.mfTextFieldDelegate = self; @@ -733,4 +758,23 @@ } } +#pragma mark - MVMCoreUIFormValidationProtocol + +- (nullable MVMCoreUIFormValidator *) formValidatorModel { + return self.formValidator; +} + +- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel { + self.formValidator = formValidatorModel; +} + +- (void)enableField:(BOOL) enable { + + if (self.validationRequired == NO) { + self.enabled = YES; + } else { + self.enabled = enable; + } +} + @end diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 1be2f3e3..fa7cc6e9 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -8,6 +8,7 @@ #import #import +#import "MVMCoreUIFormValidationProtocol.h" @class PrimaryButton; @class MFTextField; @@ -28,7 +29,7 @@ @end -@interface MFTextField : MFView +@interface MFTextField : MFView @property (nullable, weak, nonatomic) UIView *view; @@ -127,4 +128,7 @@ - (void)setAccessibilityString:(nullable NSString *)accessibilityString; +- (nullable NSString *)formFieldName; +- (nullable id)formFieldValue; + @end diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 7cdab21a..4cf01441 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -15,17 +15,29 @@ #import "MFLabel.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" +#import "MVMCoreUIFormValidator.h" + +#import + @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreJSONConstants; @interface MFTextField() +@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; @property (strong, nonatomic) UIColor *customPlaceHolderColor; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *separatorHeightConstraint; @property (strong, nonatomic) UIBezierPath *borderPath; @property (strong, nonatomic) NSCalendar *calendar; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textContainerLeftPin; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *errorLableLeftPin; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *formLabelLeftPin; + +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textContainerRightPin; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *errorLableRightPin; + @end @implementation MFTextField @@ -53,10 +65,7 @@ view.frame = self.frame; [self addSubview:view]; -// self.textFieldContainerView.layer.borderWidth = 1; -// self.textFieldContainerView.layer.borderColor = [UIColor mfSilver].CGColor; self.textField.font = [MFStyler fontForTextField]; - self.translatesAutoresizingMaskIntoConstraints = NO; self.formLabel.font = [MFStyler fontB3]; @@ -101,40 +110,34 @@ return textField; } +- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { + [MVMCoreUIFormValidator setupValidationFor:self delegate:delegate]; + + [self setWithMap:json bothDelegates:delegate]; + self.mfTextFieldDelegate = self.formValidator; + self.uiTextFieldDelegate = self.formValidator; + + [self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]]; +} + + + +- (void) setVerticalPadding:(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; +} + + + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; - [textField setWithMap:map bothDelegates:delegate]; - if (map.count > 0) { - - // Can add these to the set with map function later after verifying - NSString *string = [map string:@"fieldKey"]; - if (string.length > 0) { - textField.fieldKey = string; - } - - string = [map string:KeyType]; - if ([string isEqualToString:@"dropDown"]) { - [[textField dropDownCarrotLabel] setHidden:NO]; - [textField setHasDropDown:YES]; - } else if ([string isEqualToString:@"password"]) { - textField.textField.secureTextEntry = YES; - } else if ([string isEqualToString:@"number"]) { - textField.textField.keyboardType = UIKeyboardTypeNumberPad; - } else if ([string isEqualToString:@"email"]) { - textField.textField.keyboardType = UIKeyboardTypeEmailAddress; - } - - string = [map string:@"regex"]; - if (string.length > 0) { - textField.validationBlock = ^BOOL(NSString * _Nullable enteredValue) { - return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string]; - }; - } else { - [textField setDefaultValidationBlock]; - } - } - + [textField setWithJSON:map delegate:delegate additionalData:nil]; + [textField setVerticalPadding:0]; return textField; } @@ -320,6 +323,9 @@ - (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { if (map.count > 0) { + [MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate]; + [self setBothTextFieldDelegates:delegate]; + NSString *string = [map string:KeyLabel]; if (string.length > 0) { self.formText = string; @@ -336,8 +342,33 @@ if (string.length > 0) { self.errMessage = string; } - [MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate]; - [self setBothTextFieldDelegates:delegate]; + + // key used to send text value to server + string = [map string:@"fieldKey"]; + if (string.length > 0) { + self.fieldKey = string; + } + + string = [map string:KeyType]; + if ([string isEqualToString:@"dropDown"]) { + [[self dropDownCarrotLabel] setHidden:NO]; + [self setHasDropDown:YES]; + } else if ([string isEqualToString:@"password"]) { + self.textField.secureTextEntry = YES; + } else if ([string isEqualToString:@"number"]) { + self.textField.keyboardType = UIKeyboardTypeNumberPad; + } else if ([string isEqualToString:@"email"]) { + self.textField.keyboardType = UIKeyboardTypeEmailAddress; + } + + string = [map string:@"regex"]; + if (string.length) { + self.validationBlock = ^BOOL(NSString * _Nullable enteredValue) { + return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string]; + }; + } else { + [self setDefaultValidationBlock]; + } } } @@ -530,4 +561,25 @@ } } +#pragma mark - MVMCoreUIMoleculeViewProtocol + +- (nullable MVMCoreUIFormValidator *) formValidatorModel { + return self.formValidator; +} + +- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel { + self.formValidator = formValidatorModel; +} + +- (BOOL) isValidField { + return self.valid; +} + +- (nullable NSString *)formFieldName { + return self.fieldKey; +} +- (nullable id)formFieldValue { + return self.text; +} + @end diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index a32399fe..359041ad 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,29 +1,29 @@ - + - + - - - HelveticaNeue - - + + + + + diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 1349721d..2b8cd1cf 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -36,9 +36,14 @@ #import "MVMCoreUILoggingHandler.h" #import "MVMCoreUITabBarPageControlViewController.h" #import "MVMCoreUINavigationController.h" +#import "MVMCoreUIFormValidationProtocol.h" +#import "MVMCoreUIFormValidator.h" +#import + + @import MVMAnimationFramework; -@interface MFViewController () +@interface MFViewController() // A flag for if this view controller is observing for cache updates or not. @property (nonatomic) BOOL observingForResponseJSONUpdates; @@ -52,10 +57,19 @@ // title view for navigation bar, used for custom navigation titles @property (weak, nonatomic) UILabel *titleLabel; +@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; + @end @implementation MFViewController +- (MVMCoreUIFormValidator *)formValidatorModel { + if (self.formValidator == nil) { + self.formValidator = [MVMCoreUIFormValidator new]; + } + return self.formValidator; +} + - (void)dismiss { if (self.presentingViewController) { [[MVMCoreNavigationHandler sharedNavigationHandler] dismissViewController:self animated:YES]; @@ -241,9 +255,10 @@ if (page) { self.loadObject.pageJSON = page; } - - [self newDataBuildScreen]; - self.needToUpdateUI = YES; + + [self updateUI]; +// [self newDataBuildScreen]; +// self.needToUpdateUI = YES; [self.view setNeedsLayout]; [self.view layoutIfNeeded]; }]; @@ -401,11 +416,7 @@ } // Since we have new data, build stuff for the screen. - [self newDataBuildScreen]; - - // Update the UI after the view is loaded. - self.needToUpdateUI = YES; - self.needToupdateUIOnScreenSizeChanges = YES; + [self updateUI]; if (UIAccessibilityIsVoiceOverRunning()) { self.disableAnimations = YES; @@ -416,6 +427,15 @@ } } +- (void) updateUI { + [self newDataBuildScreen]; + [self.formValidator setEnabledByValidity]; + + // Update the UI after the view is loaded. + self.needToUpdateUI = YES; + self.needToupdateUIOnScreenSizeChanges = YES; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. @@ -587,6 +607,7 @@ [[MVMCoreUISession sharedGlobal].splitViewController.rightPanel willOpenWithActionInformation:actionInformation]; } + [self.formValidator addFormParamsWithRequestParameters:requestParameters]; requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"]; [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegate:self]; diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index 756dd8e8..c1fadf55 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -10,7 +10,7 @@ import UIKit import MVMAnimationFramework -public class ThreeLayerViewController: ProgrammaticScrollViewController { +open class ThreeLayerViewController: ProgrammaticScrollViewController { // The three main views var topView: UIView? @@ -22,8 +22,8 @@ public class ThreeLayerViewController: ProgrammaticScrollViewController { private var safeAreaView: UIView? private var heightConstraint: NSLayoutConstraint? - - public override func updateViews() { + + open override func updateViews() { super.updateViews() let width = view.bounds.width if let topView = topView as? MVMCoreViewProtocol { @@ -37,7 +37,7 @@ public class ThreeLayerViewController: ProgrammaticScrollViewController { } } - public override func updateViewConstraints() { + open override func updateViewConstraints() { super.updateViewConstraints() guard let scrollView = scrollView else { return @@ -50,7 +50,7 @@ public class ThreeLayerViewController: ProgrammaticScrollViewController { } } - public override func loadView() { + open override func loadView() { super.loadView() // The height is used to keep the bottom view at the bottom. if let contentView = contentView, let scrollView = scrollView { @@ -59,7 +59,7 @@ public class ThreeLayerViewController: ProgrammaticScrollViewController { } } - public override func newDataBuildScreen() { + open override func newDataBuildScreen() { super.newDataBuildScreen() // Removes the views @@ -78,27 +78,27 @@ public class ThreeLayerViewController: ProgrammaticScrollViewController { //MARK:-Functions to subclass // Subclass for a top view. - public func viewForTop() -> UIView? { + open func viewForTop() -> UIView? { return nil } // Subclass for a middle view. - public func viewForMiddle() -> UIView? { + open func viewForMiddle() -> UIView? { return nil } // Subclass for a bottom view. - public func viewForBottom() -> UIView? { + open func viewForBottom() -> UIView? { return nil } // If a value is set, the middle view is pinned this value below the top view, if not, space is left to fill. - public func spaceBetweenTopAndMiddle() -> CGFloat? { + open func spaceBetweenTopAndMiddle() -> CGFloat? { return nil } // If a value is set, the middle view is pinned this value above the bottom view, if not, space is left to fill. - public func spaceBetweenMiddleAndBottom() -> CGFloat? { + open func spaceBetweenMiddleAndBottom() -> CGFloat? { return nil } } @@ -246,7 +246,7 @@ extension ThreeLayerViewController { //MARK:-Animation extension ThreeLayerViewController { - public override func setupIntroAnimations() { + open override func setupIntroAnimations() { if let topView = topView, topView.subviews.count > 0 { introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: topView)) } diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 3a8029c4..d43b1eac 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -112,4 +112,9 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import +#import +#import + + + #pragma mark - Templates diff --git a/MVMCoreUI/Models/FormValidator.swift b/MVMCoreUI/Models/FormValidator.swift new file mode 100644 index 00000000..58241740 --- /dev/null +++ b/MVMCoreUI/Models/FormValidator.swift @@ -0,0 +1,14 @@ +// +// FormValidator.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +class FormValidator: NSObject { + var delegate: MVMCoreUIFormValidationProtocol? + var molecules: [MVMCoreUIFormValidationProtocol]? +} diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift b/MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift new file mode 100644 index 00000000..f21d700e --- /dev/null +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift @@ -0,0 +1,33 @@ +// +// MVMCoreUIFormValidator+FormParams.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc public extension MVMCoreUIFormValidator { + @objc public func addFormParams(requestParameters: MVMCoreRequestParameters) { + DispatchQueue.main.sync { + requestParameters.add(self.getFormParams()) + } + } + + @objc public func getFormParams() -> [String: Any] { + + var extraParam: [String: Any] = [:] + for molecule in self.molecules { + if let molecule = molecule as? MVMCoreUIFormValidationProtocol, + let formFieldName = molecule.formFieldName, + let formFieldValue = molecule.formFieldValue, + let fieldName = formFieldName(), + let fieldValue = formFieldValue() { + + extraParam[fieldName] = fieldValue + } + } + return extraParam + } +} diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift b/MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift new file mode 100644 index 00000000..c966bcfd --- /dev/null +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift @@ -0,0 +1,46 @@ +// +// MVMCoreUIFormValidator+TextFields.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc extension MVMCoreUIFormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{ + @objc public func textFieldDidEndEditing(_ textField: UITextField) { + setEnabledByValidity() + } + + @objc public func dismissFieldInput(_ sender: Any?) { + if let delegate = delegate as? MFTextFieldDelegate, + let dismissFieldInput = delegate.dismissFieldInput { + dismissFieldInput(sender) + } + } + + @objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + return true + } + + @objc public func textFieldDidBeginEditing(_ textField: UITextField) { + if let delegate = delegate as? UITextFieldDelegate, + let textFieldDidBeginEditing = delegate.textFieldDidBeginEditing { + textFieldDidBeginEditing(textField) + } + } + + @objc public func entryIsValid(_ textfield: MFTextField?) { + DispatchQueue.main.async { + self.setEnabledByValidity() + } + } + + @objc public func entryIsInvalid(_ textfield: MFTextField?) { + DispatchQueue.main.async { + self.setEnabledByValidity() + } + } +} diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.h b/MVMCoreUI/Models/MVMCoreUIFormValidator.h new file mode 100644 index 00000000..ddbaddb8 --- /dev/null +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator.h @@ -0,0 +1,31 @@ +// +// MVMCoreUIFormValidator.h +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +#import +#import +#import "MVMCoreUIFormValidationProtocol.h" + +NS_ASSUME_NONNULL_BEGIN + +@class MFTextField; + +@interface MVMCoreUIFormValidator : NSObject + +@property (weak, nonatomic) NSObject * delegate; +@property (strong, nonatomic) NSMutableArray *>* molecules; + +@property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void); + +- (void)setEnabledByValidity; +- (void)insertMolecule:(nonnull UIView *) molecule; + ++ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.m b/MVMCoreUI/Models/MVMCoreUIFormValidator.m new file mode 100644 index 00000000..b6f968f3 --- /dev/null +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator.m @@ -0,0 +1,79 @@ +// +// MVMCoreUIFormValidator.m +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +#import "MVMCoreUIFormValidator.h" +#import "MFTextField.h" +@import MVMCore.MVMCoreDispatchUtility; + + +@interface MVMCoreUIFormValidator() +@property (strong, nonatomic) NSMutableArray *textFields; +@end + +@implementation MVMCoreUIFormValidator + + +- (void)insertMolecule:(nonnull UIView *) molecule { + if (self.molecules == nil) { + self.molecules = [NSMutableArray array]; + } + if (molecule) { + [self.molecules addObject:molecule]; + } +} + ++ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate { + if ([delegate conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + && [delegate respondsToSelector:@selector(formValidatorModel)] + && [molecule conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + && [molecule respondsToSelector:@selector(setFormValidationModel:)]) { + + MVMCoreUIFormValidator *validator = [delegate formValidatorModel]; + validator.delegate = delegate; + [validator insertMolecule:molecule]; + [molecule setFormValidationModel:validator]; + } +} + + +- (void)setEnabledByValidity { + __block BOOL valid = YES; + [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + && [obj respondsToSelector:@selector(isValidField)] + && [obj isValidField] == NO) { + valid = NO; + *stop = YES; + } + }]; + BOOL shouldEnable = valid && (self.extraValidationBlock ? self.extraValidationBlock() : YES); + [self shouldEnable:shouldEnable]; +} + +- (void)shouldEnable:(BOOL) enable { + [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + && [obj respondsToSelector:@selector(enableField:)]) { + + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [obj enableField:enable]; + }]; + } + }]; +} + +- (void)entryIsValid:(nullable MFTextField *)textfield { + [self setEnabledByValidity]; +} + +- (void)entryIsInvalid:(nullable MFTextField *)textfield { + [self shouldEnable:false]; +} + + +@end diff --git a/MVMCoreUI/Molecules/MFTextFieldListView.swift b/MVMCoreUI/Molecules/MFTextFieldListView.swift index fde03981..bb267d29 100644 --- a/MVMCoreUI/Molecules/MFTextFieldListView.swift +++ b/MVMCoreUI/Molecules/MFTextFieldListView.swift @@ -10,7 +10,7 @@ import UIKit import MVMCore -public class MFTextFieldListView: MFView { +public class MFTextFieldListView: ViewConstrainingView { public var textFieldMapList: [[String: Any]]? public var parentViewContoller: MFViewController? @@ -24,7 +24,19 @@ public class MFTextFieldListView: MFView { self.primaryButton = primaryButton super.init(frame: .zero) } + + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { + self.textFieldMapList = json?.arrayForKey("textFields") as? [[String : Any]] + + if let threeLayerVC = delegate as? ThreeLayerViewController { + self.parentViewContoller = threeLayerVC + self.primaryButton = (threeLayerVC.bottomView as? StandardFooterView)?.twoButtonView.primaryButton + } + setupView() + } + + public required init?(coder decoder: NSCoder) { super.init(coder: decoder) } diff --git a/MVMCoreUI/Molecules/MoleculeStackView.swift b/MVMCoreUI/Molecules/MoleculeStackView.swift index a9ea7d8e..ab27c481 100644 --- a/MVMCoreUI/Molecules/MoleculeStackView.swift +++ b/MVMCoreUI/Molecules/MoleculeStackView.swift @@ -16,17 +16,17 @@ public class MoleculeStackView: MFView { super.init(frame: frame) } - init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { + public init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { super.init(frame: CGRect.zero) setWithJSON(json, delegate: delegate, additionalData: additionalData) } - convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { + public convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { self.init(withJSON: json, delegate: delegate, additionalData: nil) self.spacingBlock = spacingBlock } - required init?(coder aDecoder: NSCoder) { + public required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 3c36a612..9b24f257 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -11,6 +11,7 @@ @import MVMCore.NSDictionary_MFConvenience; #import "MVMCoreUIObject.h" #import +#import "MFTextField.h" @implementation MVMCoreUIMoleculeMappingObject @@ -28,7 +29,8 @@ @"standardHeader": StandardHeaderView.class, @"moleculeStack": MoleculeStackView.class, @"twoButtonView": PrimaryButtonView.class, - @"standardFooter": StandardFooterView.class + @"standardFooter": StandardFooterView.class, + @"textField" : MFTextField.class, } mutableCopy]; }); return mapping; @@ -57,8 +59,9 @@ return nil; } UIView *molecule = [self getMoleculeForName:moleculeName]; - [molecule setWithJSON:json delegate:delegate additionalData:nil]; + [molecule setWithJSON:json delegate:delegate additionalData:nil]; return molecule; } + @end diff --git a/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h b/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h new file mode 100644 index 00000000..3c76f16f --- /dev/null +++ b/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h @@ -0,0 +1,18 @@ +// +// MVMCoreUIFormMoleculesProtocol.h +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/21/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +#import + + +@protocol MVMCoreUIFormMoleculesProtocol +//- (BOOL)isValidField; +//- (void)enableField:(BOOL) enable; +// +//- (NSString *)formFieldName; +//- (NSString *)formFieldValue; +@end diff --git a/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h b/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h new file mode 100644 index 00000000..16eaeb82 --- /dev/null +++ b/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h @@ -0,0 +1,27 @@ +// +// MVMCoreUIFormValidationProtocol.h +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +#import + +@class MVMCoreUIFormValidator; + +@protocol MVMCoreUIFormValidationProtocol + +// Returns the form validator model +- (nullable MVMCoreUIFormValidator *) formValidatorModel; + +@optional +- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel; + +- (BOOL)isValidField; +- (void)enableField:(BOOL) enable; + +- (nullable NSString *)formFieldName; +- (nullable id)formFieldValue; + +@end diff --git a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift index 7f7411a3..ab7b6dec 100644 --- a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift @@ -17,14 +17,16 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { } public override func viewForTop() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { return nil } return molecule } override public func viewForBottom() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { return nil } return molecule From 629736b7fc74ac025a5c8eca64c211e649d19560 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 27 Mar 2019 11:16:58 -0400 Subject: [PATCH 02/35] swifting --- MVMCoreUI.xcodeproj/project.pbxproj | 40 +++++++--------- MVMCoreUI/Atoms/Buttons/PrimaryButton.h | 3 +- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 16 +++---- MVMCoreUI/Atoms/TextFields/MFTextField.h | 3 +- MVMCoreUI/Atoms/TextFields/MFTextField.m | 13 +++--- MVMCoreUI/BaseControllers/MFViewController.m | 12 ++--- MVMCoreUI/MVMCoreUI.h | 6 --- ...s.swift => FormValidator+FormParams.swift} | 5 +- ...s.swift => FormValidator+TextFields.swift} | 20 ++++---- MVMCoreUI/Models/FormValidator.swift | 46 +++++++++++++++++-- MVMCoreUI/Models/MVMCoreUIFormValidator.h | 10 ++-- MVMCoreUI/Models/MVMCoreUIFormValidator.m | 18 +++----- .../Protocols/FormValidationProtocol.swift | 21 +++++++++ .../MVMCoreUIFormValidationProtocol.h | 2 + 14 files changed, 126 insertions(+), 89 deletions(-) rename MVMCoreUI/Models/{MVMCoreUIFormValidator+FormParams.swift => FormValidator+FormParams.swift} (81%) rename MVMCoreUI/Models/{MVMCoreUIFormValidator+TextFields.swift => FormValidator+TextFields.swift} (55%) create mode 100644 MVMCoreUI/Protocols/FormValidationProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 23cb82de..54ff8abb 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -7,13 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */; }; - 01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */; }; + 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 */; }; + 01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */; }; 01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */; }; - 01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C0B249224A9C2000F89DF2 /* FormValidator.swift */; }; - 01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */; }; - 01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 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, ); }; }; @@ -169,13 +167,11 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+TextFields.swift"; sourceTree = ""; }; - 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+FormParams.swift"; sourceTree = ""; }; + 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; + 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; + 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; + 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormMoleculesProtocol.h; sourceTree = ""; }; - 01C0B249224A9C2000F89DF2 /* FormValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; - 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidator.h; sourceTree = ""; }; - 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIFormValidator.m; sourceTree = ""; }; - 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidationProtocol.h; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; @@ -349,7 +345,7 @@ 01C74D86224298C3009C25A3 /* Protocols */ = { isa = PBXGroup; children = ( - 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */, + 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */, 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */, ); path = Protocols; @@ -358,11 +354,9 @@ 01C74D87224298E2009C25A3 /* Models */ = { isa = PBXGroup; children = ( - 01C0B249224A9C2000F89DF2 /* FormValidator.swift */, - 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */, - 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */, - 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */, - 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */, + 0105618A224BBE7700E1557D /* FormValidator.swift */, + 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */, + 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */, ); path = Models; sourceTree = ""; @@ -739,7 +733,6 @@ D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */, D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */, D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */, - 01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */, D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */, D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */, D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, @@ -799,7 +792,6 @@ D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */, D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */, - 01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */, D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */, D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */, D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, @@ -892,7 +884,6 @@ files = ( D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, - 01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, @@ -920,6 +911,7 @@ D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, + 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, @@ -927,7 +919,6 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, - 01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */, D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, @@ -942,6 +933,7 @@ D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, + 01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, @@ -950,18 +942,18 @@ D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, - 01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */, - 01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, + 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */, D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */, + 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h index 5947c634..182a527b 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.h +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.h @@ -11,7 +11,6 @@ #import #import #import -#import "MVMCoreUIFormValidationProtocol.h" typedef enum : NSUInteger { PrimaryButtonTypeRed, @@ -27,7 +26,7 @@ typedef enum : NSUInteger { static CGFloat const PrimaryButtonHeight = 42.0; static CGFloat const PrimaryButtonSmallHeight = 30.0; -@interface PrimaryButton : MFCustomButton +@interface PrimaryButton : MFCustomButton @property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 718f5b7f..8ce0f71b 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -12,14 +12,14 @@ #import "MVMCoreUISplitViewController.h" #import "MFStyler.h" #import "UIColor+MFConvenience.h" +#import -#import "MVMCoreUIFormValidator.h" @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; -@interface PrimaryButton() +@interface PrimaryButton() @property (nonatomic) BOOL validationRequired; @property (nonatomic) BOOL smallButton; @@ -31,7 +31,7 @@ @property (strong, nonatomic) NSMutableArray *textFields; @property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType; -@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; +@property (nonnull, strong, nonatomic) FormValidator* formValidator; @end @@ -648,8 +648,8 @@ } - (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { - - [MVMCoreUIFormValidator setupValidationFor:self delegate:delegate]; + + [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; self.primaryButtonType = PrimaryButtonTypeCustom; NSString *color = [json string:@"fillColor"]; @@ -758,13 +758,13 @@ } } -#pragma mark - MVMCoreUIFormValidationProtocol +#pragma mark - FormValidationProtocol -- (nullable MVMCoreUIFormValidator *) formValidatorModel { +- (nullable FormValidator*) formValidatorModel { return self.formValidator; } -- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel { +- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel { self.formValidator = formValidatorModel; } diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index fa7cc6e9..cc5ccccb 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -8,7 +8,6 @@ #import #import -#import "MVMCoreUIFormValidationProtocol.h" @class PrimaryButton; @class MFTextField; @@ -29,7 +28,7 @@ @end -@interface MFTextField : MFView +@interface MFTextField : MFView @property (nullable, weak, nonatomic) UIView *view; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 4cf01441..5ec4375a 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -15,17 +15,16 @@ #import "MFLabel.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" -#import "MVMCoreUIFormValidator.h" -#import +#import @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreJSONConstants; -@interface MFTextField() +@interface MFTextField() -@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; +@property (strong, nonatomic) FormValidator* formValidator; @property (strong, nonatomic) UIColor *customPlaceHolderColor; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *separatorHeightConstraint; @property (strong, nonatomic) UIBezierPath *borderPath; @@ -111,7 +110,7 @@ } - (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { - [MVMCoreUIFormValidator setupValidationFor:self delegate:delegate]; + [FormValidator setupValidationWithMolecule:self delegate: (id)delegate]; [self setWithMap:json bothDelegates:delegate]; self.mfTextFieldDelegate = self.formValidator; @@ -563,11 +562,11 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (nullable MVMCoreUIFormValidator *) formValidatorModel { +- (nullable FormValidator*) formValidatorModel { return self.formValidator; } -- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel { +- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel { self.formValidator = formValidatorModel; } diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 2b8cd1cf..28c3c625 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -36,14 +36,12 @@ #import "MVMCoreUILoggingHandler.h" #import "MVMCoreUITabBarPageControlViewController.h" #import "MVMCoreUINavigationController.h" -#import "MVMCoreUIFormValidationProtocol.h" -#import "MVMCoreUIFormValidator.h" #import @import MVMAnimationFramework; -@interface MFViewController() +@interface MFViewController() // A flag for if this view controller is observing for cache updates or not. @property (nonatomic) BOOL observingForResponseJSONUpdates; @@ -57,15 +55,15 @@ // title view for navigation bar, used for custom navigation titles @property (weak, nonatomic) UILabel *titleLabel; -@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator; +@property (strong, nonatomic) FormValidator* formValidator; @end @implementation MFViewController -- (MVMCoreUIFormValidator *)formValidatorModel { +- (FormValidator *)formValidatorModel { if (self.formValidator == nil) { - self.formValidator = [MVMCoreUIFormValidator new]; + self.formValidator = [FormValidator new]; } return self.formValidator; } @@ -429,7 +427,7 @@ - (void) updateUI { [self newDataBuildScreen]; - [self.formValidator setEnabledByValidity]; + [self.formValidator enableByValidation]; // Update the UI after the view is loaded. self.needToUpdateUI = YES; diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index d43b1eac..757556d0 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -110,11 +110,5 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - Molecules #import #import -#import - -#import -#import - - #pragma mark - Templates diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift b/MVMCoreUI/Models/FormValidator+FormParams.swift similarity index 81% rename from MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift rename to MVMCoreUI/Models/FormValidator+FormParams.swift index f21d700e..2c6c1d2a 100644 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator+FormParams.swift +++ b/MVMCoreUI/Models/FormValidator+FormParams.swift @@ -8,7 +8,7 @@ import Foundation -@objc public extension MVMCoreUIFormValidator { +@objc public extension FormValidator { @objc public func addFormParams(requestParameters: MVMCoreRequestParameters) { DispatchQueue.main.sync { requestParameters.add(self.getFormParams()) @@ -19,8 +19,7 @@ import Foundation var extraParam: [String: Any] = [:] for molecule in self.molecules { - if let molecule = molecule as? MVMCoreUIFormValidationProtocol, - let formFieldName = molecule.formFieldName, + if let formFieldName = molecule.formFieldName, let formFieldValue = molecule.formFieldValue, let fieldName = formFieldName(), let fieldValue = formFieldValue() { diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift b/MVMCoreUI/Models/FormValidator+TextFields.swift similarity index 55% rename from MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift rename to MVMCoreUI/Models/FormValidator+TextFields.swift index c966bcfd..d95a4cbb 100644 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator+TextFields.swift +++ b/MVMCoreUI/Models/FormValidator+TextFields.swift @@ -8,39 +8,39 @@ import Foundation -@objc extension MVMCoreUIFormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{ - @objc public func textFieldDidEndEditing(_ textField: UITextField) { - setEnabledByValidity() +@objc extension FormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{ + public func textFieldDidEndEditing(_ textField: UITextField) { + enableByValidation() } - @objc public func dismissFieldInput(_ sender: Any?) { + public func dismissFieldInput(_ sender: Any?) { if let delegate = delegate as? MFTextFieldDelegate, let dismissFieldInput = delegate.dismissFieldInput { dismissFieldInput(sender) } } - @objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool { + public func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() return true } - @objc public func textFieldDidBeginEditing(_ textField: UITextField) { + public func textFieldDidBeginEditing(_ textField: UITextField) { if let delegate = delegate as? UITextFieldDelegate, let textFieldDidBeginEditing = delegate.textFieldDidBeginEditing { textFieldDidBeginEditing(textField) } } - @objc public func entryIsValid(_ textfield: MFTextField?) { + public func entryIsValid(_ textfield: MFTextField?) { DispatchQueue.main.async { - self.setEnabledByValidity() + self.enableByValidation() } } - @objc public func entryIsInvalid(_ textfield: MFTextField?) { + public func entryIsInvalid(_ textfield: MFTextField?) { DispatchQueue.main.async { - self.setEnabledByValidity() + self.enableByValidation() } } } diff --git a/MVMCoreUI/Models/FormValidator.swift b/MVMCoreUI/Models/FormValidator.swift index 58241740..0304ca8d 100644 --- a/MVMCoreUI/Models/FormValidator.swift +++ b/MVMCoreUI/Models/FormValidator.swift @@ -7,8 +7,48 @@ // import Foundation +import UIKit -class FormValidator: NSObject { - var delegate: MVMCoreUIFormValidationProtocol? - var molecules: [MVMCoreUIFormValidationProtocol]? +@objcMembers public class FormValidator: NSObject { + + var delegate: FormValidationProtocol? + var molecules: [UIView & FormValidationProtocol] = [] + var extraValidationBlock: (() -> Bool)? + + public func insertMolecule(_ molecule: UIView & FormValidationProtocol) { + molecules.append(molecule) + } + + public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) { + if let delegateFormValidatorModel = delegate?.formValidatorModel, + let setFormValidationModel = molecule.setFormValidationModel, + let validator = delegateFormValidatorModel() { + + validator.delegate = delegate + validator.insertMolecule(molecule) + setFormValidationModel(validator) + } + } + + public func enableByValidation() { + + var valid = true + for molecule in molecules { + if let isValidField = molecule.isValidField, + isValidField() == false { + valid = false + } + } + + let enableField = valid && (extraValidationBlock?() ?? true) + shouldEnable(enableField) + } + + public func shouldEnable(_ enable: Bool) { + for molecule in molecules { + if let enableField = molecule.enableField { + enableField(enable) + } + } + } } diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.h b/MVMCoreUI/Models/MVMCoreUIFormValidator.h index ddbaddb8..151fb17f 100644 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator.h +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator.h @@ -8,23 +8,21 @@ #import #import -#import "MVMCoreUIFormValidationProtocol.h" - NS_ASSUME_NONNULL_BEGIN @class MFTextField; @interface MVMCoreUIFormValidator : NSObject -@property (weak, nonatomic) NSObject * delegate; -@property (strong, nonatomic) NSMutableArray *>* molecules; +@property (weak, nonatomic) NSObject * delegate; +@property (strong, nonatomic) NSMutableArray *>* molecules; @property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void); - (void)setEnabledByValidity; -- (void)insertMolecule:(nonnull UIView *) molecule; +- (void)insertMolecule:(nonnull UIView *) molecule; -+ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate; ++ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate; @end diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.m b/MVMCoreUI/Models/MVMCoreUIFormValidator.m index b6f968f3..55e919ce 100644 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator.m +++ b/MVMCoreUI/Models/MVMCoreUIFormValidator.m @@ -11,14 +11,10 @@ @import MVMCore.MVMCoreDispatchUtility; -@interface MVMCoreUIFormValidator() -@property (strong, nonatomic) NSMutableArray *textFields; -@end - @implementation MVMCoreUIFormValidator -- (void)insertMolecule:(nonnull UIView *) molecule { +- (void)insertMolecule:(nonnull UIView *) molecule { if (self.molecules == nil) { self.molecules = [NSMutableArray array]; } @@ -27,10 +23,10 @@ } } -+ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate { - if ([delegate conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] ++ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate { + if ([delegate conformsToProtocol:@protocol(FormValidationProtocol)] && [delegate respondsToSelector:@selector(formValidatorModel)] - && [molecule conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + && [molecule conformsToProtocol:@protocol(FormValidationProtocol)] && [molecule respondsToSelector:@selector(setFormValidationModel:)]) { MVMCoreUIFormValidator *validator = [delegate formValidatorModel]; @@ -43,7 +39,7 @@ - (void)setEnabledByValidity { __block BOOL valid = YES; - [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] && [obj respondsToSelector:@selector(isValidField)] && [obj isValidField] == NO) { @@ -56,8 +52,8 @@ } - (void)shouldEnable:(BOOL) enable { - [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] + [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj conformsToProtocol:@protocol(FormValidationProtocol)] && [obj respondsToSelector:@selector(enableField:)]) { [MVMCoreDispatchUtility performBlockOnMainThread:^{ diff --git a/MVMCoreUI/Protocols/FormValidationProtocol.swift b/MVMCoreUI/Protocols/FormValidationProtocol.swift new file mode 100644 index 00000000..71d07467 --- /dev/null +++ b/MVMCoreUI/Protocols/FormValidationProtocol.swift @@ -0,0 +1,21 @@ +// +// FormValidationProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 3/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objc public protocol FormValidationProtocol: NSObjectProtocol { + + @objc func formValidatorModel() -> FormValidator? + + @objc optional func setFormValidationModel(_ formValidatorModel:FormValidator) + @objc optional func isValidField() -> Bool + @objc optional func enableField(_ enable: Bool) + + @objc optional func formFieldName() -> String? + @objc optional func formFieldValue() -> String? +} diff --git a/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h b/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h index 16eaeb82..3b55bd3c 100644 --- a/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h +++ b/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h @@ -7,6 +7,8 @@ // #import +//#import +//#import "MVMCoreUI-Swift.h" @class MVMCoreUIFormValidator; From 124069c0be1402f871e531e534e3cab768f2ae4a Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 15:59:28 -0400 Subject: [PATCH 03/35] change body bold to b1 --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 12 ------------ MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h | 1 - MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m | 6 ------ 4 files changed, 21 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 193fe4fe..6e1b27dd 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -41,8 +41,6 @@ // Getters + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); -+ (nonnull MFLabel *)commonLabelBodyWithSize:(CGFloat)size scale:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelBodyBold:(BOOL)scale; + (nonnull MFLabel *)commonLabelBodyLighter:(BOOL)scale; + (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index eb9ed1c6..feda5c15 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -116,18 +116,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelBodyWithSize:(CGFloat)size scale:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleBodyWithSize:size scale:scale]; - return label; -} - -+ (nonnull MFLabel *)commonLabelBodyBold:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleBodyBold:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelBodyLighter:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleBodyLighter:scale]; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 3d212499..9b640c85 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -35,7 +35,6 @@ + (nonnull UILabel *)commonLabelHeadlineExtraLarge; + (nonnull UILabel *)commonLabelHeadlineFeed; + (nonnull UILabel *)commonLabelSubheadBold; -+ (nonnull UILabel *)commonLabelBodyBold; + (nonnull UILabel *)commonLabelBodyLarge; + (nonnull UILabel *)commonLabelBodyLighter; + (nonnull UILabel *)commonLabelFeedTitle; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index a8a90a50..0f887033 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -95,12 +95,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelBodyBold { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelBodyBold:label]; - return label; -} - + (nonnull UILabel *)commonLabelBodyLarge { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelBodyLarge:label]; From 4240b6a2f4aa3952bd619d947ed195278b26f107 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 16:35:55 -0400 Subject: [PATCH 04/35] change body bold to b1 --- MVMCoreUI/Atoms/Views/MFLabel.m | 5 --- MVMCoreUI/Styles/MFStyler.h | 8 +---- MVMCoreUI/Styles/MFStyler.m | 31 ++----------------- .../Utility/MVMCoreUICommonViewsUtility.m | 6 ---- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index feda5c15..28808106 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -314,11 +314,6 @@ [self setScale:scale]; } -- (void)styleBodyBold:(BOOL)scale { - [MFStyler styleLabelBodyBold:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleBodyLighter:(BOOL)scale { [MFStyler styleLabelBodyLighter:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 2020d5c6..69e5bb55 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -154,8 +154,6 @@ B3 -> Legal + (nullable UIFont *)fontForAccountLandingGreeting; //55Rg 20pt + (nullable UIFont *)fontForBodyLarge; -//Bold System 13 -+ (nullable UIFont *)fontForBodyBold; //55Rg 10pt + (nullable UIFont *)fontForProgressBarBottomLabel; @@ -209,7 +207,6 @@ B3 -> Legal + (nullable UIFont *)fontforChatText:(BOOL)genericScaling; + (nullable UIFont *)fontForAccountLandingGreeting:(BOOL)genericScaling; + (nullable UIFont *)fontForBodyLarge:(BOOL)genericScaling; -+ (nullable UIFont *)fontForBodyBold:(BOOL)genericScaling; + (nullable UIFont *)fontForPrimaryButton:(BOOL)genericScaling; + (nullable UIFont *)fontForPrimaryButtonForWidth:(CGFloat)size; @@ -276,7 +273,6 @@ B3 -> Legal + (void)styleLabelSubheadBold:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label; + (void)styleLabelBodyLarge:(nonnull UILabel *)label; -+ (void)styleLabelBodyBold:(nonnull UILabel *)label; + (void)styleLabelBodyLighter:(nonnull UILabel *)label; @@ -297,7 +293,6 @@ B3 -> Legal + (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelSubheadBoldLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelBodyBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelBodyLighter:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; @@ -312,7 +307,6 @@ B3 -> Legal + (void)styleSetLabelTextWithHeadlineExtraLarge:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithH3:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithB2:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithBodyBold:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithB3:(nonnull UILabel *)label text:(nullable NSString *)text; #pragma mark - Attributed Strings @@ -323,7 +317,7 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetHeadlineExtraLargeAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetBodyAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetBodyBoldAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetDisabledBodyAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetLegalAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetSubtitleAttributedString:(nullable NSString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 4367b37e..a83340f9 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -302,14 +302,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontForBodyBold:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontB3:(BOOL)genericScaling { CGFloat size = 11; if (genericScaling) { @@ -578,10 +570,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForBodyLarge:YES]; } -+ (nullable UIFont *)fontForBodyBold { - return [self fontForBodyBold:YES]; -} - + (nullable UIFont *)fontB3 { return [self fontB3:YES]; } @@ -783,11 +771,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelBodyBold:(nonnull UILabel *)label { - label.font = [MFStyler fontForBodyBold]; - label.textColor = [UIColor mfCharcoalColor]; -} - + (void)styleLabelBodyLighter:(nonnull UILabel *)label { label.font = [MFStyler fontB2]; label.textColor = [UIColor mfGrayColor]; @@ -870,11 +853,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelBodyBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForBodyBold:genericScaling]; - label.textColor = [UIColor mfCharcoalColor]; -} - + (void)styleLabelBodyLighter:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB2:genericScaling]; label.textColor = [UIColor mfGrayColor]; @@ -916,11 +894,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.text = text; } -+ (void)styleSetLabelTextWithBodyBold:(UILabel *)label text:(NSString *)text { - [MFStyler styleLabelBodyBold:label]; - label.text = text; -} - + (void)styleSetLabelTextWithB3:(nonnull UILabel *)label text:(nullable NSString *)text { [MFStyler styleLabelB3:label]; label.text = text; @@ -966,8 +939,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor mfLighterGrayColor]]; } -+ (nonnull NSAttributedString *)styleGetBodyBoldAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontForBodyBold] color:[UIColor mfCharcoalColor]]; ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor mfCharcoalColor]]; } + (nonnull NSAttributedString *)styleGetLegalAttributedString:(nullable NSString *)string { diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 0f887033..f55c417f 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -101,12 +101,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelBodyLighter { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelBodyLighter:label]; - return label; -} - + (nonnull UILabel *)commonLabelFeedTitle { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleFeedCardTitleLabel:label]; From 23f75ab2cc08aaa30b77f305dbf2bb7a81410d30 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 16:52:14 -0400 Subject: [PATCH 05/35] remove BodyLighter font and label --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 10 ---------- MVMCoreUI/Styles/MFStyler.h | 3 --- MVMCoreUI/Styles/MFStyler.m | 10 ---------- MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h | 1 - 5 files changed, 26 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 6e1b27dd..1ab5f5b6 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -41,7 +41,6 @@ // Getters + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); -+ (nonnull MFLabel *)commonLabelBodyLighter:(BOOL)scale; + (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; @@ -59,7 +58,6 @@ - (void)styleB2:(BOOL)scale; - (void)styleBodyWithSize:(CGFloat)size scale:(BOOL)scale; - (void)styleBodyBold:(BOOL)scale; -- (void)styleBodyLighter:(BOOL)scale; - (void)styleBodyLarge:(BOOL)scale; - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 28808106..af868946 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -116,11 +116,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelBodyLighter:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleBodyLighter:scale]; - return label; -} + (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale { MFLabel *label = [MFLabel label]; @@ -314,11 +309,6 @@ [self setScale:scale]; } -- (void)styleBodyLighter:(BOOL)scale { - [MFStyler styleLabelBodyLighter:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleBodyLarge:(BOOL)scale { [MFStyler styleLabelBodyLarge:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 69e5bb55..c8f44aaa 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -273,7 +273,6 @@ B3 -> Legal + (void)styleLabelSubheadBold:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label; + (void)styleLabelBodyLarge:(nonnull UILabel *)label; -+ (void)styleLabelBodyLighter:(nonnull UILabel *)label; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label; @@ -293,8 +292,6 @@ B3 -> Legal + (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelSubheadBoldLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelBodyLighter:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index a83340f9..8e403bdd 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -771,11 +771,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelBodyLighter:(nonnull UILabel *)label { - label.font = [MFStyler fontB2]; - label.textColor = [UIColor mfGrayColor]; -} - + (void)styleLabelB1:(nonnull UILabel *)label { label.font = [MFStyler fontB1]; label.textColor = [UIColor blackColor]; @@ -853,11 +848,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelBodyLighter:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontB2:genericScaling]; - label.textColor = [UIColor mfGrayColor]; -} - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedCardTitle:genericScaling]; label.textColor = [UIColor blackColor]; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 9b640c85..0fc001b3 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -36,7 +36,6 @@ + (nonnull UILabel *)commonLabelHeadlineFeed; + (nonnull UILabel *)commonLabelSubheadBold; + (nonnull UILabel *)commonLabelBodyLarge; -+ (nonnull UILabel *)commonLabelBodyLighter; + (nonnull UILabel *)commonLabelFeedTitle; #pragma mark - Text Field From 6c7e7453586b570ff8833dd42abf8716db5af146 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 16:57:13 -0400 Subject: [PATCH 06/35] remove HeadlineExtraLarge --- MVMCoreUI/Atoms/Views/MFLabel.h | 1 - MVMCoreUI/Styles/MFStyler.h | 7 ---- MVMCoreUI/Styles/MFStyler.m | 35 ------------------- .../Utility/MVMCoreUICommonViewsUtility.h | 1 - .../Utility/MVMCoreUICommonViewsUtility.m | 6 ---- 5 files changed, 50 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 1ab5f5b6..4cd26fed 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -57,7 +57,6 @@ + (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; - (void)styleB2:(BOOL)scale; - (void)styleBodyWithSize:(CGFloat)size scale:(BOOL)scale; -- (void)styleBodyBold:(BOOL)scale; - (void)styleBodyLarge:(BOOL)scale; - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index c8f44aaa..21e8f726 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -141,8 +141,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineSmall2; //75Bd 32pt + (nullable UIFont *)fontForHeadlineLarge; -//75Bd 36pt -+ (nullable UIFont *)fontForHeadlineExtraLarge; //75Bd 14pt + (nullable UIFont *)fontForSubheadBold; //75Md 20pt @@ -197,7 +195,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; + (nullable UIFont *)fontForHeadlineLarge:(BOOL)genericScaling; -+ (nullable UIFont *)fontForHeadlineExtraLarge:(BOOL)genericScaling; + (nullable UIFont *)fontB1ForWidth:(CGFloat)size; + (nullable UIFont *)fontForSubheadBold:(BOOL)genericScaling; + (nullable UIFont *)fontForSubheadBoldLarge:(BOOL)genericScaling; @@ -266,7 +263,6 @@ B3 -> Legal #pragma mark - 1.0 styles + (void)styleLabelHeadlineLarge:(nonnull UILabel *)label; -+ (void)styleLabelHeadlineExtraLarge:(nonnull UILabel *)label; + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label; @@ -283,7 +279,6 @@ B3 -> Legal + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelHeadlineLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelHeadlineExtraLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; @@ -301,7 +296,6 @@ B3 -> Legal + (void)styleSetLabelTextWithH2:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithHeadlineLarge:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithHeadlineExtraLarge:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithH3:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithB2:(nonnull UILabel *)label text:(nullable NSString *)text; + (void)styleSetLabelTextWithB3:(nonnull UILabel *)label text:(nullable NSString *)text; @@ -311,7 +305,6 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetHeadlineAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetHeadlineLargeAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetHeadlineExtraLargeAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetBodyAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 8e403bdd..a556c3db 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -213,14 +213,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontForHeadlineExtraLarge:(BOOL)genericScaling { - CGFloat size = 36; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)commonLabelB1:(BOOL)genericScaling { CGFloat size = 13; if (genericScaling) { @@ -542,10 +534,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForHeadlineLarge:YES]; } -+ (nullable UIFont *)fontForHeadlineExtraLarge { - return [self fontForHeadlineExtraLarge:YES]; -} - + (nullable UIFont *)fontForSubheadBold { return [self fontForSubheadBold:YES]; } @@ -746,11 +734,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelHeadlineExtraLarge:(nonnull UILabel *)label { - label.font = [MFStyler fontForHeadlineExtraLarge]; - label.textColor = [UIColor mfRedColor]; -} - + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label { label.font = [MFStyler fontForFeedHeadline]; label.textColor = [UIColor mfRedColor]; @@ -802,11 +785,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfRedColor]; } -+ (void)styleLabelHeadlineExtraLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForHeadlineExtraLarge:genericScaling]; - label.textColor = [UIColor mfRedColor]; -} - + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedHeadline:genericScaling]; label.textColor = [UIColor blackColor]; @@ -869,15 +847,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; [MFStyler styleLabelHeadlineLarge:label]; label.text = text; } -+ (void)styleSetLabelTextWithHeadlineExtraLarge:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelHeadlineExtraLarge:label]; - label.text = text; -} - -+ (void)styleSetLabelTextWithH3:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelH3:label]; - label.text = text; -} + (void)styleSetLabelTextWithB2:(nonnull UILabel *)label text:(nullable NSString *)text { [MFStyler styleLabelB2:label]; @@ -913,10 +882,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFStyler styleGetAttributedString:string font:[MFStyler fontForHeadlineLarge] color:[UIColor mfRedColor]]; } -+ (nonnull NSAttributedString *)styleGetHeadlineExtraLargeAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontForHeadlineExtraLarge] color:[UIColor mfRedColor]]; -} - + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; } diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 0fc001b3..08392de6 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -32,7 +32,6 @@ // Creates and returns common labels + (nonnull UILabel *)label; + (nonnull UILabel *)commonLabelHeadlineLarge; -+ (nonnull UILabel *)commonLabelHeadlineExtraLarge; + (nonnull UILabel *)commonLabelHeadlineFeed; + (nonnull UILabel *)commonLabelSubheadBold; + (nonnull UILabel *)commonLabelBodyLarge; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index f55c417f..52bff2f7 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -59,12 +59,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelHeadlineExtraLarge { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineExtraLarge:label]; - return label; -} - + (nonnull UILabel *)commonLabelHeadlineFeed { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelHeadlineFeed:label]; From 883c4b6ea2195ec3360761f826d598a7bd8b3fe5 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 17:02:17 -0400 Subject: [PATCH 07/35] remove headlineblack --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 11 ----------- MVMCoreUI/Styles/MFStyler.h | 1 - 3 files changed, 14 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 4cd26fed..5cd9e730 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -44,7 +44,6 @@ + (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelHeadlineBlackWithSize:(CGFloat)size scale:(BOOL)scale; + (nonnull MFLabel *)commonLabelSubheadBold:(BOOL)scale; + (nonnull MFLabel *)commonLabelSubheadBoldLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; @@ -63,7 +62,6 @@ - (void)styleHeadlineLarge:(BOOL)scale; - (void)styleHeadlineSmall:(BOOL)scale; - (void)styleHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; -- (void)styleHeadlineBlackWithSize:(CGFloat)size scale:(BOOL)scale; - (void)styleH3:(BOOL)scale; - (void)styleSubheadBold:(BOOL)scale; - (void)styleSubheadBoldLarge:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index af868946..a89473d5 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -147,12 +147,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelHeadlineBlackWithSize:(CGFloat)size scale:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleHeadlineBlackWithSize:size scale:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelH3:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleH3:scale]; @@ -338,11 +332,6 @@ [self setScale:scale]; } -- (void)styleHeadlineBlackWithSize:(CGFloat)size scale:(BOOL)scale { - [MFStyler styleLabelHeadlineBlack:self size:size genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleH3:(BOOL)scale { [MFStyler styleLabelH3:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 21e8f726..74fc1cab 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -283,7 +283,6 @@ B3 -> Legal + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelH2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling; -+ (void)styleLabelHeadlineBlack:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling; + (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelSubheadBoldLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; From ca1c77bc104e1b8db1c0a42b921b4615a3475406 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 17:13:20 -0400 Subject: [PATCH 08/35] remove plan card title --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 11 ----------- MVMCoreUI/Styles/MFStyler.h | 7 ++----- MVMCoreUI/Styles/MFStyler.m | 30 ------------------------------ 4 files changed, 2 insertions(+), 48 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 5cd9e730..d3025b13 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -48,7 +48,6 @@ + (nonnull MFLabel *)commonLabelSubheadBoldLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; + (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelPlanCardTitle:(BOOL)scale; + (nonnull MFLabel *)commonLabelTopAlert:(BOOL)scale; // Setters @@ -68,7 +67,6 @@ - (void)styleB3:(BOOL)scale; - (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedTitle:(BOOL)scale; -- (void)stylePlanCardTitle:(BOOL)scale; - (void)styleB1:(BOOL)scale; - (void)styleTableRow:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index a89473d5..7b40f0d5 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -195,12 +195,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelPlanCardTitle:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label stylePlanCardTitle:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelB1:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleB1:scale]; @@ -373,11 +367,6 @@ [self setScale:scale]; } -- (void)stylePlanCardTitle:(BOOL)scale { - self.font = [MFStyler fontForPlanCardTitle:NO]; - [self setScale:scale]; -} - - (void)styleB1:(BOOL)scale { [MFStyler styleLabelB1:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 74fc1cab..eef4125b 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -174,9 +174,7 @@ B3 -> Legal //65Md 10pt + (nullable UIFont *)fontForProgressBarTopLabel; //75Bd 20pt -+ (nullable UIFont *)fontForPlanCardTitle; -//75Bd 18pt -+ (nullable UIFont *)fontForAccesseriesHeadline; ++ (nullable UIFont *)fontH3; //75Bd 60pt + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle; //75Bd 42pt @@ -218,8 +216,7 @@ B3 -> Legal + (nullable UIFont *)fontForSupportQuestionMark:(BOOL)genericScaling; + (nullable UIFont *)fontForSupportDateStamp:(BOOL)genericScaling; + (nullable UIFont *)fontForProgressBarTopLabel:(BOOL)genericScaling; -+ (nullable UIFont *)fontForPlanCardTitle:(BOOL)genericScaling; -+ (nullable UIFont *)fontForAccesseriesHeadline:(BOOL)genericScaling; ++ (nullable UIFont *)fontH3:(BOOL)genericScaling; + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyTitleSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyMessage:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index a556c3db..369079c2 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -432,22 +432,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontForPlanCardTitle:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - -+ (nullable UIFont *)fontForAccesseriesHeadline:(BOOL)genericScaling { - CGFloat size = 18.0; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling { CGFloat size = 60; if (genericScaling) { @@ -610,14 +594,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForProgressBarTopLabel:YES]; } -+ (nullable UIFont *)fontForPlanCardTitle { - return [self fontForPlanCardTitle:YES]; -} - -+ (nullable UIFont *)fontForAccesseriesHeadline { - return [self fontForAccesseriesHeadline:YES]; -} - + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle { return [self fontForLargeLoyaltyHeaderTitle:YES]; } @@ -804,12 +780,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfRedColor]; } -+ (void)styleLabelHeadlineBlack:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForHeadlineWithSize:size genericScaling:genericScaling]; - label.textColor = [UIColor blackColor]; -} - - + (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForSubheadBold:genericScaling]; label.textColor = [UIColor blackColor]; From 5fa9bd15720f36ca35158526a9cfeb04b473cd00 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 27 Mar 2019 17:40:37 -0400 Subject: [PATCH 09/35] remove SubheadBold and SubheadBoldlarge --- MVMCoreUI/Atoms/Views/MFLabel.h | 9 --- MVMCoreUI/Atoms/Views/MFLabel.m | 55 ------------------- MVMCoreUI/Styles/MFStyler.h | 10 ---- MVMCoreUI/Styles/MFStyler.m | 53 ------------------ .../Utility/MVMCoreUICommonViewsUtility.h | 1 - .../Utility/MVMCoreUICommonViewsUtility.m | 6 -- 6 files changed, 134 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index d3025b13..c6288c09 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -44,11 +44,8 @@ + (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; + (nonnull MFLabel *)commonLabelHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelSubheadBold:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelSubheadBoldLarge:(BOOL)scale; + (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; + (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelTopAlert:(BOOL)scale; // Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html; @@ -62,15 +59,9 @@ - (void)styleHeadlineSmall:(BOOL)scale; - (void)styleHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; - (void)styleH3:(BOOL)scale; -- (void)styleSubheadBold:(BOOL)scale; -- (void)styleSubheadBoldLarge:(BOOL)scale; - (void)styleB3:(BOOL)scale; - (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedTitle:(BOOL)scale; - (void)styleB1:(BOOL)scale; -- (void)styleTableRow:(BOOL)scale; - -// Without color -- (void)setFontH1:(BOOL)scale; @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 7b40f0d5..7a02ad78 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -153,18 +153,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelSubheadBold:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleSubheadBold:scale]; - return label; -} - -+ (nonnull MFLabel *)commonLabelSubheadBoldLarge:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleSubheadBoldLarge:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelB3:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleB3:scale]; @@ -189,24 +177,12 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleFeedTitle:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelB1:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleB1:scale]; return label; } -+ (nonnull MFLabel *)commonLabelTopAlert:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleTopAlert:scale]; - return label; -} - #pragma mark - Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html { @@ -331,17 +307,6 @@ [self setScale:scale]; } -- (void)styleSubheadBold:(BOOL)scale { - [MFStyler styleLabelSubheadBold:self genericScaling:NO]; - [self setScale:scale]; -} - - -- (void)styleSubheadBoldLarge:(BOOL)scale { - [MFStyler styleLabelSubheadBoldLarge:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleB3:(BOOL)scale { [MFStyler styleLabelB3:self genericScaling:NO]; [self setScale:scale]; @@ -362,31 +327,11 @@ [self setScale:scale]; } -- (void)styleFeedTitle:(BOOL)scale { - [MFStyler styleFeedCardTitleLabel:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleB1:(BOOL)scale { [MFStyler styleLabelB1:self genericScaling:NO]; [self setScale:scale]; } -- (void)styleTableRow:(BOOL)scale { - [MFStyler styleLabelB1:self genericScaling:NO]; - [self setScale:scale]; -} - -- (void)styleTopAlert:(BOOL)scale { - self.font = [MFStyler fontB1:NO]; - [self setScale:scale]; -} - -- (void)setFontH1:(BOOL)scale { - self.font = [MFStyler fontH1:NO]; - [self setScale:scale]; -} - - (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits { if (accessibilityTraits& UIAccessibilityTraitHeader) { diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index eef4125b..d2c02a9a 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -141,10 +141,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineSmall2; //75Bd 32pt + (nullable UIFont *)fontForHeadlineLarge; -//75Bd 14pt -+ (nullable UIFont *)fontForSubheadBold; -//75Md 20pt -+ (nullable UIFont *)fontForSubheadBoldLarge; //55Rg 14pt + (nullable UIFont *)fontforChatText; @@ -194,8 +190,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; + (nullable UIFont *)fontForHeadlineLarge:(BOOL)genericScaling; + (nullable UIFont *)fontB1ForWidth:(CGFloat)size; -+ (nullable UIFont *)fontForSubheadBold:(BOOL)genericScaling; -+ (nullable UIFont *)fontForSubheadBoldLarge:(BOOL)genericScaling; + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling; + (nullable UIFont *)fontB2ForWidth:(CGFloat)size; + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size forWidth:(CGFloat)width; @@ -216,7 +210,6 @@ B3 -> Legal + (nullable UIFont *)fontForSupportQuestionMark:(BOOL)genericScaling; + (nullable UIFont *)fontForSupportDateStamp:(BOOL)genericScaling; + (nullable UIFont *)fontForProgressBarTopLabel:(BOOL)genericScaling; -+ (nullable UIFont *)fontH3:(BOOL)genericScaling; + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyTitleSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyMessage:(BOOL)genericScaling; @@ -263,7 +256,6 @@ B3 -> Legal + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label; -+ (void)styleLabelSubheadBold:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label; + (void)styleLabelBodyLarge:(nonnull UILabel *)label; @@ -280,8 +272,6 @@ B3 -> Legal + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelH2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling; -+ (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelSubheadBoldLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 369079c2..ad1aee01 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -227,23 +227,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:pointSize]; } -+ (nullable UIFont *)fontForSubheadBold:(BOOL)genericScaling { - CGFloat size = 14; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - - -+ (nullable UIFont *)fontForSubheadBoldLarge:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontB2:(BOOL)genericScaling { CGFloat size = 13; if (genericScaling) { @@ -518,14 +501,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForHeadlineLarge:YES]; } -+ (nullable UIFont *)fontForSubheadBold { - return [self fontForSubheadBold:YES]; -} - -+ (nullable UIFont *)fontForSubheadBoldLarge { - return [self fontForSubheadBoldLarge:YES]; -} - + (nullable UIFont *)fontB2 { return [self fontB2:YES]; } @@ -715,11 +690,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfRedColor]; } -+ (void)styleLabelSubheadBold:(nonnull UILabel *)label { - label.font = [MFStyler fontForSubheadBold]; - label.textColor = [UIColor blackColor]; -} - + (void)styleLabelB2:(nonnull UILabel *)label { label.font = [MFStyler fontB2]; label.textColor = [UIColor blackColor]; @@ -735,22 +705,15 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleFeedCardTitleLabel:(nonnull UILabel *)label { - label.font = [MFStyler fontForFeedCardTitle]; - label.textColor = [UIColor blackColor]; -} - + (void)styleFeedCardTagLabel:(nonnull UILabel *)label { label.font = [MFStyler fontB3]; label.textColor = [UIColor mfBrownishGrey]; } - + (void)styleStandardSeparatorView:(nonnull UIView *)view { [view setBackgroundColor:[UIColor mfBackgroundGray]]; } - + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForHeadlineSmall:genericScaling]; label.textColor = [UIColor blackColor]; @@ -780,27 +743,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfRedColor]; } -+ (void)styleLabelSubheadBold:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForSubheadBold:genericScaling]; - label.textColor = [UIColor blackColor]; -} - -+ (void)styleLabelSubheadBoldLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForSubheadBoldLarge:genericScaling]; - label.textColor = [UIColor blackColor]; -} - - + (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForBodyLarge:genericScaling]; label.textColor = [UIColor blackColor]; } -+ (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForFeedCardTitle:genericScaling]; - label.textColor = [UIColor blackColor]; -} - + (void)styleFeedCardTagLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB3:genericScaling]; label.textColor = [UIColor mfBrownishGrey]; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 08392de6..aab5bd76 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -33,7 +33,6 @@ + (nonnull UILabel *)label; + (nonnull UILabel *)commonLabelHeadlineLarge; + (nonnull UILabel *)commonLabelHeadlineFeed; -+ (nonnull UILabel *)commonLabelSubheadBold; + (nonnull UILabel *)commonLabelBodyLarge; + (nonnull UILabel *)commonLabelFeedTitle; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 52bff2f7..1feb3e30 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -77,12 +77,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelSubheadBold { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelSubheadBold:label]; - return label; -} - + (nonnull UILabel *)commonLabelBody { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelB2:label]; From 3cc9750333d0c5213e707d9596063e34484f4eae Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 28 Mar 2019 10:39:02 -0400 Subject: [PATCH 10/35] remove 1.0 fonts --- MVMCoreUI/Atoms/Views/MFLabel.h | 32 +++-- MVMCoreUI/Atoms/Views/MFLabel.m | 115 ++++++++---------- MVMCoreUI/Molecules/TopLabelsView.m | 2 +- MVMCoreUI/Styles/MFStyler.h | 34 +----- MVMCoreUI/Styles/MFStyler.m | 95 +-------------- .../Utility/MVMCoreUICommonViewsUtility.h | 4 +- .../Utility/MVMCoreUICommonViewsUtility.m | 16 +-- 7 files changed, 91 insertions(+), 207 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index c6288c09..d1dd36bc 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -27,41 +27,49 @@ - (BOOL)hasText; #pragma mark - 2.0 - -+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale; +//75Bd 40pt + (nonnull MFLabel *)commonLabelH1:(BOOL)scale; +//75Bd 25pt + (nonnull MFLabel *)commonLabelH2:(BOOL)scale; +//75Bd 18pt + (nonnull MFLabel *)commonLabelH3:(BOOL)scale; +//75Bd 13pt + (nonnull MFLabel *)commonLabelB1:(BOOL)scale; +//55Rg 13pt ++ (nonnull MFLabel *)commonLabelB2:(BOOL)scale; +//55Rg 11pt gray + (nonnull MFLabel *)commonLabelB3:(BOOL)scale; +//75Bd 32pt ++ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; +//55Rg 20pt + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale; +//55Rg 11pt + (nonnull MFLabel *)commonLabelFeedSubMessage:(BOOL)scale; #pragma mark - 1.0 // Getters + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); -+ (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale; +//75Bd 15pt + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; -+ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; +//75Bd 16pt + (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale; // Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html; + (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; -- (void)styleB2:(BOOL)scale; -- (void)styleBodyWithSize:(CGFloat)size scale:(BOOL)scale; -- (void)styleBodyLarge:(BOOL)scale; + - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; -- (void)styleHeadlineLarge:(BOOL)scale; -- (void)styleHeadlineSmall:(BOOL)scale; -- (void)styleHeadlineWithSize:(CGFloat)size scale:(BOOL)scale; - (void)styleH3:(BOOL)scale; +- (void)styleB1:(BOOL)scale; +- (void)styleB2:(BOOL)scale; - (void)styleB3:(BOOL)scale; - (void)styleFeedHeadline:(BOOL)scale; +- (void)styleFeedMessage:(BOOL)scale; +- (void)styleFeedSubMessage:(BOOL)scale; + - (void)styleFeedTitle:(BOOL)scale; -- (void)styleB1:(BOOL)scale; +- (void)styleHeadlineSmall:(BOOL)scale; @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 7a02ad78..513326a9 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -100,28 +100,11 @@ } } -#pragma mark - Getters - - (BOOL)hasText { return self.text.length > 0 || self.attributedText.length > 0; } -+ (nonnull MFLabel *)label { - return [[MFLabel alloc] initWithFrame:CGRectZero]; -} - -+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleB2:scale]; - return label; -} - - -+ (nonnull MFLabel *)commonLabelBodyLarge:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleBodyLarge:scale]; - return label; -} +#pragma mark - 2.0 + (nonnull MFLabel *)commonLabelH1:(BOOL)scale { MFLabel *label = [MFLabel label]; @@ -135,30 +118,36 @@ return label; } -+ (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleHeadlineSmall:scale]; - return label; -} - -+ (nonnull MFLabel *)commonLabelHeadlineWithSize:(CGFloat)size scale:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleHeadlineWithSize:size scale:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelH3:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleH3:scale]; return label; } ++ (nonnull MFLabel *)commonLabelB1:(BOOL)scale { + MFLabel *label = [MFLabel label]; + [label styleB1:scale]; + return label; +} + ++ (nonnull MFLabel *)commonLabelB2:(BOOL)scale { + MFLabel *label = [MFLabel label]; + [label styleB2:scale]; + return label; +} + + (nonnull MFLabel *)commonLabelB3:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleB3:scale]; return label; } ++ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale { + MFLabel *label = [MFLabel label]; + [label styleFeedHeadline:scale]; + return label; +} + + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleFeedMessage:scale]; @@ -171,15 +160,21 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale { +#pragma mark - 1.0 + ++ (nonnull MFLabel *)label { + return [[MFLabel alloc] initWithFrame:CGRectZero]; +} + ++ (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale { MFLabel *label = [MFLabel label]; - [label styleFeedHeadline:scale]; + [label styleHeadlineSmall:scale]; return label; } -+ (nonnull MFLabel *)commonLabelB1:(BOOL)scale { ++ (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale { MFLabel *label = [MFLabel label]; - [label styleB1:scale]; + [label styleFeedTitle:scale]; return label; } @@ -263,21 +258,6 @@ self.originalAttributedString = self.attributedText; } -- (void)styleB2:(BOOL)scale { - [MFStyler styleLabelB2:self genericScaling:NO]; - [self setScale:scale]; -} - -- (void)styleBodyWithSize:(CGFloat)size scale:(BOOL)scale { - [MFStyler styleLabelB2:self size:size genericScaling:NO]; - [self setScale:scale]; -} - -- (void)styleBodyLarge:(BOOL)scale { - [MFStyler styleLabelBodyLarge:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleH1:(BOOL)scale { [MFStyler styleLabelH1:self genericScaling:NO]; [self setScale:scale]; @@ -288,30 +268,31 @@ [self setScale:scale]; } -- (void)styleHeadlineLarge:(BOOL)scale { - [MFStyler styleLabelHeadlineLarge:self genericScaling:NO]; - [self setScale:scale]; -} -- (void)styleHeadlineSmall:(BOOL)scale { - [MFStyler styleLabelHeadlineSmall:self genericScaling:NO]; - [self setScale:scale]; -} - -- (void)styleHeadlineWithSize:(CGFloat)size scale:(BOOL)scale { - [MFStyler styleLabelH2:self size:size genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleH3:(BOOL)scale { [MFStyler styleLabelH3:self genericScaling:NO]; [self setScale:scale]; } +- (void)styleB1:(BOOL)scale { + [MFStyler styleLabelB1:self genericScaling:NO]; + [self setScale:scale]; +} + +- (void)styleB2:(BOOL)scale { + [MFStyler styleLabelB2:self genericScaling:NO]; + [self setScale:scale]; +} + - (void)styleB3:(BOOL)scale { [MFStyler styleLabelB3:self genericScaling:NO]; [self setScale:scale]; } +- (void)styleFeedHeadline:(BOOL)scale { + [MFStyler styleLabelHeadlineFeed:self genericScaling:NO]; + [self setScale:scale]; +} + - (void)styleFeedMessage:(BOOL)scale { [MFStyler styleLabelFeedMessage:self genericScaling:NO]; [self setScale:scale]; @@ -322,13 +303,13 @@ [self setScale:scale]; } -- (void)styleFeedHeadline:(BOOL)scale { - [MFStyler styleLabelHeadlineFeed:self genericScaling:NO]; +- (void)styleHeadlineSmall:(BOOL)scale { + [MFStyler styleLabelHeadlineSmall:self genericScaling:NO]; [self setScale:scale]; } -- (void)styleB1:(BOOL)scale { - [MFStyler styleLabelB1:self genericScaling:NO]; +- (void)styleFeedTitle:(BOOL)scale { + [MFStyler styleFeedCardTitleLabel:self genericScaling:NO]; [self setScale:scale]; } diff --git a/MVMCoreUI/Molecules/TopLabelsView.m b/MVMCoreUI/Molecules/TopLabelsView.m index 04c9b758..08bd4007 100644 --- a/MVMCoreUI/Molecules/TopLabelsView.m +++ b/MVMCoreUI/Molecules/TopLabelsView.m @@ -180,7 +180,7 @@ #pragma mark - Common styles - (void)setAsLargeHeadline { - [MFStyler styleLabelHeadlineLarge:self.headlineLabel]; + [MFStyler styleLabelH1:self.headlineLabel]; [self layoutIfNeeded]; if (self.tableView) { [self.tableView showHeader]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index d2c02a9a..cf8f878a 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -118,6 +118,10 @@ B3 -> Legal + (nullable UIFont *)fontB4:(BOOL)genericScaling; + (nullable UIFont *)fontB4; +//55Rg 20pt ++ (nullable UIFont *)fontForFeedMessage; +//55Rg 11pt ++ (nullable UIFont *)fontForFeedSubMessage; #pragma mark - 1.0 fonts @@ -125,29 +129,20 @@ B3 -> Legal + (nullable UIFont *)fontForPlan; //75Bd 48pt + (nullable UIFont *)fontForBiggerHeadline; -//75Bd 26pt -+ (nullable UIFont *)fontForLoyaltySignUpHeadLine; //75Bd 40pt + (nullable UIFont *)fontForFeedHeadline; -//55Rg 20pt -+ (nullable UIFont *)fontForFeedMessage; -//55Rg 11pt -+ (nullable UIFont *)fontForFeedSubMessage; + //75Bd 15pt + (nullable UIFont *)fontForHeadlineSmall; //75Bd 11pt + (nullable UIFont *)fontForHeadlineTiny; //75Bd 16pt + (nullable UIFont *)fontForHeadlineSmall2; -//75Bd 32pt -+ (nullable UIFont *)fontForHeadlineLarge; //55Rg 14pt + (nullable UIFont *)fontforChatText; //55Rg 16pt + (nullable UIFont *)fontForAccountLandingGreeting; -//55Rg 20pt -+ (nullable UIFont *)fontForBodyLarge; //55Rg 10pt + (nullable UIFont *)fontForProgressBarBottomLabel; @@ -169,8 +164,6 @@ B3 -> Legal + (nullable UIFont *)fontForSupportDateStamp; //65Md 10pt + (nullable UIFont *)fontForProgressBarTopLabel; -//75Bd 20pt -+ (nullable UIFont *)fontH3; //75Bd 60pt + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle; //75Bd 42pt @@ -181,21 +174,18 @@ B3 -> Legal + (nullable UIFont *)fontForUnreadMessageOnSupport; // Returns the fonts for these styles allowing to apply a generic scale by device or not. -+ (nullable UIFont *)fontForHeadlineWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedSubMessage:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; -+ (nullable UIFont *)fontForHeadlineLarge:(BOOL)genericScaling; + (nullable UIFont *)fontB1ForWidth:(CGFloat)size; + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling; + (nullable UIFont *)fontB2ForWidth:(CGFloat)size; + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size forWidth:(CGFloat)width; + (nullable UIFont *)fontforChatText:(BOOL)genericScaling; + (nullable UIFont *)fontForAccountLandingGreeting:(BOOL)genericScaling; -+ (nullable UIFont *)fontForBodyLarge:(BOOL)genericScaling; + (nullable UIFont *)fontForPrimaryButton:(BOOL)genericScaling; + (nullable UIFont *)fontForPrimaryButtonForWidth:(CGFloat)size; @@ -252,12 +242,10 @@ B3 -> Legal #pragma mark - 1.0 styles -+ (void)styleLabelHeadlineLarge:(nonnull UILabel *)label; + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label; -+ (void)styleLabelBodyLarge:(nonnull UILabel *)label; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label; @@ -267,30 +255,19 @@ B3 -> Legal + (void)styleStandardSeparatorView:(nonnull UIView *)view; + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelHeadlineLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelH2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling; -+ (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; //------------------------------------------------- -// Sets the text with strings attributed with these styles. - -+ (void)styleSetLabelTextWithH2:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithHeadlineLarge:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithH3:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithB2:(nonnull UILabel *)label text:(nullable NSString *)text; -+ (void)styleSetLabelTextWithB3:(nonnull UILabel *)label text:(nullable NSString *)text; #pragma mark - Attributed Strings + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetHeadlineAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetHeadlineLargeAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetBodyAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; @@ -306,6 +283,7 @@ B3 -> Legal //------------------------------------------------- // Returns colors for Gradient Text presets + + (nonnull NSArray *)gradientSpecialTicketGold; + (nonnull NSArray *)gradientSpecialTicketGoldCGColor; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index ad1aee01..c37e9746 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -128,13 +128,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - Fonts -+ (nullable UIFont *)fontForHeadlineWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling { - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontForPlan:(BOOL)genericScaling { CGFloat size = 100; if (genericScaling) { @@ -151,14 +144,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontForLoyaltySignUpHeadLine:(BOOL)genericScaling { - CGFloat size = 26; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling { CGFloat size = 32; if (genericScaling) { @@ -205,14 +190,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:pointSize]; } -+ (nullable UIFont *)fontForHeadlineLarge:(BOOL)genericScaling { - CGFloat size = 40; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)commonLabelB1:(BOOL)genericScaling { CGFloat size = 13; if (genericScaling) { @@ -269,14 +246,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontForBodyLarge:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; -} - + (nullable UIFont *)fontB3:(BOOL)genericScaling { CGFloat size = 11; if (genericScaling) { @@ -469,10 +438,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForBiggerHeadLine:YES]; } -+ (nullable UIFont *)fontForLoyaltySignUpHeadLine { - return [self fontForLoyaltySignUpHeadLine:YES]; -} - + (nullable UIFont *)fontForFeedHeadline { return [self fontForFeedHeadline:YES]; } @@ -497,10 +462,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForHeadlineSmall2:YES]; } -+ (nullable UIFont *)fontForHeadlineLarge { - return [self fontForHeadlineLarge:YES]; -} - + (nullable UIFont *)fontB2 { return [self fontB2:YES]; } @@ -513,10 +474,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForAccountLandingGreeting:YES]; } -+ (nullable UIFont *)fontForBodyLarge { - return [self fontForBodyLarge:YES]; -} - + (nullable UIFont *)fontB3 { return [self fontB3:YES]; } @@ -680,11 +637,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 1.0 Styles -+ (void)styleLabelHeadlineLarge:(nonnull UILabel *)label { - label.font = [MFStyler fontForHeadlineLarge]; - label.textColor = [UIColor blackColor]; -} - + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label { label.font = [MFStyler fontForFeedHeadline]; label.textColor = [UIColor mfRedColor]; @@ -695,13 +647,13 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelBodyLarge:(nonnull UILabel *)label { - label.font = [MFStyler fontForBodyLarge]; ++ (void)styleLabelB1:(nonnull UILabel *)label { + label.font = [MFStyler fontB1]; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelB1:(nonnull UILabel *)label { - label.font = [MFStyler fontB1]; ++ (void)styleFeedCardTitleLabel:(nonnull UILabel *)label { + label.font = [MFStyler fontForFeedCardTitle]; label.textColor = [UIColor blackColor]; } @@ -719,11 +671,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelHeadlineLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForHeadlineLarge:genericScaling]; - label.textColor = [UIColor mfRedColor]; -} - + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedHeadline:genericScaling]; label.textColor = [UIColor blackColor]; @@ -738,13 +685,9 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.font = [MFStyler fontForFeedSubMessage:genericScaling]; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelH2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForHeadlineWithSize:size genericScaling:genericScaling]; - label.textColor = [UIColor mfRedColor]; -} -+ (void)styleLabelBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForBodyLarge:genericScaling]; ++ (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontForFeedCardTitle:genericScaling]; label.textColor = [UIColor blackColor]; } @@ -753,28 +696,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfBrownishGrey]; } -#pragma mark - Set Text With Styles - -+ (void)styleSetLabelTextWithH2:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelH2:label]; - label.text = text; -} - -+ (void)styleSetLabelTextWithHeadlineLarge:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelHeadlineLarge:label]; - label.text = text; -} - -+ (void)styleSetLabelTextWithB2:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelB2:label]; - label.text = text; -} - -+ (void)styleSetLabelTextWithB3:(nonnull UILabel *)label text:(nullable NSString *)text { - [MFStyler styleLabelB3:label]; - label.text = text; -} - #pragma mark - Attributed Strings + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color { @@ -795,10 +716,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor mfRedColor]]; } -+ (nonnull NSAttributedString *)styleGetHeadlineLargeAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontForHeadlineLarge] color:[UIColor mfRedColor]]; -} - + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; } diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index aab5bd76..9e3e2ad8 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -20,6 +20,7 @@ #pragma mark - 2.0 labels ++ (nonnull UILabel *)commonLabelH1; + (nonnull UILabel *)commonLabelH2; + (nonnull UILabel *)commonLabelH3; + (nonnull UILabel *)commonLabelB1; @@ -31,9 +32,8 @@ // Creates and returns common labels + (nonnull UILabel *)label; -+ (nonnull UILabel *)commonLabelHeadlineLarge; + (nonnull UILabel *)commonLabelHeadlineFeed; -+ (nonnull UILabel *)commonLabelBodyLarge; ++ (nonnull UILabel *)commonLabelFeedHeadline; + (nonnull UILabel *)commonLabelFeedTitle; #pragma mark - Text Field diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index 1feb3e30..a22c8e68 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -53,18 +53,18 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelHeadlineLarge { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineLarge:label]; - return label; -} - + (nonnull UILabel *)commonLabelHeadlineFeed { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelHeadlineFeed:label]; return label; } ++ (nonnull UILabel *)commonLabelH1 { + UILabel *label = [MVMCoreUICommonViewsUtility label]; + [MFStyler styleLabelH1:label]; + return label; +} + + (nonnull UILabel *)commonLabelH2 { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelH2:label]; @@ -83,9 +83,9 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelBodyLarge { ++ (nonnull UILabel *)commonLabelFeedHeadline { UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelBodyLarge:label]; + [MFStyler styleLabelHeadlineFeed:label]; return label; } From 6ee6170031651b2914dbcf448f27ddaad7f3ff13 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 28 Mar 2019 10:43:09 -0400 Subject: [PATCH 11/35] remove feedsubmessage --- MVMCoreUI/Atoms/Views/MFLabel.h | 3 --- MVMCoreUI/Atoms/Views/MFLabel.m | 11 ----------- MVMCoreUI/Styles/MFStyler.h | 5 ----- MVMCoreUI/Styles/MFStyler.m | 22 ---------------------- 4 files changed, 41 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index d1dd36bc..45710013 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -43,8 +43,6 @@ + (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; //55Rg 20pt + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale; -//55Rg 11pt -+ (nonnull MFLabel *)commonLabelFeedSubMessage:(BOOL)scale; #pragma mark - 1.0 @@ -67,7 +65,6 @@ - (void)styleB3:(BOOL)scale; - (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedMessage:(BOOL)scale; -- (void)styleFeedSubMessage:(BOOL)scale; - (void)styleFeedTitle:(BOOL)scale; - (void)styleHeadlineSmall:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 513326a9..4e6637a8 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -154,12 +154,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedSubMessage:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleFeedSubMessage:scale]; - return label; -} - #pragma mark - 1.0 + (nonnull MFLabel *)label { @@ -298,11 +292,6 @@ [self setScale:scale]; } -- (void)styleFeedSubMessage:(BOOL)scale { - [MFStyler styleLabelFeedSubMessage:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleHeadlineSmall:(BOOL)scale { [MFStyler styleLabelHeadlineSmall:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index cf8f878a..c60c853b 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -120,8 +120,6 @@ B3 -> Legal //55Rg 20pt + (nullable UIFont *)fontForFeedMessage; -//55Rg 11pt -+ (nullable UIFont *)fontForFeedSubMessage; #pragma mark - 1.0 fonts @@ -176,7 +174,6 @@ B3 -> Legal // Returns the fonts for these styles allowing to apply a generic scale by device or not. + (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling; -+ (nullable UIFont *)fontForFeedSubMessage:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; @@ -244,7 +241,6 @@ B3 -> Legal + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; -+ (void)styleLabelFeedSubMessage:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label; @@ -257,7 +253,6 @@ B3 -> Legal + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index c37e9746..170b16c0 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -160,14 +160,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontForFeedSubMessage:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; -} - + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling { CGFloat size = 15; if (genericScaling) { @@ -446,10 +438,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForFeedMessage:YES]; } -+ (nullable UIFont *)fontForFeedSubMessage { - return [self fontForFeedSubMessage:YES]; -} - + (nullable UIFont *)fontForHeadlineSmall { return [self fontForHeadlineSmall:YES]; } @@ -630,11 +618,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelFeedSubMessage:(nonnull UILabel *)label { - label.font = [MFStyler fontForFeedMessage]; - label.textColor = [UIColor blackColor]; -} - #pragma mark - 1.0 Styles + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label { @@ -681,11 +664,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelFeedSubMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForFeedSubMessage:genericScaling]; - label.textColor = [UIColor blackColor]; -} - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedCardTitle:genericScaling]; label.textColor = [UIColor blackColor]; From b43690d10ebbbec16b6e5d1d9ba2e0bcf0dae2bc Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 28 Mar 2019 11:19:18 -0400 Subject: [PATCH 12/35] clean up some fonts method --- MVMCoreUI/Atoms/Views/MFLabel.h | 3 - MVMCoreUI/Atoms/Views/MFLabel.m | 11 -- MVMCoreUI/Styles/MFStyler.h | 23 ++- MVMCoreUI/Styles/MFStyler.m | 150 +++++++----------- .../Utility/MVMCoreUICommonViewsUtility.h | 3 +- .../Utility/MVMCoreUICommonViewsUtility.m | 16 +- 6 files changed, 72 insertions(+), 134 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 45710013..4b2d6f37 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -50,8 +50,6 @@ + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); //75Bd 15pt + (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; -//75Bd 16pt -+ (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale; // Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html; @@ -66,7 +64,6 @@ - (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedMessage:(BOOL)scale; -- (void)styleFeedTitle:(BOOL)scale; - (void)styleHeadlineSmall:(BOOL)scale; @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 4e6637a8..9714fc57 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -166,12 +166,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedTitle:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleFeedTitle:scale]; - return label; -} - #pragma mark - Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html { @@ -297,11 +291,6 @@ [self setScale:scale]; } -- (void)styleFeedTitle:(BOOL)scale { - [MFStyler styleFeedCardTitleLabel:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits { if (accessibilityTraits& UIAccessibilityTraitHeader) { diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index c60c853b..f58610ab 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -114,11 +114,9 @@ B3 -> Legal //55Rg 11pt + (nullable UIFont *)fontB3:(BOOL)genericScaling; + (nullable UIFont *)fontB3; -//55Rg 14pt -+ (nullable UIFont *)fontB4:(BOOL)genericScaling; -+ (nullable UIFont *)fontB4; //55Rg 20pt ++ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedMessage; #pragma mark - 1.0 fonts @@ -127,9 +125,8 @@ B3 -> Legal + (nullable UIFont *)fontForPlan; //75Bd 48pt + (nullable UIFont *)fontForBiggerHeadline; -//75Bd 40pt +//75Bd 32pt + (nullable UIFont *)fontForFeedHeadline; - //75Bd 15pt + (nullable UIFont *)fontForHeadlineSmall; //75Bd 11pt @@ -172,8 +169,9 @@ B3 -> Legal + (nullable UIFont *)fontForUnreadMessageOnSupport; // Returns the fonts for these styles allowing to apply a generic scale by device or not. ++ (nullable UIFont *)fontForBiggerHeadLine:(BOOL)genericScaling; ++ (nullable UIFont *)fontForPlan:(BOOL)genericScaling; + (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling; -+ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; @@ -225,15 +223,13 @@ B3 -> Legal + (void)styleLabelB1:(nonnull UILabel *)label; + (void)styleLabelB1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelB2:(nonnull UILabel *)label; + (void)styleLabelB2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelB2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling; + (void)styleLabelB3:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelB3:(nonnull UILabel *)label; -+ (void)styleLabelB4:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelB4:(nonnull UILabel *)label; - + (void)styleLabelTextStyle2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelTextStyle2:(nonnull UILabel *)label; @@ -241,13 +237,10 @@ B3 -> Legal + (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; -+ (void)styleLabelB2:(nonnull UILabel *)label; - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label; - + (void)styleStandardSeparatorView:(nonnull UIView *)view; + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; @@ -264,10 +257,12 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetHeadlineAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetBodyAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string; + + (nonnull NSAttributedString *)styleGetDisabledBodyAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetLegalAttributedString:(nullable NSString *)string; + + (nonnull NSAttributedString *)styleGetSubtitleAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetDisabledSubtitleAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetTopAlignedAttributeStringWithLeftString:(nullable NSString *)left centerString:(nonnull NSString *)center rightString:(nullable NSString *)right withCenterStringFontSize:(CGFloat)fontSize andColor:(nonnull UIColor *)color; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 170b16c0..00e8c55c 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -126,8 +126,56 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontH3:YES]; } ++ (nullable UIFont *)fontB1:(BOOL)genericScaling { + CGFloat size = 13; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont75Bd:size]; +} + ++ (nullable UIFont *)fontB1 { + return [self fontB1:YES]; +} + ++ (nullable UIFont *)fontB2:(BOOL)genericScaling { + CGFloat size = 13; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; +} + ++ (nullable UIFont *)fontB2 { + return [self fontB2:YES]; +} + ++ (nullable UIFont *)fontB3:(BOOL)genericScaling { + CGFloat size = 11; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; +} + ++ (nullable UIFont *)fontB3 { + return [self fontB3:YES]; +} + #pragma mark - Fonts ++ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling { + CGFloat size = 20; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; +} + ++ (nullable UIFont *)fontForFeedMessage { + return [self fontForFeedMessage:YES]; +} + + (nullable UIFont *)fontForPlan:(BOOL)genericScaling { CGFloat size = 100; if (genericScaling) { @@ -136,6 +184,10 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } ++ (nullable UIFont *)fontForPlan { + return [self fontForPlan:YES]; +} + + (nullable UIFont *)fontForBiggerHeadLine:(BOOL)genericScaling { CGFloat size = 48; if (genericScaling) { @@ -144,6 +196,10 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } ++ (nullable UIFont *)fontForBiggerHeadline { + return [self fontForBiggerHeadLine:YES]; +} + + (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling { CGFloat size = 32; if (genericScaling) { @@ -152,12 +208,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; ++ (nullable UIFont *)fontForFeedHeadline { + return [self fontForFeedHeadline:YES]; } + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling { @@ -182,28 +234,12 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:pointSize]; } -+ (nullable UIFont *)commonLabelB1:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontB1ForWidth:(CGFloat)size { CGFloat pointSize = 13; pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; return [MFFonts mfFont75Bd:pointSize]; } -+ (nullable UIFont *)fontB2:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; -} - + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling { if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; @@ -238,14 +274,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontB3:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; -} - + (nullable UIFont *)fontForProgressBarBottomLabel:(BOOL)genericScaling { CGFloat size = 10; if (genericScaling) { @@ -254,14 +282,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontB1:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontForPrimaryButton:(BOOL)genericScaling { CGFloat size = 14; if (genericScaling) { @@ -344,14 +364,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontB4:(BOOL)genericScaling { - CGFloat size = 14; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; -} - + (nullable UIFont *)fontForSupportQuestionMark:(BOOL)genericScaling { CGFloat size = 18; if (genericScaling) { @@ -422,22 +434,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFontOcratxt:size]; } -+ (nullable UIFont *)fontForPlan { - return [self fontForPlan:YES]; -} - -+ (nullable UIFont *)fontForBiggerHeadline { - return [self fontForBiggerHeadLine:YES]; -} - -+ (nullable UIFont *)fontForFeedHeadline { - return [self fontForFeedHeadline:YES]; -} - -+ (nullable UIFont *)fontForFeedMessage { - return [self fontForFeedMessage:YES]; -} - + (nullable UIFont *)fontForHeadlineSmall { return [self fontForHeadlineSmall:YES]; } @@ -450,10 +446,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForHeadlineSmall2:YES]; } -+ (nullable UIFont *)fontB2 { - return [self fontB2:YES]; -} - + (nullable UIFont *)fontforChatText { return [self fontforChatText:NO]; } @@ -462,18 +454,10 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForAccountLandingGreeting:YES]; } -+ (nullable UIFont *)fontB3 { - return [self fontB3:YES]; -} - + (nullable UIFont *)fontForProgressBarBottomLabel { return [self fontForProgressBarBottomLabel:YES]; } -+ (nullable UIFont *)fontB1 { - return [self fontB1:YES]; -} - + (nullable UIFont *)fontForPrimaryButton { return [self fontForPrimaryButton:YES]; } @@ -498,10 +482,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForFeedCardTitle:YES]; } -+ (nullable UIFont *)fontB4 { - return [self fontB4:YES]; -} - + (nullable UIFont *)fontForSupportQuestionMark { return [self fontForSupportQuestionMark:YES]; } @@ -593,16 +573,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfBattleshipGrey]; } -+ (void)styleLabelB4:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontB4:genericScaling]; - label.textColor = [UIColor blackColor]; -} - -+ (void)styleLabelB4:(nonnull UILabel *)label { - label.font = [MFStyler fontB4]; - label.textColor = [UIColor blackColor]; -} - + (void)styleLabelTextStyle2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB2:genericScaling]; label.textColor = [UIColor mfBattleshipGrey]; @@ -698,7 +668,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; } -+ (nonnull NSAttributedString *)styleGetBodyAttributedString:(nullable NSString *)string { ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor blackColor]]; } @@ -710,7 +680,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor mfCharcoalColor]]; } -+ (nonnull NSAttributedString *)styleGetLegalAttributedString:(nullable NSString *)string { ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfGrayColor]]; } diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 9e3e2ad8..5220205b 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -26,7 +26,6 @@ + (nonnull UILabel *)commonLabelB1; + (nonnull UILabel *)commonLabelB2; + (nonnull UILabel *)commonLabelB3; -+ (nonnull UILabel *)commonLabelB4; #pragma mark - Labels @@ -34,7 +33,7 @@ + (nonnull UILabel *)label; + (nonnull UILabel *)commonLabelHeadlineFeed; + (nonnull UILabel *)commonLabelFeedHeadline; -+ (nonnull UILabel *)commonLabelFeedTitle; ++ (nonnull UILabel *)commonLabelHeadlineSmall; #pragma mark - Text Field diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index a22c8e68..e870f1e7 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -77,21 +77,15 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelBody { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelB2:label]; - return label; -} - + (nonnull UILabel *)commonLabelFeedHeadline { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelHeadlineFeed:label]; return label; } -+ (nonnull UILabel *)commonLabelFeedTitle { ++ (nonnull UILabel *)commonLabelHeadlineSmall { UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleFeedCardTitleLabel:label]; + [MFStyler styleLabelHeadlineSmall:label genericScaling:YES]; return label; } @@ -113,12 +107,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelB4 { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelB4:label]; - return label; -} - #pragma mark - Text Field + (nonnull UIPickerView *)addPickerToTextField:(nonnull UITextField *)textField delegate:(nullable id )delegate { From 0db36c1405564d5a61689c3f3a07b694470ec29f Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 28 Mar 2019 12:01:57 -0400 Subject: [PATCH 13/35] reduce fonts --- MVMCoreUI/Atoms/Views/MFLabel.h | 6 ----- MVMCoreUI/Atoms/Views/MFLabel.m | 13 ---------- MVMCoreUI/Styles/MFStyler.h | 4 ---- .../Utility/MVMCoreUICommonViewsUtility.h | 2 -- .../Utility/MVMCoreUICommonViewsUtility.m | 24 +++++-------------- 5 files changed, 6 insertions(+), 43 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 4b2d6f37..a5ca49ab 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -44,12 +44,8 @@ //55Rg 20pt + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale; -#pragma mark - 1.0 - // Getters + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); -//75Bd 15pt -+ (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale; // Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html; @@ -64,6 +60,4 @@ - (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedMessage:(BOOL)scale; -- (void)styleHeadlineSmall:(BOOL)scale; - @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 9714fc57..0370e23f 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -154,18 +154,10 @@ return label; } -#pragma mark - 1.0 - + (nonnull MFLabel *)label { return [[MFLabel alloc] initWithFrame:CGRectZero]; } -+ (nonnull MFLabel *)commonLabelHeadlineSmall:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleHeadlineSmall:scale]; - return label; -} - #pragma mark - Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html { @@ -286,11 +278,6 @@ [self setScale:scale]; } -- (void)styleHeadlineSmall:(BOOL)scale { - [MFStyler styleLabelHeadlineSmall:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits { if (accessibilityTraits& UIAccessibilityTraitHeader) { diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index f58610ab..41177f14 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -125,14 +125,10 @@ B3 -> Legal + (nullable UIFont *)fontForPlan; //75Bd 48pt + (nullable UIFont *)fontForBiggerHeadline; -//75Bd 32pt -+ (nullable UIFont *)fontForFeedHeadline; //75Bd 15pt + (nullable UIFont *)fontForHeadlineSmall; //75Bd 11pt + (nullable UIFont *)fontForHeadlineTiny; -//75Bd 16pt -+ (nullable UIFont *)fontForHeadlineSmall2; //55Rg 14pt + (nullable UIFont *)fontforChatText; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index 5220205b..d8d5c27d 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -31,9 +31,7 @@ // Creates and returns common labels + (nonnull UILabel *)label; -+ (nonnull UILabel *)commonLabelHeadlineFeed; + (nonnull UILabel *)commonLabelFeedHeadline; -+ (nonnull UILabel *)commonLabelHeadlineSmall; #pragma mark - Text Field diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index e870f1e7..dfae6b26 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -53,12 +53,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelHeadlineFeed { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineFeed:label]; - return label; -} - + (nonnull UILabel *)commonLabelH1 { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelH1:label]; @@ -77,18 +71,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelFeedHeadline { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineFeed:label]; - return label; -} - -+ (nonnull UILabel *)commonLabelHeadlineSmall { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineSmall:label genericScaling:YES]; - return label; -} - + (nonnull UILabel *)commonLabelB1 { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelB1:label]; @@ -107,6 +89,12 @@ static const CGFloat VertialShadowOffset = 6; return label; } ++ (nonnull UILabel *)commonLabelFeedHeadline { + UILabel *label = [MVMCoreUICommonViewsUtility label]; + [MFStyler styleLabelHeadlineFeed:label]; + return label; +} + #pragma mark - Text Field + (nonnull UIPickerView *)addPickerToTextField:(nonnull UITextField *)textField delegate:(nullable id )delegate { From 560ea1030d606dd2d66884415bd12030f0f2bbcd Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 1 Apr 2019 12:01:44 -0400 Subject: [PATCH 14/35] add actions into mflabel --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 ++ MVMCoreUI/Atoms/Views/MFLabel.m | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index a5ca49ab..7a73e1df 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -20,6 +20,8 @@ // Set this to use a custom sizing object during updateView instead of the standard. @property (nonatomic, strong, nullable) MFSizeObject *sizeObject; +@property (nonatomic, strong, nullable) NSDictionary *actions; + // Set the font and set to scale - (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 0370e23f..0bf52d22 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -17,6 +17,8 @@ @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreJSONConstants; +@import MVMCore.MVMCoreActionHandler; +@import MVMCore.UILabel_MFCustom; @interface MFLabel () @@ -198,6 +200,7 @@ NSArray *attributes = [json array:@"attributes"]; if (attributes) { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}]; + NSMutableDictionary *actions = [NSMutableDictionary new]; for (NSDictionary *attribute in attributes) { NSNumber *location = [attribute optionalNumberForKey:@"location"]; NSNumber *length = [attribute optionalNumberForKey:@"length"]; @@ -225,10 +228,18 @@ if (font) { [attributedString addAttribute:NSFontAttributeName value:font range:range]; } + } else if ([type isEqualToString:@"link"]) { + label.userInteractionEnabled = YES; + [actions setObject:attribute forKey:[NSValue valueWithRange:range]]; } } } label.attributedText = attributedString; + if ([label isKindOfClass:[MFLabel class]]) { + MFLabel *mflabel = (MFLabel *)label; + mflabel.actions = actions; + } + } } } @@ -289,4 +300,25 @@ } +#pragma mark - action + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + NSDictionary *actionMap = [self areTouchesInActionString:touches]; + if (actionMap) { + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:nil delegate:nil]; + } +} + +- (NSDictionary *)areTouchesInActionString:(NSSet *)touches { + CGPoint location = [[touches anyObject] locationInView:self]; + for (NSValue *valueOfRange in self.actions.allKeys) { + NSRange range = [valueOfRange rangeValue]; + CGRect rect = [self boundingRectForCharacterRange:range]; + if (CGRectContainsPoint(rect, location)){ + return [self.actions objectForKey:valueOfRange]; + } + } + return nil; +} + @end From 499f9eb55db81be5577b44ba8c2555cd5fb3877b Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Mon, 1 Apr 2019 13:30:31 -0400 Subject: [PATCH 15/35] Fixed setWithJSON, allows it to work properly with Atom molecule. Provided more properties to control. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index af7d1d60..9f48d358 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -112,9 +112,7 @@ open class CaretButton: MFCustomButton { } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - - // Configure class properties with JSON values + guard let jsonDictionary = json else { return } if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { @@ -128,5 +126,17 @@ open class CaretButton: MFCustomButton { if let disabledColorHex = jsonDictionary["disabledColor"] as? String { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } + + if let caretViewHeight = jsonDictionary["caretViewHeight"] as? NSNumber { + rightViewHeight = caretViewHeight + } + + if let caretViewWidth = jsonDictionary["caretViewWidth"] as? NSNumber { + rightViewWidth = caretViewWidth + } + + if let buttonText = jsonDictionary["buttonText"] as? String { + setTitle(buttonText, for: .normal) + } } } From b70f27f67afc05a37440da92f8334bcac946bd4f Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 1 Apr 2019 14:53:29 -0400 Subject: [PATCH 16/35] change feed headline to H32 --- MVMCoreUI/Atoms/Views/MFLabel.h | 6 +- MVMCoreUI/Atoms/Views/MFLabel.m | 21 +++--- MVMCoreUI/Styles/MFStyler.h | 10 ++- MVMCoreUI/Styles/MFStyler.m | 64 +++++++++---------- .../Utility/MVMCoreUICommonViewsUtility.h | 2 +- .../Utility/MVMCoreUICommonViewsUtility.m | 12 ++-- 6 files changed, 59 insertions(+), 56 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 7a73e1df..f6dd14e1 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -35,14 +35,14 @@ + (nonnull MFLabel *)commonLabelH2:(BOOL)scale; //75Bd 18pt + (nonnull MFLabel *)commonLabelH3:(BOOL)scale; +//75Bd 32pt ++ (nonnull MFLabel *)commonLabelH32:(BOOL)scale; //75Bd 13pt + (nonnull MFLabel *)commonLabelB1:(BOOL)scale; //55Rg 13pt + (nonnull MFLabel *)commonLabelB2:(BOOL)scale; //55Rg 11pt gray + (nonnull MFLabel *)commonLabelB3:(BOOL)scale; -//75Bd 32pt -+ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale; //55Rg 20pt + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale; @@ -56,10 +56,10 @@ - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; - (void)styleH3:(BOOL)scale; +- (void)styleH32:(BOOL)scale; - (void)styleB1:(BOOL)scale; - (void)styleB2:(BOOL)scale; - (void)styleB3:(BOOL)scale; -- (void)styleFeedHeadline:(BOOL)scale; - (void)styleFeedMessage:(BOOL)scale; @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 0bf52d22..0f57c944 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -125,6 +125,11 @@ [label styleH3:scale]; return label; } ++ (nonnull MFLabel *)commonLabelH32:(BOOL)scale { + MFLabel *label = [MFLabel label]; + [label styleH32:scale]; + return label; +} + (nonnull MFLabel *)commonLabelB1:(BOOL)scale { MFLabel *label = [MFLabel label]; @@ -144,12 +149,6 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedHeadline:(BOOL)scale { - MFLabel *label = [MFLabel label]; - [label styleFeedHeadline:scale]; - return label; -} - + (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale { MFLabel *label = [MFLabel label]; [label styleFeedMessage:scale]; @@ -264,6 +263,11 @@ [self setScale:scale]; } +- (void)styleH32:(BOOL)scale { + [MFStyler styleLabelH32:self genericScaling:NO]; + [self setScale:scale]; +} + - (void)styleB1:(BOOL)scale { [MFStyler styleLabelB1:self genericScaling:NO]; [self setScale:scale]; @@ -279,11 +283,6 @@ [self setScale:scale]; } -- (void)styleFeedHeadline:(BOOL)scale { - [MFStyler styleLabelHeadlineFeed:self genericScaling:NO]; - [self setScale:scale]; -} - - (void)styleFeedMessage:(BOOL)scale { [MFStyler styleLabelFeedMessage:self genericScaling:NO]; [self setScale:scale]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 41177f14..3ef51144 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -104,6 +104,9 @@ B3 -> Legal //75Bd 18pt + (nullable UIFont *)fontH3:(BOOL)genericScaling; + (nullable UIFont *)fontH3; +//75Bd 32pt ++ (nullable UIFont *)fontH32:(BOOL)genericScaling; ++ (nullable UIFont *)fontH32; //75Bd 13pt + (nullable UIFont *)fontB1:(BOOL)genericScaling; @@ -167,8 +170,8 @@ B3 -> Legal // Returns the fonts for these styles allowing to apply a generic scale by device or not. + (nullable UIFont *)fontForBiggerHeadLine:(BOOL)genericScaling; + (nullable UIFont *)fontForPlan:(BOOL)genericScaling; -+ (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling; ++ (nullable UIFont *)fontForHeadlineSmall2; + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; + (nullable UIFont *)fontB1ForWidth:(CGFloat)size; @@ -216,6 +219,9 @@ B3 -> Legal + (void)styleLabelH3:(nonnull UILabel *)label; + (void)styleLabelH3:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelH32:(nonnull UILabel *)label; ++ (void)styleLabelH32:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + + (void)styleLabelB1:(nonnull UILabel *)label; + (void)styleLabelB1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; @@ -231,7 +237,6 @@ B3 -> Legal #pragma mark - 1.0 styles -+ (void)styleLabelHeadlineFeed:(nonnull UILabel *)label; + (void)styleLabelFeedMessage:(nonnull UILabel *)label; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label; @@ -240,7 +245,6 @@ B3 -> Legal + (void)styleStandardSeparatorView:(nonnull UIView *)view; + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 00e8c55c..edeeb625 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -126,6 +126,18 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontH3:YES]; } ++ (nullable UIFont *)fontH32:(BOOL)genericScaling { + CGFloat size = 32; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont75Bd:size]; +} + ++ (nullable UIFont *)fontH32 { + return [self fontH32:YES]; +} + + (nullable UIFont *)fontB1:(BOOL)genericScaling { CGFloat size = 13; if (genericScaling) { @@ -200,18 +212,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForBiggerHeadLine:YES]; } -+ (nullable UIFont *)fontForFeedHeadline:(BOOL)genericScaling { - CGFloat size = 32; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - -+ (nullable UIFont *)fontForFeedHeadline { - return [self fontForFeedHeadline:YES]; -} - + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling { CGFloat size = 15; if (genericScaling) { @@ -548,11 +548,31 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } ++ (void)styleLabelH32:(nonnull UILabel *)label { + label.font = [MFStyler fontH32]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelH32:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontH32:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelB1:(nonnull UILabel *)label { + label.font = [MFStyler fontB1]; + label.textColor = [UIColor blackColor]; +} + + (void)styleLabelB1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB1:genericScaling]; label.textColor = [UIColor blackColor]; } ++ (void)styleLabelB2:(nonnull UILabel *)label { + label.font = [MFStyler fontB2]; + label.textColor = [UIColor blackColor]; +} + + (void)styleLabelB2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB2:genericScaling]; label.textColor = [UIColor blackColor]; @@ -590,21 +610,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 1.0 Styles -+ (void)styleLabelHeadlineFeed:(nonnull UILabel *)label { - label.font = [MFStyler fontForFeedHeadline]; - label.textColor = [UIColor mfRedColor]; -} - -+ (void)styleLabelB2:(nonnull UILabel *)label { - label.font = [MFStyler fontB2]; - label.textColor = [UIColor blackColor]; -} - -+ (void)styleLabelB1:(nonnull UILabel *)label { - label.font = [MFStyler fontB1]; - label.textColor = [UIColor blackColor]; -} - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label { label.font = [MFStyler fontForFeedCardTitle]; label.textColor = [UIColor blackColor]; @@ -624,11 +629,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelHeadlineFeed:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForFeedHeadline:genericScaling]; - label.textColor = [UIColor blackColor]; -} - + (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedMessage:genericScaling]; label.textColor = [UIColor blackColor]; diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h index d8d5c27d..cc1df5e6 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.h @@ -23,6 +23,7 @@ + (nonnull UILabel *)commonLabelH1; + (nonnull UILabel *)commonLabelH2; + (nonnull UILabel *)commonLabelH3; ++ (nonnull UILabel *)commonLabelH32; + (nonnull UILabel *)commonLabelB1; + (nonnull UILabel *)commonLabelB2; + (nonnull UILabel *)commonLabelB3; @@ -31,7 +32,6 @@ // Creates and returns common labels + (nonnull UILabel *)label; -+ (nonnull UILabel *)commonLabelFeedHeadline; #pragma mark - Text Field diff --git a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m index dfae6b26..affbc470 100644 --- a/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUICommonViewsUtility.m @@ -71,6 +71,12 @@ static const CGFloat VertialShadowOffset = 6; return label; } ++ (nonnull UILabel *)commonLabelH32 { + UILabel *label = [MVMCoreUICommonViewsUtility label]; + [MFStyler styleLabelH32:label]; + return label; +} + + (nonnull UILabel *)commonLabelB1 { UILabel *label = [MVMCoreUICommonViewsUtility label]; [MFStyler styleLabelB1:label]; @@ -89,12 +95,6 @@ static const CGFloat VertialShadowOffset = 6; return label; } -+ (nonnull UILabel *)commonLabelFeedHeadline { - UILabel *label = [MVMCoreUICommonViewsUtility label]; - [MFStyler styleLabelHeadlineFeed:label]; - return label; -} - #pragma mark - Text Field + (nonnull UIPickerView *)addPickerToTextField:(nonnull UITextField *)textField delegate:(nullable id )delegate { From 1baa755cae3881a8d039af8d44ea106cb56cbf9a Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 1 Apr 2019 15:05:42 -0400 Subject: [PATCH 17/35] change font to B20 form feed message --- MVMCoreUI/Atoms/Views/MFLabel.h | 4 ++-- MVMCoreUI/Atoms/Views/MFLabel.m | 8 ++++---- MVMCoreUI/Styles/MFStyler.h | 12 ++++++------ MVMCoreUI/Styles/MFStyler.m | 29 +++++++++++++++-------------- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index f6dd14e1..896d1dca 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -44,7 +44,7 @@ //55Rg 11pt gray + (nonnull MFLabel *)commonLabelB3:(BOOL)scale; //55Rg 20pt -+ (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale; ++ (nonnull MFLabel *)commonLabelB20:(BOOL)scale; // Getters + (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel()); @@ -60,6 +60,6 @@ - (void)styleB1:(BOOL)scale; - (void)styleB2:(BOOL)scale; - (void)styleB3:(BOOL)scale; -- (void)styleFeedMessage:(BOOL)scale; +- (void)styleB20:(BOOL)scale; @end diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 0f57c944..c9d10129 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -149,9 +149,9 @@ return label; } -+ (nonnull MFLabel *)commonLabelFeedMessage:(BOOL)scale { ++ (nonnull MFLabel *)commonLabelB20:(BOOL)scale { MFLabel *label = [MFLabel label]; - [label styleFeedMessage:scale]; + [label styleB20:scale]; return label; } @@ -283,8 +283,8 @@ [self setScale:scale]; } -- (void)styleFeedMessage:(BOOL)scale { - [MFStyler styleLabelFeedMessage:self genericScaling:NO]; +- (void)styleB20:(BOOL)scale { + [MFStyler styleLabelB20:self genericScaling:NO]; [self setScale:scale]; } diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 3ef51144..ef3fc8fa 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -117,10 +117,9 @@ B3 -> Legal //55Rg 11pt + (nullable UIFont *)fontB3:(BOOL)genericScaling; + (nullable UIFont *)fontB3; - //55Rg 20pt -+ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling; -+ (nullable UIFont *)fontForFeedMessage; ++ (nullable UIFont *)fontB20:(BOOL)genericScaling; ++ (nullable UIFont *)fontB20; #pragma mark - 1.0 fonts @@ -232,20 +231,21 @@ B3 -> Legal + (void)styleLabelB3:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelB3:(nonnull UILabel *)label; ++ (void)styleLabelB20:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelB20:(nonnull UILabel *)label; + + (void)styleLabelTextStyle2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelTextStyle2:(nonnull UILabel *)label; #pragma mark - 1.0 styles -+ (void)styleLabelFeedMessage:(nonnull UILabel *)label; - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label; + (void)styleStandardSeparatorView:(nonnull UIView *)view; + (void)styleLabelHeadlineSmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; -+ (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleFeedCardTagLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index edeeb625..433b0ff8 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -174,9 +174,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontB3:YES]; } -#pragma mark - Fonts - -+ (nullable UIFont *)fontForFeedMessage:(BOOL)genericScaling { ++ (nullable UIFont *)fontB20:(BOOL)genericScaling { CGFloat size = 20; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; @@ -184,10 +182,12 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:size]; } -+ (nullable UIFont *)fontForFeedMessage { - return [self fontForFeedMessage:YES]; ++ (nullable UIFont *)fontB20 { + return [self fontB20:YES]; } +#pragma mark - 1.0 Fonts + + (nullable UIFont *)fontForPlan:(BOOL)genericScaling { CGFloat size = 100; if (genericScaling) { @@ -593,6 +593,16 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfBattleshipGrey]; } ++ (void)styleLabelB20:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontB20:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelB20:(nonnull UILabel *)label { + label.font = [MFStyler fontB20]; + label.textColor = [UIColor blackColor]; +} + + (void)styleLabelTextStyle2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontB2:genericScaling]; label.textColor = [UIColor mfBattleshipGrey]; @@ -603,10 +613,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor mfBattleshipGrey]; } -+ (void)styleLabelFeedMessage:(nonnull UILabel *)label { - label.font = [MFStyler fontForFeedMessage]; - label.textColor = [UIColor blackColor]; -} #pragma mark - 1.0 Styles @@ -629,11 +635,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelFeedMessage:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { - label.font = [MFStyler fontForFeedMessage:genericScaling]; - label.textColor = [UIColor blackColor]; -} - + (void)styleFeedCardTitleLabel:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForFeedCardTitle:genericScaling]; label.textColor = [UIColor blackColor]; From 1f837786801f9849b0867eb20144ecdc9fdf8edc Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 1 Apr 2019 15:22:17 -0400 Subject: [PATCH 18/35] remove useless font --- MVMCoreUI/Styles/MFStyler.h | 23 +++++---------------- MVMCoreUI/Styles/MFStyler.m | 40 ------------------------------------- 2 files changed, 5 insertions(+), 58 deletions(-) diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index ef3fc8fa..64e406e7 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -129,41 +129,31 @@ B3 -> Legal + (nullable UIFont *)fontForBiggerHeadline; //75Bd 15pt + (nullable UIFont *)fontForHeadlineSmall; -//75Bd 11pt -+ (nullable UIFont *)fontForHeadlineTiny; - //55Rg 14pt + (nullable UIFont *)fontforChatText; //55Rg 16pt + (nullable UIFont *)fontForAccountLandingGreeting; - //55Rg 10pt + (nullable UIFont *)fontForProgressBarBottomLabel; //55Rg 14pt + (nullable UIFont *)fontForPrimaryButton; -//55Rg 12pt +//75Bd 11pt + (nullable UIFont *)fontForSmallButton; -//45Lt 20pt +//55Rg 16pt + (nullable UIFont *)fontForTextField; //55Rg 12pt + (nullable UIFont *)fontForTextFieldUnderLabel; -//45Lt 24pt +//55Rg 24pt + (nullable UIFont *)fontForHeadlineAlternative; -//65Md 16pt +//75Bd 16pt + (nullable UIFont *)fontForFeedCardTitle; -//65Md 18pt -+ (nullable UIFont *)fontForSupportQuestionMark; -//65Md 11pt -+ (nullable UIFont *)fontForSupportDateStamp; -//65Md 10pt -+ (nullable UIFont *)fontForProgressBarTopLabel; //75Bd 60pt + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle; //75Bd 42pt + (nullable UIFont *)fontForLoyaltyTitleSmall; //55Rg 20pt + (nullable UIFont *)fontForLoyaltyMessage; -//45Lt 24pt only for support +//75Bd 10pt only for support + (nullable UIFont *)fontForUnreadMessageOnSupport; // Returns the fonts for these styles allowing to apply a generic scale by device or not. @@ -190,9 +180,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineAlternativeForWidth:(CGFloat)size; + (nullable UIFont *)fontForFeedCardTitle:(BOOL)genericScaling; -+ (nullable UIFont *)fontForSupportQuestionMark:(BOOL)genericScaling; -+ (nullable UIFont *)fontForSupportDateStamp:(BOOL)genericScaling; -+ (nullable UIFont *)fontForProgressBarTopLabel:(BOOL)genericScaling; + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyTitleSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForLoyaltyMessage:(BOOL)genericScaling; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 433b0ff8..48da21f3 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -364,30 +364,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont75Bd:size]; } -+ (nullable UIFont *)fontForSupportQuestionMark:(BOOL)genericScaling { - CGFloat size = 18; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - -+ (nullable UIFont *)fontForSupportDateStamp:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - -+ (nullable UIFont *)fontForProgressBarTopLabel:(BOOL)genericScaling { - CGFloat size = 10; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling { CGFloat size = 60; if (genericScaling) { @@ -438,10 +414,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForHeadlineSmall:YES]; } -+ (nullable UIFont *)fontForHeadlineTiny { - return [MFFonts mfFont75Bd:11]; -} - + (nullable UIFont *)fontForHeadlineSmall2 { return [self fontForHeadlineSmall2:YES]; } @@ -482,18 +454,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [self fontForFeedCardTitle:YES]; } -+ (nullable UIFont *)fontForSupportQuestionMark { - return [self fontForSupportQuestionMark:YES]; -} - -+ (nullable UIFont *)fontForSupportDateStamp { - return [self fontForSupportDateStamp:YES]; -} - -+ (nullable UIFont *)fontForProgressBarTopLabel { - return [self fontForProgressBarTopLabel:YES]; -} - + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle { return [self fontForLargeLoyaltyHeaderTitle:YES]; } From dd407f45f96847ebec5e88285c4ae6ce36679010 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Mon, 1 Apr 2019 16:44:33 -0400 Subject: [PATCH 19/35] changes made. Reduced access to caret dimensions. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 9f48d358..930cdd68 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,34 +109,24 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear + setTitle(actionMap?.optionalStringForKey(KeyTitle), for: .normal) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - - guard let jsonDictionary = json else { return } + setWithActionMap(actionMap, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) - if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { + guard let dictionary = json else { return } + + if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } - if let enableColorHex = jsonDictionary["enableColor"] as? String { + if let enableColorHex = dictionary["enableColor"] as? String { enabledColor = UIColor.mfGet(forHex: enableColorHex) } - if let disabledColorHex = jsonDictionary["disabledColor"] as? String { + if let disabledColorHex = dictionary["disabledColor"] as? String { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } - - if let caretViewHeight = jsonDictionary["caretViewHeight"] as? NSNumber { - rightViewHeight = caretViewHeight - } - - if let caretViewWidth = jsonDictionary["caretViewWidth"] as? NSNumber { - rightViewWidth = caretViewWidth - } - - if let buttonText = jsonDictionary["buttonText"] as? String { - setTitle(buttonText, for: .normal) - } } } From ff3055a4c77de6528b8b622f2320272b32f5c3a6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 2 Apr 2019 15:55:16 -0400 Subject: [PATCH 20/35] improvement --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 8 -- MVMCoreUI/Atoms/TextFields/MFTextField.m | 16 +--- MVMCoreUI/Models/FormValidator.swift | 15 ++-- MVMCoreUI/Models/MVMCoreUIFormValidator.h | 29 ------- MVMCoreUI/Models/MVMCoreUIFormValidator.m | 75 ------------------- MVMCoreUI/Molecules/MFTextFieldListView.swift | 12 --- .../Protocols/FormValidationProtocol.swift | 4 +- .../MVMCoreUIFormMoleculesProtocol.h | 18 ----- .../MVMCoreUIFormValidationProtocol.h | 29 ------- 10 files changed, 14 insertions(+), 196 deletions(-) delete mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator.h delete mode 100644 MVMCoreUI/Models/MVMCoreUIFormValidator.m delete mode 100644 MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h delete mode 100644 MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 699ad526..5df32702 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 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 */; }; 01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */; }; - 01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */; }; 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, ); }; }; @@ -168,7 +167,6 @@ 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; - 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormMoleculesProtocol.h; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; @@ -340,7 +338,6 @@ isa = PBXGroup; children = ( 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */, - 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */, ); path = Protocols; sourceTree = ""; @@ -775,7 +772,6 @@ D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */, D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */, - 01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */, D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */, D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */, diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index a7c8ee4a..7600bcf0 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -760,14 +760,6 @@ #pragma mark - FormValidationProtocol -- (nullable FormValidator*) formValidatorModel { - return self.formValidator; -} - -- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel { - self.formValidator = formValidatorModel; -} - - (void)enableField:(BOOL) enable { if (self.validationRequired == NO) { diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 49e26395..92ddfe0b 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -24,7 +24,6 @@ @interface MFTextField() -@property (strong, nonatomic) FormValidator* formValidator; @property (strong, nonatomic) UIColor *customPlaceHolderColor; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *separatorHeightConstraint; @property (strong, nonatomic) UIBezierPath *borderPath; @@ -113,14 +112,13 @@ [FormValidator setupValidationWithMolecule:self delegate: (id)delegate]; [self setWithMap:json bothDelegates:delegate]; - self.mfTextFieldDelegate = self.formValidator; - self.uiTextFieldDelegate = self.formValidator; + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; + self.mfTextFieldDelegate = formValidator; + self.uiTextFieldDelegate = formValidator; [self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]]; } - - - (void) setVerticalPadding:(CGFloat) padding { self.textContainerLeftPin.constant = padding; self.errorLableLeftPin.constant = padding; @@ -562,14 +560,6 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (nullable FormValidator*) formValidatorModel { - return self.formValidator; -} - -- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel { - self.formValidator = formValidatorModel; -} - - (BOOL) isValidField { return self.valid; } diff --git a/MVMCoreUI/Models/FormValidator.swift b/MVMCoreUI/Models/FormValidator.swift index 0304ca8d..1b546d69 100644 --- a/MVMCoreUI/Models/FormValidator.swift +++ b/MVMCoreUI/Models/FormValidator.swift @@ -18,20 +18,26 @@ import UIKit public func insertMolecule(_ molecule: UIView & FormValidationProtocol) { molecules.append(molecule) } + + public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? { + if let delegateFormValidatorModel = delegate.formValidatorModel, + let validator = delegateFormValidatorModel() { + return validator + } else { + return nil + } + } public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) { if let delegateFormValidatorModel = delegate?.formValidatorModel, - let setFormValidationModel = molecule.setFormValidationModel, let validator = delegateFormValidatorModel() { - + validator.delegate = delegate validator.insertMolecule(molecule) - setFormValidationModel(validator) } } public func enableByValidation() { - var valid = true for molecule in molecules { if let isValidField = molecule.isValidField, @@ -39,7 +45,6 @@ import UIKit valid = false } } - let enableField = valid && (extraValidationBlock?() ?? true) shouldEnable(enableField) } diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.h b/MVMCoreUI/Models/MVMCoreUIFormValidator.h deleted file mode 100644 index 151fb17f..00000000 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// MVMCoreUIFormValidator.h -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import -#import -NS_ASSUME_NONNULL_BEGIN - -@class MFTextField; - -@interface MVMCoreUIFormValidator : NSObject - -@property (weak, nonatomic) NSObject * delegate; -@property (strong, nonatomic) NSMutableArray *>* molecules; - -@property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void); - -- (void)setEnabledByValidity; -- (void)insertMolecule:(nonnull UIView *) molecule; - -+ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Models/MVMCoreUIFormValidator.m b/MVMCoreUI/Models/MVMCoreUIFormValidator.m deleted file mode 100644 index 55e919ce..00000000 --- a/MVMCoreUI/Models/MVMCoreUIFormValidator.m +++ /dev/null @@ -1,75 +0,0 @@ -// -// MVMCoreUIFormValidator.m -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreUIFormValidator.h" -#import "MFTextField.h" -@import MVMCore.MVMCoreDispatchUtility; - - -@implementation MVMCoreUIFormValidator - - -- (void)insertMolecule:(nonnull UIView *) molecule { - if (self.molecules == nil) { - self.molecules = [NSMutableArray array]; - } - if (molecule) { - [self.molecules addObject:molecule]; - } -} - -+ (void)setupValidationFor:(nonnull UIView *) molecule delegate:(nonnull NSObject *)delegate { - if ([delegate conformsToProtocol:@protocol(FormValidationProtocol)] - && [delegate respondsToSelector:@selector(formValidatorModel)] - && [molecule conformsToProtocol:@protocol(FormValidationProtocol)] - && [molecule respondsToSelector:@selector(setFormValidationModel:)]) { - - MVMCoreUIFormValidator *validator = [delegate formValidatorModel]; - validator.delegate = delegate; - [validator insertMolecule:molecule]; - [molecule setFormValidationModel:validator]; - } -} - - -- (void)setEnabledByValidity { - __block BOOL valid = YES; - [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)] - && [obj respondsToSelector:@selector(isValidField)] - && [obj isValidField] == NO) { - valid = NO; - *stop = YES; - } - }]; - BOOL shouldEnable = valid && (self.extraValidationBlock ? self.extraValidationBlock() : YES); - [self shouldEnable:shouldEnable]; -} - -- (void)shouldEnable:(BOOL) enable { - [self.molecules enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj conformsToProtocol:@protocol(FormValidationProtocol)] - && [obj respondsToSelector:@selector(enableField:)]) { - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [obj enableField:enable]; - }]; - } - }]; -} - -- (void)entryIsValid:(nullable MFTextField *)textfield { - [self setEnabledByValidity]; -} - -- (void)entryIsInvalid:(nullable MFTextField *)textfield { - [self shouldEnable:false]; -} - - -@end diff --git a/MVMCoreUI/Molecules/MFTextFieldListView.swift b/MVMCoreUI/Molecules/MFTextFieldListView.swift index bb267d29..6d24e19a 100644 --- a/MVMCoreUI/Molecules/MFTextFieldListView.swift +++ b/MVMCoreUI/Molecules/MFTextFieldListView.swift @@ -24,18 +24,6 @@ public class MFTextFieldListView: ViewConstrainingView { self.primaryButton = primaryButton super.init(frame: .zero) } - - - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - self.textFieldMapList = json?.arrayForKey("textFields") as? [[String : Any]] - - if let threeLayerVC = delegate as? ThreeLayerViewController { - self.parentViewContoller = threeLayerVC - self.primaryButton = (threeLayerVC.bottomView as? StandardFooterView)?.twoButtonView.primaryButton - } - setupView() - } - public required init?(coder decoder: NSCoder) { super.init(coder: decoder) diff --git a/MVMCoreUI/Protocols/FormValidationProtocol.swift b/MVMCoreUI/Protocols/FormValidationProtocol.swift index 71d07467..bfdbb0fd 100644 --- a/MVMCoreUI/Protocols/FormValidationProtocol.swift +++ b/MVMCoreUI/Protocols/FormValidationProtocol.swift @@ -10,9 +10,7 @@ import Foundation @objc public protocol FormValidationProtocol: NSObjectProtocol { - @objc func formValidatorModel() -> FormValidator? - - @objc optional func setFormValidationModel(_ formValidatorModel:FormValidator) + @objc optional func formValidatorModel() -> FormValidator? @objc optional func isValidField() -> Bool @objc optional func enableField(_ enable: Bool) diff --git a/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h b/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h deleted file mode 100644 index 3c76f16f..00000000 --- a/MVMCoreUI/Protocols/MVMCoreUIFormMoleculesProtocol.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// MVMCoreUIFormMoleculesProtocol.h -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/21/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import - - -@protocol MVMCoreUIFormMoleculesProtocol -//- (BOOL)isValidField; -//- (void)enableField:(BOOL) enable; -// -//- (NSString *)formFieldName; -//- (NSString *)formFieldValue; -@end diff --git a/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h b/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h deleted file mode 100644 index 3b55bd3c..00000000 --- a/MVMCoreUI/Protocols/MVMCoreUIFormValidationProtocol.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// MVMCoreUIFormValidationProtocol.h -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 3/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import -//#import -//#import "MVMCoreUI-Swift.h" - -@class MVMCoreUIFormValidator; - -@protocol MVMCoreUIFormValidationProtocol - -// Returns the form validator model -- (nullable MVMCoreUIFormValidator *) formValidatorModel; - -@optional -- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel; - -- (BOOL)isValidField; -- (void)enableField:(BOOL) enable; - -- (nullable NSString *)formFieldName; -- (nullable id)formFieldValue; - -@end From 8b3d561543286d0168a50393fbc8ef2db3b037a5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 2 Apr 2019 17:16:22 -0400 Subject: [PATCH 21/35] code review --- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 4 +- MVMCoreUI/Atoms/TextFields/MFTextField.m | 113 ++++++++++++----------- 2 files changed, 62 insertions(+), 55 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 7600bcf0..6c3ed6a9 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -31,7 +31,6 @@ @property (strong, nonatomic) NSMutableArray *textFields; @property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType; -@property (nonnull, strong, nonatomic) FormValidator* formValidator; @end @@ -682,7 +681,6 @@ - (void)setEnabledByValidity { - __block BOOL valid = YES; [self.textFields enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (!((MFTextField *)obj).valid) { @@ -711,7 +709,7 @@ [self setEnabledByValidity]; } -- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField{ +- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField { if (self.textFields == nil) { self.textFields = [NSMutableArray array]; } diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 92ddfe0b..b6718865 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -35,6 +35,7 @@ @property (weak, nonatomic) IBOutlet NSLayoutConstraint *textContainerRightPin; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *errorLableRightPin; +@property (nonatomic) BOOL isMolecule; @end @@ -48,6 +49,13 @@ self.label.font = [MFStyler fontForTextFieldUnderLabel]; [MFStyler styleTextField:self.textField]; [self.dashLine updateView:size]; + + if (self.isMolecule) { + [self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]]; + + } else { + [self setVerticalPadding:0]; + } }]; } @@ -109,17 +117,17 @@ } - (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { - [FormValidator setupValidationWithMolecule:self delegate: (id)delegate]; - + + self.isMolecule = YES; + [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; [self setWithMap:json bothDelegates:delegate]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; self.mfTextFieldDelegate = formValidator; self.uiTextFieldDelegate = formValidator; - [self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]]; } -- (void) setVerticalPadding:(CGFloat) padding { +- (void)setVerticalPadding:(CGFloat) padding { self.textContainerLeftPin.constant = padding; self.errorLableLeftPin.constant = padding; self.formLabelLeftPin.constant = padding; @@ -134,7 +142,6 @@ MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; [textField setWithJSON:map delegate:delegate additionalData:nil]; - [textField setVerticalPadding:0]; return textField; } @@ -319,53 +326,55 @@ } - (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { - if (map.count > 0) { - [MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate]; - [self setBothTextFieldDelegates:delegate]; - - NSString *string = [map string:KeyLabel]; - if (string.length > 0) { - self.formText = string; - } - string = [map string:KeyValue]; - if (string.length > 0) { - self.text = string; - } - string = [map stringForKey:KeyDisable]; - if ([string isEqual:StringY] || [map boolForKey:KeyDisable]) { - [self enable:NO]; - } - string = [map string:KeyErrorMessage]; - if (string.length > 0) { - self.errMessage = string; - } - - // key used to send text value to server - string = [map string:@"fieldKey"]; - if (string.length > 0) { - self.fieldKey = string; - } - - string = [map string:KeyType]; - if ([string isEqualToString:@"dropDown"]) { - [[self dropDownCarrotLabel] setHidden:NO]; - [self setHasDropDown:YES]; - } else if ([string isEqualToString:@"password"]) { - self.textField.secureTextEntry = YES; - } else if ([string isEqualToString:@"number"]) { - self.textField.keyboardType = UIKeyboardTypeNumberPad; - } else if ([string isEqualToString:@"email"]) { - self.textField.keyboardType = UIKeyboardTypeEmailAddress; - } - - string = [map string:@"regex"]; - if (string.length) { - self.validationBlock = ^BOOL(NSString * _Nullable enteredValue) { - return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string]; - }; - } else { - [self setDefaultValidationBlock]; - } + if (map.count == 0) { + return; + } + + [MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate]; + [self setBothTextFieldDelegates:delegate]; + + NSString *string = [map string:KeyLabel]; + if (string.length > 0) { + self.formText = string; + } + string = [map string:KeyValue]; + if (string.length > 0) { + self.text = string; + } + string = [map stringForKey:KeyDisable]; + if ([string isEqual:StringY] || [map boolForKey:KeyDisable]) { + [self enable:NO]; + } + string = [map string:KeyErrorMessage]; + if (string.length > 0) { + self.errMessage = string; + } + + // key used to send text value to server + string = [map string:@"fieldKey"]; + if (string.length > 0) { + self.fieldKey = string; + } + + string = [map string:KeyType]; + if ([string isEqualToString:@"dropDown"]) { + [[self dropDownCarrotLabel] setHidden:NO]; + [self setHasDropDown:YES]; + } else if ([string isEqualToString:@"password"]) { + self.textField.secureTextEntry = YES; + } else if ([string isEqualToString:@"number"]) { + self.textField.keyboardType = UIKeyboardTypeNumberPad; + } else if ([string isEqualToString:@"email"]) { + self.textField.keyboardType = UIKeyboardTypeEmailAddress; + } + + string = [map string:@"regex"]; + if (string.length) { + self.validationBlock = ^BOOL(NSString * _Nullable enteredValue) { + return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string]; + }; + } else { + [self setDefaultValidationBlock]; } } From d0ac49663a3c896093c17f4025db5205bbcf56cb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 2 Apr 2019 17:21:56 -0400 Subject: [PATCH 22/35] space --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index b6718865..67b3f73a 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -137,7 +137,6 @@ self.formLabelRightPin.constant = padding; } - + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; From cad3555156b6242fe1409d800c099dc337521676 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 09:40:03 -0400 Subject: [PATCH 23/35] Removed unnecessary setTitle call. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 930cdd68..d9a51c19 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,7 +109,6 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear - setTitle(actionMap?.optionalStringForKey(KeyTitle), for: .normal) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { From 39edb4c0555d5f2390c60a4176d2dfdcd975e11a Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 09:44:47 -0400 Subject: [PATCH 24/35] changes actionMap to json. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index d9a51c19..99a32098 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -112,7 +112,7 @@ open class CaretButton: MFCustomButton { } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - setWithActionMap(actionMap, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) + setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) guard let dictionary = json else { return } From 00feea9a58f869ed52fe42d0858d8caa1538219f Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 12:09:17 -0400 Subject: [PATCH 25/35] Added default text color for enabled and disabled states. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 99a32098..7d67afb1 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,6 +109,8 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear + setTitleColor(enabledColor, for: .normal) + setTitleColor(disabledColor, for: .disabled) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { @@ -120,8 +122,8 @@ open class CaretButton: MFCustomButton { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } - if let enableColorHex = dictionary["enableColor"] as? String { - enabledColor = UIColor.mfGet(forHex: enableColorHex) + if let enabledColorHex = dictionary["enabledColor"] as? String { + enabledColor = UIColor.mfGet(forHex: enabledColorHex) } if let disabledColorHex = dictionary["disabledColor"] as? String { From 7d7284bd8d50202a10704a9de24d96b6979f2fcc Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 3 Apr 2019 12:21:31 -0400 Subject: [PATCH 26/35] remove actions from mflabel --- MVMCoreUI/Atoms/Views/MFLabel.h | 2 -- MVMCoreUI/Atoms/Views/MFLabel.m | 24 ------------------------ 2 files changed, 26 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 896d1dca..22308465 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -20,8 +20,6 @@ // Set this to use a custom sizing object during updateView instead of the standard. @property (nonatomic, strong, nullable) MFSizeObject *sizeObject; -@property (nonatomic, strong, nullable) NSDictionary *actions; - // Set the font and set to scale - (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale; diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index c9d10129..c689e980 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -199,7 +199,6 @@ NSArray *attributes = [json array:@"attributes"]; if (attributes) { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}]; - NSMutableDictionary *actions = [NSMutableDictionary new]; for (NSDictionary *attribute in attributes) { NSNumber *location = [attribute optionalNumberForKey:@"location"]; NSNumber *length = [attribute optionalNumberForKey:@"length"]; @@ -229,14 +228,12 @@ } } else if ([type isEqualToString:@"link"]) { label.userInteractionEnabled = YES; - [actions setObject:attribute forKey:[NSValue valueWithRange:range]]; } } } label.attributedText = attributedString; if ([label isKindOfClass:[MFLabel class]]) { MFLabel *mflabel = (MFLabel *)label; - mflabel.actions = actions; } } @@ -299,25 +296,4 @@ } -#pragma mark - action - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - NSDictionary *actionMap = [self areTouchesInActionString:touches]; - if (actionMap) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:nil delegate:nil]; - } -} - -- (NSDictionary *)areTouchesInActionString:(NSSet *)touches { - CGPoint location = [[touches anyObject] locationInView:self]; - for (NSValue *valueOfRange in self.actions.allKeys) { - NSRange range = [valueOfRange rangeValue]; - CGRect rect = [self boundingRectForCharacterRange:range]; - if (CGRectContainsPoint(rect, location)){ - return [self.actions objectForKey:valueOfRange]; - } - } - return nil; -} - @end From 4e328eeb83e01a8b88ef1c4c8b50e78ab63e66e3 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 3 Apr 2019 15:46:06 -0400 Subject: [PATCH 27/35] update label and styler --- MVMCoreUI/Atoms/Views/MFLabel.m | 6 ------ MVMCoreUI/Styles/MFStyler.m | 34 +++++++++++++-------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index c689e980..72d0d359 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -226,16 +226,10 @@ if (font) { [attributedString addAttribute:NSFontAttributeName value:font range:range]; } - } else if ([type isEqualToString:@"link"]) { - label.userInteractionEnabled = YES; } } } label.attributedText = attributedString; - if ([label isKindOfClass:[MFLabel class]]) { - MFLabel *mflabel = (MFLabel *)label; - } - } } } diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 48da21f3..fc9b0c6c 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -498,19 +498,13 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; [self styleLabelH2:label genericScaling:YES]; } -+ (void)styleLabelH3:(nonnull UILabel *)label { - label.font = [MFStyler fontH3]; - label.textColor = [UIColor blackColor]; -} - + (void)styleLabelH3:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontH3:genericScaling]; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelH32:(nonnull UILabel *)label { - label.font = [MFStyler fontH32]; - label.textColor = [UIColor blackColor]; ++ (void)styleLabelH3:(nonnull UILabel *)label { + [self styleLabelH3:label genericScaling:YES]; } + (void)styleLabelH32:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -518,9 +512,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelB1:(nonnull UILabel *)label { - label.font = [MFStyler fontB1]; - label.textColor = [UIColor blackColor]; ++ (void)styleLabelH32:(nonnull UILabel *)label { + [self styleLabelH32:label genericScaling:YES]; } + (void)styleLabelB1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -528,9 +521,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } -+ (void)styleLabelB2:(nonnull UILabel *)label { - label.font = [MFStyler fontB2]; - label.textColor = [UIColor blackColor]; ++ (void)styleLabelB1:(nonnull UILabel *)label { + [self styleLabelB1:label genericScaling:YES]; } + (void)styleLabelB2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -538,9 +530,12 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; label.textColor = [UIColor blackColor]; } ++ (void)styleLabelB2:(nonnull UILabel *)label { + [self styleLabelB2:label genericScaling:YES]; +} + + (void)styleLabelB2:(nonnull UILabel *)label size:(CGFloat)size genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontForBodyWithSize:size genericScaling:genericScaling]; - label.textColor = [UIColor blackColor]; } + (void)styleLabelB3:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -549,8 +544,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (void)styleLabelB3:(nonnull UILabel *)label { - label.font = [MFStyler fontB3]; - label.textColor = [UIColor mfBattleshipGrey]; + [self styleLabelB3:label genericScaling:YES]; } + (void)styleLabelB20:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -559,8 +553,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (void)styleLabelB20:(nonnull UILabel *)label { - label.font = [MFStyler fontB20]; - label.textColor = [UIColor blackColor]; + [self styleLabelB20:label genericScaling:YES]; } + (void)styleLabelTextStyle2:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { @@ -569,8 +562,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (void)styleLabelTextStyle2:(nonnull UILabel *)label { - label.font = [MFStyler fontB2]; - label.textColor = [UIColor mfBattleshipGrey]; + [self styleLabelTextStyle2:label genericScaling:YES]; } From b58c191401071322f97be1615855fa86a944a779 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 3 Apr 2019 16:12:27 -0400 Subject: [PATCH 28/35] update stylegetattributestring function name to 2.0 change grayish color to mfgraycolor for body lighter --- MVMCoreUI/Styles/MFStyler.h | 11 +++++------ MVMCoreUI/Styles/MFStyler.m | 34 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 64e406e7..488a0648 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -242,16 +242,15 @@ B3 -> Legal #pragma mark - Attributed Strings + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; -+ (nonnull NSAttributedString *)styleGetHeadlineAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetDisabledBodyAttributedString:(nullable NSString *)string; - -+ (nonnull NSAttributedString *)styleGetSubtitleAttributedString:(nullable NSString *)string; -+ (nonnull NSAttributedString *)styleGetDisabledSubtitleAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetDisabledB2AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetTopAlignedAttributeStringWithLeftString:(nullable NSString *)left centerString:(nonnull NSString *)center rightString:(nullable NSString *)right withCenterStringFontSize:(CGFloat)fontSize andColor:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetTopAlignedAttributeStringWithLeftStringRightTop:(nullable NSString *)left centerString:(nonnull NSString *)center rightString:(nullable NSString *)right withCenterStringFontSize:(CGFloat)fontSize andColor:(nonnull UIColor *)color; + (void)styleGetAlignCenteredAttrituedString:(nullable NSMutableAttributedString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index fc9b0c6c..36d04e51 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -613,38 +613,38 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return attributedString; } -+ (nonnull NSAttributedString *)styleGetHeadlineAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor mfRedColor]]; ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1] color:[UIColor blackColor]]; } -+ (nonnull NSAttributedString *)styleGetSubheadAttributedString:(nullable NSString *)string { ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; } ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor blackColor]]; +} + + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor blackColor]]; } -+ (nonnull NSAttributedString *)styleGetDisabledBodyAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor mfLighterGrayColor]]; -} - -+ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor mfCharcoalColor]]; -} - + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfGrayColor]]; + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfBattleshipGrey]]; } -+ (nonnull NSAttributedString *)styleGetSubtitleAttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor blackColor]]; -} - -+ (nonnull NSAttributedString *)styleGetDisabledSubtitleAttributedString:(nullable NSString *)string { ++ (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string { return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor mfLighterGrayColor]]; } ++ (nonnull NSAttributedString *)styleGetDisabledB2AttributedString:(nullable NSString *)string { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor mfLighterGrayColor]]; +} + + (nonnull NSAttributedString *)styleGetTopAlignedAttributeStringWithLeftString:(nullable NSString *)left centerString:(nonnull NSString *)center rightString:(nullable NSString *)right withCenterStringFontSize:(CGFloat)fontSize andColor:(nonnull UIColor *)color { if (left == nil){ left = @""; From 63f02a0c7ce46a1127fc6d90d89d67915b48be30 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 3 Apr 2019 17:05:21 -0400 Subject: [PATCH 29/35] code review --- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 20 +----- MVMCoreUI/Atoms/TextFields/MFTextField.m | 24 +++---- MVMCoreUI/BaseControllers/MFViewController.m | 14 ++-- .../Models/FormValidator+FormParams.swift | 23 +++--- .../Models/FormValidator+TextFields.swift | 70 ++++++++++++++++--- 5 files changed, 90 insertions(+), 61 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 6c3ed6a9..9a4c06a1 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -709,21 +709,6 @@ [self setEnabledByValidity]; } -- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField { - if (self.textFields == nil) { - self.textFields = [NSMutableArray array]; - } - if (textField) { - [self.textFields addObject:textField]; - } - - for (MFTextField *field in self.textFields) { - field.mfTextFieldDelegate = self; - [field setDefaultValidationBlock]; - } - [self setEnabledByValidity]; -} - - (void)handleEnablingWithTextFields:(nullable NSArray *)textFields { if (self.textFields) { @@ -758,9 +743,8 @@ #pragma mark - FormValidationProtocol -- (void)enableField:(BOOL) enable { - - if (self.validationRequired == NO) { +- (void)enableField:(BOOL)enable { + if (!self.validationRequired) { self.enabled = YES; } else { self.enabled = enable; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 67b3f73a..b5dfdcef 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -51,10 +51,9 @@ [self.dashLine updateView:size]; if (self.isMolecule) { - [self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]]; - + [self setHorizontalPadding:[MFStyler defaultHorizontalPaddingForSize:size]]; } else { - [self setVerticalPadding:0]; + [self setHorizontalPadding:0]; } }]; } @@ -116,18 +115,17 @@ return textField; } -- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { - +- (void)setAsMolecule { self.isMolecule = YES; - [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; - [self setWithMap:json bothDelegates:delegate]; - - FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; - self.mfTextFieldDelegate = formValidator; - self.uiTextFieldDelegate = formValidator; } -- (void)setVerticalPadding:(CGFloat) padding { +- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { + [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; + [self setWithMap:json bothDelegates:formValidator]; +} + +- (void)setHorizontalPadding:(CGFloat) padding { self.textContainerLeftPin.constant = padding; self.errorLableLeftPin.constant = padding; self.formLabelLeftPin.constant = padding; @@ -568,7 +566,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (BOOL) isValidField { +- (BOOL)isValidField { return self.valid; } diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 28c3c625..1b880cc3 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -55,7 +55,7 @@ // title view for navigation bar, used for custom navigation titles @property (weak, nonatomic) UILabel *titleLabel; -@property (strong, nonatomic) FormValidator* formValidator; +@property (strong, nonatomic) FormValidator *formValidator; @end @@ -254,9 +254,7 @@ self.loadObject.pageJSON = page; } - [self updateUI]; -// [self newDataBuildScreen]; -// self.needToUpdateUI = YES; + [self updateUI]; [self.view setNeedsLayout]; [self.view layoutIfNeeded]; }]; @@ -416,6 +414,10 @@ // Since we have new data, build stuff for the screen. [self updateUI]; + // Update the UI after the view is loaded. + self.needToUpdateUI = YES; + self.needToupdateUIOnScreenSizeChanges = YES; + if (UIAccessibilityIsVoiceOverRunning()) { self.disableAnimations = YES; } @@ -428,10 +430,6 @@ - (void) updateUI { [self newDataBuildScreen]; [self.formValidator enableByValidation]; - - // Update the UI after the view is loaded. - self.needToUpdateUI = YES; - self.needToupdateUIOnScreenSizeChanges = YES; } - (void)didReceiveMemoryWarning { diff --git a/MVMCoreUI/Models/FormValidator+FormParams.swift b/MVMCoreUI/Models/FormValidator+FormParams.swift index 2c6c1d2a..2f1e9f99 100644 --- a/MVMCoreUI/Models/FormValidator+FormParams.swift +++ b/MVMCoreUI/Models/FormValidator+FormParams.swift @@ -10,23 +10,22 @@ import Foundation @objc public extension FormValidator { @objc public func addFormParams(requestParameters: MVMCoreRequestParameters) { - DispatchQueue.main.sync { - requestParameters.add(self.getFormParams()) - } + requestParameters.add(self.getFormParams()) } @objc public func getFormParams() -> [String: Any] { - var extraParam: [String: Any] = [:] - for molecule in self.molecules { - if let formFieldName = molecule.formFieldName, - let formFieldValue = molecule.formFieldValue, - let fieldName = formFieldName(), - let fieldValue = formFieldValue() { - - extraParam[fieldName] = fieldValue + MVMCoreDispatchUtility.performSyncBlock(onMainThread: { + for molecule in self.molecules { + if let formFieldName = molecule.formFieldName, + let formFieldValue = molecule.formFieldValue, + let fieldName = formFieldName(), + let fieldValue = formFieldValue() { + + extraParam[fieldName] = fieldValue + } } - } + }) return extraParam } } diff --git a/MVMCoreUI/Models/FormValidator+TextFields.swift b/MVMCoreUI/Models/FormValidator+TextFields.swift index d95a4cbb..04437f0a 100644 --- a/MVMCoreUI/Models/FormValidator+TextFields.swift +++ b/MVMCoreUI/Models/FormValidator+TextFields.swift @@ -8,27 +8,67 @@ import Foundation -@objc extension FormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{ +@objc extension FormValidator: UITextFieldDelegate { public func textFieldDidEndEditing(_ textField: UITextField) { enableByValidation() - } - - public func dismissFieldInput(_ sender: Any?) { - if let delegate = delegate as? MFTextFieldDelegate, - let dismissFieldInput = delegate.dismissFieldInput { - dismissFieldInput(sender) + if let delegate = delegate as? UITextFieldDelegate { + delegate.textFieldDidEndEditing?(textField) } } public func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() + if let delegate = delegate as? UITextFieldDelegate { + return delegate.textFieldShouldReturn?(textField) ?? true + } return true } public func textFieldDidBeginEditing(_ textField: UITextField) { - if let delegate = delegate as? UITextFieldDelegate, - let textFieldDidBeginEditing = delegate.textFieldDidBeginEditing { - textFieldDidBeginEditing(textField) + if let delegate = delegate as? UITextFieldDelegate { + delegate.textFieldDidBeginEditing?(textField) + } + } + + public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { + if let delegate = delegate as? UITextFieldDelegate { + return delegate.textFieldShouldBeginEditing?(textField) ?? true + } + return true + } + + public func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { + if let delegate = delegate as? UITextFieldDelegate { + return delegate.textFieldShouldEndEditing?(textField) ?? true + } + return true + } + + public func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) { + if let delegate = delegate as? UITextFieldDelegate { + delegate.textFieldDidEndEditing?(textField, reason: reason) + } + } + + public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + if let delegate = delegate as? UITextFieldDelegate { + return delegate.textField?(textField, shouldChangeCharactersIn: range, replacementString: string) ?? true + } + return true + } + + public func textFieldShouldClear(_ textField: UITextField) -> Bool { + if let delegate = delegate as? UITextFieldDelegate { + return delegate.textFieldShouldClear?(textField) ?? true + } + return true + } +} + +@objc extension FormValidator: MFTextFieldDelegate { + public func dismissFieldInput(_ sender: Any?) { + if let delegate = delegate as? MFTextFieldDelegate { + delegate.dismissFieldInput?(sender) } } @@ -36,11 +76,21 @@ import Foundation DispatchQueue.main.async { self.enableByValidation() } + MVMCoreDispatchUtility.performBlock(onMainThread: { + if let delegate = self.delegate as? MFTextFieldDelegate { + delegate.entryIsValid?(textfield) + } + }) } public func entryIsInvalid(_ textfield: MFTextField?) { DispatchQueue.main.async { self.enableByValidation() } + MVMCoreDispatchUtility.performBlock(onMainThread: { + if let delegate = self.delegate as? MFTextFieldDelegate { + delegate.entryIsInvalid?(textfield) + } + }) } } From 30fe1c6a086d8b8ae776540ca9f6a2c87ccbfbc3 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 4 Apr 2019 08:26:58 -0400 Subject: [PATCH 30/35] remove import for actions in mflabel --- MVMCoreUI/Atoms/Views/MFLabel.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 72d0d359..66b434e5 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -17,8 +17,6 @@ @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreJSONConstants; -@import MVMCore.MVMCoreActionHandler; -@import MVMCore.UILabel_MFCustom; @interface MFLabel () From c78482bad3b0ee5fc40c70d22f8690fa23da3448 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 4 Apr 2019 09:29:54 -0400 Subject: [PATCH 31/35] added @class. --- MVMCoreUI/Styles/MFStyler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 2020d5c6..3a30ad6c 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -9,7 +9,7 @@ #import #import - +@class LabelWithInternalButton; @class MFSizeObject; //enum for border From df67ded57bb0de3036d4daf5195650a05d16496a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 4 Apr 2019 09:47:45 -0400 Subject: [PATCH 32/35] small formatting fixes --- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 2 - MVMCoreUI/Atoms/TextFields/MFTextField.h | 1 + MVMCoreUI/Atoms/TextFields/MFTextField.m | 46 ++++++++++---------- MVMCoreUI/BaseControllers/MFViewController.m | 9 ++-- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 9a4c06a1..5a708f2c 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -13,8 +13,6 @@ #import "MFStyler.h" #import "UIColor+MFConvenience.h" #import - - @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreGetterUtility; @import MVMCore.NSDictionary_MFConvenience; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index cc5ccccb..81b4059f 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -127,6 +127,7 @@ - (void)setAccessibilityString:(nullable NSString *)accessibilityString; +// For Validator Protocol - (nullable NSString *)formFieldName; - (nullable id)formFieldValue; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index b5dfdcef..565e086c 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -15,9 +15,7 @@ #import "MFLabel.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" - #import - @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreJSONConstants; @@ -115,26 +113,6 @@ return textField; } -- (void)setAsMolecule { - self.isMolecule = YES; -} - -- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { - [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; - FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; - [self setWithMap:json bothDelegates:formValidator]; -} - -- (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; -} - + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; @@ -390,6 +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)dealloc { [self setBothTextFieldDelegates:nil]; } @@ -566,6 +554,19 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol +- (void)setAsMolecule { + self.isMolecule = YES; +} + +- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { + [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; + [self setWithMap:json bothDelegates:formValidator]; +} + +#pragma mark - FormValidationProtocol + + - (BOOL)isValidField { return self.valid; } @@ -573,6 +574,7 @@ - (nullable NSString *)formFieldName { return self.fieldKey; } + - (nullable id)formFieldValue { return self.text; } diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 1b880cc3..c4ee3756 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -37,8 +37,6 @@ #import "MVMCoreUITabBarPageControlViewController.h" #import "MVMCoreUINavigationController.h" #import - - @import MVMAnimationFramework; @interface MFViewController() @@ -411,11 +409,9 @@ [self initialLoad]; } - // Since we have new data, build stuff for the screen. + // Since we have new data, build stuff for the screen and update the ui once the screen is done laying out. [self updateUI]; - // Update the UI after the view is loaded. - self.needToUpdateUI = YES; self.needToupdateUIOnScreenSizeChanges = YES; if (UIAccessibilityIsVoiceOverRunning()) { @@ -427,9 +423,10 @@ } } -- (void) updateUI { +- (void)updateUI { [self newDataBuildScreen]; [self.formValidator enableByValidation]; + self.needToUpdateUI = YES; } - (void)didReceiveMemoryWarning { From 8d3a6852cdbca9593bee27915c68e5a6b47a8dfd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 4 Apr 2019 10:15:01 -0400 Subject: [PATCH 33/35] remove extra block --- MVMCoreUI/Models/FormValidator+TextFields.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Models/FormValidator+TextFields.swift b/MVMCoreUI/Models/FormValidator+TextFields.swift index 04437f0a..2532910d 100644 --- a/MVMCoreUI/Models/FormValidator+TextFields.swift +++ b/MVMCoreUI/Models/FormValidator+TextFields.swift @@ -73,10 +73,8 @@ import Foundation } public func entryIsValid(_ textfield: MFTextField?) { - DispatchQueue.main.async { - self.enableByValidation() - } MVMCoreDispatchUtility.performBlock(onMainThread: { + self.enableByValidation() if let delegate = self.delegate as? MFTextFieldDelegate { delegate.entryIsValid?(textfield) } @@ -84,10 +82,8 @@ import Foundation } public func entryIsInvalid(_ textfield: MFTextField?) { - DispatchQueue.main.async { - self.enableByValidation() - } MVMCoreDispatchUtility.performBlock(onMainThread: { + self.enableByValidation() if let delegate = self.delegate as? MFTextFieldDelegate { delegate.entryIsInvalid?(textfield) } From ba3dec304332141853d7abf68304d91f83728998 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 4 Apr 2019 11:51:45 -0400 Subject: [PATCH 34/35] comments --- MVMCoreUI/Protocols/FormValidationProtocol.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Protocols/FormValidationProtocol.swift b/MVMCoreUI/Protocols/FormValidationProtocol.swift index bfdbb0fd..afce4d28 100644 --- a/MVMCoreUI/Protocols/FormValidationProtocol.swift +++ b/MVMCoreUI/Protocols/FormValidationProtocol.swift @@ -10,10 +10,18 @@ import Foundation @objc public protocol FormValidationProtocol: NSObjectProtocol { - @objc optional func formValidatorModel() -> FormValidator? + // Getter method to get the FormValidator form the delegate (Mostly from the parent View Controller) + @objc optional func formValidatorModel() -> FormValidator? + + // Used to check the validity of the field, to enable/disable the primary button. @objc optional func isValidField() -> Bool + + // Based on the isValidField(), the fields which needs to be enabled can call this method @objc optional func enableField(_ enable: Bool) + // The Field name key value pair for sending to server @objc optional func formFieldName() -> String? + + // The Feild value key value paid for sending to server @objc optional func formFieldValue() -> String? } From 63aa52da3999a3f996ec9f09b8dbb23e4d32a4bb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 4 Apr 2019 13:45:18 -0400 Subject: [PATCH 35/35] new group --- MVMCoreUI.xcodeproj/project.pbxproj | 22 ++++++------------- .../FormValidationProtocol.swift | 0 .../FormValidator+FormParams.swift | 0 .../FormValidator+TextFields.swift | 0 .../FormValidator.swift | 0 5 files changed, 7 insertions(+), 15 deletions(-) rename MVMCoreUI/{Protocols => FormUIHelpers}/FormValidationProtocol.swift (100%) rename MVMCoreUI/{Models => FormUIHelpers}/FormValidator+FormParams.swift (100%) rename MVMCoreUI/{Models => FormUIHelpers}/FormValidator+TextFields.swift (100%) rename MVMCoreUI/{Models => FormUIHelpers}/FormValidator.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5df32702..76684a5d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 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 */; }; - 01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */; }; + 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.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, ); }; }; @@ -166,7 +166,7 @@ 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; - 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; + 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; @@ -334,22 +334,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 01C74D86224298C3009C25A3 /* Protocols */ = { - isa = PBXGroup; - children = ( - 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */, - ); - path = Protocols; - sourceTree = ""; - }; - 01C74D87224298E2009C25A3 /* Models */ = { + 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( + 0198F79E225679870066C936 /* FormValidationProtocol.swift */, 0105618A224BBE7700E1557D /* FormValidator.swift */, 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */, 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */, ); - path = Models; + path = FormUIHelpers; sourceTree = ""; }; D22D1F582204D2590077CEC0 /* LegacyControllers */ = { @@ -385,8 +378,7 @@ D29DF0CE21E404D4003B2FB9 /* MVMCoreUI */ = { isa = PBXGroup; children = ( - 01C74D87224298E2009C25A3 /* Models */, - 01C74D86224298C3009C25A3 /* Protocols */, + 01C74D87224298E2009C25A3 /* FormUIHelpers */, D29DF31421ECECA7003B2FB9 /* SupportingFiles */, D29DF27021E79B2C003B2FB9 /* OtherHandlers */, D29DF13A21E68682003B2FB9 /* Utility */, @@ -916,8 +908,8 @@ D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, - 01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, + 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, diff --git a/MVMCoreUI/Protocols/FormValidationProtocol.swift b/MVMCoreUI/FormUIHelpers/FormValidationProtocol.swift similarity index 100% rename from MVMCoreUI/Protocols/FormValidationProtocol.swift rename to MVMCoreUI/FormUIHelpers/FormValidationProtocol.swift diff --git a/MVMCoreUI/Models/FormValidator+FormParams.swift b/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift similarity index 100% rename from MVMCoreUI/Models/FormValidator+FormParams.swift rename to MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift diff --git a/MVMCoreUI/Models/FormValidator+TextFields.swift b/MVMCoreUI/FormUIHelpers/FormValidator+TextFields.swift similarity index 100% rename from MVMCoreUI/Models/FormValidator+TextFields.swift rename to MVMCoreUI/FormUIHelpers/FormValidator+TextFields.swift diff --git a/MVMCoreUI/Models/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift similarity index 100% rename from MVMCoreUI/Models/FormValidator.swift rename to MVMCoreUI/FormUIHelpers/FormValidator.swift