diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1e5cb6da..02edf94e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -55,12 +55,10 @@ D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF15F21E69996003B2FB9 /* MFViewController.m */; }; D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16021E69996003B2FB9 /* MFViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17321E69E1F003B2FB9 /* MFCaretButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */; }; D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */; }; D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */; }; D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17221E69E1F003B2FB9 /* MFTextButton.m */; }; @@ -80,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 */; }; D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF26821E6AA0B003B2FB9 /* FLAnimatedImage.m */; }; D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF26921E6AA0B003B2FB9 /* FLAnimatedImageView.m */; }; D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF26A21E6AA0B003B2FB9 /* FLAnimatedImage.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -109,8 +105,6 @@ D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF13921E68637003B2FB9 /* MFStyler.m */; }; D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */; }; - D29DF2A521E7B2A0003B2FB9 /* MFCaretView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2A321E7B29F003B2FB9 /* MFCaretView.m */; }; - D29DF2A621E7B2A0003B2FB9 /* MFCaretView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2A421E7B2A0003B2FB9 /* MFCaretView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */; }; D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */; }; @@ -158,6 +152,9 @@ 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 */; }; + DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; + DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; + DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -221,12 +218,10 @@ D29DF15A21E697DA003B2FB9 /* SeparatorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SeparatorView.m; sourceTree = ""; }; D29DF15F21E69996003B2FB9 /* MFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFViewController.m; sourceTree = ""; }; D29DF16021E69996003B2FB9 /* MFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFViewController.h; sourceTree = ""; }; - D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = ""; }; D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCustomButton.h; sourceTree = ""; }; D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonDelegateProtocol.h; sourceTree = ""; }; D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryButton.h; sourceTree = ""; }; D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; - D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = ""; }; D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCustomButton.m; sourceTree = ""; }; D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryButton.m; sourceTree = ""; }; D29DF17221E69E1F003B2FB9 /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; @@ -244,8 +239,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 = ""; }; D29DF26821E6AA0B003B2FB9 /* FLAnimatedImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImage.m; sourceTree = ""; }; D29DF26921E6AA0B003B2FB9 /* FLAnimatedImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImageView.m; sourceTree = ""; }; D29DF26A21E6AA0B003B2FB9 /* FLAnimatedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImage.h; sourceTree = ""; }; @@ -271,8 +264,6 @@ D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFProgrammaticTableViewController.m; sourceTree = ""; }; D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIUtility.h; sourceTree = ""; }; D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIUtility.m; sourceTree = ""; }; - D29DF2A321E7B29F003B2FB9 /* MFCaretView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCaretView.m; sourceTree = ""; }; - D29DF2A421E7B2A0003B2FB9 /* MFCaretView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCaretView.h; sourceTree = ""; }; D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIConstants.h; sourceTree = ""; }; D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIConstants.m; sourceTree = ""; }; D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextView.m; sourceTree = ""; }; @@ -316,6 +307,9 @@ 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 = ""; }; + DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; + DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; + DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -525,6 +519,7 @@ D29DF16821E69E1F003B2FB9 /* Buttons */ = { isa = PBXGroup; children = ( + DBC4391A224421A0001AB423 /* CaretButton.swift */, D29DF25821E6A22D003B2FB9 /* MFButtonProtocol.h */, D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */, D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */, @@ -533,8 +528,6 @@ D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */, D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */, D29DF17221E69E1F003B2FB9 /* MFTextButton.m */, - D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */, - D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */, ); path = Buttons; sourceTree = ""; @@ -542,6 +535,8 @@ D29DF17D21E69E26003B2FB9 /* Views */ = { isa = PBXGroup; children = ( + DBC4391622442196001AB423 /* CaretView.swift */, + DBC4391722442197001AB423 /* DashLine.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, D29DF28521E7AC2B003B2FB9 /* MFLabel.h */, @@ -559,10 +554,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 */, D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, @@ -699,7 +690,6 @@ files = ( D29DF18021E69E49003B2FB9 /* MFView.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 */, @@ -735,8 +725,6 @@ D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */, D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */, D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */, - D29DF17321E69E1F003B2FB9 /* MFCaretButton.h in Headers */, - D29DF2A621E7B2A0003B2FB9 /* MFCaretView.h in Headers */, D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */, D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */, D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */, @@ -848,7 +836,9 @@ buildActionMask = 2147483647; files = ( D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, + DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, + DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, @@ -890,8 +880,6 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, 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 */, @@ -903,11 +891,11 @@ D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, - D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, + DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift new file mode 100644 index 00000000..af7d1d60 --- /dev/null +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -0,0 +1,132 @@ +// +// CaretButton.swift +// MVMCoreUI +// +// Created by Kolli, Praneeth on 1/5/18. +// Created by Christiano, Kevin on 3/18/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + + +open class CaretButton: MFCustomButton { + //------------------------------------------------------ + // MARK: - Constants + //------------------------------------------------------ + + private let CaretViewHeight: Float = 10.8 + private let CaretViewWidth: Float = 6.6 + + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + + @objc public var rightView: UIView? + @objc public var rightViewHeight: NSNumber? + @objc public var rightViewWidth: NSNumber? + + @objc public var enabledColor: UIColor = .black { + didSet { + setTitleColor(enabledColor, for: .normal) + changeCaretColor() + } + } + + @objc public var disabledColor: UIColor = .mfSilver() { + didSet { + setTitleColor(disabledColor, for: .disabled) + changeCaretColor() + } + } + + private var caretSpacingConstraint: NSLayoutConstraint? + + //------------------------------------------------------ + // MARK: - Lifecycle + //------------------------------------------------------ + + override open func layoutSubviews() { + + addCaretImageView() + super.layoutSubviews() + } + + public func setEnabled(_ enabled: Bool) { + super.isEnabled = enabled + + changeCaretColor() + } + + //------------------------------------------------------ + // MARK: - Functions + //------------------------------------------------------ + + private func changeCaretColor() { + + if let rightCaretView = rightView as? CaretView { + rightCaretView.tintColor = isEnabled ? enabledColor : disabledColor + } + } + + private func addCaretImageView() { + + rightView?.removeFromSuperview() + + let width = CGFloat(rightViewWidth?.floatValue ?? CaretViewWidth) + let height = CGFloat(rightViewHeight?.floatValue ?? CaretViewHeight) + + let edgeInsets: UIEdgeInsets = contentEdgeInsets + contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width) + + let caretView: UIView = rightView ?? CaretView() + rightView = caretView + rightView?.translatesAutoresizingMaskIntoConstraints = false + addSubview(caretView) + + 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) + caretLabelSpacing.isActive = true + caretSpacingConstraint = caretLabelSpacing + + NSLayoutConstraint(item: caretView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self, attribute: .right, relatedBy: .greaterThanOrEqual, toItem: caretView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + contentHorizontalAlignment = .left + //set correct color after layout + changeCaretColor() + } + + public func updateCaretSpacing(_ spacing: CGFloat) { + + caretSpacingConstraint?.constant = spacing + } + + //------------------------------------------------------ + // MARK: - Atomization + //------------------------------------------------------ + + // Default values for view. + @objc open override func setAsMolecule() { + + backgroundColor = .clear + } + + @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 { + backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + + if let enableColorHex = jsonDictionary["enableColor"] as? String { + enabledColor = UIColor.mfGet(forHex: enableColorHex) + } + + if let disabledColorHex = jsonDictionary["disabledColor"] as? String { + disabledColor = UIColor.mfGet(forHex: disabledColorHex) + } + } +} diff --git a/MVMCoreUI/Atoms/Buttons/MFCaretButton.h b/MVMCoreUI/Atoms/Buttons/MFCaretButton.h deleted file mode 100644 index 64bd8a0f..00000000 --- a/MVMCoreUI/Atoms/Buttons/MFCaretButton.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// MFCaretButton.h -// MobileFirstFramework -// -// Created by Kolli, Praneeth on 1/5/18. -// Copyright © 2018 Verizon Wireless. All rights reserved. -// - -#import -#import -@interface MFCaretButton : MFCustomButton - -@property (nullable, nonatomic, strong) UIView *rightView; -@property (nullable, nonatomic, strong) NSNumber *rightViewHeight; -@property (nullable, nonatomic, strong) NSNumber *rightViewWidth; - --(void)updateCaretSpacing:(CGFloat)spacing; - -/* The fill color of the Caret and titleLabel. The default is blackColor */ --(void)setEnableCaretColor:(nullable UIColor *)enableCaretColor; - -/* The fill color of the Caret and titleLabel. The default is mfSilver */ --(void)setDisabledCaretColor:(nullable UIColor *)disabledCaretColor; - -@end diff --git a/MVMCoreUI/Atoms/Buttons/MFCaretButton.m b/MVMCoreUI/Atoms/Buttons/MFCaretButton.m deleted file mode 100644 index bd8f058c..00000000 --- a/MVMCoreUI/Atoms/Buttons/MFCaretButton.m +++ /dev/null @@ -1,113 +0,0 @@ -// -// MFCaretButton.m -// MobileFirstFramework -// -// Created by Kolli, Praneeth on 1/5/18. -// Copyright © 2018 Verizon Wireless. All rights reserved. -// - -#import "MFCaretButton.h" -#import "MFCaretView.h" -#import "UIColor+MFConvenience.h" - -@interface MFCaretButton () - -@property (nonatomic, strong) UIColor *enableColor; -@property (nonatomic, strong) UIColor *disabledColor; -@property (nonatomic, strong) NSLayoutConstraint *caretSpacingConstraint; - -@end - -@implementation MFCaretButton - -CGFloat const CaretViewHeight = 10.8f; -CGFloat const CaretViewWidth = 6.6f; - - -- (void)layoutSubviews { - [self addCaretImageView]; - [super layoutSubviews]; -} - -- (void)setEnabled:(BOOL)enabled { - [super setEnabled:enabled]; - [self changeCaretColor]; -} -- (void)changeCaretColor { - [self setTitleColor:self.enableColor forState:UIControlStateNormal]; - [self setTitleColor:self.disabledColor forState:UIControlStateDisabled]; - if ([self.rightView isKindOfClass:[MFCaretView class]]) { - MFCaretView *caretView = (MFCaretView *)self.rightView; - if (self.enabled) { - [caretView setLineColor:self.enableColor]; - } else { - [caretView setLineColor:self.disabledColor]; - } - } -} - -- (void)addCaretImageView { - [self.rightView removeFromSuperview]; - UIEdgeInsets edgeInsets = self.contentEdgeInsets; - CGFloat rightInset = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth; - UIEdgeInsets newInsets = UIEdgeInsetsMake(edgeInsets.top, edgeInsets.left, edgeInsets.bottom, 4 + rightInset); - self.contentEdgeInsets = newInsets; - UIView *caretViewIs = self.rightView; - if (!self.rightView) { - caretViewIs = [[MFCaretView alloc]init]; - self.rightView = caretViewIs; - } - self.rightView.translatesAutoresizingMaskIntoConstraints = NO; - [self addSubview:self.rightView]; - - CGFloat width = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth; - NSLayoutConstraint *caretViewWidthConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]; - caretViewWidthConstraint.active = YES; - - CGFloat height = self.rightViewHeight?self.rightViewHeight.floatValue:CaretViewHeight; - NSLayoutConstraint *caretViewHeightConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:height]; - caretViewHeightConstraint.active = YES; - - NSLayoutConstraint *caretLabelSpacing = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:4.0]; - caretLabelSpacing.active = YES; - self.caretSpacingConstraint = caretLabelSpacing; - - NSLayoutConstraint *caretCenterY = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; - caretCenterY.active = YES; - - NSLayoutConstraint *caretLabelRightPin = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:caretViewIs attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; - caretLabelRightPin.active = YES; - self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; - //set correct color after layout - [self changeCaretColor]; -} -- (void)updateCaretSpacing:(CGFloat)spacing { - if (self.caretSpacingConstraint != nil) { - self.caretSpacingConstraint.constant = spacing; - } -} -- (void)setEnableCaretColor:(UIColor *)enableCaretColor { - self.enableColor = enableCaretColor; - [self changeCaretColor]; -} -- (void)setDisabledCaretColor:(UIColor *)disabledCaretColor { - self.disabledColor = disabledCaretColor; - [self changeCaretColor]; -} -@synthesize enableColor = _enableColor; -- (UIColor *)enableColor { - if (!_enableColor) { - _enableColor = [UIColor blackColor]; - } - return _enableColor; -} - -@synthesize disabledColor = _disabledColor; -- (UIColor *)disabledColor { - if (!_disabledColor) { - _disabledColor = [UIColor mfSilver]; - } - return _disabledColor; -} - -@end diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 5237acb6..21236e70 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -10,13 +10,15 @@ @import MVMCore.MVMCoreActionDelegateProtocol; #import #import +#import +@import MVMCore.MVMCoreViewProtocol; typedef void (^ButtonTapBlock)(id _Nonnull sender); extern CGFloat const CloseButtonHeight; extern CGFloat const CloseButtonWidth; -@interface MFCustomButton : UIButton +@interface MFCustomButton : UIButton @property (nullable, nonatomic, strong) NSDictionary *actionMap; @property (nullable, nonatomic, weak) id buttonDelegate; @@ -35,4 +37,5 @@ extern CGFloat const CloseButtonWidth; - (void)addAccessibilityForCameraControl; - (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction; + @end 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/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 @@ -