From 656652b962bd9d93048400b3937f86c7629f7252 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 09:35:26 -0400 Subject: [PATCH 01/78] Conversion of MFLabel to Label. WIP. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atoms/Views/Label.swift | 388 ++++++++++++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 MVMCoreUI/Atoms/Views/Label.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 40733e65..a3219890 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -152,6 +152,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 */; }; + DB891E832253FA8500022516 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; 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 */; }; @@ -307,6 +308,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 = ""; }; + DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; 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 = ""; }; @@ -566,6 +568,7 @@ D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, + DB891E822253FA8500022516 /* Label.swift */, ); path = Views; sourceTree = ""; @@ -867,6 +870,7 @@ D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, + DB891E832253FA8500022516 /* Label.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift new file mode 100644 index 00000000..1f48273a --- /dev/null +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -0,0 +1,388 @@ +// +// Label.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/22/17. +// Converted by Christiano, Kevin on 4/2/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import MVMCore +import MVMCoreUI + + +class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + + // Set this property if you want updateView to update the font based on this standard and the size passed in. + var standardFontSize: CGFloat = 0.0 + + // Set this to use a custom sizing object during updateView instead of the standard. + var sizeObject: MFSizeObject? + + private var scaleSize: NSNumber? + + // Used for scaling the font in updateView. + private var originalAttributedString: NSAttributedString? + + override var accessibilityTraits: UIAccessibilityTraits { + get { + return super.accessibilityTraits + } + set(accessibilityTraits) { + if accessibilityTraits.rawValue & UIAccessibilityTraits.header.rawValue != 0 { + let noHeaderTraits: UIAccessibilityTraits = UIAccessibilityTraits(rawValue: accessibilityTraits.rawValue - UIAccessibilityTraits.header.rawValue) + super.accessibilityTraits = noHeaderTraits + } else { + super.accessibilityTraits = accessibilityTraits + } + } + } + + var hasText: Bool { + return text.length > 0 || (attributedText?.length ?? 0) > 0 + } + + //------------------------------------------------------ + // MARK: - Initialization + //------------------------------------------------------ + + func setupView() { + backgroundColor = UIColor.clear + numberOfLines = 0 + lineBreakMode = NSLineBreakMode.byWordWrapping + translatesAutoresizingMaskIntoConstraints = false + } + + init() { + setupView() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + setupView() + } + + override init(frame: CGRect) { + super.init(frame: frame) + setupView() + } + + convenience init(standardFontSize size: CGFloat) { + self.init() + standardFontSize = size + } + + func updateView(_ size: CGFloat) { + + scaleSize = NSNumber(value: Float(size)) + + if originalAttributedString { + var attributedString = NSMutableAttributedString(attributedString: originalAttributedString) + attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) + originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in + // Loop the original attributed string, resize the fonts. + let font: UIFont? = value?.withSize(MFStyler.sizeObjectGeneric(forCurrentDevice: value?.pointSize).getValueBased(onSize: size)) + attributedString.addAttribute(.font, value: font, range: range) + }) + attributedText = attributedString + } else if !fequal(standardFontSize, 0) { + var sizeObject: MFSizeObject? = self.sizeObject + if sizeObject == nil { + sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) + } + self.font = self.font.withSize(sizeObject?.getValueBased(onSize: size) ?? 0.0) + } + } + + func setFont(_ font: UIFont, scale: Bool) { + self.font = font + setScale(scale) + } + + func setScale(_ scale: Bool) { + if scale { + standardFontSize = font.pointSize + updateView((scaleSize ? CGFloat(scaleSize?.floatValue ?? 0) : MVMCoreUISplitViewController.getApplicationViewWidth())) + } else { + standardFontSize = 0 + } + } + + class func label() -> Label { + return Label(frame: CGRect.zero) + } + + class func commonLabelB2(_ scale: Bool) -> Label { + let label = Label.label() + label.styleB2(scale) + return label + } + + class func commonLabelBody(withSize size: CGFloat, scale: Bool) -> Label { + let label = Label.label() + label.styleBody(withSize: size, scale: scale) + return label + } + + class func commonLabelBodyBold(_ scale: Bool) -> Label { + let label = Label() + label.styleBodyBold(scale) + return label + } + + class func commonLabelBodyLighter(_ scale: Bool) -> Label { + let label = Label() + label.styleBodyLighter(scale) + return label + } + + class func commonLabelBodyLarge(_ scale: Bool) -> Label { + let label = Label() + label.styleBodyLarge(scale) + return label + } + + class func commonLabelH1(_ scale: Bool) -> Label { + let label = Label() + label.styleH1(scale) + return label + } + + class func commonLabelH2(_ scale: Bool) -> Label { + let label = Label() + label.styleH2(scale) + return label + } + + class func commonLabelHeadlineSmall(_ scale: Bool) -> Label { + let label = Label() + label.styleHeadlineSmall(scale) + return label + } + + class func commonLabelHeadline(withSize size: CGFloat, scale: Bool) -> Label { + let label = Label() + label.styleHeadline(withSize: size, scale: scale) + return label + } + + class func commonLabelHeadlineBlack(withSize size: CGFloat, scale: Bool) -> Label { + let label = Label() + label.styleHeadlineBlack(withSize: size, scale: scale) + return label + } + + class func commonLabelH3(_ scale: Bool) -> Label { + let label = Label() + label.styleH3(scale) + return label + } + + class func commonLabelSubheadBold(_ scale: Bool) -> Label { + let label = Label() + label.styleSubheadBold(scale) + return label + } + + class func commonLabelSubheadBoldLarge(_ scale: Bool) -> Label { + let label = Label() + label.styleSubheadBoldLarge(scale) + return label + } + + class func commonLabelB3(_ scale: Bool) -> Label { + let label = Label() + label.styleB3(scale) + return label + } + + class func commonLabelFeedMessage(_ scale: Bool) -> Label { + let label = Label() + label.styleFeedMessage(scale) + return label + } + + class func commonLabelFeedSubMessage(_ scale: Bool) -> Label { + let label = Label() + label.styleFeedSubMessage(scale) + return label + } + + class func commonLabelFeedHeadline(_ scale: Bool) -> Label { + let label = Label() + label.styleFeedHeadline(scale) + return label + } + + class func commonLabelFeedTitle(_ scale: Bool) -> Label { + let label = Label() + label.styleFeedTitle(scale) + return label + } + + class func commonLabelPlanCardTitle(_ scale: Bool) -> Label { + let label = Label() + label.stylePlanCardTitle(scale) + return label + } + + class func commonLabelB1(_ scale: Bool) -> Label { + let label = Label() + label.styleB1(scale) + return label + } + + class func commonLabelTopAlert(_ scale: Bool) -> Label { + let label = Label() + label.styleTopAlert(scale) + return label + } + + class func setLabel(_ label: UILabel?, withHTML html: String?) { + let data: Data? = html?.data(using: .utf8) + if data != nil { + var error: Error? = nil + if let data = data { + label?.attributedText = try? NSAttributedString(data: data, + options: [NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue as Any], + documentAttributes: nil) + } + if let labelError = error { + try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")) + } + } + } + + class func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + + // TODO: !!! + } + + func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData) + originalAttributedString = attributedText + } + + func styleB2(_ scale: Bool) { + MFStyler.styleLabelB2(self, genericScaling: false) + setScale(scale) + } + + func styleBody(withSize size: CGFloat, scale: Bool) { + MFStyler.styleLabelB2(self, size: size, genericScaling: false) + setScale(scale) + } + + func styleBodyBold(_ scale: Bool) { + MFStyler.styleLabelBodyBold(self, genericScaling: false) + setScale(scale) + } + + func styleBodyLighter(_ scale: Bool) { + MFStyler.styleLabelBodyLighter(self, genericScaling: false) + setScale(scale) + } + + func styleBodyLarge(_ scale: Bool) { + MFStyler.styleLabelBodyLarge(self, genericScaling: false) + setScale(scale) + } + + func styleH1(_ scale: Bool) { + MFStyler.styleLabelH1(self, genericScaling: false) + setScale(scale) + } + + func styleH2(_ scale: Bool) { + MFStyler.styleLabelH2(self, genericScaling: false) + setScale(scale) + } + + func styleHeadlineLarge(_ scale: Bool) { + MFStyler.styleLabelHeadlineLarge(self, genericScaling: false) + setScale(scale) + } + + func styleHeadlineSmall(_ scale: Bool) { + MFStyler.styleLabelHeadlineSmall(self, genericScaling: false) + setScale(scale) + } + + func styleHeadline(withSize size: CGFloat, scale: Bool) { + MFStyler.styleLabelH2(self, size: size, genericScaling: false) + setScale(scale) + } + + func styleHeadlineBlack(withSize size: CGFloat, scale: Bool) { + MFStyler.styleLabelHeadlineBlack(self, size: size, genericScaling: false) + setScale(scale) + } + + func styleH3(_ scale: Bool) { + MFStyler.styleLabelH3(self, genericScaling: false) + setScale(scale) + } + + func styleSubheadBold(_ scale: Bool) { + MFStyler.styleLabelSubheadBold(self, genericScaling: false) + setScale(scale) + } + + func styleSubheadBoldLarge(_ scale: Bool) { + MFStyler.styleLabelSubheadBoldLarge(self, genericScaling: false) + setScale(scale) + } + + func styleB3(_ scale: Bool) { + MFStyler.styleLabelB3(self, genericScaling: false) + setScale(scale) + } + + func styleFeedMessage(_ scale: Bool) { + MFStyler.styleLabelFeedMessage(self, genericScaling: false) + setScale(scale) + } + + func styleFeedSubMessage(_ scale: Bool) { + MFStyler.styleLabelFeedSubMessage(self, genericScaling: false) + setScale(scale) + } + + func styleFeedHeadline(_ scale: Bool) { + MFStyler.styleLabelHeadlineFeed(self, genericScaling: false) + setScale(scale) + } + + func styleFeedTitle(_ scale: Bool) { + MFStyler.styleFeedCardTitleLabel(self, genericScaling: false) + setScale(scale) + } + + func stylePlanCardTitle(_ scale: Bool) { + font = MFStyler.font(forPlanCardTitle: false) + setScale(scale) + } + + func styleB1(_ scale: Bool) { + MFStyler.styleLabelB1(self, genericScaling: false) + setScale(scale) + } + + func styleTableRow(_ scale: Bool) { + MFStyler.styleLabelB1(self, genericScaling: false) + setScale(scale) + } + + func styleTopAlert(_ scale: Bool) { + font = MFStyler.fontB1(false) + setScale(scale) + } + + func setFontH1(_ scale: Bool) { + font = MFStyler.fontH1(false) + setScale(scale) + } +} From 08dc3335683fc86e4f41536d4e692f0d1a08ed02 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 11:14:13 -0400 Subject: [PATCH 02/78] Further work on conversion. --- MVMCoreUI/Atoms/Views/Label.swift | 348 +++++++++++++++++------------- 1 file changed, 196 insertions(+), 152 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 1f48273a..fbff2265 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -42,7 +42,16 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } var hasText: Bool { - return text.length > 0 || (attributedText?.length ?? 0) > 0 + + if let text = text, !text.isEmpty { + return true + } + + if let attributedText = attributedText, !attributedText.string.isEmpty { + return true + } + + return false } //------------------------------------------------------ @@ -57,6 +66,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } init() { + super.init(frame: .zero) setupView() } @@ -79,12 +89,12 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { scaleSize = NSNumber(value: Float(size)) - if originalAttributedString { + if let originalAttributedString = originalAttributedString { var attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in // Loop the original attributed string, resize the fonts. - let font: UIFont? = value?.withSize(MFStyler.sizeObjectGeneric(forCurrentDevice: value?.pointSize).getValueBased(onSize: size)) + let font: UIFont? = (value? as AnyObject).withSize(MFStyler.sizeObjectGeneric(forCurrentDevice: value?.pointSize).getValueBased(onSize: size)) attributedString.addAttribute(.font, value: font, range: range) }) attributedText = attributedString @@ -115,155 +125,100 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { return Label(frame: CGRect.zero) } - class func commonLabelB2(_ scale: Bool) -> Label { - let label = Label.label() - label.styleB2(scale) - return label - } - - class func commonLabelBody(withSize size: CGFloat, scale: Bool) -> Label { - let label = Label.label() - label.styleBody(withSize: size, scale: scale) - return label - } - - class func commonLabelBodyBold(_ scale: Bool) -> Label { - let label = Label() - label.styleBodyBold(scale) - return label - } - - class func commonLabelBodyLighter(_ scale: Bool) -> Label { - let label = Label() - label.styleBodyLighter(scale) - return label - } - - class func commonLabelBodyLarge(_ scale: Bool) -> Label { - let label = Label() - label.styleBodyLarge(scale) - return label - } - - class func commonLabelH1(_ scale: Bool) -> Label { - let label = Label() - label.styleH1(scale) - return label - } - - class func commonLabelH2(_ scale: Bool) -> Label { - let label = Label() - label.styleH2(scale) - return label - } - - class func commonLabelHeadlineSmall(_ scale: Bool) -> Label { - let label = Label() - label.styleHeadlineSmall(scale) - return label - } - - class func commonLabelHeadline(withSize size: CGFloat, scale: Bool) -> Label { - let label = Label() - label.styleHeadline(withSize: size, scale: scale) - return label - } - - class func commonLabelHeadlineBlack(withSize size: CGFloat, scale: Bool) -> Label { - let label = Label() - label.styleHeadlineBlack(withSize: size, scale: scale) - return label - } - - class func commonLabelH3(_ scale: Bool) -> Label { - let label = Label() - label.styleH3(scale) - return label - } - - class func commonLabelSubheadBold(_ scale: Bool) -> Label { - let label = Label() - label.styleSubheadBold(scale) - return label - } - - class func commonLabelSubheadBoldLarge(_ scale: Bool) -> Label { - let label = Label() - label.styleSubheadBoldLarge(scale) - return label - } - - class func commonLabelB3(_ scale: Bool) -> Label { - let label = Label() - label.styleB3(scale) - return label - } - - class func commonLabelFeedMessage(_ scale: Bool) -> Label { - let label = Label() - label.styleFeedMessage(scale) - return label - } - - class func commonLabelFeedSubMessage(_ scale: Bool) -> Label { - let label = Label() - label.styleFeedSubMessage(scale) - return label - } - - class func commonLabelFeedHeadline(_ scale: Bool) -> Label { - let label = Label() - label.styleFeedHeadline(scale) - return label - } - - class func commonLabelFeedTitle(_ scale: Bool) -> Label { - let label = Label() - label.styleFeedTitle(scale) - return label - } - - class func commonLabelPlanCardTitle(_ scale: Bool) -> Label { - let label = Label() - label.stylePlanCardTitle(scale) - return label - } - - class func commonLabelB1(_ scale: Bool) -> Label { - let label = Label() - label.styleB1(scale) - return label - } - - class func commonLabelTopAlert(_ scale: Bool) -> Label { - let label = Label() - label.styleTopAlert(scale) - return label - } - - class func setLabel(_ label: UILabel?, withHTML html: String?) { - let data: Data? = html?.data(using: .utf8) - if data != nil { - var error: Error? = nil - if let data = data { - label?.attributedText = try? NSAttributedString(data: data, - options: [NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue as Any], - documentAttributes: nil) - } - if let labelError = error { - try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")) - } - } - } - - class func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + enum Style { + case commonLabelB2(scale: Bool) + case commonLabelBody(size: CGFloat, scale: Bool) + case commonLabelBodyBold(scale: Bool) + case commonLabelBodyLighter(scale: Bool) + case commonLabelBodyLarge(scale: Bool) + case commonLabelH1(scale: Bool) + case commonLabelH2(scale: Bool) + case commonLabelHeadlineSmall(scale: Bool) + case commonLabelHeadline(size: CGFloat, scale: Bool) + case commonLabelHeadlineBlack(size: CGFloat, scale: Bool) + case commonLabelH3(scale: Bool) + case commonLabelSubheadBold(scale: Bool) + case commonLabelSubheadBoldLarge(scale: Bool) + case commonLabelB3(scale: Bool) + case commonLabelFeedMessage(scale: Bool) + case commonLabelFeedSubMessage(scale: Bool) + case commonLabelFeedHeadline(scale: Bool) + case commonLabelFeedTitle(scale: Bool) + case commonLabelPlanCardTitle(scale: Bool) + case commonLabelB1(scale: Bool) + case commonLabelTopAlert(scale: Bool) - // TODO: !!! - } - - func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData) - originalAttributedString = attributedText + func getLabel() -> Label { + + let label = Label() + + switch self { + case .commonLabelB2(let scale): + label.styleB2(scale) + + case .commonLabelBody(let size, let scale): + label.styleBody(withSize: size, scale: scale) + + case .commonLabelBodyBold(let scale): + label.styleBodyBold(scale) + + case .commonLabelBodyLighter(let scale): + label.styleBodyLighter(scale) + + case .commonLabelBodyLarge(let scale): + label.styleBodyLarge(scale) + + case .commonLabelH1(let scale): + label.styleH1(scale) + + case .commonLabelH2(let scale): + label.styleH2(scale) + + case .commonLabelHeadlineSmall(let scale): + label.styleHeadlineSmall(scale) + + case .commonLabelHeadline(let size, let scale): + label.styleHeadline(withSize: size, scale: scale) + + case .commonLabelHeadlineBlack(let size, let scale): + label.styleHeadlineBlack(withSize: size, scale: scale) + + case .commonLabelH3(let scale): + label.styleH3(scale) + + case .commonLabelSubheadBold(let scale): + label.styleSubheadBold(scale) + + case .commonLabelSubheadBoldLarge(let scale): + label.styleSubheadBoldLarge(scale) + + case .commonLabelB3(let scale): + label.styleB3(scale) + + case .commonLabelFeedMessage(let scale): + label.styleFeedMessage(scale) + + case .commonLabelFeedSubMessage(let scale): + label.styleFeedSubMessage(scale) + + case .commonLabelFeedHeadline(let scale): + label.styleFeedHeadline(scale) + + case .commonLabelFeedTitle(let scale): + label.styleFeedTitle(scale) + + case .commonLabelPlanCardTitle(let scale): + label.stylePlanCardTitle(scale) + + case .commonLabelB1(let scale): + label.styleB1(scale) + + case .commonLabelTopAlert(let scale): + label.styleTopAlert(scale) + } + + return label + } } func styleB2(_ scale: Bool) { @@ -345,7 +300,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { MFStyler.styleLabelFeedMessage(self, genericScaling: false) setScale(scale) } - + func styleFeedSubMessage(_ scale: Bool) { MFStyler.styleLabelFeedSubMessage(self, genericScaling: false) setScale(scale) @@ -385,4 +340,93 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { font = MFStyler.fontH1(false) setScale(scale) } + + class func setLabel(_ label: UILabel?, withHTML html: String?) { + let data: Data? = html?.data(using: .utf8) + if data != nil { + var error: Error? = nil + if let data = data { + label?.attributedText = try? NSAttributedString(data: data, + options: [NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue], + documentAttributes: nil) + } + if let labelError = error { + try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")) + } + } + } + + class func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + + if let label = label { + label.text = json?.optionalStringForKey(KeyText) + setLabel(label, withHTML: json?.stringForkey("html")) + + if let textColorHex = json?.optionalStringForKey(KeyTextColor) { + label.textColor = UIColor.mfGet(forHex: textColorHex) + } + + if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor) { + label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + + if let accessibilityText = json?.optionalStringForKey("accessibilityText") { + label.accessibilityLabel = accessibilityText + } + + var fontSize = json?.floatForKey("fontSize") + + if let fontName = json?.optionalStringForKey("fontName"), let fontSize = fontSize { + label.font = MFFonts.mfFont(withName: fontName, size: CGFloat(fontSize) == 0.0 ? label.font.pointSize : CGFloat(fontSize)) + } else if let fontSize = fontSize { + label.font = label.font.withSize(CGFloat(fontSize)) + } + + if let attributes = json?.arrayForKey("attributes") { + var attributedString = NSMutableAttributedString(string: label.text, attributes: [NSAttributedString.Key.font: label.font, + NSAttributedString.Key.foregroundColor: label.textColor]) + for case let attribute as [String: Any] in attributes { + var location = attribute.optionalNumber(forKey: "location") + var length = attribute.optionalNumber(forKey: "length") + if location && length { + + var range = NSRange(location: Int(location.uintValue), length: Int(length.uintValue)) + var type = attribute.string(KeyType) + + if type == "underline" { + attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) + + } else if type == "strikethrough" { + attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) + + } else if type == "color" { + if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { + attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) + } + } else if type == "font" { + + var fontSize = attribute.floatForKey("size") + var font: UIFont? + + if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { + font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) + } else { + font = label.font.withSize(CGFloat(fontSize)) + } + + if font != nil { + attributedString.addAttribute(.font, value: font, range: range) + } + } + } + } + label.attributedText = attributedString + } + } + } + + func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData) + originalAttributedString = attributedText + } } From ce68eafd348182bbb82ab231c9bb365e73b48f50 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 13:31:29 -0400 Subject: [PATCH 03/78] stopping for now. --- MVMCoreUI/Atoms/Views/Label.swift | 106 ++++++++++++++++++------------ 1 file changed, 65 insertions(+), 41 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index fbff2265..88b07f00 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -59,6 +59,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ func setupView() { + backgroundColor = UIColor.clear numberOfLines = 0 lineBreakMode = NSLineBreakMode.byWordWrapping @@ -85,24 +86,32 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { standardFontSize = size } + //------------------------------------------------------ + // MARK: - Functions + //------------------------------------------------------ + func updateView(_ size: CGFloat) { scaleSize = NSNumber(value: Float(size)) if let originalAttributedString = originalAttributedString { - var attributedString = NSMutableAttributedString(attributedString: originalAttributedString) + let attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) + originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in // Loop the original attributed string, resize the fonts. - let font: UIFont? = (value? as AnyObject).withSize(MFStyler.sizeObjectGeneric(forCurrentDevice: value?.pointSize).getValueBased(onSize: size)) - attributedString.addAttribute(.font, value: font, range: range) + let font: UIFont? = (value as? UIFont)?.withSize((MFStyler.sizeObjectGeneric(forCurrentDevice: ((value as? UIFont)?.pointSize)!)?.getValueBased(onSize: size))!) + attributedString.addAttribute(.font, value: font as Any, range: range) }) attributedText = attributedString - } else if !fequal(standardFontSize, 0) { + + } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0) { var sizeObject: MFSizeObject? = self.sizeObject + if sizeObject == nil { sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) } + self.font = self.font.withSize(sizeObject?.getValueBased(onSize: size) ?? 0.0) } } @@ -115,7 +124,11 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { func setScale(_ scale: Bool) { if scale { standardFontSize = font.pointSize - updateView((scaleSize ? CGFloat(scaleSize?.floatValue ?? 0) : MVMCoreUISplitViewController.getApplicationViewWidth())) + if let scaleSize = scaleSize { + updateView(CGFloat(scaleSize.floatValue)) + } else { + updateView(MVMCoreUISplitViewController.getApplicationViewWidth()) + } } else { standardFontSize = 0 } @@ -148,7 +161,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { case commonLabelB1(scale: Bool) case commonLabelTopAlert(scale: Bool) - func getLabel() -> Label { + func createLabel() -> Label { let label = Label() @@ -221,6 +234,10 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } } + //------------------------------------------------------ + // MARK: - Methods + //------------------------------------------------------ + func styleB2(_ scale: Bool) { MFStyler.styleLabelB2(self, genericScaling: false) setScale(scale) @@ -344,14 +361,14 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { class func setLabel(_ label: UILabel?, withHTML html: String?) { let data: Data? = html?.data(using: .utf8) if data != nil { - var error: Error? = nil + let error: Error? = nil if let data = data { label?.attributedText = try? NSAttributedString(data: data, - options: [NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue], + options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) } if let labelError = error { - try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")) + try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")!) } } } @@ -374,7 +391,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { label.accessibilityLabel = accessibilityText } - var fontSize = json?.floatForKey("fontSize") + let fontSize = json?.floatForKey("fontSize") if let fontName = json?.optionalStringForKey("fontName"), let fontSize = fontSize { label.font = MFFonts.mfFont(withName: fontName, size: CGFloat(fontSize) == 0.0 ? label.font.pointSize : CGFloat(fontSize)) @@ -382,42 +399,41 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { label.font = label.font.withSize(CGFloat(fontSize)) } - if let attributes = json?.arrayForKey("attributes") { - var attributedString = NSMutableAttributedString(string: label.text, attributes: [NSAttributedString.Key.font: label.font, + if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font, NSAttributedString.Key.foregroundColor: label.textColor]) for case let attribute as [String: Any] in attributes { - var location = attribute.optionalNumber(forKey: "location") - var length = attribute.optionalNumber(forKey: "length") - if location && length { + let location = attribute.floatForKey("location") + let length = attribute.floatForKey("length") + + let range = NSRange(location: Int(location), length: Int(length)) + + switch attribute.stringForkey(KeyType){ + case "underline": + attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) - var range = NSRange(location: Int(location.uintValue), length: Int(length.uintValue)) - var type = attribute.string(KeyType) + case "strikethrough": + attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) - if type == "underline" { - attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) - - } else if type == "strikethrough" { - attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) - - } else if type == "color" { - if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { - attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) - } - } else if type == "font" { - - var fontSize = attribute.floatForKey("size") - var font: UIFont? - - if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { - font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) - } else { - font = label.font.withSize(CGFloat(fontSize)) - } - - if font != nil { - attributedString.addAttribute(.font, value: font, range: range) - } + case "color": + if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { + attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) } + case "font": + let fontSize = attribute.floatForKey("size") + var font: UIFont? + + if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { + font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) + } else { + font = label.font.withSize(CGFloat(fontSize)) + } + + if font != nil { + attributedString.addAttribute(.font, value: font as Any, range: range) + } + default: + continue } } label.attributedText = attributedString @@ -425,6 +441,14 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } } + //------------------------------------------------------ + // MARK: - Atomization + //------------------------------------------------------ + + func setAsMolecule() { + // Empty + } + func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData) originalAttributedString = attributedText From 2b4d8b95c961fb5dee5bd5575454c23ab920c246 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 3 Apr 2019 14:46:34 -0400 Subject: [PATCH 04/78] checkbox --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ MVMCoreUI/Atoms/Views/CheckBoxWithLabel.swift | 31 ++++++++++++ MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h | 3 ++ MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 47 ++++++++++++++++++- MVMCoreUI/Atoms/Views/ViewConstrainingView.h | 3 ++ MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 28 ++++++----- .../MVMCoreUIMoleculeMappingObject.m | 3 +- .../Protocols/FormValidationProtocol.swift | 2 +- 8 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/CheckBoxWithLabel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5df32702..201e8d9a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 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 */; }; + 013DAB042254FCE00092ABB7 /* CheckBoxWithLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 013DAB032254FCE00092ABB7 /* CheckBoxWithLabel.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, ); }; }; @@ -167,6 +168,7 @@ 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 = ""; }; + 013DAB032254FCE00092ABB7 /* CheckBoxWithLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxWithLabel.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 = ""; }; @@ -595,6 +597,7 @@ D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, + 013DAB032254FCE00092ABB7 /* CheckBoxWithLabel.swift */, ); path = Views; sourceTree = ""; @@ -870,6 +873,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, + 013DAB042254FCE00092ABB7 /* CheckBoxWithLabel.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CheckBoxWithLabel.swift b/MVMCoreUI/Atoms/Views/CheckBoxWithLabel.swift new file mode 100644 index 00000000..533ee060 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/CheckBoxWithLabel.swift @@ -0,0 +1,31 @@ +// +// ChecckBoxWithLabel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 4/3/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class CheckBoxWithLabel: ViewConstrainingView { + let mvmCheckBox = MVMCoreUICheckBox(frame: .zero) + + public init() { + super.init(frame: .zero) + } + + public required init?(coder decoder: NSCoder) { + super.init(coder: decoder) + } + + public override func setupView() { + super.setupView() + addConstrainedView(mvmCheckBox) + } + + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + mvmCheckBox.setWithJSON(json, delegate: delegate, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h index 853293c7..32fb1e02 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h @@ -59,4 +59,7 @@ - (void)setValueForAccessibilityText:(nullable NSString *)text; - (void)hideDescriptionLabelAndPinCheckboxToRight; +// Molecule Design +- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; + @end diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index c67c628f..f00d9101 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -16,10 +16,13 @@ #import "UIColor+MFConvenience.h" #import "MVMCoreUIUtility.h" #import "MFStyler.h" +#import + static const CGFloat FaultTolerance = 20.f; static const CGFloat CheckBoxHeightWidth = 18.0; -@interface MVMCoreUICheckBox () + +@interface MVMCoreUICheckBox () @property (nonatomic, readwrite) BOOL isSelected; @property (weak, nonatomic) UIView *checkedSquare; @@ -38,12 +41,32 @@ static const CGFloat CheckBoxHeightWidth = 18.0; @property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxWidth; @property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxHeight; +@property (nonatomic) BOOL isRequired; +@property (nullable, strong, nonatomic) NSString *fieldKey; +@property (nullable, weak) id delegate; + @end @implementation MVMCoreUICheckBox #pragma mark - convenient class methods +- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { + [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; + self.delegate = (id)delegate; + self.fieldKey = [json stringForKey:@"fieldKey"]; + self.isRequired = [json boolForKey:@"required"]; + + NSString *checkedColorHex = [json string:@"checkedColor"]; + NSString *unCheckedColorHex = [json string:@"unCheckedColor"]; + + UIColor *checkedColor = checkedColorHex ? [UIColor mfGetColorForHex:checkedColorHex]: [UIColor blackColor]; + UIColor *unCheckedColor = unCheckedColorHex ? [UIColor mfGetColorForHex:unCheckedColorHex]: [UIColor clearColor]; + NSString *label = [json string:@"label"]; + + [self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor text:label]; +} + + (instancetype)mfCheckBox { MVMCoreUICheckBox *checkBox = [[self alloc] initWithFrame:CGRectZero]; checkBox.translatesAutoresizingMaskIntoConstraints = NO; @@ -68,6 +91,23 @@ static const CGFloat CheckBoxHeightWidth = 18.0; return checkBox; } +#pragma mark - FormValidationProtocol + +- (BOOL)isValidField { + if (self.isRequired) { + return self.isSelected; + } + return true; +} + +- (nullable NSString *)formFieldName { + return self.fieldKey; +} + +- (nullable id)formFieldValue { + return @(self.isSelected); +} + #pragma mark - inits - (instancetype)initWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text { @@ -253,7 +293,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0; [self setSelected:selected animated:animated runBlock:YES]; } -- (void)setSelected:(BOOL)selected animated:(BOOL)animated runBlock:(BOOL)runBlock{ +- (void)setSelected:(BOOL)selected animated:(BOOL)animated runBlock:(BOOL)runBlock { [self addAccessibilityLabel:selected]; self.isSelected = selected; @@ -271,6 +311,9 @@ static const CGFloat CheckBoxHeightWidth = 18.0; } completion:nil]; [self.checkMark updateCheckSelected:NO animated:animated]; } + + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:self.delegate]; + [formValidator enableByValidation]; } - (void)setColor:(nullable UIColor *)color forState:(UIControlState)state { diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h index bb4740a7..939c3b6f 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h @@ -47,4 +47,7 @@ // For setting up the view. - (void)setupView; +// Add a View Constraining View +- (void)addConstrainedView:(nonnull UIView *)view; + @end diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index a88b61c3..1ef339fb 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -28,28 +28,30 @@ ViewConstrainingView *constrainingView = [[ViewConstrainingView alloc] initWithFrame:CGRectZero]; constrainingView.translatesAutoresizingMaskIntoConstraints = NO; constrainingView.backgroundColor = [UIColor clearColor]; - + [constrainingView addConstrainedView:view]; + return constrainingView; +} + +- (void)addConstrainedView:(nonnull UIView *)view { view.translatesAutoresizingMaskIntoConstraints = NO; - [constrainingView addSubview:view]; - constrainingView.constrainedView = view; + [self addSubview:view]; + self.constrainedView = view; - NSLayoutConstraint *leftPin = [view.leftAnchor constraintEqualToAnchor:constrainingView.leftAnchor]; - constrainingView.leftPin = leftPin; + NSLayoutConstraint *leftPin = [view.leftAnchor constraintEqualToAnchor:self.leftAnchor]; + self.leftPin = leftPin; leftPin.active = YES; - NSLayoutConstraint *topPin = [view.topAnchor constraintEqualToAnchor:constrainingView.topAnchor]; - constrainingView.topPin = topPin; + NSLayoutConstraint *topPin = [view.topAnchor constraintEqualToAnchor:self.topAnchor]; + self.topPin = topPin; topPin.active = YES; - NSLayoutConstraint *bottomPin = [constrainingView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor]; - constrainingView.bottomPin = bottomPin; + NSLayoutConstraint *bottomPin = [self.bottomAnchor constraintEqualToAnchor:view.bottomAnchor]; + self.bottomPin = bottomPin; bottomPin.active = YES; - NSLayoutConstraint *rightPin = [constrainingView.rightAnchor constraintEqualToAnchor:view.rightAnchor]; - constrainingView.rightPin = rightPin; + NSLayoutConstraint *rightPin = [self.rightAnchor constraintEqualToAnchor:view.rightAnchor]; + self.rightPin = rightPin; rightPin.active = YES; - - return constrainingView; } - (void)pinToSuperView { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 0936f9df..4eb66001 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -32,7 +32,8 @@ @"standardFooter": StandardFooterView.class, @"caretView": CaretView.class, @"caretButton": CaretButton.class, - @"textField" : MFTextField.class + @"textField" : MFTextField.class, + @"checkbox" : CheckBoxWithLabel.class } mutableCopy]; }); return mapping; diff --git a/MVMCoreUI/Protocols/FormValidationProtocol.swift b/MVMCoreUI/Protocols/FormValidationProtocol.swift index bfdbb0fd..5336af24 100644 --- a/MVMCoreUI/Protocols/FormValidationProtocol.swift +++ b/MVMCoreUI/Protocols/FormValidationProtocol.swift @@ -15,5 +15,5 @@ import Foundation @objc optional func enableField(_ enable: Bool) @objc optional func formFieldName() -> String? - @objc optional func formFieldValue() -> String? + @objc optional func formFieldValue() -> Any? } From edde99cc23cbeee7cab9539849bbfa1713dd32ad Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Sun, 7 Apr 2019 20:18:40 -0400 Subject: [PATCH 05/78] Changes made to satisfy update to MFLabel. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +- MVMCoreUI/Atoms/Views/Label.swift | 491 +++++++++++----------------- 2 files changed, 186 insertions(+), 309 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5d4a752c..5731bd78 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -157,10 +157,10 @@ 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 */; }; - DB891E832253FA8500022516 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; 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 */; }; + DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -886,6 +886,7 @@ D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, + DBEFFA04225A829700230692 /* Label.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, @@ -893,7 +894,6 @@ D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, - DB891E832253FA8500022516 /* Label.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 88b07f00..61bf9a12 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -54,6 +54,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { return false } + //------------------------------------------------------ // MARK: - Initialization //------------------------------------------------------ @@ -86,10 +87,193 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { standardFontSize = size } + //------------------------------------------------------ + // MARK: - Enum + //------------------------------------------------------ + + enum Style { + case commonLabelB2(scale: Bool) + case commonLabelH1(scale: Bool) + case commonLabelH2(scale: Bool) + case commonLabelH32(scale: Bool) + case commonLabelH3(scale: Bool) + case commonLabelB3(scale: Bool) + case commonLabelB20(scale: Bool) + case commonLabelB1(scale: Bool) + + func createLabel() -> Label { + + let label = Label() + + switch self { + case .commonLabelB2(let scale): + label.styleB2(scale) + + case .commonLabelH1(let scale): + label.styleH1(scale) + + case .commonLabelH2(let scale): + label.styleH2(scale) + + case .commonLabelH32(let scale): + label.styleH32(scale) + + case .commonLabelH3(let scale): + label.styleH3(scale) + + case .commonLabelB3(let scale): + label.styleB3(scale) + + case .commonLabelB20(let scale): + label.styleB20(scale) + + case .commonLabelB1(let scale): + label.styleB1(scale) + } + + return label + } + } + //------------------------------------------------------ // MARK: - Functions //------------------------------------------------------ + static func label() -> Label { + return Label(frame: CGRect.zero) + } + + static func setLabel(_ label: UILabel?, withHTML html: String?) { + let data: Data? = html?.data(using: .utf8) + if data != nil { + let error: Error? = nil + if let data = data { + label?.attributedText = try? NSAttributedString(data: data, + options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], + documentAttributes: nil) + + // label?.attributedText = try? NSAttributedString(data: data, options: [ + // NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue + // ], documentAttributes: nil) + } + if let labelError = error { + try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")!) + } + } + } + + static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + + if let label = label { + label.text = json?.optionalStringForKey(KeyText) + setLabel(label, withHTML: json?.stringForkey("html")) + + if let textColorHex = json?.optionalStringForKey(KeyTextColor) { + label.textColor = UIColor.mfGet(forHex: textColorHex) + } + + if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor) { + label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + + if let accessibilityText = json?.optionalStringForKey("accessibilityText") { + label.accessibilityLabel = accessibilityText + } + + let fontSize = json?.floatForKey("fontSize") + + if let fontName = json?.optionalStringForKey("fontName"), let fontSize = fontSize { + label.font = MFFonts.mfFont(withName: fontName, size: CGFloat(fontSize) == 0.0 ? label.font.pointSize : CGFloat(fontSize)) + } else if let fontSize = fontSize { + label.font = label.font.withSize(CGFloat(fontSize)) + } + + if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font, + NSAttributedString.Key.foregroundColor: label.textColor]) + for case let attribute as [String: Any] in attributes { + let location = attribute.floatForKey("location") + let length = attribute.floatForKey("length") + + let range = NSRange(location: Int(location), length: Int(length)) + + switch attribute.stringForkey(KeyType){ + case "underline": + attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) + + case "strikethrough": + attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) + + case "color": + if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { + attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) + } + case "font": + let fontSize = attribute.floatForKey("size") + var font: UIFont? + + if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { + font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) + } else { + font = label.font.withSize(CGFloat(fontSize)) + } + + if font != nil { + attributedString.addAttribute(.font, value: font as Any, range: range) + } + default: + continue + } + } + label.attributedText = attributedString + } + } + } + + //------------------------------------------------------ + // MARK: - Methods + //------------------------------------------------------ + + func styleH1(_ scale: Bool) { + MFStyler.styleLabelH1(self, genericScaling: false) + setScale(scale) + } + + func styleH2(_ scale: Bool) { + MFStyler.styleLabelH2(self, genericScaling: false) + setScale(scale) + } + + func styleH3(_ scale: Bool) { + MFStyler.styleLabelH3(self, genericScaling: false) + setScale(scale) + } + + func styleH32(_ scale: Bool) { + MFStyler.styleLabelH32(self, genericScaling: false) + setScale(scale) + } + + func styleB1(_ scale: Bool) { + MFStyler.styleLabelB1(self, genericScaling: false) + setScale(scale) + } + + func styleB2(_ scale: Bool) { + MFStyler.styleLabelB2(self, genericScaling: false) + setScale(scale) + } + + func styleB3(_ scale: Bool) { + MFStyler.styleLabelB3(self, genericScaling: false) + setScale(scale) + } + + func styleB20(_ scale: Bool) { + MFStyler.styleLabelB20(self, genericScaling: false) + setScale(scale) + } + func updateView(_ size: CGFloat) { scaleSize = NSNumber(value: Float(size)) @@ -134,313 +318,6 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } } - class func label() -> Label { - return Label(frame: CGRect.zero) - } - - enum Style { - case commonLabelB2(scale: Bool) - case commonLabelBody(size: CGFloat, scale: Bool) - case commonLabelBodyBold(scale: Bool) - case commonLabelBodyLighter(scale: Bool) - case commonLabelBodyLarge(scale: Bool) - case commonLabelH1(scale: Bool) - case commonLabelH2(scale: Bool) - case commonLabelHeadlineSmall(scale: Bool) - case commonLabelHeadline(size: CGFloat, scale: Bool) - case commonLabelHeadlineBlack(size: CGFloat, scale: Bool) - case commonLabelH3(scale: Bool) - case commonLabelSubheadBold(scale: Bool) - case commonLabelSubheadBoldLarge(scale: Bool) - case commonLabelB3(scale: Bool) - case commonLabelFeedMessage(scale: Bool) - case commonLabelFeedSubMessage(scale: Bool) - case commonLabelFeedHeadline(scale: Bool) - case commonLabelFeedTitle(scale: Bool) - case commonLabelPlanCardTitle(scale: Bool) - case commonLabelB1(scale: Bool) - case commonLabelTopAlert(scale: Bool) - - func createLabel() -> Label { - - let label = Label() - - switch self { - case .commonLabelB2(let scale): - label.styleB2(scale) - - case .commonLabelBody(let size, let scale): - label.styleBody(withSize: size, scale: scale) - - case .commonLabelBodyBold(let scale): - label.styleBodyBold(scale) - - case .commonLabelBodyLighter(let scale): - label.styleBodyLighter(scale) - - case .commonLabelBodyLarge(let scale): - label.styleBodyLarge(scale) - - case .commonLabelH1(let scale): - label.styleH1(scale) - - case .commonLabelH2(let scale): - label.styleH2(scale) - - case .commonLabelHeadlineSmall(let scale): - label.styleHeadlineSmall(scale) - - case .commonLabelHeadline(let size, let scale): - label.styleHeadline(withSize: size, scale: scale) - - case .commonLabelHeadlineBlack(let size, let scale): - label.styleHeadlineBlack(withSize: size, scale: scale) - - case .commonLabelH3(let scale): - label.styleH3(scale) - - case .commonLabelSubheadBold(let scale): - label.styleSubheadBold(scale) - - case .commonLabelSubheadBoldLarge(let scale): - label.styleSubheadBoldLarge(scale) - - case .commonLabelB3(let scale): - label.styleB3(scale) - - case .commonLabelFeedMessage(let scale): - label.styleFeedMessage(scale) - - case .commonLabelFeedSubMessage(let scale): - label.styleFeedSubMessage(scale) - - case .commonLabelFeedHeadline(let scale): - label.styleFeedHeadline(scale) - - case .commonLabelFeedTitle(let scale): - label.styleFeedTitle(scale) - - case .commonLabelPlanCardTitle(let scale): - label.stylePlanCardTitle(scale) - - case .commonLabelB1(let scale): - label.styleB1(scale) - - case .commonLabelTopAlert(let scale): - label.styleTopAlert(scale) - } - - return label - } - } - - //------------------------------------------------------ - // MARK: - Methods - //------------------------------------------------------ - - func styleB2(_ scale: Bool) { - MFStyler.styleLabelB2(self, genericScaling: false) - setScale(scale) - } - - func styleBody(withSize size: CGFloat, scale: Bool) { - MFStyler.styleLabelB2(self, size: size, genericScaling: false) - setScale(scale) - } - - func styleBodyBold(_ scale: Bool) { - MFStyler.styleLabelBodyBold(self, genericScaling: false) - setScale(scale) - } - - func styleBodyLighter(_ scale: Bool) { - MFStyler.styleLabelBodyLighter(self, genericScaling: false) - setScale(scale) - } - - func styleBodyLarge(_ scale: Bool) { - MFStyler.styleLabelBodyLarge(self, genericScaling: false) - setScale(scale) - } - - func styleH1(_ scale: Bool) { - MFStyler.styleLabelH1(self, genericScaling: false) - setScale(scale) - } - - func styleH2(_ scale: Bool) { - MFStyler.styleLabelH2(self, genericScaling: false) - setScale(scale) - } - - func styleHeadlineLarge(_ scale: Bool) { - MFStyler.styleLabelHeadlineLarge(self, genericScaling: false) - setScale(scale) - } - - func styleHeadlineSmall(_ scale: Bool) { - MFStyler.styleLabelHeadlineSmall(self, genericScaling: false) - setScale(scale) - } - - func styleHeadline(withSize size: CGFloat, scale: Bool) { - MFStyler.styleLabelH2(self, size: size, genericScaling: false) - setScale(scale) - } - - func styleHeadlineBlack(withSize size: CGFloat, scale: Bool) { - MFStyler.styleLabelHeadlineBlack(self, size: size, genericScaling: false) - setScale(scale) - } - - func styleH3(_ scale: Bool) { - MFStyler.styleLabelH3(self, genericScaling: false) - setScale(scale) - } - - func styleSubheadBold(_ scale: Bool) { - MFStyler.styleLabelSubheadBold(self, genericScaling: false) - setScale(scale) - } - - func styleSubheadBoldLarge(_ scale: Bool) { - MFStyler.styleLabelSubheadBoldLarge(self, genericScaling: false) - setScale(scale) - } - - func styleB3(_ scale: Bool) { - MFStyler.styleLabelB3(self, genericScaling: false) - setScale(scale) - } - - func styleFeedMessage(_ scale: Bool) { - MFStyler.styleLabelFeedMessage(self, genericScaling: false) - setScale(scale) - } - - func styleFeedSubMessage(_ scale: Bool) { - MFStyler.styleLabelFeedSubMessage(self, genericScaling: false) - setScale(scale) - } - - func styleFeedHeadline(_ scale: Bool) { - MFStyler.styleLabelHeadlineFeed(self, genericScaling: false) - setScale(scale) - } - - func styleFeedTitle(_ scale: Bool) { - MFStyler.styleFeedCardTitleLabel(self, genericScaling: false) - setScale(scale) - } - - func stylePlanCardTitle(_ scale: Bool) { - font = MFStyler.font(forPlanCardTitle: false) - setScale(scale) - } - - func styleB1(_ scale: Bool) { - MFStyler.styleLabelB1(self, genericScaling: false) - setScale(scale) - } - - func styleTableRow(_ scale: Bool) { - MFStyler.styleLabelB1(self, genericScaling: false) - setScale(scale) - } - - func styleTopAlert(_ scale: Bool) { - font = MFStyler.fontB1(false) - setScale(scale) - } - - func setFontH1(_ scale: Bool) { - font = MFStyler.fontH1(false) - setScale(scale) - } - - class func setLabel(_ label: UILabel?, withHTML html: String?) { - let data: Data? = html?.data(using: .utf8) - if data != nil { - let error: Error? = nil - if let data = data { - label?.attributedText = try? NSAttributedString(data: data, - options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], - documentAttributes: nil) - } - if let labelError = error { - try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")!) - } - } - } - - class func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - - if let label = label { - label.text = json?.optionalStringForKey(KeyText) - setLabel(label, withHTML: json?.stringForkey("html")) - - if let textColorHex = json?.optionalStringForKey(KeyTextColor) { - label.textColor = UIColor.mfGet(forHex: textColorHex) - } - - if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor) { - label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) - } - - if let accessibilityText = json?.optionalStringForKey("accessibilityText") { - label.accessibilityLabel = accessibilityText - } - - let fontSize = json?.floatForKey("fontSize") - - if let fontName = json?.optionalStringForKey("fontName"), let fontSize = fontSize { - label.font = MFFonts.mfFont(withName: fontName, size: CGFloat(fontSize) == 0.0 ? label.font.pointSize : CGFloat(fontSize)) - } else if let fontSize = fontSize { - label.font = label.font.withSize(CGFloat(fontSize)) - } - - if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font, - NSAttributedString.Key.foregroundColor: label.textColor]) - for case let attribute as [String: Any] in attributes { - let location = attribute.floatForKey("location") - let length = attribute.floatForKey("length") - - let range = NSRange(location: Int(location), length: Int(length)) - - switch attribute.stringForkey(KeyType){ - case "underline": - attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) - - case "strikethrough": - attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) - - case "color": - if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { - attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) - } - case "font": - let fontSize = attribute.floatForKey("size") - var font: UIFont? - - if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { - font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) - } else { - font = label.font.withSize(CGFloat(fontSize)) - } - - if font != nil { - attributedString.addAttribute(.font, value: font as Any, range: range) - } - default: - continue - } - } - label.attributedText = attributedString - } - } - } - //------------------------------------------------------ // MARK: - Atomization //------------------------------------------------------ From 741785cc228129c1acfb2424ce7d3fdf6e750c9d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 9 Apr 2019 13:46:28 -0400 Subject: [PATCH 06/78] secondary default as white for the feed --- MVMCoreUI/Molecules/TwoButtonView.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index ee03ff49..66ef8600 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -25,6 +25,11 @@ import UIKit super.init(frame: frame) } + public func setDefaultCustom() { + primaryButton?.setAsStandardCustom() + secondaryButton?.setAsSecondaryCustom() + } + // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) @@ -139,8 +144,7 @@ import UIKit open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON, legacy: false) - primaryButton?.setAsStandardCustom() - secondaryButton?.setAsSecondaryCustom() + setDefaultCustom() primaryButton?.setWithJSON(primaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) secondaryButton?.setWithJSON(secondaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) } From 4b02477592314de0fdd0b8876f7f10a93586d8bf Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 9 Apr 2019 14:33:41 -0400 Subject: [PATCH 07/78] merge From 39ce8af7ab2ba4fa537deca2308b30e5e56788d9 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 9 Apr 2019 15:18:14 -0400 Subject: [PATCH 08/78] further work on conversion. --- MVMCoreUI/Atoms/Views/Label.swift | 118 ++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 61bf9a12..2b491d07 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -54,7 +54,6 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { return false } - //------------------------------------------------------ // MARK: - Initialization //------------------------------------------------------ @@ -88,61 +87,115 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } //------------------------------------------------------ - // MARK: - Enum + // MARK: - Enum Generator //------------------------------------------------------ enum Style { - case commonLabelB2(scale: Bool) - case commonLabelH1(scale: Bool) - case commonLabelH2(scale: Bool) - case commonLabelH32(scale: Bool) - case commonLabelH3(scale: Bool) - case commonLabelB3(scale: Bool) - case commonLabelB20(scale: Bool) - case commonLabelB1(scale: Bool) + case B1(scale: Bool) + case B2(scale: Bool) + case B3(scale: Bool) + case B20(scale: Bool) + case H1(scale: Bool) + case H2(scale: Bool) + case H3(scale: Bool) + case H32(scale: Bool) + case none - func createLabel() -> Label { + func create() -> Label { let label = Label() switch self { - case .commonLabelB2(let scale): + case .B1(let scale): + label.styleB1(scale) + + case .B2(let scale): label.styleB2(scale) - case .commonLabelH1(let scale): - label.styleH1(scale) - - case .commonLabelH2(let scale): - label.styleH2(scale) - - case .commonLabelH32(let scale): - label.styleH32(scale) - - case .commonLabelH3(let scale): - label.styleH3(scale) - - case .commonLabelB3(let scale): + case .B3(let scale): label.styleB3(scale) - case .commonLabelB20(let scale): + case .B20(let scale): label.styleB20(scale) - case .commonLabelB1(let scale): - label.styleB1(scale) + case .H1(let scale): + label.styleH1(scale) + + case .H2(let scale): + label.styleH2(scale) + + case .H3(let scale): + label.styleH3(scale) + + case .H32(let scale): + label.styleH32(scale) + + case .none: + break; } return label } } + + /* + class func commonLabelH1(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH1(scale) + return label + } + + class func commonLabelH2(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH2(scale) + return label + } + + class func commonLabelH3(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH3(scale) + return label + } + + class func commonLabelH32(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH32(scale) + return label + } + + class func commonLabelB1(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB1(scale) + return label + } + + class func commonLabelB2(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB2(scale) + return label + } + + class func commonLabelB3(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB3(scale) + return label + } + + class func commonLabelB20(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB20(scale) + return label + } + + class func label() -> MFLabel { + return Label(frame: CGRect.zero) + } + */ //------------------------------------------------------ // MARK: - Functions //------------------------------------------------------ - static func label() -> Label { - return Label(frame: CGRect.zero) - } - static func setLabel(_ label: UILabel?, withHTML html: String?) { let data: Data? = html?.data(using: .utf8) if data != nil { @@ -152,6 +205,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) + // compare with above... // label?.attributedText = try? NSAttributedString(data: data, options: [ // NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue // ], documentAttributes: nil) From b1869730f5bac198e7fbb8f390d3a54197b41c0e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 10 Apr 2019 12:43:39 -0400 Subject: [PATCH 09/78] button_delegate --- MVMCoreUI/Molecules/TwoButtonView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index 9e6cf4ee..03f9f67b 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -172,7 +172,7 @@ import UIKit public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) { self.init() - setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonMap) + setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) primaryButton?.setAsSmall(small) secondaryButton?.setAsSmall(small) } From 074efcbf1d4417642946761ae437e001e8950ab0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 10 Apr 2019 15:49:07 -0400 Subject: [PATCH 10/78] layout margins --- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 1 - .../MVMCoreUIStackableViewController.h | 6 ++- .../MVMCoreUIStackableViewController.m | 37 ++++++++++++++----- .../ThreeLayerViewController.swift | 24 ++++++------ .../NSLayoutConstraint+MFConvenience.h | 7 ++++ .../NSLayoutConstraint+MFConvenience.m | 18 +++++++++ MVMCoreUI/Molecules/MoleculeStackView.swift | 7 ++-- MVMCoreUI/Styles/MFStyler.h | 1 + MVMCoreUI/Styles/MFStyler.m | 12 ++++++ 9 files changed, 86 insertions(+), 27 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index a88b61c3..780b65aa 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -138,7 +138,6 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol - (void)setAsMolecule { - self.updateViewHorizontalDefaults = YES; } @end diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h index 9e7d352e..0c702925 100644 --- a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h +++ b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h @@ -29,13 +29,15 @@ // Returns the standard space around ui objects. + (UIEdgeInsets)standardSpaceAroundUIObjectForSize:(CGFloat)size; -// Consolidates generateFormViewWithUIArray and spaceArroundUIObject into one class object so other view controllers can take advantage of these functions. +// Consolidates generateFormViewWithUIArray and spaceArroundUIObject into one class object so other view controllers can take advantage of these functions. By default does not pin to margins. + (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; ++ (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray useMargins:(BOOL)useMargins withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; + (void)populateViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; + (void)populateView:(nonnull UIView *)view withUIArrayForConstrainingViews:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; -// Does the actual laying out. The formuiarray views should already be added to the view. +// Does the actual laying out. The formuiarray views should already be added to the view. By default does not pin to margins + (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; ++ (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray useMargins:(BOOL)useMargins withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; + (void)autoLayoutViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; + (void)autoLayoutViewWithConstrainingViewsWithUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m index 86f4ebfe..7a14762a 100644 --- a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m +++ b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m @@ -10,6 +10,7 @@ #import "MFStyler.h" #import "ViewConstrainingView.h" #import "MVMCoreUIUtility.h" +#import "NSLayoutConstraint+MFConvenience.h" @interface MVMCoreUIStackableViewController () @end @@ -69,11 +70,15 @@ } + (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { + [self populateView:view withUIArray:formUIArray useMargins:NO withSpacingBlock:spacingBlock]; +} + ++ (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray useMargins:(BOOL)useMargins withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { if ([formUIArray count] > 0) { for (UIView *subview in formUIArray) { [view addSubview:subview]; } - [MVMCoreUIStackableViewController autoLayoutView:view withUIArray:formUIArray withSpacingBlock:spacingBlock]; + [MVMCoreUIStackableViewController autoLayoutView:view withUIArray:formUIArray useMargins:useMargins withSpacingBlock:spacingBlock]; } } @@ -96,34 +101,46 @@ } } -+ (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { ++ (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray useMargins:(BOOL)useMargins withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { if ([formUIArray count] > 0) { // Adds the first object to the view and pins it to the top of the content view. - id previousUIObject = [formUIArray objectAtIndex:0]; - UIEdgeInsets spaceAroundObjectPrevious = spacingBlock(previousUIObject); + UIView *previousUIObject = [formUIArray objectAtIndex:0]; [previousUIObject setTranslatesAutoresizingMaskIntoConstraints:NO]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-top@999-[previousUIObject]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"top":@(spaceAroundObjectPrevious.top)} views:NSDictionaryOfVariableBindings(previousUIObject)]]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-left@999-[previousUIObject]-right-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"left":@(spaceAroundObjectPrevious.left),@"right":@(spaceAroundObjectPrevious.right)} views:NSDictionaryOfVariableBindings(previousUIObject)]]; + UIEdgeInsets spaceAroundObjectPrevious = spacingBlock(previousUIObject); + NSLayoutConstraint *constraint = [NSLayoutConstraint pinViewTopToSuperview:previousUIObject useMargins:useMargins constant:spaceAroundObjectPrevious.top]; + constraint.priority = 999; + constraint.active = YES; + constraint = [NSLayoutConstraint pinViewLeftToSuperview:previousUIObject useMargins:useMargins constant:spaceAroundObjectPrevious.left]; + constraint.priority = 999; + constraint.active = YES; + [NSLayoutConstraint pinViewRightToSuperview:previousUIObject useMargins:useMargins constant:spaceAroundObjectPrevious.right].active = YES; // Sets the horizontal spacing and adds vertical spacing between all ui objects. for (NSUInteger i = 1; i < [formUIArray count]; i++) { - id uiObject = [formUIArray objectAtIndex:i]; + UIView *uiObject = [formUIArray objectAtIndex:i]; UIEdgeInsets spaceAroundObjectCurrent = spacingBlock(uiObject); [uiObject setTranslatesAutoresizingMaskIntoConstraints:NO]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[previousUIObject]-space-[uiObject]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"space":@(spaceAroundObjectPrevious.bottom + spaceAroundObjectCurrent.top)} views:NSDictionaryOfVariableBindings(previousUIObject,uiObject)]]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-left@999-[uiObject]-right-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"left":@(spaceAroundObjectCurrent.left),@"right":@(spaceAroundObjectCurrent.right)} views:NSDictionaryOfVariableBindings(uiObject)]]; - + constraint = [NSLayoutConstraint pinViewLeftToSuperview:uiObject useMargins:useMargins constant:spaceAroundObjectCurrent.left]; + constraint.priority = 999; + constraint.active = YES; + [NSLayoutConstraint pinViewRightToSuperview:uiObject useMargins:useMargins constant:spaceAroundObjectCurrent.right].active = YES; + previousUIObject = uiObject; spaceAroundObjectPrevious = spaceAroundObjectCurrent; } // Pins the last object to the bottom of the content view. - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[previousUIObject]-bottom-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"bottom":@(spaceAroundObjectPrevious.bottom)} views:NSDictionaryOfVariableBindings(previousUIObject)]]; + [NSLayoutConstraint pinViewBottomToSuperview:previousUIObject useMargins:useMargins constant:spaceAroundObjectPrevious.bottom].active = YES; } } ++ (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { + [self autoLayoutView:view withUIArray:formUIArray useMargins:NO withSpacingBlock:spacingBlock]; +} + + (void)autoLayoutViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { if ([formUIArray count] > 0) { diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index c1fadf55..2573388c 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -16,6 +16,7 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { var topView: UIView? var middleView: UIView? var bottomView: UIView? + var useMargins: Bool = true // The bottom view can be put outside of the scrolling area. var bottomViewOutsideOfScroll = false @@ -26,6 +27,7 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { open override func updateViews() { super.updateViews() let width = view.bounds.width + MFStyler.setDefaultMarginsFor(contentView, size: width) if let topView = topView as? MVMCoreViewProtocol { topView.updateView(width) } @@ -116,9 +118,9 @@ extension ThreeLayerViewController { return nil } contentView.addSubview(topView) - topView.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true - contentView.rightAnchor.constraint(equalTo: topView.rightAnchor).isActive = true - topView.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true + NSLayoutConstraint.pinViewTop(toSuperview: topView, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: topView, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: topView, useMargins: useMargins, constant: 0).isActive = true return topView } @@ -133,8 +135,8 @@ extension ThreeLayerViewController { return nil } contentView.addSubview(middleView) - middleView.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true - contentView.rightAnchor.constraint(equalTo: middleView.rightAnchor).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: middleView, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: middleView, useMargins: useMargins, constant: 0).isActive = true middleView.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) return middleView } @@ -220,17 +222,17 @@ extension ThreeLayerViewController { return } contentView.addSubview(view); - contentView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - contentView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - view.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewBottom(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true } func addViewOutsideOfScrollViewBottom(_ view: UIView) { self.view?.addSubview(view) if let scrollView = scrollView, let parentView = self.view { view.topAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true - view.leftAnchor.constraint(equalTo: parentView.leftAnchor).isActive = true - parentView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true if #available(iOS 11.0, *) { parentView.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true if let safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: parentView) { @@ -238,7 +240,7 @@ extension ThreeLayerViewController { self.safeAreaView = safeAreaView } } else { - parentView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true + NSLayoutConstraint.pinViewBottom(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true } } } diff --git a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h index ed9d1876..c8e12cae 100644 --- a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h +++ b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h @@ -55,6 +55,13 @@ extern NSString * _Nonnull const ConstraintWidth; +(nullable NSDictionary *)constraintAlignView :(nonnull UIView *)firstView toSecondView :(nonnull UIView *)secondView alignX :(BOOL)alignX alignY :(BOOL)alignY; +#pragma mark - With Margins + ++ (nonnull NSLayoutConstraint *)pinViewTopToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; ++ (nonnull NSLayoutConstraint *)pinViewLeftToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; ++ (nonnull NSLayoutConstraint *)pinViewRightToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; ++ (nonnull NSLayoutConstraint *)pinViewBottomToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; + #pragma mark - Scaling constraints // These functions will pin a view to its super view with space that is a ratio of the anchor (by default the super view's width if nothing is passed in). (So if the space is 24 and the super's width is 320 in the design, then the ratio should be 24/320 and this will be multiplied by the super's current width, so that the constraint always linearly scales). diff --git a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m index 1ed0acd1..39a315c1 100644 --- a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m +++ b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m @@ -150,6 +150,24 @@ NSString *const ConstraintWidth = @"width"; return constraintsDictionary; } +#pragma mark - With Margins + ++ (NSLayoutConstraint *)pinViewTopToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant { + return [view.topAnchor constraintEqualToAnchor:(useMargins ? view.superview.layoutMarginsGuide.topAnchor : view.superview.topAnchor) constant:constant]; +} + ++ (NSLayoutConstraint *)pinViewLeftToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant { + return [view.leftAnchor constraintEqualToAnchor:(useMargins ? view.superview.layoutMarginsGuide.leftAnchor : view.superview.leftAnchor) constant:constant]; +} + ++ (NSLayoutConstraint *)pinViewRightToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant { + return [(useMargins ? view.superview.layoutMarginsGuide.rightAnchor : view.superview.rightAnchor) constraintEqualToAnchor:view.rightAnchor constant:constant]; +} + ++ (NSLayoutConstraint *)pinViewBottomToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant { + return [(useMargins ? view.superview.layoutMarginsGuide.bottomAnchor : view.superview.bottomAnchor) constraintEqualToAnchor:view.bottomAnchor constant:constant]; +} + #pragma mark - Scaling constraints + (nullable NSDictionary *)scalingConstraintPinSubview:(nullable UIView *)subview pinTop:(BOOL)pinTop topConstant:(CGFloat)topConstant pinBottom:(BOOL)pinBottom bottomConstant:(CGFloat)bottomConstant pinLeft:(BOOL)pinLeft leftConstant:(CGFloat)leftConstant pinRight:(BOOL)pinRight rightConstant:(CGFloat)rightConstant baseConstant:(CGFloat)baseConstant { diff --git a/MVMCoreUI/Molecules/MoleculeStackView.swift b/MVMCoreUI/Molecules/MoleculeStackView.swift index ab27c481..1c70d6eb 100644 --- a/MVMCoreUI/Molecules/MoleculeStackView.swift +++ b/MVMCoreUI/Molecules/MoleculeStackView.swift @@ -11,7 +11,8 @@ import UIKit public class MoleculeStackView: MFView { var spacingBlock: ((Any) -> UIEdgeInsets)? var moleculesArray: [UIView]? - + var useMargins: Bool = false + public override init(frame: CGRect) { super.init(frame: frame) } @@ -67,9 +68,9 @@ public class MoleculeStackView: MFView { } if let spacingBlock = spacingBlock { - MVMCoreUIStackableViewController.populateView(self, withUIArray: moleculesArray, withSpacingBlock: spacingBlock) + MVMCoreUIStackableViewController.populateView(self, withUIArray: moleculesArray, useMargins: useMargins, withSpacingBlock: spacingBlock) } else { - MVMCoreUIStackableViewController.populateView(self, withUIArray: moleculesArray) { (object) -> UIEdgeInsets in + MVMCoreUIStackableViewController.populateView(self, withUIArray: moleculesArray, useMargins: useMargins) { (object) -> UIEdgeInsets in if object as AnyObject? === moleculesArray.first { return UIEdgeInsets.zero } else { diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 488a0648..f9626b1f 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -90,6 +90,7 @@ B3 -> Legal + (CGFloat)defaultVerticalPaddingForApplicationWidth; + (CGFloat)defaultHorizontalPaddingForSize:(CGFloat)size; + (CGFloat)defaultVerticalPaddingForSize:(CGFloat)size; ++ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size; //------------------------------------------------- // Returns the fonts for these styles. Scales them as needed by default diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 36d04e51..e7f14546 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -12,6 +12,7 @@ #import "UIColor+MFConvenience.h" #import "NSLayoutConstraint+MFConvenience.h" #import "MVMCoreUISplitViewController.h" +@import MVMCore.MVMCoreDispatchUtility; CGFloat const PaddingDefault = 24; CGFloat const PaddingDefaultHorizontalSpacing = 32; @@ -88,6 +89,17 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [[MFSizeObject sizeObjectWithScalingStandardSize:PaddingDefaultVerticalSpacing] getValueBasedOnSize:size]; } ++ (void)setDefaultMarginsForView:(nullable UIView *)view size:(CGFloat)size { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CGFloat padding = [MFStyler defaultHorizontalPaddingForSize:size]; + if (@available(iOS 11.0, *)) { + view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(0, padding, 0, padding); + } else { + view.layoutMargins = UIEdgeInsetsMake(0, padding, 0, padding); + } + }]; +} + #pragma mark - 2.0 fonts + (nullable UIFont *)fontH1:(BOOL)genericScaling { From 0e5582beedc428ff16f2fd3ab29f5077a7e88995 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 10 Apr 2019 16:33:47 -0400 Subject: [PATCH 11/78] Removing enum. won't bridge to objc correctly. --- MVMCoreUI/Atoms/Views/Label.swift | 89 +++++++------------------------ 1 file changed, 20 insertions(+), 69 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 2b491d07..b0b32fcc 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -87,110 +87,61 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } //------------------------------------------------------ - // MARK: - Enum Generator + // MARK: - Functions //------------------------------------------------------ - - enum Style { - case B1(scale: Bool) - case B2(scale: Bool) - case B3(scale: Bool) - case B20(scale: Bool) - case H1(scale: Bool) - case H2(scale: Bool) - case H3(scale: Bool) - case H32(scale: Bool) - case none - - func create() -> Label { - - let label = Label() - - switch self { - case .B1(let scale): - label.styleB1(scale) - - case .B2(let scale): - label.styleB2(scale) - - case .B3(let scale): - label.styleB3(scale) - - case .B20(let scale): - label.styleB20(scale) - - case .H1(let scale): - label.styleH1(scale) - - case .H2(let scale): - label.styleH2(scale) - - case .H3(let scale): - label.styleH3(scale) - - case .H32(let scale): - label.styleH32(scale) - - case .none: - break; - } - - return label - } - } - - /* - class func commonLabelH1(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + + class func commonLabelH1(_ scale: Bool) -> Label { + let label = Label.label() label.styleH1(scale) return label } - class func commonLabelH2(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelH2(_ scale: Bool) -> Label { + let label = Label.label() label.styleH2(scale) return label } - class func commonLabelH3(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelH3(_ scale: Bool) -> Label { + let label = Label.label() label.styleH3(scale) return label } - class func commonLabelH32(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelH32(_ scale: Bool) -> Label { + let label = Label.label() label.styleH32(scale) return label } - class func commonLabelB1(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelB1(_ scale: Bool) -> Label { + let label = Label.label() label.styleB1(scale) return label } - class func commonLabelB2(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelB2(_ scale: Bool) -> Label { + let label = Label.label() label.styleB2(scale) return label } - class func commonLabelB3(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelB3(_ scale: Bool) -> Label { + let label = Label.label() label.styleB3(scale) return label } - class func commonLabelB20(_ scale: Bool) -> MFLabel { - let label = MFLabel.label() + class func commonLabelB20(_ scale: Bool) -> Label { + let label = Label.label() label.styleB20(scale) return label } - class func label() -> MFLabel { + class func label() -> Label { return Label(frame: CGRect.zero) } - */ + //------------------------------------------------------ // MARK: - Functions From fa4b03ac1d0b2f67c68df8f74d827704f63f42cd Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Apr 2019 11:20:46 -0400 Subject: [PATCH 12/78] code review --- MVMCoreUI.xcodeproj/project.pbxproj | 1 - MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 +- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h | 1 - MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 8 ++++---- MVMCoreUI/Utility/MVMCoreUIConstants.h | 3 +++ MVMCoreUI/Utility/MVMCoreUIConstants.m | 3 +++ 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c32e376c..eca11941 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -869,7 +869,6 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, - 013DAB042254FCE00092ABB7 /* CheckBoxWithLabel.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..ff1d3fd8 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -326,7 +326,7 @@ } // key used to send text value to server - string = [map string:@"fieldKey"]; + string = [map string:KeyFieldKey]; if (string.length > 0) { self.fieldKey = string; } diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h index 32fb1e02..831c1994 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h @@ -59,7 +59,6 @@ - (void)setValueForAccessibilityText:(nullable NSString *)text; - (void)hideDescriptionLabelAndPinCheckboxToRight; -// Molecule Design - (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; @end diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index f00d9101..fb81e0b5 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -54,15 +54,15 @@ static const CGFloat CheckBoxHeightWidth = 18.0; - (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; self.delegate = (id)delegate; - self.fieldKey = [json stringForKey:@"fieldKey"]; - self.isRequired = [json boolForKey:@"required"]; - + self.fieldKey = [json stringForKey:KeyFieldKey]; + self.isRequired = [json boolForKey:KeyRequired]; + NSString *checkedColorHex = [json string:@"checkedColor"]; NSString *unCheckedColorHex = [json string:@"unCheckedColor"]; UIColor *checkedColor = checkedColorHex ? [UIColor mfGetColorForHex:checkedColorHex]: [UIColor blackColor]; UIColor *unCheckedColor = unCheckedColorHex ? [UIColor mfGetColorForHex:unCheckedColorHex]: [UIColor clearColor]; - NSString *label = [json string:@"label"]; + NSString *label = [json string:KeyLabel]; [self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor text:label]; } diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index 93f77713..ba0eff4d 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -35,6 +35,9 @@ extern NSString * const KeyTextColor; extern NSString * const KeyIsHidden; extern NSString * const KeyIsOpaque; +extern NSString * const KeyFieldKey; +extern NSString * const KeyRequired; + #pragma mark - Values extern NSString * const StringY; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index 684f013b..43763ae2 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -18,6 +18,8 @@ NSString * const KeyValue = @"value"; NSString * const KeyLabel = @"label"; NSString * const KeyDisable = @"disable"; NSString * const KeyFieldName = @"fieldName"; +NSString * const KeyFieldKey = @"fieldKey"; +NSString * const KeyRequired = @"required"; NSString * const KeyHideMainMenu = @"hideMainMenu"; NSString * const KeyProgressPercent = @"progressPercent"; @@ -34,6 +36,7 @@ NSString * const KeyTextColor = @"textColor"; NSString * const KeyIsHidden = @"isHidden"; NSString * const KeyIsOpaque = @"isOpaque"; + #pragma mark - Values NSString * const StringY = @"Y"; From 1b1c35873a10dfec7340d65002bddafb9e62fe53 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 11 Apr 2019 14:25:34 -0400 Subject: [PATCH 13/78] development of Label conversion. wip. --- MVMCoreUI/Atoms/Views/Label.swift | 42 ++++++++++++------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b0b32fcc..ee6ec1ab 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -22,7 +22,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { // Set this to use a custom sizing object during updateView instead of the standard. var sizeObject: MFSizeObject? - private var scaleSize: NSNumber? + private var scaleSize: CGFloat? // Used for scaling the font in updateView. private var originalAttributedString: NSAttributedString? @@ -43,15 +43,9 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { var hasText: Bool { - if let text = text, !text.isEmpty { - return true - } + guard let text = text, let attributedText = attributedText else { return false } - if let attributedText = attributedText, !attributedText.string.isEmpty { - return true - } - - return false + return !text.isEmpty || !attributedText.string.isEmpty } //------------------------------------------------------ @@ -60,9 +54,9 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { func setupView() { - backgroundColor = UIColor.clear + backgroundColor = .clear numberOfLines = 0 - lineBreakMode = NSLineBreakMode.byWordWrapping + lineBreakMode = .byWordWrapping translatesAutoresizingMaskIntoConstraints = false } @@ -142,7 +136,6 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { return Label(frame: CGRect.zero) } - //------------------------------------------------------ // MARK: - Functions //------------------------------------------------------ @@ -281,43 +274,40 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { func updateView(_ size: CGFloat) { - scaleSize = NSNumber(value: Float(size)) + scaleSize = size if let originalAttributedString = originalAttributedString { let attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in + // Loop the original attributed string, resize the fonts. - let font: UIFont? = (value as? UIFont)?.withSize((MFStyler.sizeObjectGeneric(forCurrentDevice: ((value as? UIFont)?.pointSize)!)?.getValueBased(onSize: size))!) - attributedString.addAttribute(.font, value: font as Any, range: range) + if let fontObj = value as? UIFont, let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: fontObj.pointSize)?.getValueBased(onSize: size) { + + attributedString.addAttribute(.font, value: fontObj.withSize(stylerSize) as Any, range: range) + } }) attributedText = attributedString } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0) { - var sizeObject: MFSizeObject? = self.sizeObject - - if sizeObject == nil { - sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) + if let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { + self.font = self.font.withSize(sizeObject.getValueBased(onSize: size)) } - - self.font = self.font.withSize(sizeObject?.getValueBased(onSize: size) ?? 0.0) } } func setFont(_ font: UIFont, scale: Bool) { + self.font = font setScale(scale) } func setScale(_ scale: Bool) { + if scale { standardFontSize = font.pointSize - if let scaleSize = scaleSize { - updateView(CGFloat(scaleSize.floatValue)) - } else { - updateView(MVMCoreUISplitViewController.getApplicationViewWidth()) - } + updateView(scaleSize ?? MVMCoreUISplitViewController.getApplicationViewWidth()) } else { standardFontSize = 0 } From 0a3bd5c8348c67a3b47c95eab847c2932bf5f9c5 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 11 Apr 2019 16:58:53 -0400 Subject: [PATCH 14/78] Updated the string analysis of setText to account for scenarios where an HTML tag is passed as a delimiter. Reoriented the design of the tuple. --- .../Atoms/Views/LabelWithInternalButton.swift | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 3810294a..a827c40d 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -10,7 +10,7 @@ import MVMCore public typealias ActionBlock = () -> Void -private typealias ActionIndiciesTuple = (startIndex: String.Index?, endIndex: String.Index?, revisedText: String?) +private typealias ActionableStringTuple = (front: String?, middle: String?, end: String?) public typealias ActionObjectDelegate = (NSObjectProtocol & MVMCoreActionDelegateProtocol) public typealias ButtonObjectDelegate = (NSObjectProtocol & ButtonDelegateProtocol) public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProtocol & MVMCoreLoadDelegateProtocol & MVMCorePresentationDelegateProtocol & NSObjectProtocol @@ -381,37 +381,41 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt private func setText(_ text: String?, startTag: String?, endTag: String?) { - let actionRange: ActionIndiciesTuple = rangeOfText(text, startTag: startTag, endTag: endTag) + let actionableTuple: ActionableStringTuple = rangeOfText(text, startTag: startTag, endTag: endTag) - if let revisedText = actionRange.revisedText, let startBraceIndex = actionRange.startIndex, let endBraceIndex = actionRange.endIndex { - - frontText = String(revisedText[revisedText.startIndex.. ActionIndiciesTuple { + private func rangeOfText(_ text: String?, startTag: String?, endTag: String?) -> ActionableStringTuple { - var fullText = text ?? "" - var actionRange: ActionIndiciesTuple = (startIndex: nil, endIndex: nil, revisedText: nil) + var actionableTuple: ActionableStringTuple = (front: nil, middle: nil, end: nil) - if let leftBrace = startTag, let rightBrace = endTag, fullText.contains(Character(leftBrace)) && fullText.contains(Character(rightBrace)) { - actionRange.startIndex = fullText.firstIndex(of: Character(leftBrace)) - fullText = fullText.replacingOccurrences(of: leftBrace, with: "") + guard let text = text else { return actionableTuple } + + if let leftTag = startTag, text.contains(leftTag) { - actionRange.endIndex = fullText.firstIndex(of: Character(rightBrace)) - fullText = fullText.replacingOccurrences(of: rightBrace, with: "") + let firstHalf = text.components(separatedBy: leftTag) + actionableTuple.front = firstHalf.first + + if let rightTag = endTag, text.contains(rightTag) { + + let secondHalf = firstHalf[1].components(separatedBy: rightTag) + actionableTuple.middle = secondHalf[0] + actionableTuple.end = secondHalf[1] + } } - - actionRange.revisedText = fullText - return actionRange + + return actionableTuple } @objc public func setActionMap(_ actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate delegate: ActionObjectDelegate?) { From db672f1c21a86636ed8d84439a771e4391682c26 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Fri, 12 Apr 2019 09:53:30 -0400 Subject: [PATCH 15/78] Trimming whitespace to prevent double spaces from occurring. --- MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index a827c40d..42661311 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -384,9 +384,9 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt let actionableTuple: ActionableStringTuple = rangeOfText(text, startTag: startTag, endTag: endTag) if let front = actionableTuple.front, let middle = actionableTuple.middle, let end = actionableTuple.end { - frontText = front - actionText = middle - backText = end + frontText = front.trimmingCharacters(in: .whitespaces) + actionText = middle.trimmingCharacters(in: .whitespaces) + backText = end.trimmingCharacters(in: .whitespaces) self.text = getTextFromStringComponents() } else { frontText = text @@ -408,7 +408,6 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt actionableTuple.front = firstHalf.first if let rightTag = endTag, text.contains(rightTag) { - let secondHalf = firstHalf[1].components(separatedBy: rightTag) actionableTuple.middle = secondHalf[0] actionableTuple.end = secondHalf[1] From d6fdf9958e8665688e4b1b44af11521a91b673a5 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Fri, 12 Apr 2019 12:12:33 -0400 Subject: [PATCH 16/78] Converted MFLabel to Label. --- MVMCoreUI/Atoms/Views/Label.swift | 93 ++++++++++++++----------------- 1 file changed, 41 insertions(+), 52 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index ee6ec1ab..fb9fee06 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -33,7 +33,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } set(accessibilityTraits) { if accessibilityTraits.rawValue & UIAccessibilityTraits.header.rawValue != 0 { - let noHeaderTraits: UIAccessibilityTraits = UIAccessibilityTraits(rawValue: accessibilityTraits.rawValue - UIAccessibilityTraits.header.rawValue) + let noHeaderTraits = UIAccessibilityTraits(rawValue: accessibilityTraits.rawValue - UIAccessibilityTraits.header.rawValue) super.accessibilityTraits = noHeaderTraits } else { super.accessibilityTraits = accessibilityTraits @@ -42,9 +42,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } var hasText: Bool { - guard let text = text, let attributedText = attributedText else { return false } - return !text.isEmpty || !attributedText.string.isEmpty } @@ -53,7 +51,6 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ func setupView() { - backgroundColor = .clear numberOfLines = 0 lineBreakMode = .byWordWrapping @@ -84,55 +81,55 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { // MARK: - Functions //------------------------------------------------------ - class func commonLabelH1(_ scale: Bool) -> Label { + static func commonLabelH1(_ scale: Bool) -> Label { let label = Label.label() label.styleH1(scale) return label } - class func commonLabelH2(_ scale: Bool) -> Label { + static func commonLabelH2(_ scale: Bool) -> Label { let label = Label.label() label.styleH2(scale) return label } - class func commonLabelH3(_ scale: Bool) -> Label { + static func commonLabelH3(_ scale: Bool) -> Label { let label = Label.label() label.styleH3(scale) return label } - class func commonLabelH32(_ scale: Bool) -> Label { + static func commonLabelH32(_ scale: Bool) -> Label { let label = Label.label() label.styleH32(scale) return label } - class func commonLabelB1(_ scale: Bool) -> Label { + static func commonLabelB1(_ scale: Bool) -> Label { let label = Label.label() label.styleB1(scale) return label } - class func commonLabelB2(_ scale: Bool) -> Label { + static func commonLabelB2(_ scale: Bool) -> Label { let label = Label.label() label.styleB2(scale) return label } - class func commonLabelB3(_ scale: Bool) -> Label { + static func commonLabelB3(_ scale: Bool) -> Label { let label = Label.label() label.styleB3(scale) return label } - class func commonLabelB20(_ scale: Bool) -> Label { + static func commonLabelB20(_ scale: Bool) -> Label { let label = Label.label() label.styleB20(scale) return label } - class func label() -> Label { + static func label() -> Label { return Label(frame: CGRect.zero) } @@ -141,21 +138,16 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ static func setLabel(_ label: UILabel?, withHTML html: String?) { + let data: Data? = html?.data(using: .utf8) - if data != nil { - let error: Error? = nil - if let data = data { - label?.attributedText = try? NSAttributedString(data: data, - options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], - documentAttributes: nil) - - // compare with above... - // label?.attributedText = try? NSAttributedString(data: data, options: [ - // NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue - // ], documentAttributes: nil) - } - if let labelError = error { - try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")!) + + if let data = data { + do { + label?.attributedText = try NSAttributedString(data: data, + options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], + documentAttributes: nil) + } catch { + MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse")!) } } } @@ -178,24 +170,24 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { label.accessibilityLabel = accessibilityText } - let fontSize = json?.floatForKey("fontSize") + let fontSize = json?.floatForKey("fontSize") ?? 0.0 - if let fontName = json?.optionalStringForKey("fontName"), let fontSize = fontSize { - label.font = MFFonts.mfFont(withName: fontName, size: CGFloat(fontSize) == 0.0 ? label.font.pointSize : CGFloat(fontSize)) - } else if let fontSize = fontSize { + if let fontName = json?.optionalStringForKey("fontName") { + label.font = MFFonts.mfFont(withName: fontName, size: fontSize == 0.0 ? label.font.pointSize : CGFloat(fontSize)) + } else { label.font = label.font.withSize(CGFloat(fontSize)) } if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font, - NSAttributedString.Key.foregroundColor: label.textColor]) + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as Any, + NSAttributedString.Key.foregroundColor: label.textColor as Any]) for case let attribute as [String: Any] in attributes { - let location = attribute.floatForKey("location") - let length = attribute.floatForKey("length") + let range = NSRange(location: Int(attribute.floatForKey("location")), + length: Int(attribute.floatForKey("length"))) - let range = NSRange(location: Int(location), length: Int(length)) + guard let attributeType = attribute.optionalStringForKey(KeyType) else { continue } - switch attribute.stringForkey(KeyType){ + switch attributeType { case "underline": attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) @@ -208,7 +200,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } case "font": let fontSize = attribute.floatForKey("size") - var font: UIFont? + let font: UIFont? if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) @@ -216,9 +208,8 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { font = label.font.withSize(CGFloat(fontSize)) } - if font != nil { - attributedString.addAttribute(.font, value: font as Any, range: range) - } + attributedString.addAttribute(.font, value: font as Any, range: range) + default: continue } @@ -273,38 +264,30 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } func updateView(_ size: CGFloat) { - scaleSize = size if let originalAttributedString = originalAttributedString { let attributedString = NSMutableAttributedString(attributedString: originalAttributedString) attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length)) - originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in - // Loop the original attributed string, resize the fonts. if let fontObj = value as? UIFont, let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: fontObj.pointSize)?.getValueBased(onSize: size) { - attributedString.addAttribute(.font, value: fontObj.withSize(stylerSize) as Any, range: range) } }) attributedText = attributedString - } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0) { - if let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { - self.font = self.font.withSize(sizeObject.getValueBased(onSize: size)) - } + } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { + self.font = self.font.withSize(sizeObject.getValueBased(onSize: size)) } } func setFont(_ font: UIFont, scale: Bool) { - self.font = font setScale(scale) } func setScale(_ scale: Bool) { - if scale { standardFontSize = font.pointSize updateView(scaleSize ?? MVMCoreUISplitViewController.getApplicationViewWidth()) @@ -318,11 +301,17 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ func setAsMolecule() { - // Empty + + setupView() } func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData) + originalAttributedString = attributedText + + if let actionText = dictionary["actionText"] as? String { + self.actionText = actionText + } } } From 71f1f499e07df833c28fbc951b1bb25b43745ffa Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Fri, 12 Apr 2019 12:23:55 -0400 Subject: [PATCH 17/78] optional check improvements. --- MVMCoreUI/Atoms/Views/Label.swift | 134 +++++++++++++++--------------- 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index fb9fee06..75f21ce3 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -139,83 +139,81 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { static func setLabel(_ label: UILabel?, withHTML html: String?) { - let data: Data? = html?.data(using: .utf8) + guard let data = html?.data(using: .utf8) else { return } - if let data = data { - do { - label?.attributedText = try NSAttributedString(data: data, - options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], - documentAttributes: nil) - } catch { - MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse")!) + do { + label?.attributedText = try NSAttributedString(data: data, + options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], + documentAttributes: nil) + } catch { + if let coreErrorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse") { + MVMCoreUILoggingHandler.shared()?.addError(toLog: coreErrorObject) } } } static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - if let label = label { - label.text = json?.optionalStringForKey(KeyText) - setLabel(label, withHTML: json?.stringForkey("html")) - - if let textColorHex = json?.optionalStringForKey(KeyTextColor) { - label.textColor = UIColor.mfGet(forHex: textColorHex) - } - - if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor) { - label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) - } - - if let accessibilityText = json?.optionalStringForKey("accessibilityText") { - label.accessibilityLabel = accessibilityText - } - - let fontSize = json?.floatForKey("fontSize") ?? 0.0 - - if let fontName = json?.optionalStringForKey("fontName") { - label.font = MFFonts.mfFont(withName: fontName, size: fontSize == 0.0 ? label.font.pointSize : CGFloat(fontSize)) - } else { - label.font = label.font.withSize(CGFloat(fontSize)) - } - - if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as Any, - NSAttributedString.Key.foregroundColor: label.textColor as Any]) - for case let attribute as [String: Any] in attributes { - let range = NSRange(location: Int(attribute.floatForKey("location")), - length: Int(attribute.floatForKey("length"))) + guard let label = label else { return } + + label.text = json?.optionalStringForKey(KeyText) + setLabel(label, withHTML: json?.stringForkey("html")) + + if let textColorHex = json?.optionalStringForKey(KeyTextColor), !textColorHex.isEmpty { + label.textColor = UIColor.mfGet(forHex: textColorHex) + } + + if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor), !backgroundColorHex.isEmpty { + label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) + } + + label.accessibilityLabel = json?.optionalStringForKey("accessibilityText") + + let fontSize = json?.floatForKey("fontSize") ?? 0.0 + + if let fontName = json?.optionalStringForKey("fontName") { + label.font = MFFonts.mfFont(withName: fontName, size: fontSize == 0.0 ? label.font.pointSize : CGFloat(fontSize)) + } else { + label.font = label.font.withSize(CGFloat(fontSize)) + } + + if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as Any, + NSAttributedString.Key.foregroundColor: label.textColor as Any]) + for case let attribute as [String: Any] in attributes { + let range = NSRange(location: Int(attribute.floatForKey("location")), + length: Int(attribute.floatForKey("length"))) + + guard let attributeType = attribute.optionalStringForKey(KeyType) else { continue } + + switch attributeType { + case "underline": + attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) - guard let attributeType = attribute.optionalStringForKey(KeyType) else { continue } + case "strikethrough": + attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) - switch attributeType { - case "underline": - attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) - - case "strikethrough": - attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick, range: range) - - case "color": - if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { - attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) - } - case "font": - let fontSize = attribute.floatForKey("size") - let font: UIFont? - - if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { - font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) - } else { - font = label.font.withSize(CGFloat(fontSize)) - } - - attributedString.addAttribute(.font, value: font as Any, range: range) - - default: - continue + case "color": + if let colorHex = attribute.optionalStringForKey(KeyTextColor), !colorHex.isEmpty { + attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) } + case "font": + let fontSize = attribute.floatForKey("size") + let font: UIFont? + + if let fontName = attribute.optionalStringForKey("name"), !fontName.isEmpty { + font = MFFonts.mfFont(withName: fontName, size: fontSize != 0.0 ? CGFloat(fontSize) : CGFloat(label.font.pointSize)) + } else { + font = label.font.withSize(CGFloat(fontSize)) + } + + attributedString.addAttribute(.font, value: font as Any, range: range) + + default: + continue } - label.attributedText = attributedString } + label.attributedText = attributedString } } @@ -310,8 +308,8 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { originalAttributedString = attributedText - if let actionText = dictionary["actionText"] as? String { - self.actionText = actionText - } +// if let actionText = dictionary["actionText"] as? String { +// self.actionText = actionText +// } } } From f1d80adf5727c7959b7cca82c402e1708b80508d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 12 Apr 2019 15:32:43 -0400 Subject: [PATCH 18/78] delegate object and simple deprecation --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/BaseControllers/MFViewController.h | 1 + MVMCoreUI/BaseControllers/MFViewController.m | 4 ++++ MVMCoreUI/OtherHandlers/DelegateObject.swift | 18 ++++++++++++++++++ .../OtherHandlers/MVMCoreUILoggingHandler.h | 1 - MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h | 1 - MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h | 1 + 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 MVMCoreUI/OtherHandlers/DelegateObject.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8a2e4453..dea12c71 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -157,6 +157,7 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; + D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */; }; 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 */; }; @@ -317,6 +318,7 @@ D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; + D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; 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 = ""; }; @@ -634,6 +636,7 @@ D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { isa = PBXGroup; children = ( + D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */, D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, @@ -865,6 +868,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, + D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index 8d5c6678..8c1d5766 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -31,6 +31,7 @@ @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; +@class DelegateObject; @interface MFViewController : UIViewController diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index c4ee3756..6b27c7d9 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -180,6 +180,10 @@ return YES; } +- (nullable DelegateObject *)delegateObject { + return [MVMCoreUIDelegateObject createWithDelegateForAll:self]; +} + #pragma mark - Response Handling - (void)observeForResponseJSONUpdates { diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/DelegateObject.swift new file mode 100644 index 00000000..e6c13dd5 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/DelegateObject.swift @@ -0,0 +1,18 @@ +// +// DelegateObject.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objc(MVMCoreUIDelegateObject) +open class DelegateObject: MVMCore.DelegateObject { + public weak var formValidationProtocol: FormValidationProtocol? + + open override func setAll(withDelegate delegate: Any) { + formValidationProtocol = delegate as? FormValidationProtocol + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h index 56bb60a2..003d67f8 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h @@ -7,7 +7,6 @@ // @import MVMCore.MVMCoreLoggingHandler; -@class MVMCoreTopAlertObject; @class MFViewController; NS_ASSUME_NONNULL_BEGIN diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h index 9391356c..46b392b7 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h @@ -10,7 +10,6 @@ #import #import -@class MVMCoreTopAlertObject; @class MFCustomButton; @interface MVMCoreUITopAlertBaseView : MFView diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h index 6ebd1026..50dd9b26 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h @@ -11,6 +11,7 @@ #import @class PrimaryButton; +@class MVMCoreTopAlertObject; @interface MVMCoreUITopAlertMainView : MVMCoreUITopAlertBaseView From aa4da8f74f8cc4951cf6859d8fc3b8a828ce3de0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 11:14:29 -0400 Subject: [PATCH 19/78] deprecating --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.h | 17 +++-- MVMCoreUI/Atoms/Buttons/MFCustomButton.m | 71 ++++++++++++++------ MVMCoreUI/OtherHandlers/DelegateObject.swift | 4 +- 4 files changed, 65 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 7d67afb1..72c04900 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -106,14 +106,14 @@ open class CaretButton: MFCustomButton { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { + @objc open 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]?) { + @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 21236e70..47ac89e4 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -11,14 +11,14 @@ #import #import #import -@import MVMCore.MVMCoreViewProtocol; +@class MVMCoreUIDelegateObject; 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; @@ -28,14 +28,19 @@ extern CGFloat const CloseButtonWidth; - (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event; // Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; - -// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate -- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate; +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; //accessibility - (void)addAccessibilityForCameraControl; - (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction; +#pragma mark - Deprecated + +// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData __deprecated; + +// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate +- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate __deprecated; + @end diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m index 0a78856c..45daebcc 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m @@ -13,6 +13,7 @@ @import MVMCore.NSDictionary_MFConvenience; #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" +#import CGFloat const CloseButtonHeight = 40.0f; CGFloat const CloseButtonWidth = 40.0f; @@ -37,6 +38,52 @@ CGFloat const CloseButtonWidth = 40.0f; } } +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { + + self.actionMap = actionMap; + self.titleLabel.numberOfLines = 0; + self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; + [self setTitle:[actionMap stringForKey:KeyTitle] forState:UIControlStateNormal]; + + [self setEnabled:![actionMap[KeyDisableButton]boolValue]]; + + self.buttonDelegate = delegateObject.buttonDelegate; + __weak MFCustomButton *weakSelf = self; + [self addBlock:^(id _Nonnull sender) { + + BOOL performAction = YES; + if (weakSelf.buttonDelegate && [weakSelf.buttonDelegate respondsToSelector:@selector(button:shouldPerformActionWithMap:additionalData:)]) { + performAction = [weakSelf.buttonDelegate button:weakSelf shouldPerformActionWithMap:actionMap additionalData:additionalData]; + } + + if (performAction) { + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject]; + } + } forControlEvents:UIControlEventTouchUpInside]; +} + +//accessibility +-(void)addAccessibilityForCameraControl{ + self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"]; + self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"]; + self.accessibilityTraits = UIAccessibilityTraitNone; +} + + +- (UIAccessibilityCustomAction *)accessibilityCustomAction { + NSString *name = self.accessibilityLabel ?: self.titleLabel.text; + return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)]; +} + +- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action { + if (self.buttonTapBlock) { + self.buttonTapBlock(self); + } + return YES; +} + +#pragma mark - Deprecated + - (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { self.actionMap = actionMap; @@ -53,11 +100,11 @@ CGFloat const CloseButtonWidth = 40.0f; } - (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate { - + if (!buttonDelegate) { [self setWithActionMap:actionMap delegate:actionDelegate additionalData:additionalData]; } else { - + self.actionMap = actionMap; self.titleLabel.numberOfLines = 0; self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -86,24 +133,4 @@ CGFloat const CloseButtonWidth = 40.0f; } } -//accessibility --(void)addAccessibilityForCameraControl{ - self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"]; - self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"]; - self.accessibilityTraits = UIAccessibilityTraitNone; -} - - -- (UIAccessibilityCustomAction *)accessibilityCustomAction { - NSString *name = self.accessibilityLabel ?: self.titleLabel.text; - return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)]; -} - -- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action { - if (self.buttonTapBlock) { - self.buttonTapBlock(self); - } - return YES; -} - @end diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/DelegateObject.swift index e6c13dd5..d7a2ac65 100644 --- a/MVMCoreUI/OtherHandlers/DelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/DelegateObject.swift @@ -11,8 +11,10 @@ import UIKit @objc(MVMCoreUIDelegateObject) open class DelegateObject: MVMCore.DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? - + public weak var buttonDelegate: ButtonDelegateProtocol? + open override func setAll(withDelegate delegate: Any) { formValidationProtocol = delegate as? FormValidationProtocol + buttonDelegate = delegate as? ButtonDelegateProtocol } } From ad3c0f90b4db607c2dcf489a3f8f2b2c7686d3a3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 11:46:26 -0400 Subject: [PATCH 20/78] molecule view changes --- MVMCoreUI/Atoms/Views/MFLabel.m | 6 +++--- MVMCoreUI/Atoms/Views/MFView.m | 2 +- MVMCoreUI/Molecules/ButtonView.swift | 6 +++--- MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 66b434e5..3857cd8d 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -170,7 +170,7 @@ } } -+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { ++ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { if (label) { label.text = [json string:KeyText]; [self setLabel:label withHTML:[json string:@"html"]]; @@ -232,8 +232,8 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [MFLabel setUILabel:self withJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [MFLabel setUILabel:self withJSON:json delegateObject:delegateObject additionalData:additionalData]; self.originalAttributedString = self.attributedText; } diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Atoms/Views/MFView.m index 1ab4cda1..6c0f8309 100644 --- a/MVMCoreUI/Atoms/Views/MFView.m +++ b/MVMCoreUI/Atoms/Views/MFView.m @@ -43,7 +43,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { self.json = json; } diff --git a/MVMCoreUI/Molecules/ButtonView.swift b/MVMCoreUI/Molecules/ButtonView.swift index f48044dd..5391640c 100644 --- a/MVMCoreUI/Molecules/ButtonView.swift +++ b/MVMCoreUI/Molecules/ButtonView.swift @@ -58,9 +58,9 @@ import UIKit primaryButton?.setAsMolecule() } - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - primaryButton?.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUI.DelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Constraining diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 3dd8de67..19cc1e21 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -7,11 +7,12 @@ // #import +@class MVMCoreUIDelegateObject; @protocol MVMCoreUIMoleculeViewProtocol // Sets up the ui based on the json -- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; @optional From 5ebcba15fa808f214f5ebdfced5d6a2150d34a2b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 12:59:27 -0400 Subject: [PATCH 21/78] molecule delegate object --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.h | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.m | 6 +- MVMCoreUI/Atoms/Views/CaretView.swift | 7 +- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +- MVMCoreUI/Atoms/Views/LabelView.m | 6 +- .../Atoms/Views/LabelWithInternalButton.swift | 3 +- MVMCoreUI/Atoms/Views/MFLabel.m | 4 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 4 +- MVMCoreUI/Atoms/Views/MFView.m | 3 +- MVMCoreUI/Atoms/Views/SeparatorView.m | 4 +- MVMCoreUI/Molecules/ButtonView.swift | 6 +- .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 4 +- MVMCoreUI/Molecules/MoleculeStackView.swift | 14 ++-- MVMCoreUI/Molecules/StandardFooterView.swift | 8 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 10 +-- MVMCoreUI/Molecules/TwoButtonView.swift | 82 ++++++++++--------- ...ct.swift => MVMCoreUIDelegateObject.swift} | 3 +- .../MVMCoreUIMoleculeMappingObject.h | 3 +- .../MVMCoreUIMoleculeMappingObject.m | 4 +- .../MoleculeStackCenteredTemplate.swift | 6 +- .../Templates/MoleculeStackTemplate.swift | 6 +- 23 files changed, 106 insertions(+), 97 deletions(-) rename MVMCoreUI/OtherHandlers/{DelegateObject.swift => MVMCoreUIDelegateObject.swift} (85%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index dea12c71..1f3e1d53 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -157,7 +157,7 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; - D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */; }; + D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; 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 */; }; @@ -318,7 +318,7 @@ D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; - D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; sourceTree = ""; }; + D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; 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 = ""; }; @@ -636,7 +636,7 @@ D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { isa = PBXGroup; children = ( - D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */, + D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */, D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, @@ -868,7 +868,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, - D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */, + D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 72c04900..0849ed26 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -113,8 +113,8 @@ open class CaretButton: MFCustomButton { setTitleColor(disabledColor, for: .disabled) } - @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 47ac89e4..9d08883d 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -11,7 +11,7 @@ #import #import #import -@class MVMCoreUIDelegateObject; +@class DelegateObject; typedef void (^ButtonTapBlock)(id _Nonnull sender); @@ -28,7 +28,7 @@ extern CGFloat const CloseButtonWidth; - (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event; // Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; //accessibility - (void)addAccessibilityForCameraControl; diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m index 45daebcc..1610f42b 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m @@ -38,7 +38,7 @@ CGFloat const CloseButtonWidth = 40.0f; } } -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { self.actionMap = actionMap; self.titleLabel.numberOfLines = 0; @@ -47,7 +47,9 @@ CGFloat const CloseButtonWidth = 40.0f; [self setEnabled:![actionMap[KeyDisableButton]boolValue]]; - self.buttonDelegate = delegateObject.buttonDelegate; + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + self.buttonDelegate = ((MVMCoreUIDelegateObject *)delegateObject).buttonDelegate; + } __weak MFCustomButton *weakSelf = self; [self addBlock:^(id _Nonnull sender) { diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 563dc2d1..eb3a4c4b 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -94,10 +94,9 @@ open class CaretView: MFView { defaultState() } - - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - + + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) // Configure class properties with JSON values guard let jsonDictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 9b3e7f52..82c05b27 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -68,8 +68,8 @@ open class DashLine: MFView { isHidden = false } - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) // Configure class properties with JSON values guard let jsonDictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/LabelView.m b/MVMCoreUI/Atoms/Views/LabelView.m index f1d7b2f0..15915cec 100644 --- a/MVMCoreUI/Atoms/Views/LabelView.m +++ b/MVMCoreUI/Atoms/Views/LabelView.m @@ -72,9 +72,9 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegate:delegate additionalData:additionalData]; - [self.label setWithJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; + [self.label setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; } - (void)alignLeft { diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 3810294a..b749b41f 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -553,8 +553,7 @@ extension LabelWithInternalButton: MVMCoreUIMoleculeViewProtocol { } - @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - + @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { // Configure class properties with JSON values guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 3857cd8d..5fb19037 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -170,7 +170,7 @@ } } -+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { ++ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { if (label) { label.text = [json string:KeyText]; [self setLabel:label withHTML:[json string:@"html"]]; @@ -232,7 +232,7 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { [MFLabel setUILabel:self withJSON:json delegateObject:delegateObject additionalData:additionalData]; self.originalAttributedString = self.attributedText; } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 257fe041..b08dc249 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -203,8 +203,8 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol functions - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Atoms/Views/MFView.m index 6c0f8309..4bd73485 100644 --- a/MVMCoreUI/Atoms/Views/MFView.m +++ b/MVMCoreUI/Atoms/Views/MFView.m @@ -7,6 +7,7 @@ // #import "MFView.h" +@import MVMCore.Swift; @implementation MFView @@ -43,7 +44,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { self.json = json; } diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.m b/MVMCoreUI/Atoms/Views/SeparatorView.m index 73cd84ff..95fe8bb8 100644 --- a/MVMCoreUI/Atoms/Views/SeparatorView.m +++ b/MVMCoreUI/Atoms/Views/SeparatorView.m @@ -95,8 +95,8 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if (json) { self.hidden = NO; NSString *type = [json string:KeyType]; diff --git a/MVMCoreUI/Molecules/ButtonView.swift b/MVMCoreUI/Molecules/ButtonView.swift index 5391640c..8958887c 100644 --- a/MVMCoreUI/Molecules/ButtonView.swift +++ b/MVMCoreUI/Molecules/ButtonView.swift @@ -33,9 +33,9 @@ import UIKit primaryButton?.isEnabled = enabled } - public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate: NSObject?, buttonDelegate: Any?) { + public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { super.init(frame: .zero) - setWithJSON(json, delegate: actionDelegate, additionalData: additionalData) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - MVMCoreViewProtocol @@ -58,7 +58,7 @@ import UIKit primaryButton?.setAsMolecule() } - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUI.DelegateObject?, additionalData: [AnyHashable : Any]?) { + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 19cc1e21..ac92e0a1 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -7,12 +7,12 @@ // #import -@class MVMCoreUIDelegateObject; +@class DelegateObject; @protocol MVMCoreUIMoleculeViewProtocol // Sets up the ui based on the json -- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; @optional diff --git a/MVMCoreUI/Molecules/MoleculeStackView.swift b/MVMCoreUI/Molecules/MoleculeStackView.swift index 1c70d6eb..57b0108c 100644 --- a/MVMCoreUI/Molecules/MoleculeStackView.swift +++ b/MVMCoreUI/Molecules/MoleculeStackView.swift @@ -17,13 +17,13 @@ public class MoleculeStackView: MFView { super.init(frame: frame) } - public init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { + public init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) { super.init(frame: CGRect.zero) - setWithJSON(json, delegate: delegate, additionalData: additionalData) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - public convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { - self.init(withJSON: json, delegate: delegate, additionalData: nil) + public convenience init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { + self.init(withJSON: json, delegateObject: delegateObject, additionalData: nil) self.spacingBlock = spacingBlock } @@ -48,8 +48,8 @@ public class MoleculeStackView: MFView { } } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) guard let molecules = json?.arrayForKey("molecules") as? [[String: Any]] else { return } @@ -58,7 +58,7 @@ public class MoleculeStackView: MFView { var moleculesArray = [] as [UIView] for moleculeJSON in molecules { if let name = moleculeJSON.optionalStringForKey("moleculeName"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForName(name) { - molecule.setWithJSON(moleculeJSON, delegate: delegate, additionalData: additionalData) + molecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) moleculesArray.append(molecule) } } diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index 99880b9b..a170d023 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -103,12 +103,12 @@ public class StandardFooterView: ViewConstrainingView { rightConstraintTextButton?.constant = constant } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = .mfGet(forHex: colorString) } - twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegate: delegate, additionalData: additionalData) - textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegate: delegate, additionalData: additionalData) + twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData) + textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 8c05a4c6..488e31c1 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -110,8 +110,8 @@ public class StandardHeaderView: ViewConstrainingView { separatorView?.rightPin?.constant = constant } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = .mfGet(forHex: colorString) } @@ -123,11 +123,11 @@ public class StandardHeaderView: ViewConstrainingView { } let headlineJSON = json?.optionalDictionaryForKey("headline") - headlineLabel.setWithJSON(headlineJSON, delegate: delegate, additionalData: additionalData) + headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) let bodyJSON = json?.optionalDictionaryForKey("body") - messageLabel.setWithJSON(bodyJSON, delegate: delegate, additionalData: additionalData) + messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) let separatorJSON = json?.optionalDictionaryForKey("separator") - separatorView?.setWithJSON(separatorJSON, delegate: delegate, additionalData: additionalData) + separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) if separatorView?.isHidden ?? true { bottomPin?.constant = 0 diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index c56d82bf..58586126 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -39,14 +39,14 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton") let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton") - set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, actionDelegate: delegate, additionalData: additionalData, buttonDelegate: delegate) + set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Constraining @@ -142,33 +142,14 @@ import UIKit } } - open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON, legacy: false) setDefaultCustom() - primaryButton?.setWithJSON(primaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) - secondaryButton?.setWithJSON(secondaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) + primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData) + secondaryButton?.setWithJSON(secondaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Legacy - open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) - let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) - setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - } - - open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) - if primaryButtonMap != nil, secondaryButtonMap != nil { - primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - } else if primaryButtonMap != nil { - primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - primaryButton?.bordered = false - } else if secondaryButtonMap != nil { - primaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - primaryButton?.bordered = true - } - } public convenience init(buttonSmall small: Bool, enabled: Bool) { self.init() @@ -178,18 +159,6 @@ import UIKit primaryButton?.isEnabled = enabled } - public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) { - self.init() - setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - primaryButton?.setAsSmall(small) - secondaryButton?.setAsSmall(small) - } - - public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - self.init() - setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - } - public func hidePrimaryLeftButton() { guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else { return @@ -229,3 +198,42 @@ import UIKit secondaryButton?.isHidden = true } } + +// MARK: - Deprecate +extension TwoButtonView { + @available(*, deprecated) + open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) + if primaryButtonMap != nil, secondaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + } else if primaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + primaryButton?.bordered = false + } else if secondaryButtonMap != nil { + primaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + primaryButton?.bordered = true + } + } + + @available(*, deprecated) + open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) + let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + } + + @available(*, deprecated) + public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) { + self.init() + setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + primaryButton?.setAsSmall(small) + secondaryButton?.setAsSmall(small) + } + + @available(*, deprecated) + public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + self.init() + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + } +} diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift similarity index 85% rename from MVMCoreUI/OtherHandlers/DelegateObject.swift rename to MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index d7a2ac65..91ce13c3 100644 --- a/MVMCoreUI/OtherHandlers/DelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -8,8 +8,7 @@ import UIKit -@objc(MVMCoreUIDelegateObject) -open class DelegateObject: MVMCore.DelegateObject { +open class MVMCoreUIDelegateObject: DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? public weak var buttonDelegate: ButtonDelegateProtocol? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h index 7d229bbe..a79ca208 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h @@ -8,6 +8,7 @@ #import #import +@class DelegateObject; @interface MVMCoreUIMoleculeMappingObject : NSObject @@ -19,6 +20,6 @@ // Returns the molecule for the given name. - (nullable UIView *)getMoleculeForName:(nonnull NSString *)name; -- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate; +- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject; @end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 0936f9df..c1d7a36d 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -55,13 +55,13 @@ return nil; } -- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate { +- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject { NSString *moleculeName = [json string:@"moleculeName"]; if (!moleculeName) { return nil; } UIView *molecule = [self getMoleculeForName:moleculeName]; - [molecule setWithJSON:json delegate:delegate additionalData:nil]; + [molecule setWithJSON:json delegateObject:delegateObject additionalData:nil]; return molecule; } diff --git a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift index ab7b6dec..bdd187fe 100644 --- a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift @@ -12,13 +12,13 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { public override func viewForMiddle() -> UIView? { let molecule = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") - let moleculeStack = MoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil) + let moleculeStack = MoleculeStackView(withJSON: molecule, delegateObject: delegateObject(), additionalData: nil) return moleculeStack } public override func viewForTop() -> UIView? { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule @@ -26,7 +26,7 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { override public func viewForBottom() -> UIView? { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 2910782d..dfcef277 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -16,7 +16,7 @@ public class MoleculeStackTemplate: 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, delegateObject: delegateObject()) else { return nil } return molecule @@ -26,11 +26,11 @@ public class MoleculeStackTemplate: ThreeLayerViewController { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") else { return nil } - return MoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil) + return MoleculeStackView(withJSON: moleculeJSON, delegateObject: delegateObject(), additionalData: nil) } 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, delegateObject: delegateObject()) else { return nil } return molecule From 8c19755ba87f42842d1248dda57b2d87daac1906 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 13:31:45 -0400 Subject: [PATCH 22/78] warning fix --- MVMCoreUI/Atoms/Buttons/MFTextButton.m | 4 +-- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 11 ++++--- MVMCoreUI/Atoms/Views/MFLabel.h | 3 +- MVMCoreUI/BaseControllers/MFViewController.m | 10 +++--- ...MVMCoreUITabBarPageControlViewController.m | 2 +- .../FormValidator+FormParams.swift | 4 +-- ...abelsAndBottomButtonsTableViewController.m | 2 +- .../TopLabelsAndBottomButtonsViewController.m | 2 +- MVMCoreUI/Molecules/TwoButtonView.swift | 31 +++++++++++++++++++ 9 files changed, 51 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index ff4c372c..0a72eee7 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -128,12 +128,12 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { NSString *color = [json string:KeyTextColor]; if (color) { [self setTitleColor:[UIColor mfGetColorForHex:color] forState:UIControlStateNormal]; } - [self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; + [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; if ([self titleForState:UIControlStateNormal].length == 0) { self.heightConstraint.constant = 0; } else { diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index fd7ad2b9..2085b5c8 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -648,10 +648,11 @@ [self setAsStandardCustom]; } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { - - [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; - +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + } + self.primaryButtonType = PrimaryButtonTypeCustom; NSString *color = [json string:@"fillColor"]; if (color) { @@ -676,7 +677,7 @@ 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)]; + [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; } #pragma mark - Handling Validations diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 22308465..7dc4fd8d 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -9,6 +9,7 @@ #import #import @class MFSizeObject; +@class DelegateObject; @interface MFLabel : UILabel @@ -49,7 +50,7 @@ // 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)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 6b27c7d9..c378391a 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -138,7 +138,7 @@ // Creates an initial load object if needed. if (!self.loadObject) { - self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegate:self]; + self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegateObject:[self delegateObject]]; } // Avoid the setter so we are only setting the bool and wait for view will appear to update the navigation bar. @@ -343,7 +343,7 @@ if (rightPanelLinkDict) { [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict additionalData:nil - delegate:self]; + delegateObject:[self delegateObject]]; return YES; } else { return NO; @@ -607,7 +607,7 @@ [self.formValidator addFormParamsWithRequestParameters:requestParameters]; requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"]; - [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegate:self]; + [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]]; } - (void)handleBackAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { @@ -662,7 +662,7 @@ - (void)handleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { - [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegate:self]; + [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:[self delegateObject]]; } - (void)handleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { @@ -689,7 +689,7 @@ } - (nullable MVMCoreAlertObject *)alertObjectToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject { - return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject actionDelegate:self]; + return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject delegateObject:[self delegateObject]]; } - (void)handleFieldErrors:(nullable NSArray *)fieldErrors loadObject:(nonnull MVMCoreLoadObject *)loadObject { diff --git a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m index 489a4696..d06ca5f4 100644 --- a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m +++ b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m @@ -394,7 +394,7 @@ if (customAdditionalData) { [additionalData addEntriesFromDictionary:customAdditionalData]; } - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:self]; + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[self delegateObject]]; } } return NO; diff --git a/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift b/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift index 2f1e9f99..17da0e72 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift @@ -9,11 +9,11 @@ import Foundation @objc public extension FormValidator { - @objc public func addFormParams(requestParameters: MVMCoreRequestParameters) { + @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { requestParameters.add(self.getFormParams()) } - @objc public func getFormParams() -> [String: Any] { + @objc func getFormParams() -> [String: Any] { var extraParam: [String: Any] = [:] MVMCoreDispatchUtility.performSyncBlock(onMainThread: { for molecule in self.molecules { diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 7a16405b..ca75b778 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -117,7 +117,7 @@ // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap]; - TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self]; + TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil]; self.secondaryButton = buttonView.secondaryButton; self.primaryButton = buttonView.primaryButton; diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index be14e149..149b399c 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -127,7 +127,7 @@ // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap]; - TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self]; + TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil]; self.secondaryButton = buttonView.secondaryButton; self.primaryButton = buttonView.primaryButton; bottomView = buttonView; diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index 58586126..66b7210a 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -150,6 +150,17 @@ import UIKit } // MARK: - Legacy + public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + self.init() + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } + + public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: AnyHashable]?) { + self.init() + setup(withButtonMap: buttonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.setAsSmall(small) + secondaryButton?.setAsSmall(small) + } public convenience init(buttonSmall small: Bool, enabled: Bool) { self.init() @@ -159,6 +170,26 @@ import UIKit primaryButton?.isEnabled = enabled } + open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) + if primaryButtonMap != nil, secondaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } else if primaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.bordered = false + } else if secondaryButtonMap != nil { + primaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.bordered = true + } + } + + open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) + let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } + public func hidePrimaryLeftButton() { guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else { return From 01c5abc0272c776323003fc0825da8a8d5468e51 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 13:47:19 -0400 Subject: [PATCH 23/78] warning fix --- MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m index 4b19c49c..fe8d940b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m @@ -19,6 +19,8 @@ #import "MVMCoreUICommonViewsUtility.h" #import "MFStyler.h" #import "MVMCoreUISession.h" +#import + @import MVMCore.MVMCoreTopAlertDelegateProtocol; @implementation MVMCoreUITopAlertBaseView @@ -35,7 +37,7 @@ } if (performAction) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:[MVMCoreUISession sharedGlobal].topAlertView]; + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]]; } } forControlEvents:UIControlEventTouchUpInside]; } From e2e6cbabf6f16e74db34f4f01f2440bf2632dbf7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 14:39:37 -0400 Subject: [PATCH 24/78] textfield delegate object fix --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..77509325 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -116,7 +116,7 @@ + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; - [textField setWithJSON:map delegate:delegate additionalData:nil]; + [textField setWithJSON:map delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:delegate] additionalData:nil]; return textField; } @@ -558,10 +558,12 @@ 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)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + [self setWithMap:json bothDelegates:formValidator]; + } } #pragma mark - FormValidationProtocol From 9278ad75ea8d1511e71a1b074d9bd81bfb0db250 Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 15 Apr 2019 14:50:45 -0400 Subject: [PATCH 25/78] add override status bar function --- .../MVMCoreUIDetailViewProtocol.h | 3 +++ .../MVMCoreUISplitViewController.h | 3 +++ .../MVMCoreUISplitViewController.m | 20 ++++++++++++++++++- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 3 +++ MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 10 +++++++++- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 0c5a865d..5eeafc9f 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -30,6 +30,9 @@ NS_ASSUME_NONNULL_BEGIN // View Controller can override this method and do custom action instead of opening the left panel - (BOOL)isOverridingLeftButton; +//return desired status bar style based on different View Controller +- (UIStatusBarStyle)panelPreferredStatusBarStyle; + @end NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 2ef7fa25..88b61188 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -105,6 +105,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { + (CGFloat)getApplicationViewWidth; + (CGFloat)getApplicationViewMaxSize; +// return subviewcontrollers' prefer status bar style +- (UIStatusBarStyle)getDefaultStatusBarStyle; + #pragma mark - Main Subclassables // Can subclass to set threshold for when the drawers are permanently extended. Default is 1000 for the left panel and 2000 for both. diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index d70bdb6e..dd76cc92 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -877,7 +877,25 @@ CGFloat const PanelAnimationDuration = 0.2; } - (UIStatusBarStyle)preferredStatusBarStyle { - return self.topAlertView.statusBarStyle; + if (self.topAlertView.topAlertObject) { + return self.topAlertView.statusBarStyle; + } else { + UIStatusBarStyle style = [self getDefaultStatusBarStyle]; + if (self.topAlertView.statusBarStyle != style) { + [self.topAlertView resetStatusBar]; + } + return style; + } +} + +- (UIStatusBarStyle)getDefaultStatusBarStyle { + UIViewController *viewController = [self getCurrentDetailViewController]; + if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [viewController respondsToSelector:@selector(panelPreferredStatusBarStyle)] + && [((UIViewController *)viewController) panelPreferredStatusBarStyle]) { + return [((UIViewController *)viewController) panelPreferredStatusBarStyle]; + } + return UIStatusBarStyleDefault; } #pragma mark - Getters diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 46d56cb6..f4de6d5b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -41,6 +41,9 @@ - (void)expandStatusBarView; - (void)collapseStatusBarView; +//reset status bar color to default based on splitview +- (void)resetStatusBar; + // Can be subclassed for custom views. - (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 735f28d9..a582638c 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -189,7 +189,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [weakSelf.superview layoutIfNeeded]; } completion:^(BOOL finished) { [weakSelf.animationDelegate topAlertViewFinishAnimation]; - [weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); UIView *view = weakSelf.currentAlert; @@ -204,6 +203,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [operation markAsFinished]; completionHandler(finished); weakSelf.topAlertObject = nil; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [weakSelf resetStatusBar]; + }]; }]; }]; }]; @@ -242,4 +244,10 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; }]; } +- (void)resetStatusBar { + UIStatusBarStyle style = [[MVMCoreUISplitViewController mainSplitViewController] getDefaultStatusBarStyle]; + UIColor *backgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; + [self setStatusBarColor:backgroundColor statusBarStyle:style]; +} + @end From 7343f24e9bb4c5f1148b3eb6e06f72079878be24 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 15:09:25 -0400 Subject: [PATCH 26/78] missed super --- MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index 91ce13c3..eaf892fb 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -13,6 +13,7 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var buttonDelegate: ButtonDelegateProtocol? open override func setAll(withDelegate delegate: Any) { + super.setAll(withDelegate: delegate) formValidationProtocol = delegate as? FormValidationProtocol buttonDelegate = delegate as? ButtonDelegateProtocol } From da1f5a5703d935fb3660f4055c5234c676ce99a2 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Mon, 15 Apr 2019 16:50:35 -0400 Subject: [PATCH 27/78] Converted MFLabel (objc) to Label (Swift). Pulled LabelWithoutAccessibilityTraits from Mobilefirst module and converted it. Altered imports where needed. --- MVMCoreUI.xcodeproj/project.pbxproj | 14 +- MVMCoreUI/Atoms/TextFields/MFTextField.h | 4 +- MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 - MVMCoreUI/Atoms/TextFields/MFTextField.xib | 6 +- MVMCoreUI/Atoms/Views/Label.swift | 103 ++++--- MVMCoreUI/Atoms/Views/LabelView.h | 4 +- MVMCoreUI/Atoms/Views/LabelView.m | 3 +- .../Atoms/Views/LabelWithInternalButton.swift | 4 +- .../LabelWithoutAccessibilityTraits.swift | 35 +++ MVMCoreUI/Atoms/Views/MFLabel.h | 63 ---- MVMCoreUI/Atoms/Views/MFLabel.m | 291 ------------------ MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h | 4 +- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 3 +- .../TopLabelsAndBottomButtonsViewController.h | 1 - MVMCoreUI/MVMCoreUI.h | 2 - MVMCoreUI/Molecules/StandardHeaderView.swift | 8 +- MVMCoreUI/Molecules/TopLabelsView.h | 7 +- MVMCoreUI/Molecules/TopLabelsView.m | 5 +- .../MVMCoreUIMoleculeMappingObject.m | 2 +- 19 files changed, 125 insertions(+), 436 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/LabelWithoutAccessibilityTraits.swift delete mode 100644 MVMCoreUI/Atoms/Views/MFLabel.h delete mode 100644 MVMCoreUI/Atoms/Views/MFLabel.m diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ff46aef9..015803e6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -96,8 +96,6 @@ D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */; }; D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28521E7AC2B003B2FB9 /* MFLabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28621E7AC2B003B2FB9 /* MFLabel.m */; }; D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */; }; D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */; }; @@ -161,6 +159,7 @@ DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; }; DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */; }; + DBE3596E22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */; }; DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; /* End PBXBuildFile section */ @@ -263,8 +262,6 @@ D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIDetailViewProtocol.h; sourceTree = ""; }; D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICommonViewsUtility.m; sourceTree = ""; }; D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = ""; }; - D29DF28521E7AC2B003B2FB9 /* MFLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLabel.h; sourceTree = ""; }; - D29DF28621E7AC2B003B2FB9 /* MFLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLabel.m; sourceTree = ""; }; D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewConstrainingView.h; sourceTree = ""; }; D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewConstrainingView.m; sourceTree = ""; }; D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProgrammaticScrollViewController.m; sourceTree = ""; }; @@ -318,13 +315,12 @@ D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; 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 = ""; }; DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; 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 = ""; }; DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithInternalButton.swift; sourceTree = ""; }; + DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithoutAccessibilityTraits.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -566,8 +562,6 @@ DBC4391722442197001AB423 /* DashLine.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, - D29DF28521E7AC2B003B2FB9 /* MFLabel.h */, - D29DF28621E7AC2B003B2FB9 /* MFLabel.m */, D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, @@ -595,6 +589,7 @@ DB891E822253FA8500022516 /* Label.swift */, 0198F7A02256A80A0066C936 /* MFRadioButton.h */, 0198F7A22256A80A0066C936 /* MFRadioButton.m */, + DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */, ); path = Views; sourceTree = ""; @@ -747,7 +742,6 @@ D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */, D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, - D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */, D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */, D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */, D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */, @@ -906,7 +900,6 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, - D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, @@ -919,6 +912,7 @@ D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, + DBE3596E22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift in Sources */, 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 81b4059f..27dd8414 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -11,7 +11,7 @@ @class PrimaryButton; @class MFTextField; -@class MFLabel; +@class Label; @protocol MFTextFieldDelegate @@ -34,7 +34,7 @@ @property (nullable, weak, nonatomic) IBOutlet UIView *textFieldContainerView; @property (nullable, weak, nonatomic) IBOutlet UITextField *textField; -@property (nullable, weak, nonatomic) IBOutlet MFLabel *formLabel; +@property (nullable, weak, nonatomic) IBOutlet Label *formLabel; @property (nullable, weak, nonatomic) IBOutlet UIView *separatorView;//make it public so outsider class can know the posistion of it. @property (nullable, weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..64169579 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -7,12 +7,10 @@ // #import "MFTextField.h" -#import #import "MFTextFieldSubclassExtension.h" #import "MFStyler.h" #import "UIColor+MFConvenience.h" #import "MVMCoreUICommonViewsUtility.h" -#import "MFLabel.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" #import diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index b60f1ff3..e839533f 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,11 +1,11 @@ - + - + @@ -98,7 +98,7 @@ -