From a5ff57f65ca4764058903ad5ba86a949fc3071b8 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 19 Mar 2019 11:28:05 -0400 Subject: [PATCH 01/17] Converted DashLine class, replacing objective-c version. Provided capacity for atomization. Added constant value "isHidden". Updated import statements to allow for cross language interpretation. --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++-- MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 +- MVMCoreUI/Atoms/Views/DashLine.h | 17 ----- MVMCoreUI/Atoms/Views/DashLine.m | 46 ------------- MVMCoreUI/Atoms/Views/DashLine.swift | 88 ++++++++++++++++++++++++ MVMCoreUI/MVMCoreUI.h | 1 - MVMCoreUI/Utility/MVMCoreUIConstants.h | 2 + MVMCoreUI/Utility/MVMCoreUIConstants.m | 2 + 8 files changed, 97 insertions(+), 73 deletions(-) delete mode 100644 MVMCoreUI/Atoms/Views/DashLine.h delete mode 100644 MVMCoreUI/Atoms/Views/DashLine.m create mode 100644 MVMCoreUI/Atoms/Views/DashLine.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index bae49737..de3962aa 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -78,8 +78,6 @@ D29DF25621E6A177003B2FB9 /* MFTextFieldSubclassExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF25721E6A177003B2FB9 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF25921E6A22D003B2FB9 /* MFButtonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF25A21E6A2B6003B2FB9 /* DashLine.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF25D21E6A2B6003B2FB9 /* DashLine.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF25B21E6A2B6003B2FB9 /* DashLine.m */; }; D29DF26021E6A985003B2FB9 /* MFLoadImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF25E21E6A985003B2FB9 /* MFLoadImageView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF26121E6A985003B2FB9 /* MFLoadImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF25F21E6A985003B2FB9 /* MFLoadImageView.m */; }; D29DF26421E6A9D9003B2FB9 /* MFTransparentGIFView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF26221E6A9D9003B2FB9 /* MFTransparentGIFView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -160,6 +158,7 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */; }; + DBD1E75522412BDB00C6AFF4 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBD1E75422412BDB00C6AFF4 /* DashLine.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -244,8 +243,6 @@ D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextFieldSubclassExtension.h; sourceTree = ""; }; D29DF24C21E6A177003B2FB9 /* MFTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextField.h; sourceTree = ""; }; D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFButtonProtocol.h; sourceTree = ""; }; - D29DF25A21E6A2B6003B2FB9 /* DashLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DashLine.h; sourceTree = ""; }; - D29DF25B21E6A2B6003B2FB9 /* DashLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DashLine.m; sourceTree = ""; }; D29DF25E21E6A985003B2FB9 /* MFLoadImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLoadImageView.h; sourceTree = ""; }; D29DF25F21E6A985003B2FB9 /* MFLoadImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLoadImageView.m; sourceTree = ""; }; D29DF26221E6A9D9003B2FB9 /* MFTransparentGIFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTransparentGIFView.h; sourceTree = ""; }; @@ -320,6 +317,7 @@ D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelWithInternalButton.h; sourceTree = ""; }; D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelWithInternalButton.m; sourceTree = ""; }; + DBD1E75422412BDB00C6AFF4 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -546,6 +544,7 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + DBD1E75422412BDB00C6AFF4 /* DashLine.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, D29DF28521E7AC2B003B2FB9 /* MFLabel.h */, @@ -565,8 +564,6 @@ D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, D29DF15921E697DA003B2FB9 /* SeparatorView.h */, D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, - D29DF25A21E6A2B6003B2FB9 /* DashLine.h */, - D29DF25B21E6A2B6003B2FB9 /* DashLine.m */, D29DF2A421E7B2A0003B2FB9 /* MFCaretView.h */, D29DF2A321E7B29F003B2FB9 /* MFCaretView.m */, D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, @@ -706,7 +703,6 @@ D29DF18021E69E49003B2FB9 /* MFView.h in Headers */, D29DF26421E6A9D9003B2FB9 /* MFTransparentGIFView.h in Headers */, D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */, - D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */, D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */, D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */, D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */, @@ -868,6 +864,7 @@ D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, + DBD1E75522412BDB00C6AFF4 /* DashLine.swift in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, @@ -900,7 +897,6 @@ D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, D29DF2A521E7B2A0003B2FB9 /* MFCaretView.m in Sources */, - D29DF25D21E6A2B6003B2FB9 /* DashLine.m in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 7cdab21a..65529753 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -7,7 +7,7 @@ // #import "MFTextField.h" -#import "DashLine.h" +#import #import "MFTextFieldSubclassExtension.h" #import "MFStyler.h" #import "UIColor+MFConvenience.h" diff --git a/MVMCoreUI/Atoms/Views/DashLine.h b/MVMCoreUI/Atoms/Views/DashLine.h deleted file mode 100644 index a67d5285..00000000 --- a/MVMCoreUI/Atoms/Views/DashLine.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// DashLine.h -// mobilefirst -// -// Created by Chris Yang on 2/11/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import -#import - -@interface DashLine : MFView - -@property (nonatomic, strong) UIColor *bgColor; -@property (nonatomic, strong) UIColor *dashColor; - -@end diff --git a/MVMCoreUI/Atoms/Views/DashLine.m b/MVMCoreUI/Atoms/Views/DashLine.m deleted file mode 100644 index b99f4dab..00000000 --- a/MVMCoreUI/Atoms/Views/DashLine.m +++ /dev/null @@ -1,46 +0,0 @@ -// -// DashLine.m -// mobilefirst -// -// Created by Chris Yang on 2/11/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import "DashLine.h" -#import "UIColor+MFConvenience.h" -@import MVMCore.MVMCoreDispatchUtility; - -@implementation DashLine - -- (void)updateView:(CGFloat)size { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [self setNeedsDisplay]; - }]; -} - -- (void)drawRect:(CGRect)rect { - CAShapeLayer *dashLayer = [[CAShapeLayer alloc]init]; - dashLayer.backgroundColor = [UIColor clearColor].CGColor; - dashLayer.frame = self.bounds; - for (CAShapeLayer *sublayer in self.layer.sublayers) { - [sublayer removeFromSuperlayer]; - } - [self.layer addSublayer:dashLayer]; - - UIBezierPath *path = [[UIBezierPath alloc]init]; - [path moveToPoint:CGPointMake(dashLayer.frame.origin.x, dashLayer.frame.size.height/2.f)]; //add yourStartPoint here - [path addLineToPoint:CGPointMake(dashLayer.frame.size.width, 0)]; - [path stroke]; - - dashLayer.strokeStart = 0.0; - dashLayer.lineWidth = 1; - dashLayer.lineJoin = kCALineJoinMiter; - dashLayer.lineCap = kCALineCapRound; - dashLayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:2], nil]; - dashLayer.path = path.CGPath; - dashLayer.strokeColor = self.dashColor.CGColor ?: [UIColor mfLighterGrayColor].CGColor; - dashLayer.fillColor = [UIColor clearColor].CGColor; - dashLayer.backgroundColor = self.bgColor.CGColor ?: [UIColor whiteColor].CGColor; -} - -@end diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift new file mode 100644 index 00000000..ee40ac0a --- /dev/null +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -0,0 +1,88 @@ +// +// DashLine_Swift.swift +// MVMCoreUI + +// Created by Chris Yang on 2/11/16. +// Converted by Christiano, Kevin on 3/18/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import MVMCore + + +@objc open class DashLine: MFView { + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + + @objc public var bgColor: UIColor? + @objc public var dashColor: UIColor? + + //------------------------------------------------------ + // MARK: - Lifecycle + //------------------------------------------------------ + + @objc override open func updateView(_ size: CGFloat) { + MVMCoreDispatchUtility.performBlock(onMainThread: { + self.setNeedsDisplay() + }) + } + + @objc override open func draw(_ rect: CGRect) { + + let dashLayer = CAShapeLayer() + dashLayer.backgroundColor = UIColor.clear.cgColor + dashLayer.frame = bounds + + if let sublayers = self.layer.sublayers { + for sublayer in sublayers { + sublayer.removeFromSuperlayer() + } + } + + self.layer.addSublayer(dashLayer) + + let path = UIBezierPath() + path.move(to: CGPoint(x: dashLayer.frame.origin.x, y: dashLayer.frame.size.height / 2.0)) //add yourStartPoint here + path.addLine(to: CGPoint(x: dashLayer.frame.size.width, y: 0)) + path.stroke() + + dashLayer.strokeStart = 0.0 + dashLayer.lineWidth = 1 + dashLayer.lineJoin = .miter + dashLayer.lineCap = .round + dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] + dashLayer.path = path.cgPath + dashLayer.strokeColor = self.dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor + dashLayer.fillColor = UIColor.clear.cgColor + dashLayer.backgroundColor = self.bgColor?.cgColor ?? UIColor.white.cgColor + } + + //------------------------------------------------------ + // MARK: - Atomization + //------------------------------------------------------ + + @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 { + self.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + + if let isHiddenValue = jsonDictionary[KeyIsHidden] as? Bool { + self.isHidden = isHiddenValue + } + + if let bgColorHex = jsonDictionary["bgColor"] as? String { + self.bgColor = UIColor.mfGet(forHex: bgColorHex) + } + + if let dashColorHex = jsonDictionary["dashColor"] as? String { + self.dashColor = UIColor.mfGet(forHex: dashColorHex) + } + } + +} diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index f1fdd0b9..1082acaf 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -84,7 +84,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import #import #import #import diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index 40f0e2ac..112fa3e0 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -32,6 +32,8 @@ extern NSString * const KeyBackgroundColor; extern NSString * const KeyText; extern NSString * const KeyTextColor; +extern NSString * const KeyIsHidden; + #pragma mark - Values extern NSString * const StringY; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index 0bf34449..5ec58ac7 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -31,6 +31,8 @@ NSString * const KeyBackgroundColor = @"backgroundColor"; NSString * const KeyText = @"text"; NSString * const KeyTextColor = @"textColor"; +NSString * const KeyIsHidden = @"isHidden"; + #pragma mark - Values NSString * const StringY = @"Y"; From 17eb09ef42bf07daa08661bf9f1072b5a37f14b6 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 19 Mar 2019 13:29:41 -0400 Subject: [PATCH 02/17] Registered DashLine with Molecule Mapper. --- MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 3c36a612..eeb93394 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -28,7 +28,8 @@ @"standardHeader": StandardHeaderView.class, @"moleculeStack": MoleculeStackView.class, @"twoButtonView": PrimaryButtonView.class, - @"standardFooter": StandardFooterView.class + @"standardFooter": StandardFooterView.class, + @"dashLine": DashLine.class } mutableCopy]; }); return mapping; From ffdf287106f22457f208fe2f92c117e4266aa767 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 19 Mar 2019 16:03:23 -0400 Subject: [PATCH 03/17] Setting the module in xib appeared to solve the value issue. --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 1 + MVMCoreUI/Atoms/TextFields/MFTextField.xib | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 65529753..e84fbbce 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -37,6 +37,7 @@ self.formLabel.font = [MFStyler fontB3]; self.label.font = [MFStyler fontForTextFieldUnderLabel]; [MFStyler styleTextField:self.textField]; + UIColor *c = self.dashLine.dashColor; [self.dashLine updateView:size]; }]; } diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index a32399fe..535218a3 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,18 +1,13 @@ - + - + - - - HelveticaNeue - - @@ -62,7 +57,7 @@ -