From 39c96849c813d7f145298dd7efe339cc67620d30 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Wed, 18 Dec 2019 17:58:53 -0500 Subject: [PATCH 01/15] Translates MFCustomButton to Button --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Atoms/Buttons/Button.swift | 57 +++++++++++++++++++++++ MVMCoreUI/Atoms/Buttons/CaretButton.swift | 10 ++-- 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 MVMCoreUI/Atoms/Buttons/Button.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 900edec2..cbb61895 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; + C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; }; @@ -230,6 +231,7 @@ 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; + C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = ""; }; @@ -733,6 +735,7 @@ DBC4391A224421A0001AB423 /* CaretButton.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, + C003506023AA94CD00B6AC29 /* Button.swift */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, @@ -1158,6 +1161,7 @@ D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, + C003506123AA94CD00B6AC29 /* Button.swift in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift new file mode 100644 index 00000000..d87ee030 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -0,0 +1,57 @@ +// +// Button.swift +// MVMCoreUI +// +// Created by Robinson, Blake on 12/18/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +@objcMembers open class Button: UIButton, MFButtonProtocol { + + public var actionMap: [AnyHashable: Any]? + public weak var buttonDelegate: ButtonDelegateProtocol? + public var heightConstraint: NSLayoutConstraint? + + //Does buttonTap block need to be rewritten in swift? + private var buttonTapBlock: ButtonTapBlock? + + public func addBlock(_ buttonTapBlock: @escaping ButtonTapBlock, event: Event) { + self.buttonTapBlock = buttonTapBlock + addTarget(self, action: #selector(callBlock(_:)), for: event) + } + + func callBlock(_ sender: Button) { + guard let buttonTapBlock = buttonTapBlock else { return } + buttonTapBlock(self) + } + + public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + self.actionMap = actionMap + self.titleLabel?.numberOfLines = 0 + self.titleLabel?.lineBreakMode = .byWordWrapping + setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) + + if let actionMap = self.actionMap, + let disableButtonAsAny = actionMap[KeyDisableButton], + let isDisabled = disableButtonAsAny as? Bool { + + isEnabled = !isDisabled + } + + if let mVMCoreUIDelegateObject = delegateObject as? MVMCoreUIDelegateObject { + self.buttonDelegate = mVMCoreUIDelegateObject.buttonDelegate + } + + self.addBlock({ [weak self] (sender) in + guard let self = self else { return } + var performAction = true + if let shouldPerformAction = self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) { + performAction = shouldPerformAction + } + if performAction { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + + }, event: .touchUpInside) + } +} diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index b01d2758..f1b391d8 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -8,7 +8,7 @@ // -open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { +open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { //------------------------------------------------------ // MARK: - Constants @@ -46,10 +46,10 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI super.layoutSubviews() } - public func setEnabled(_ enabled: Bool) { - super.isEnabled = enabled - - changeCaretColor() + override public var isEnabled: Bool { + didSet { + changeCaretColor() + } } public func updateView(_ size: CGFloat) { From 4b855a1a63c4e9df57ff86ed112e2e8e74e7b7fa Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 09:28:41 -0500 Subject: [PATCH 02/15] Removes unused property heightConstraint --- MVMCoreUI/Atoms/Buttons/Button.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index d87ee030..c6c187fe 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -10,7 +10,6 @@ public var actionMap: [AnyHashable: Any]? public weak var buttonDelegate: ButtonDelegateProtocol? - public var heightConstraint: NSLayoutConstraint? //Does buttonTap block need to be rewritten in swift? private var buttonTapBlock: ButtonTapBlock? From 109ef544796d75d039bfd8b82fe2898f6a618f4e Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 09:53:09 -0500 Subject: [PATCH 03/15] Rewrote ButtonTapBlock in swift --- MVMCoreUI/Atoms/Buttons/Button.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index c6c187fe..cd93f755 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -6,22 +6,22 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // +public typealias ButtonBlock = (Button) -> Void + @objcMembers open class Button: UIButton, MFButtonProtocol { public var actionMap: [AnyHashable: Any]? public weak var buttonDelegate: ButtonDelegateProtocol? + private var buttonBlock: ButtonBlock? - //Does buttonTap block need to be rewritten in swift? - private var buttonTapBlock: ButtonTapBlock? - - public func addBlock(_ buttonTapBlock: @escaping ButtonTapBlock, event: Event) { - self.buttonTapBlock = buttonTapBlock + public func addBlock(_ buttonBlock: @escaping ButtonBlock, event: Event) { + self.buttonBlock = buttonBlock addTarget(self, action: #selector(callBlock(_:)), for: event) } func callBlock(_ sender: Button) { - guard let buttonTapBlock = buttonTapBlock else { return } - buttonTapBlock(self) + guard let buttonBlock = buttonBlock else { return } + buttonBlock(self) } public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { From 2c5e2286b1cc9e691e051e02177790c67664e272 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 10:06:54 -0500 Subject: [PATCH 04/15] Removed line setting title because title won't be part of actionMap in the future --- MVMCoreUI/Atoms/Buttons/Button.swift | 1 - MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index cd93f755..77a790fc 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -28,7 +28,6 @@ public typealias ButtonBlock = (Button) -> Void self.actionMap = actionMap self.titleLabel?.numberOfLines = 0 self.titleLabel?.lineBreakMode = .byWordWrapping - setTitle(actionMap?.stringForkey(KeyTitle), for: .normal) if let actionMap = self.actionMap, let disableButtonAsAny = actionMap[KeyDisableButton], diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index f1b391d8..86f1185e 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -119,6 +119,10 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons guard let dictionary = json else { return } + if let title = dictionary.optionalStringForKey(KeyTitle) { + setTitle(title, for: .normal) + } + if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } From 8f23dd391c338f3a41d2fbc9831f30451047c3f9 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 10:19:42 -0500 Subject: [PATCH 05/15] Removes disabled logic from Button because it won't be in the actionMap going forward --- MVMCoreUI/Atoms/Buttons/Button.swift | 7 ------- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index 77a790fc..c1e631a2 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -29,13 +29,6 @@ public typealias ButtonBlock = (Button) -> Void self.titleLabel?.numberOfLines = 0 self.titleLabel?.lineBreakMode = .byWordWrapping - if let actionMap = self.actionMap, - let disableButtonAsAny = actionMap[KeyDisableButton], - let isDisabled = disableButtonAsAny as? Bool { - - isEnabled = !isDisabled - } - if let mVMCoreUIDelegateObject = delegateObject as? MVMCoreUIDelegateObject { self.buttonDelegate = mVMCoreUIDelegateObject.buttonDelegate } diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 86f1185e..668505a8 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -123,6 +123,12 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons setTitle(title, for: .normal) } + if let disableButtonAsAny = dictionary[KeyDisableButton], + let isDisabled = disableButtonAsAny as? Bool { + + isEnabled = !isDisabled + } + if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } From 6cf4ba0594c70f238cbbba6ee5ea75e9012f2d48 Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 10:30:14 -0500 Subject: [PATCH 06/15] Improved swifty-ness of these lines --- MVMCoreUI/Atoms/Buttons/Button.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index c1e631a2..263d5cb1 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -34,14 +34,11 @@ public typealias ButtonBlock = (Button) -> Void } self.addBlock({ [weak self] (sender) in - guard let self = self else { return } - var performAction = true - if let shouldPerformAction = self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) { - performAction = shouldPerformAction - } - if performAction { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - } + guard let self = self, + let performAction = self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData), + performAction else { return } + + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) }, event: .touchUpInside) } From 1de7618e5cc0f668bfd46f5819919080bc829d2c Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 10:35:11 -0500 Subject: [PATCH 07/15] Changed to MVMCoreUIDelegateObject --- MVMCoreUI/Atoms/Buttons/Button.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index 263d5cb1..66bed2b3 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -24,14 +24,12 @@ public typealias ButtonBlock = (Button) -> Void buttonBlock(self) } - public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionMap = actionMap self.titleLabel?.numberOfLines = 0 self.titleLabel?.lineBreakMode = .byWordWrapping - if let mVMCoreUIDelegateObject = delegateObject as? MVMCoreUIDelegateObject { - self.buttonDelegate = mVMCoreUIDelegateObject.buttonDelegate - } + buttonDelegate = delegateObject?.buttonDelegate self.addBlock({ [weak self] (sender) in guard let self = self, From 82c76c6084158d223cb7c189f7582d2f96da142d Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Thu, 19 Dec 2019 10:37:57 -0500 Subject: [PATCH 08/15] Removed self where unnecessary --- MVMCoreUI/Atoms/Buttons/Button.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index 66bed2b3..2845e66a 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -26,12 +26,12 @@ public typealias ButtonBlock = (Button) -> Void public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionMap = actionMap - self.titleLabel?.numberOfLines = 0 - self.titleLabel?.lineBreakMode = .byWordWrapping + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping buttonDelegate = delegateObject?.buttonDelegate - self.addBlock({ [weak self] (sender) in + addBlock({ [weak self] (sender) in guard let self = self, let performAction = self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData), performAction else { return } From e674fe4d94290c98e0accc15076640d53780bd92 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Jan 2020 14:19:37 -0500 Subject: [PATCH 09/15] Adding protocols, comments, and mild reworks. --- MVMCoreUI/Atoms/Buttons/Button.swift | 115 +++++++++++++++++++--- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 16 +-- 2 files changed, 108 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index 2845e66a..21a9b227 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -6,38 +6,129 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -public typealias ButtonBlock = (Button) -> Void +public typealias ButtonBlock = (Button) -> () + @objcMembers open class Button: UIButton, MFButtonProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var json: [AnyHashable: Any]? public var actionMap: [AnyHashable: Any]? - public weak var buttonDelegate: ButtonDelegateProtocol? + + private var initialSetupPerformed = false + private var buttonBlock: ButtonBlock? - public func addBlock(_ buttonBlock: @escaping ButtonBlock, event: Event) { + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + public weak var buttonDelegate: ButtonDelegateProtocol? + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public convenience init() { + self.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + fatalError("Button does not support xib.") + } + + //-------------------------------------------------- + // MARK: - Setup + //-------------------------------------------------- + + public func initialSetup() { + + if !initialSetupPerformed { + initialSetupPerformed = true + setupView() + } + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func addBlock( event: Event, _ buttonBlock: @escaping ButtonBlock) { self.buttonBlock = buttonBlock addTarget(self, action: #selector(callBlock(_:)), for: event) } func callBlock(_ sender: Button) { - guard let buttonBlock = buttonBlock else { return } - buttonBlock(self) + buttonBlock?(self) } public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionMap = actionMap + titleLabel?.numberOfLines = 0 titleLabel?.lineBreakMode = .byWordWrapping buttonDelegate = delegateObject?.buttonDelegate - addBlock({ [weak self] (sender) in - guard let self = self, - let performAction = self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData), - performAction else { return } + addBlock(event: .touchUpInside) { [weak self] sender in + guard let self = self else { return } - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - - }, event: .touchUpInside) + if self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } + } +} + +// MARK: - MVMCoreUIMoleculeViewProtocol +extension Button: MVMCoreUIMoleculeViewProtocol { + + public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + self.json = json + + guard let dictionary = json else { return } + + if let backgroundColorString = dictionary[KeyBackgroundColor] as? String { + backgroundColor = UIColor.mfGet(forHex: backgroundColorString) + } + + if let title = dictionary[KeyTitle] as? String { + setTitle(title, for: .normal) + } + } + + public func reset() { + backgroundColor = .clear + } +} + + +// MARK: - MVMCoreViewProtocol +extension Button: MVMCoreViewProtocol { + + public func updateView(_ size: CGFloat) {} + + /// Will be called only once. + public func setupView() { + + translatesAutoresizingMaskIntoConstraints = false + insetsLayoutMarginsFromSafeArea = false + } +} + +// MARK: AppleGuidelinesProtocol +extension Button: AppleGuidelinesProtocol { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } } diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 22bc3cd5..5311df31 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -17,7 +17,6 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons private let CARET_VIEW_HEIGHT: Float = 10.5 private let CARET_VIEW_WIDTH: Float = 6.5 - //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -47,13 +46,10 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons } override public var isEnabled: Bool { - didSet { - changeCaretColor() - } + didSet { changeCaretColor() } } - public func updateView(_ size: CGFloat) { - } + public func updateView(_ size: CGFloat) { } //------------------------------------------------------ // MARK: - Functions @@ -86,7 +82,7 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons NSLayoutConstraint(item: caretView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: width).isActive = true NSLayoutConstraint(item: caretView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: height).isActive = true - let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4.0) + let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4) caretLabelSpacing.isActive = true caretSpacingConstraint = caretLabelSpacing @@ -123,9 +119,7 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons setTitle(title, for: .normal) } - if let disableButtonAsAny = dictionary[KeyDisableButton], - let isDisabled = disableButtonAsAny as? Bool { - + if let disableButtonAsAny = dictionary[KeyDisableButton], let isDisabled = disableButtonAsAny as? Bool { isEnabled = !isDisabled } @@ -147,7 +141,7 @@ open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewCons } open func horizontalAlignment() -> UIStackView.Alignment { - return UIStackView.Alignment.leading; + return .leading } public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { From 6b983d2f69e042b176f363900047cb30332d4d1b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Jan 2020 14:11:50 -0500 Subject: [PATCH 10/15] Moved out. --- MVMCoreUI/Atoms/Buttons/Button.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/Atoms/Buttons/Button.swift index 21a9b227..1d5d743e 100644 --- a/MVMCoreUI/Atoms/Buttons/Button.swift +++ b/MVMCoreUI/Atoms/Buttons/Button.swift @@ -74,9 +74,6 @@ public typealias ButtonBlock = (Button) -> () public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionMap = actionMap - titleLabel?.numberOfLines = 0 - titleLabel?.lineBreakMode = .byWordWrapping - buttonDelegate = delegateObject?.buttonDelegate addBlock(event: .touchUpInside) { [weak self] sender in @@ -122,6 +119,8 @@ extension Button: MVMCoreViewProtocol { translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping } } From 0b9f641d878a9c05bfe1b71fb759125a46134afa Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Jan 2020 15:43:10 -0500 Subject: [PATCH 11/15] reset super. --- 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 5311df31..3b241f82 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -8,7 +8,7 @@ // -open class CaretButton: Button, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { +open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol { //------------------------------------------------------ // MARK: - Constants From 9308d6d89234a3bde6f2c432dbd60b9fe98f2ba1 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 9 Jan 2020 16:01:12 -0500 Subject: [PATCH 12/15] Move Button to Base Classes Folder. --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- MVMCoreUI/{Atoms/Buttons => BaseClasses}/Button.swift | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename MVMCoreUI/{Atoms/Buttons => BaseClasses}/Button.swift (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 820e034f..245bc8d4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -748,7 +748,6 @@ DBC4391A224421A0001AB423 /* CaretButton.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, - C003506023AA94CD00B6AC29 /* Button.swift */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */, D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */, @@ -915,6 +914,7 @@ D2B18B7D236090D500A9AEDC /* BaseClasses */ = { isa = PBXGroup; children = ( + C003506023AA94CD00B6AC29 /* Button.swift */, D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B802360945C00A9AEDC /* View.swift */, 0A5D59C323AD488600EFD9E9 /* Protocols */, diff --git a/MVMCoreUI/Atoms/Buttons/Button.swift b/MVMCoreUI/BaseClasses/Button.swift similarity index 100% rename from MVMCoreUI/Atoms/Buttons/Button.swift rename to MVMCoreUI/BaseClasses/Button.swift From ad4eddb45007f02fe29c6c330964b967e53d5ad5 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 13 Jan 2020 14:43:16 -0500 Subject: [PATCH 13/15] some class is using a xib. --- MVMCoreUI/Atoms/Views/DashLine.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index edd911e0..c66d68b7 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -31,7 +31,6 @@ open class DashLine: View { required public init?(coder: NSCoder) { super.init(coder: coder) - fatalError("DashLine xib not supported") } //------------------------------------------------------ From 57753f66978a0cbe4970feb20d3f7b49fd0da828 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 15:26:51 -0500 Subject: [PATCH 14/15] Change keys --- MVMCoreUI/Atoms/Views/Checkbox.swift | 2 +- MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m | 2 +- .../Models/Template/StackPageTemplateModel.swift | 2 +- .../SwitchMolecules/HeadlineBodySwitch.swift | 4 +--- .../HeadlineBodyTextButtonSwitch.swift | 4 ++-- .../SwitchMolecules/LabelSwitch.swift | 2 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- .../HeadlineBodyTextButton.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackModel.swift | 2 +- .../MVMCoreUIMoleculeMappingObject.m | 16 ++++++++-------- .../MVMCoreUIViewControllerMappingObject.m | 4 ++-- 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index a206953a..50571e30 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -454,7 +454,7 @@ import MVMCore isEnabled(enabled) } - if let actionMap = dictionary.optionalDictionaryForKey("actionMap") { + if let actionMap = dictionary.optionalDictionaryForKey("action") { actionBlock = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m index 33874a8d..4b66d519 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUISwitch.m @@ -171,7 +171,7 @@ const CGFloat SwitchShakeIntensity = 2; [self setState:[json boolForKey:@"state"] animated:false]; - NSDictionary *actionMap = [json dict:@"actionMap"]; + NSDictionary *actionMap = [json dict:@"action"]; if (actionMap) { [self addTarget:self action:@selector(addCustomAction) forControlEvents:UIControlEventTouchUpInside]; } diff --git a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift index 9cce36ab..0e5e4488 100644 --- a/MVMCoreUI/Models/Template/StackPageTemplateModel.swift +++ b/MVMCoreUI/Models/Template/StackPageTemplateModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class StackPageTemplateModel: TemplateModelProtocol { - public static var identifier: String = "moleculeStack" + public static var identifier: String = "stack" public var pageType: String diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index eca878ab..fee32b2f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -39,8 +39,6 @@ import UIKit open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) -// guard let headlineModel = model as? headlinebodyswitch -// headlineBody.setWithModel(mode, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##additionalData: [String : AnyHashable]?##[String : AnyHashable]?#>) } public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -52,7 +50,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift index b0cf6956..5ee9c41f 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyTextButtonSwitch.swift @@ -37,8 +37,8 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyTextButton"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyLink"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift index f60202b3..50c19c1d 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/LabelSwitch.swift @@ -38,7 +38,7 @@ import UIKit public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData) + mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index c13638d8..ad231597 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -37,7 +37,7 @@ public class StandardHeaderView: MoleculeContainer { // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - if let separatorJSON = json?.optionalDictionaryForKey("separator") { + if let separatorJSON = json?.optionalDictionaryForKey("line") { line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift index 7c24cff4..ca696f1a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyTextButton.swift @@ -66,7 +66,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData) + textButton.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData) } open override func reset() { diff --git a/MVMCoreUI/Organisms/MoleculeStackModel.swift b/MVMCoreUI/Organisms/MoleculeStackModel.swift index 73c7c0a5..e364ca07 100644 --- a/MVMCoreUI/Organisms/MoleculeStackModel.swift +++ b/MVMCoreUI/Organisms/MoleculeStackModel.swift @@ -9,7 +9,7 @@ import Foundation @objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol { - public static var identifier: String = "moleculeStack" + public static var identifier: String = "stack" public var backgroundColor: Color? public var molecules: [StackItemModel] public var axis: NSLayoutConstraint.Axis = .vertical diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index e32f8962..2b8aa2fa 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -29,9 +29,9 @@ @"label": Label.class, @"line": Line.class, @"button": PrimaryButton.class, - @"textButton": MFTextButton.class, + @"link": MFTextButton.class, @"header": StandardHeaderView.class, - @"moleculeStack": MoleculeStackView.class, + @"stack": MoleculeStackView.class, @"twoButtonView": TwoButtonView.class, @"footer": StandardFooterView.class, @"caretView": CaretView.class, @@ -40,7 +40,7 @@ @"dropDown": DropDown.class, @"digitTextField": MFDigitTextField.class, @"checkbox": Checkbox.class, - @"checkboxWithLabel": CheckboxWithLabelView.class, + @"checkboxLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, @"progressbar": ProgressBar.class, @"circleProgress": GraphView.class, @@ -49,7 +49,7 @@ @"radioButtonLabel": RadioButtonLabel.class, @"listItem": MoleculeTableViewCell.class, @"accordionListItem": AccordionMoleculeTableViewCell.class, - @"switch": MVMCoreUISwitch.class, + @"toggle": MVMCoreUISwitch.class, @"leftRightLabelView": LeftRightLabelView.class, @"actionDetailWithImage": ActionDetailWithImage.class, @"image": MFLoadImageView.class, @@ -60,10 +60,10 @@ @"barsPager": MVMCoreUIPageControl.class, @"scroller": Scroller.class, @"imageHeadlineBody": ImageHeadlineBody.class, - @"labelSwitch": LabelSwitch.class, - @"headlineBodySwitch": HeadlineBodySwitch.class, - @"headlineBodyTextButton": HeadlineBodyTextButton.class, - @"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class, + @"labelToggle": LabelSwitch.class, + @"headlineBodyToggle": HeadlineBodySwitch.class, + @"headlineBodyLink": HeadlineBodyTextButton.class, + @"headlineBodyLinkToggle": HeadlineBodyTextButtonSwitch.class, @"tabsListItem": TabsTableViewCell.class, @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 2bc1a0dd..7bdccc8e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -19,9 +19,9 @@ static NSMutableDictionary *viewControllerMapping; dispatch_once(&onceToken, ^{ viewControllerMapping = [@{ - @"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], + @"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], - @"moleculeList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], + @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] } mutableCopy]; From 5c2f93e06f04b39a1dbaae6be874deb0ac227edb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 13 Jan 2020 15:28:53 -0500 Subject: [PATCH 15/15] move register to init for now dash line update temporary for legacy --- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 94bd987c..9d438af5 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -19,6 +19,8 @@ open class DashLine: View { get { return model as? DashLineModel } } + // Legacy + @objc public var dashColor: UIColor? @objc private var dashLayer: CAShapeLayer? //------------------------------------------------------ @@ -56,7 +58,7 @@ open class DashLine: View { dashLayer.lineCap = .round dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)] dashLayer.path = path.cgPath - dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? UIColor.mfLighterGray().cgColor + dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor dashLayer.fillColor = UIColor.clear.cgColor dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor self.dashLayer = dashLayer