From 392ab144acac53120803230765bb70662fd9c41f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Nov 2019 16:01:43 -0500 Subject: [PATCH 01/11] small fixes --- MVMCoreUI/Atoms/Views/GraphView.swift | 4 ++-- MVMCoreUI/Atoms/Views/Line.swift | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index eb2b2099..6ef3132c 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -93,8 +93,8 @@ public struct GraphObject { mutating func updateSize() { switch size { case .small: - diameter = MFSizeObject(standardSize: 24)?.getValueBasedOnApplicationWidth() ?? 24 - lineWidth = MFSizeObject(standardSize: 5)?.getValueBasedOnApplicationWidth() ?? 5 + diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20 + lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4 break case .medium: diameter = MFSizeObject(standardSize: 100)?.getValueBasedOnApplicationWidth() ?? 100 diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index f7a81ac5..d5f4f4b6 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -38,8 +38,6 @@ import UIKit case .none: heightConstraint?.constant = 0 } - setNeedsLayout() - layoutIfNeeded() } } From 63556707bc66928585b966a3287932b9aac2fd5f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 Nov 2019 13:49:01 -0500 Subject: [PATCH 02/11] temporary dropdown molecule label reuse font fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atoms/TextFields/MFTextField.h | 1 + MVMCoreUI/Atoms/TextFields/MFTextField.m | 1 + MVMCoreUI/Atoms/TextFields/MFTextField.xib | 9 +- MVMCoreUI/Atoms/Views/DropDown.swift | 55 ++++++++++++ MVMCoreUI/Atoms/Views/Label.swift | 28 +++--- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 1 - .../Items/DropDownFilterTableViewCell.swift | 70 +++++++++++++++ .../MVMCoreUIMoleculeMappingObject.m | 10 ++- MVMCoreUI/Styles/MFStyler.h | 10 +++ MVMCoreUI/Styles/MFStyler.m | 90 +++++++++++++------ 11 files changed, 234 insertions(+), 49 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/DropDown.swift create mode 100644 MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 391e20f5..515e24ee 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -50,6 +50,8 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; + D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -246,6 +248,8 @@ D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = ""; }; D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; + D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; + D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = ""; }; D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; @@ -509,6 +513,7 @@ D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, + D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */, ); path = Items; sourceTree = ""; @@ -752,6 +757,7 @@ D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, + D268C711238D6699007F2C1C /* DropDown.swift */, D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, @@ -1071,6 +1077,7 @@ D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, + D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, @@ -1154,6 +1161,7 @@ D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, + D268C712238D6699007F2C1C /* DropDown.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 8ccbe22e..aa3ab573 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -74,6 +74,7 @@ //default error message @property (nullable, strong, nonatomic) NSString *errMessage; +@property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *errorHeightConstraint; @property (nullable, copy, nonatomic) void (^editCompleteAction)(NSString * _Nullable text); diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index cfef9090..fec796bf 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -558,6 +558,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:delegateObject.formValidationProtocol]; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index cb9821f1..c11beb5c 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -15,6 +13,7 @@ + diff --git a/MVMCoreUI/Atoms/Views/DropDown.swift b/MVMCoreUI/Atoms/Views/DropDown.swift new file mode 100644 index 00000000..88d0a2c2 --- /dev/null +++ b/MVMCoreUI/Atoms/Views/DropDown.swift @@ -0,0 +1,55 @@ +// +// DropDown.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class DropDown: MFTextField { + let picker = MVMCoreUICommonViewsUtility.commonPickerView()! + + public override func getNib() -> UINib? { + return UINib(nibName: String(describing: MFTextField.self), bundle: MVMCoreUIUtility.bundleForMVMCoreUI()) + } + + public override func setupView() { + super.setupView() + dropDownCarrotWidth?.isActive = false + errorHeightConstraint?.constant = 0 + } + + override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + guard let textField = textField, textField.inputView == nil else { return } + picker.delegate = self + picker.dataSource = self + picker.tag = textField.tag + textField.inputView = picker + picker.reloadAllComponents() + MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: delegateObject?.uiTextFieldDelegate) + textField.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,picker.selectedRow(inComponent: 0)]) + } +} + +extension DropDown: UIPickerViewDelegate { + public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return json?.stringWithChainOfKeysOrIndexes([KeyValue,row]) + } + + public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + textField?.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,row]) + } +} + +extension DropDown: UIPickerViewDataSource { + public func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 1 + } + + public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return json?.optionalArrayForKey(KeyValue)?.count ?? 0 + } +} diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 8474d74a..b2cc4f56 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -212,9 +212,12 @@ public typealias ActionBlock = () -> () } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - guard let label = label else { return } - label.attributedText = nil + + // Some properties can only be set on Label. + // Label fonts should not be scaled because it will be scaled in updateView. + let mvmLabel = label as? Label + label.text = json?.optionalStringForKey(KeyText) setLabel(label, withHTML: json?.optionalStringForKey("html")) @@ -230,9 +233,7 @@ public typealias ActionBlock = () -> () } } - if let wholeViewIsClickable = json?.boolForKey("makeWholeViewClickable") { - (label as? Label)?.makeWholeViewClickable = wholeViewIsClickable - } + mvmLabel?.makeWholeViewClickable = json?.boolForKey("makeWholeViewClickable") ?? false if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor), !backgroundColorHex.isEmpty { label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) @@ -241,12 +242,12 @@ public typealias ActionBlock = () -> () label.accessibilityLabel = json?.optionalStringForKey("accessibilityText") if let fontStyle = json?.optionalStringForKey("fontStyle") { - MFStyler.styleLabel(label, withStyle: fontStyle) + MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil) } else { let fontSize = json?["fontSize"] as? CGFloat if let fontName = json?.optionalStringForKey("fontName") { - label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize) + label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { label.font = label.font.withSize(fontSize) } @@ -256,8 +257,8 @@ public typealias ActionBlock = () -> () label.textColor = UIColor.mfGet(forHex: textColorHex) } - if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as UIFont, + if let attributes = json?.optionalArrayForKey("attributes"), let labelText = label.text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: mvmLabel?.font.withSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, NSAttributedString.Key.foregroundColor: label.textColor as UIColor]) for case let attribute as [String: Any] in attributes { guard let attributeType = attribute.optionalStringForKey(KeyType), @@ -298,7 +299,7 @@ public typealias ActionBlock = () -> () case "font": if let fontStyle = attribute.optionalStringForKey("style") { - let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) + let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle, genericScaling: mvmLabel == nil) attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range) @@ -307,7 +308,7 @@ public typealias ActionBlock = () -> () var font: UIFont? if let fontName = attribute.optionalStringForKey("name") { - font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize) + font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { font = label.font.withSize(fontSize) } @@ -330,6 +331,7 @@ public typealias ActionBlock = () -> () } } label.attributedText = attributedString + mvmLabel?.originalAttributedString = attributedString } } @@ -419,7 +421,7 @@ public typealias ActionBlock = () -> () if let floatScale = scaleSize?.floatValue { updateView(CGFloat(floatScale)) } else { - updateView(MVMCoreUISplitViewController.getApplicationViewWidth()) + updateView(MVMCoreUIUtility.getWidth()) } } else { standardFontSize = 0 @@ -581,8 +583,6 @@ extension Label { @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { clauses = [] Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) - originalAttributedString = attributedText - hero = json?["hero"] as? Int } diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 66a3a83d..f7aaf7f6 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -357,7 +357,6 @@ if (!self.constrainedView) { [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; } - [self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if (self.shouldSetupMoleculeFromJSON) { NSDictionary *moleculeJSON = [json dict:KeyMolecule]; if (self.molecule) { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift new file mode 100644 index 00000000..518e3b51 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -0,0 +1,70 @@ +// +// DropDownFilterTableViewCell.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 9/6/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class DropDownFilterTableViewCell: TableViewCell { + let dropDown = DropDown(forDropDownWithBothDelegates: nil) + var delegateObject: MVMCoreUIDelegateObject? + var previousIndex = NSNotFound + var dropDownSelectionObservation: NSKeyValueObservation? + + // MARK: - MFViewProtocol + override public func setupView() { + super.setupView() + guard let dropDown = dropDown, dropDown.superview == nil else { + return + } + bottomMarginPadding = 0 + + dropDown.translatesAutoresizingMaskIntoConstraints = false + contentView.addSubview(dropDown) + + NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: dropDown, useMargins: true).values)) + + #warning("Once we have the state manager, we will need to change this logic to only add or remove on user selection...Want to avoid re-use crashes from array size differences") + dropDownSelectionObservation = observe( + \.dropDown?.textField?.text, + options: [.old, .new] + ) { [weak self] object, change in + guard change.newValue != change.oldValue, let self = self, + let options = self.dropDown?.json?.optionalArrayForKey(KeyValue) as? [NSString], + let index = options.firstIndex(of: change.newValue!! as NSString), + let moleculesArrays = self.json?.arrayForKey(KeyMolecules) as? [[[AnyHashable: Any]]] else { return } + + if self.previousIndex != NSNotFound { + let previousMolecules = moleculesArrays[self.previousIndex] + self.delegateObject?.moleculeDelegate?.removeMolecules?(previousMolecules, sender: self, animation: .fade) + } + let molecules = moleculesArrays[index] + self.delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .fade) + self.previousIndex = index + } + } + + public override func updateView(_ size: CGFloat) { + super.updateView(size) + dropDown?.updateView(size) + } + + // MARK: - MoleculeDelegateProtocol + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + bottomSeparatorView?.style = .none + self.delegateObject = delegateObject + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate + dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate + dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData) + } + + public override func reset() { + super.reset() + bottomMarginPadding = 0 + bottomSeparatorView?.style = .none + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 4303dc55..51a07225 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -35,10 +35,11 @@ @"footer": StandardFooterView.class, @"caretView": CaretView.class, @"caretButton": CaretButton.class, - @"textField" : MFTextField.class, - @"digitTextField" : MFDigitTextField.class, - @"checkbox" : Checkbox.class, - @"checkboxWithLabel" : CheckboxWithLabelView.class, + @"textField": MFTextField.class, + @"dropDown": DropDown.class, + @"digitTextField": MFDigitTextField.class, + @"checkbox": Checkbox.class, + @"checkboxWithLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, @"progressbar": ProgressBar.class, @"circleProgress": GraphView.class, @@ -63,6 +64,7 @@ @"headlineBodyTextButton": HeadlineBodyTextButton.class, @"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class, @"tabsListItem": TabsTableViewCell.class, + @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class } mutableCopy]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 5b73c8e2..bdef57ba 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -210,6 +210,7 @@ B3 -> Legal /// Will style the label based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20 + (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style; ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelH1:(nonnull UILabel *)label; @@ -258,6 +259,7 @@ B3 -> Legal /// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20 + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style; ++ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string; @@ -266,6 +268,14 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + (nonnull NSAttributedString *)styleGetDisabledB2AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 18246f7f..c3dc8946 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -516,26 +516,30 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 2.0 Styles -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style { ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { if ([style isEqualToString:@"H1"]) { - [self styleLabelH1:label]; + [self styleLabelH1:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H2"]) { - [self styleLabelH2:label]; + [self styleLabelH2:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H3"]) { - [self styleLabelH3:label]; + [self styleLabelH3:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H32"]) { - [self styleLabelH32:label]; + [self styleLabelH32:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B1"]) { - [self styleLabelB1:label]; + [self styleLabelB1:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B3"]) { - [self styleLabelB3:label]; + [self styleLabelB3:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B20"]) { - [self styleLabelB20:label]; + [self styleLabelB20:label genericScaling:genericScaling]; } else { - [self styleLabelB2:label]; + [self styleLabelB2:label genericScaling:genericScaling]; } } ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style { + [self styleLabel:label withStyle:style genericScaling:YES]; +} + + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontH1:genericScaling]; label.textColor = [UIColor blackColor]; @@ -656,22 +660,26 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - Attributed Strings + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style { + return [self styleGetAttributedString:string withStyle:style genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { if ([style isEqualToString:@"H1"]) { - return [self styleGetH1AttributedString:string]; + return [self styleGetH1AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H2"]) { - return [self styleGetH2AttributedString:string]; + return [self styleGetH2AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H3"]) { - return [self styleGetH3AttributedString:string]; + return [self styleGetH3AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H32"]) { - return [self styleGetH32AttributedString:string]; + return [self styleGetH32AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B1"]) { - return [self styleGetB1AttributedString:string]; + return [self styleGetB1AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B3"]) { - return [self styleGetB3AttributedString:string]; + return [self styleGetB3AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B20"]) { - return [self styleGetB20AttributedString:string]; + return [self styleGetB20AttributedString:string genericScaling:genericScaling]; } else { - return [self styleGetB2AttributedString:string]; + return [self styleGetB2AttributedString:string genericScaling:genericScaling]; } } @@ -690,35 +698,67 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1] color:[UIColor blackColor]]; + return [MFStyler styleGetH1AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor blackColor]]; + return [MFStyler styleGetH2AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; + return [MFStyler styleGetH3AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32] color:[UIColor blackColor]]; + return [MFStyler styleGetH32AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor blackColor]]; + return [MFStyler styleGetB1AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor blackColor]]; + return [MFStyler styleGetB2AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfBattleshipGrey]]; + return [MFStyler styleGetB3AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3:genericScaling] color:[UIColor mfBattleshipGrey]]; } + (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20] color:[UIColor blackColor]]; + return [MFStyler styleGetB20AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string { From f5270ae12e38ae7ed0874d532e8088ebc9d67032 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Wed, 27 Nov 2019 14:03:51 -0500 Subject: [PATCH 03/11] remove navigation bar check for manual inset calculation as it impacts presented controllers --- MVMCoreUI/BaseControllers/MFScrollingViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.m b/MVMCoreUI/BaseControllers/MFScrollingViewController.m index 56019cb7..67e01d93 100644 --- a/MVMCoreUI/BaseControllers/MFScrollingViewController.m +++ b/MVMCoreUI/BaseControllers/MFScrollingViewController.m @@ -91,7 +91,7 @@ static NSTimeInterval const HandScrollAnimationTiming = 7.f; - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - BOOL automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; + BOOL automaticInset = self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; // Takes into account the navigation bar. if (!automaticInset && (self.edgesForExtendedLayout & UIRectEdgeTop)) { From ee773eed89ac2e3e71cd743f6497e24deb65591b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 Nov 2019 15:02:03 -0500 Subject: [PATCH 04/11] key change --- MVMCoreUI/Atoms/Views/DropDown.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/DropDown.swift b/MVMCoreUI/Atoms/Views/DropDown.swift index 88d0a2c2..929bd67f 100644 --- a/MVMCoreUI/Atoms/Views/DropDown.swift +++ b/MVMCoreUI/Atoms/Views/DropDown.swift @@ -30,17 +30,17 @@ import UIKit textField.inputView = picker picker.reloadAllComponents() MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: delegateObject?.uiTextFieldDelegate) - textField.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,picker.selectedRow(inComponent: 0)]) + textField.text = json?.stringWithChainOfKeysOrIndexes(["options",picker.selectedRow(inComponent: 0)]) } } extension DropDown: UIPickerViewDelegate { public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return json?.stringWithChainOfKeysOrIndexes([KeyValue,row]) + return json?.stringWithChainOfKeysOrIndexes(["options",row]) } public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - textField?.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,row]) + textField?.text = json?.stringWithChainOfKeysOrIndexes(["options",row]) } } @@ -50,6 +50,6 @@ extension DropDown: UIPickerViewDataSource { } public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - return json?.optionalArrayForKey(KeyValue)?.count ?? 0 + return json?.optionalArrayForKey("options")?.count ?? 0 } } From dc5174cbe4e38f97addeeea00663e9ca1d541235 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 28 Nov 2019 20:48:07 +0530 Subject: [PATCH 05/11] key name mismatch fix. --- MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 518e3b51..31a6cc61 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -33,7 +33,7 @@ import UIKit options: [.old, .new] ) { [weak self] object, change in guard change.newValue != change.oldValue, let self = self, - let options = self.dropDown?.json?.optionalArrayForKey(KeyValue) as? [NSString], + let options = self.dropDown?.json?.optionalArrayForKey("options") as? [NSString], let index = options.firstIndex(of: change.newValue!! as NSString), let moleculesArrays = self.json?.arrayForKey(KeyMolecules) as? [[[AnyHashable: Any]]] else { return } From 3e46438fd0be5c32707fadee2d201b9a68c59a68 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 2 Dec 2019 10:11:04 -0500 Subject: [PATCH 06/11] label font bugfix caused by the dissonance between label and styler setting.... --- MVMCoreUI/Atoms/Views/Label.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index b2cc4f56..99a28463 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -243,8 +243,12 @@ public typealias ActionBlock = () -> () if let fontStyle = json?.optionalStringForKey("fontStyle") { MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil) + mvmLabel?.standardFontSize = label.font.pointSize } else { let fontSize = json?["fontSize"] as? CGFloat + if let fontSize = fontSize { + mvmLabel?.standardFontSize = fontSize + } if let fontName = json?.optionalStringForKey("fontName") { label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) From 7e48670179862ac05f93fcca898bc06b2e280949 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 4 Dec 2019 12:38:57 -0500 Subject: [PATCH 07/11] Adding Model for UIColor and supporting UIColor Extension. --- MVMCoreUI.xcodeproj/project.pbxproj | 18 +- MVMCoreUI/Categories/UIColor+Extension.swift | 180 ++++++++++++++++++ .../Models/ConstrainingMoleculeProtocol.swift | 2 +- MVMCoreUI/Models/MoleculeProtocol.swift | 16 +- .../Models/Molecules/FormModelProtocol.swift | 6 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 3 +- .../Models/Primitive Models/ColorModel.swift | 95 +++++++++ 7 files changed, 305 insertions(+), 15 deletions(-) create mode 100644 MVMCoreUI/Categories/UIColor+Extension.swift create mode 100644 MVMCoreUI/Models/Primitive Models/ColorModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6a7921e5..9215b753 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; + 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* ColorModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -279,6 +281,8 @@ 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; + 0AA33B35239813EE0067DD0F /* ColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorModel.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -488,6 +492,7 @@ 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + 0AA33B322398134B0067DD0F /* Primitive Models */, 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, @@ -524,6 +529,14 @@ path = Molecules; sourceTree = ""; }; + 0AA33B322398134B0067DD0F /* Primitive Models */ = { + isa = PBXGroup; + children = ( + 0AA33B35239813EE0067DD0F /* ColorModel.swift */, + ); + path = "Primitive Models"; + sourceTree = ""; + }; 946EE1B5237B663A0036751F /* Extensions */ = { isa = PBXGroup; children = ( @@ -779,6 +792,7 @@ D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */, D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */, + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */, ); path = Categories; sourceTree = ""; @@ -879,7 +893,7 @@ DBC4391722442197001AB423 /* DashLine.swift */, 944589202385D6E900DE9FD4 /* DashLineModel.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, - 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, + 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */, @@ -1208,6 +1222,7 @@ 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, @@ -1273,6 +1288,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, + 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift new file mode 100644 index 00000000..56986044 --- /dev/null +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -0,0 +1,180 @@ +// +// UIColor+Extension.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + + +import UIKit + + +extension UIColor { + //-------------------------------------------------- + // MARK: - Brand + //-------------------------------------------------- + + /// HEX: #000000 + public static let mvmBlack = UIColor.black + + /// HEX: #FFFFFF + public static let mvmWhite = UIColor.white + + /// HEX: #D52B1E + public static let mvmRed = UIColor.getColor(red: 213, green: 43, blue: 30) + + /// HEX: #CC4D0F + public static let mvmOrange = UIColor.getColor(red: 204, green: 77, blue: 15) + + /// HEX: #008631 + public static let mvmGreen = UIColor.getColor(red: 0, green: 134, blue: 49) + + /// HEX: #007AB8 + public static let mvmBlue = UIColor.getColor(red: 0, green: 122, blue: 184) + + /// HEX: #007AB8 + public static let mvmBlueGradient = UIColor.getColor(red: 0, green: 122, blue: 184) + + /// HEX: #FFBC3D + public static let mvmYellow = UIColor.getColor(red: 255, green: 188, blue: 61) + + /// HEX: #F6F6F6 + public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) + + /// HEX: #D8DADA + public static let mvmCoolGray3 = UIColor.getColor(red: 216, green: 218, blue: 218) + + /// HEX: #747676 + public static let mvmCoolGray6 = UIColor.getColor(red: 116, green: 118, blue: 118) + + //-------------------------------------------------- + // MARK: - VZ UP Brand + //-------------------------------------------------- + + /// HEX: #B89B56 + public static let vzupGold = UIColor.getColor(red: 184, green: 155, blue: 68) + + /// HEX: #F9D542 + public static let vzupYellow1 = UIColor.getColor(red: 249, green: 213, blue: 66) + + /// HEX: #F4CA53 + public static let vzupYellow2 = UIColor.getColor(red: 244, green: 202, blue: 83) + + /// HEX: #CC9B2D + public static let vzupYellow3 = UIColor.getColor(red: 204, green: 155, blue: 45) + + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + /// Convenience to get a grayscale UIColor where the same value is used for red, green, and blue. + public class func grayscale(rgb: Int, alpha: CGFloat = 1.0) -> UIColor { + + let grayscale = CGFloat(rgb) / 255.0 + return UIColor(red: grayscale, green: grayscale, blue: grayscale, alpha: alpha) + } + + /// Convenience to get a UIColor via Int. + public class func getColor(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha) + } + + /// Convenience to get a UIColor via CGFloat. + public class func getColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha) + } + + /// Gets UIColor via an 8 digit hex string. + public class func getColorBy(hex: String) -> UIColor { + + var hexint: UInt32 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt32(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + green: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + blue: (CGFloat(hexint & 0xFF)) / 255, + alpha: 1) + } + + /// Gets UIColor via an 8 digit hex string. The last two being the alpha channel. + public class func getColorWithTransparencyBy(hex: String) -> UIColor { + + var hexint: UInt32 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt32(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF000000) >> 24)) / 255, + green: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + blue: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + alpha: (CGFloat(hexint & 0xFF)) / 255) + } + + public class func gradientColor(_ color: UIColor?) -> UIColor { + + var h: CGFloat = 0 + var s: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + + if color?.getHue(&h, saturation: &s, brightness: &b, alpha: &a) ?? false { + return UIColor(hue: h, saturation: max(s - 0.17, 0.0), brightness: min(b - 0.03, 1.0), alpha: a) + } + + return .white + } + + public class func setBackgroundColor(forNavigationBar color: UIColor, navigationBar: UINavigationBar, transparent: Bool) { + + DispatchQueue.main.async { + + let view = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1)) + view.backgroundColor = color + + UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0) + + if let context = UIGraphicsGetCurrentContext() { + view.layer.render(in: context) + } + + let image = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + + if transparent { + navigationBar.setBackgroundImage(UIImage(), for: .default) + navigationBar.isTranslucent = false + } else { + navigationBar.setBackgroundImage(image, for: .default) + } + } + } + + /// - parameter color: The UIColor intended to retrieve its hex value. + public class func hexString(for color: UIColor) -> String? { + + guard let components = color.cgColor.components else { return nil } + + if color.cgColor.numberOfComponents >= 3 { + let r = Int(CGFloat(components[0]) * 255) + let g = Int(CGFloat(components[1]) * 255) + let b = Int(CGFloat(components[2]) * 255) + + // If alpha of color is less than 1.0 then alpha hex is relevant. + if color.cgColor.numberOfComponents == 4 && components[3] < 1.0 { + let a = Int(CGFloat(components[3]) * 255) + return String(format: "%02X%02X%02X%02X", r, g, b, a) + } + + return String(format: "%02X%02X%02X", r, g, b) + } + + return nil + } +} diff --git a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift index 91d4a566..5cb24c4d 100644 --- a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift +++ b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol ConstrainingMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? {get} + var molecule: MoleculeProtocol? { get } } extension ConstrainingMoleculeProtocol { diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 2ddc4061..e8120568 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -1,15 +1,15 @@ import Foundation public protocol MoleculeProtocol: Model { - var moleculeName: String? {get} - var backgroundColor: String? {get} - var dictionary: [AnyHashable: Any]? {get} - var molecule: MoleculeProtocol? {get} + var moleculeName: String? { get } + var backgroundColor: String? { get } + var dictionary: [AnyHashable: Any]? { get } + var molecule: MoleculeProtocol? { get } - var useHorizontalMargins: Bool? {get} - var useVerticalMargins: Bool? {get} - var horizontalAlignment: String? {get} - var verticalAlignment: String? {get} + var useHorizontalMargins: Bool? { get } + var useVerticalMargins: Bool? { get } + var horizontalAlignment: String? { get } + var verticalAlignment: String? { get } } extension MoleculeProtocol { diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift index 4cd76354..aa298716 100644 --- a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol FormModelProtocol: Model { - var required: Bool? {get} - var fieldKey: String? {get} - var groupName: String? {get} + var required: Bool? { get } + var fieldKey: String? { get } + var groupName: String? { get } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 0dca783c..5d4129e2 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -15,7 +15,7 @@ import Foundation public var molecule: MoleculeProtocol? public var seperator: MoleculeProtocol? - public init(molecule: MoleculeProtocol?){ + public init(molecule: MoleculeProtocol?) { self.molecule = molecule self.moleculeName = Self.identifier } @@ -38,4 +38,3 @@ import Foundation try container.encodeIfPresent(self.molecule, forKey: .molecule) } } - diff --git a/MVMCoreUI/Models/Primitive Models/ColorModel.swift b/MVMCoreUI/Models/Primitive Models/ColorModel.swift new file mode 100644 index 00000000..68fb16de --- /dev/null +++ b/MVMCoreUI/Models/Primitive Models/ColorModel.swift @@ -0,0 +1,95 @@ +// +// ColorModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +/** + Allows Hex values to be modeled into a UIColor object with its surrounding metadata. + */ +open class ColorModel: Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + static var identifier: String = "color" + + public let uiColor: UIColor + public var hex: String = "" + + public var red: CGFloat = 0 + public var green: CGFloat = 0 + public var blue: CGFloat = 0 + public var alpha: CGFloat = 1 + + public var hexWithHash: String { + return "#" + hex + } + + //-------------------------------------------------- + // MARK: - Class Initializer + //-------------------------------------------------- + + init(uiColor: UIColor) { + self.uiColor = uiColor + + hex = UIColor.hexString(for: uiColor) ?? "" + + if !hex.isEmpty { + determineRGBA() + } + } + + //-------------------------------------------------- + // MARK: - Codable Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + hex = try container.decode(String.self).replacingOccurrences(of: "#", with: "") + + if hex.count == 8 { + uiColor = UIColor.getColorWithTransparencyBy(hex: hex) + } else { + uiColor = UIColor.getColorBy(hex: hex) + } + + determineRGBA() + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(hexWithHash) + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func convertHexToFloat(start: String.Index, end: String.Index) -> CGFloat { + + return CGFloat(Int(hex[start.. Date: Wed, 4 Dec 2019 12:56:38 -0500 Subject: [PATCH 08/11] Add overtaking indicator to openPanel callback method. --- .../MVMCoreUIDetailViewProtocol.h | 2 ++ .../MVMCoreUISplitViewController.m | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 038769fb..377508c7 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -16,7 +16,9 @@ NS_ASSUME_NONNULL_BEGIN @optional - (void)panelWillAppear:(nonnull NSObject *)panel; +- (void)panelWillAppear:(nonnull NSObject *)panel overtakingDetail:(BOOL)willOvertake; - (void)panelDidAppear:(nonnull NSObject *)panel; +- (void)panelDidAppear:(nonnull NSObject *)panel overtakingDetail:(BOOL)didOvertake; - (void)panelWillDisappear:(nonnull NSObject *)panel; - (void)panelDidDisappear:(nonnull NSObject *)panel; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index b529ac19..b5177b9b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -357,16 +357,19 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewLeading.constant < .1) { + BOOL shouldExtendLeftPanel = [self shouldExtendLeftPanel]; + if (explict) { self.explictlyShowingPanel = self.leftPanel; } + void (^animations)(void) = [self getLeftPanelShowAnimationBlock]; void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.leftPanel animated:animated]; + [self panelDidAppear:self.leftPanel didExtend:shouldExtendLeftPanel animated:animated]; }; - if (![self shouldExtendLeftPanel]) { + if (!shouldExtendLeftPanel) { if ([self.leftPanel respondsToSelector:@selector(showArrow)]){ [self.leftPanel showArrow]; } @@ -389,7 +392,7 @@ CGFloat const PanelAnimationDuration = 0.2; } self.mainViewCoverView.hidden = NO; - [self panelWillAppear:self.leftPanel animated:animated]; + [self panelWillAppear:self.leftPanel willExtend:shouldExtendLeftPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; } else { @@ -547,19 +550,22 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewTrailing.constant < .1) { + BOOL shouldExtendRightPanel = [self shouldExtendRightPanel]; + if (explict) { self.explictlyShowingPanel = self.rightPanel; } + void (^animations)(void) = [self getRightPanelShowAnimationBlock]; void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.rightPanel animated:animated]; + [self panelDidAppear:self.rightPanel didExtend:shouldExtendRightPanel animated:animated]; self.mainView.accessibilityElementsHidden = YES; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.rightPanel); }; self.mainViewCoverView.hidden = NO; - if (![self shouldExtendRightPanel]) { + if (!shouldExtendRightPanel) { if ([self.rightPanel respondsToSelector:@selector(showArrow)]){ [self.rightPanel showArrow]; } @@ -579,7 +585,7 @@ CGFloat const PanelAnimationDuration = 0.2; self.rightPanelSeparator = rightPanelSeparator; } - [self panelWillAppear:self.rightPanel animated:animated]; + [self panelWillAppear:self.rightPanel willExtend:shouldExtendRightPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; } else { @@ -612,7 +618,7 @@ CGFloat const PanelAnimationDuration = 0.2; [self hideRightPanelIfNeededAnimated:YES]; } -- (void)panelWillAppear:(UIViewController *)panel animated:(BOOL)animated { +- (void)panelWillAppear:(UIViewController *)panel willExtend:(BOOL)willExtend animated:(BOOL)animated { if ([panel respondsToSelector:@selector(willAppear:)]) { [panel willAppear:animated]; } else { @@ -621,13 +627,15 @@ CGFloat const PanelAnimationDuration = 0.2; UIViewController *controller = [self getCurrentDetailViewController]; if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { + if ([protocolController respondsToSelector:@selector(panelWillAppear:overtakingDetail:)]) { + [protocolController panelWillAppear:panel overtakingDetail:!willExtend]; + } else if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { [protocolController panelWillAppear:panel]; } } } -- (void)panelDidAppear:(UIViewController *)panel animated:(BOOL)animated { +- (void)panelDidAppear:(UIViewController *)panel didExtend:(BOOL)didExtend animated:(BOOL)animated { if ([panel respondsToSelector:@selector(didAppear:)]) { [panel didAppear:animated]; } else { @@ -636,7 +644,9 @@ CGFloat const PanelAnimationDuration = 0.2; UIViewController *controller = [self getCurrentDetailViewController]; if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { + if ([protocolController respondsToSelector:@selector(panelDidAppear:overtakingDetail:)]) { + [protocolController panelDidAppear:panel overtakingDetail:!didExtend]; + } else if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { [protocolController panelDidAppear:panel]; } } From d95e42330eaf9bce9aacd0597983b6a84f5c9270 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Dec 2019 13:09:50 -0500 Subject: [PATCH 09/11] moving files --- MVMCoreUI.xcodeproj/project.pbxproj | 12 ++++++------ MVMCoreUI/{Atoms => Legacy}/Views/MFRadioButton.h | 0 MVMCoreUI/{Atoms => Legacy}/Views/MFRadioButton.m | 0 .../{Atoms => Legacy}/Views/MVMCoreUICheckBox.h | 0 .../{Atoms => Legacy}/Views/MVMCoreUICheckBox.m | 0 .../{Atoms => Legacy}/Views/MVMCoreUICheckMarkView.h | 0 .../{Atoms => Legacy}/Views/MVMCoreUICheckMarkView.m | 0 .../Items/DropDownFilterTableViewCell.swift | 2 +- MVMCoreUI/Organisms/MoleculeStackView.swift | 4 ++-- 9 files changed, 9 insertions(+), 9 deletions(-) rename MVMCoreUI/{Atoms => Legacy}/Views/MFRadioButton.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFRadioButton.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUICheckBox.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUICheckBox.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUICheckMarkView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MVMCoreUICheckMarkView.m (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 515e24ee..900edec2 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -454,6 +454,12 @@ D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF15921E697DA003B2FB9 /* SeparatorView.h */, D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, + D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */, + D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */, + D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */, + D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, + 0198F7A02256A80A0066C936 /* MFRadioButton.h */, + 0198F7A22256A80A0066C936 /* MFRadioButton.m */, ); path = Views; sourceTree = ""; @@ -764,16 +770,10 @@ D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, - D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */, - D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */, - D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */, - D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, - 0198F7A02256A80A0066C936 /* MFRadioButton.h */, - 0198F7A22256A80A0066C936 /* MFRadioButton.m */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, diff --git a/MVMCoreUI/Atoms/Views/MFRadioButton.h b/MVMCoreUI/Legacy/Views/MFRadioButton.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MFRadioButton.h rename to MVMCoreUI/Legacy/Views/MFRadioButton.h diff --git a/MVMCoreUI/Atoms/Views/MFRadioButton.m b/MVMCoreUI/Legacy/Views/MFRadioButton.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MFRadioButton.m rename to MVMCoreUI/Legacy/Views/MFRadioButton.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.h b/MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.h rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.m b/MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.m rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.m diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 518e3b51..31a6cc61 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -33,7 +33,7 @@ import UIKit options: [.old, .new] ) { [weak self] object, change in guard change.newValue != change.oldValue, let self = self, - let options = self.dropDown?.json?.optionalArrayForKey(KeyValue) as? [NSString], + let options = self.dropDown?.json?.optionalArrayForKey("options") as? [NSString], let index = options.firstIndex(of: change.newValue!! as NSString), let moleculesArrays = self.json?.arrayForKey(KeyMolecules) as? [[[AnyHashable: Any]]] else { return } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index cafe21b0..dc7cc81e 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -264,7 +264,7 @@ public class MoleculeStackView: ViewConstrainingView { } else if let previousView = items.last(where: { stackItem in return !stackItem.gone })?.view { - _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: true) + view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) @@ -281,7 +281,7 @@ public class MoleculeStackView: ViewConstrainingView { } else if let previousView = items.last(where: { stackItem in return !stackItem.gone })?.view { - _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: false) + view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) From c627901d7475498733a7af07843eef3e4452c38f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 4 Dec 2019 15:28:22 -0500 Subject: [PATCH 10/11] updates to color model and extension. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +-- MVMCoreUI/Categories/UIColor+Extension.swift | 70 +++++++++++++------ .../{ColorModel.swift => Color.swift} | 57 ++++++++++----- 3 files changed, 92 insertions(+), 43 deletions(-) rename MVMCoreUI/Models/Primitive Models/{ColorModel.swift => Color.swift} (63%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9215b753..779cd132 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -49,7 +49,7 @@ 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; - 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* ColorModel.swift */; }; + 0AA33B36239813EE0067DD0F /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B35239813EE0067DD0F /* Color.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -282,7 +282,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; - 0AA33B35239813EE0067DD0F /* ColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorModel.swift; sourceTree = ""; }; + 0AA33B35239813EE0067DD0F /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -532,7 +532,7 @@ 0AA33B322398134B0067DD0F /* Primitive Models */ = { isa = PBXGroup; children = ( - 0AA33B35239813EE0067DD0F /* ColorModel.swift */, + 0AA33B35239813EE0067DD0F /* Color.swift */, ); path = "Primitive Models"; sourceTree = ""; @@ -1288,7 +1288,7 @@ 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */, D22479962316AF6E003FCCF9 /* HeadlineBodyTextButton.swift in Sources */, - 0AA33B36239813EE0067DD0F /* ColorModel.swift in Sources */, + 0AA33B36239813EE0067DD0F /* Color.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 56986044..fab1ae6f 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -9,8 +9,27 @@ import UIKit +public typealias ColorHexTuple = (uiColor: UIColor, hex: String) extension UIColor { + + /// Dictionary to access brand approved colors by name. + public static let names: [String: ColorHexTuple] = ["black": (.mvmBlack, "#000000"), + "white": (.mvmWhite, "#FFFFFF"), + "red": (.mvmRed, "#D52B1E"), + "orange": (.mvmOrange, "#CC4D0F"), + "green": (.mvmGreen, "#008631"), + "blue": (.mvmBlue, "#007AB8"), + "blueGradient": (.mvmBlueGradient, "#007AB8"), + "yellow": (.mvmYellow, "#FFBC3D"), + "coolGray1": (.mvmCoolGray1, "#F6F6F6"), + "coolGray3": (.mvmCoolGray3, "#D8DADA"), + "coolGray6": (.mvmCoolGray6, "#747676"), + "vzupGold": (.vzupGold, "#B89B56"), + "vzupYellow1": (.vzupYellow1, "#F9D542"), + "vzupYellow2": (.vzupYellow2, "#F4CA53"), + "vzupYellow3": (.vzupYellow3, "#CC9B2D")] + //-------------------------------------------------- // MARK: - Brand //-------------------------------------------------- @@ -22,47 +41,47 @@ extension UIColor { public static let mvmWhite = UIColor.white /// HEX: #D52B1E - public static let mvmRed = UIColor.getColor(red: 213, green: 43, blue: 30) + public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) /// HEX: #CC4D0F - public static let mvmOrange = UIColor.getColor(red: 204, green: 77, blue: 15) + public static let mvmOrange = UIColor.color8Bits(red: 204, green: 77, blue: 15) /// HEX: #008631 - public static let mvmGreen = UIColor.getColor(red: 0, green: 134, blue: 49) + public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 49) /// HEX: #007AB8 - public static let mvmBlue = UIColor.getColor(red: 0, green: 122, blue: 184) + public static let mvmBlue = UIColor.color8Bits(red: 0, green: 122, blue: 184) /// HEX: #007AB8 - public static let mvmBlueGradient = UIColor.getColor(red: 0, green: 122, blue: 184) + public static let mvmBlueGradient = UIColor.color8Bits(red: 0, green: 122, blue: 184) /// HEX: #FFBC3D - public static let mvmYellow = UIColor.getColor(red: 255, green: 188, blue: 61) + public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) /// HEX: #F6F6F6 public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) /// HEX: #D8DADA - public static let mvmCoolGray3 = UIColor.getColor(red: 216, green: 218, blue: 218) + public static let mvmCoolGray3 = UIColor.color8Bits(red: 216, green: 218, blue: 218) /// HEX: #747676 - public static let mvmCoolGray6 = UIColor.getColor(red: 116, green: 118, blue: 118) + public static let mvmCoolGray6 = UIColor.color8Bits(red: 116, green: 118, blue: 118) //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- /// HEX: #B89B56 - public static let vzupGold = UIColor.getColor(red: 184, green: 155, blue: 68) + public static let vzupGold = UIColor.color8Bits(red: 184, green: 155, blue: 68) /// HEX: #F9D542 - public static let vzupYellow1 = UIColor.getColor(red: 249, green: 213, blue: 66) + public static let vzupYellow1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) /// HEX: #F4CA53 - public static let vzupYellow2 = UIColor.getColor(red: 244, green: 202, blue: 83) + public static let vzupYellow2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) /// HEX: #CC9B2D - public static let vzupYellow3 = UIColor.getColor(red: 204, green: 155, blue: 45) + public static let vzupYellow3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) //-------------------------------------------------- // MARK: - Functions @@ -75,14 +94,14 @@ extension UIColor { return UIColor(red: grayscale, green: grayscale, blue: grayscale, alpha: alpha) } - /// Convenience to get a UIColor via Int. - public class func getColor(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { + /// Convenience to get a UIColor. + public class func color8Bits(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { return UIColor(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha) } - /// Convenience to get a UIColor via CGFloat. - public class func getColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { + /// Convenience to get a UIColor. + public class func color8Bits(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha) } @@ -90,11 +109,11 @@ extension UIColor { /// Gets UIColor via an 8 digit hex string. public class func getColorBy(hex: String) -> UIColor { - var hexint: UInt32 = 0 + var hexint: UInt64 = 0 let scanner = Scanner(string: hex) scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") - scanner.scanHexInt32(&hexint) + scanner.scanHexInt64(&hexint) return UIColor(red: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, green: (CGFloat((hexint & 0xFF00) >> 8)) / 255, @@ -105,11 +124,11 @@ extension UIColor { /// Gets UIColor via an 8 digit hex string. The last two being the alpha channel. public class func getColorWithTransparencyBy(hex: String) -> UIColor { - var hexint: UInt32 = 0 + var hexint: UInt64 = 0 let scanner = Scanner(string: hex) scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") - scanner.scanHexInt32(&hexint) + scanner.scanHexInt64(&hexint) return UIColor(red: (CGFloat((hexint & 0xFF000000) >> 24)) / 255, green: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, @@ -177,4 +196,15 @@ extension UIColor { return nil } + + public class func getColorAndHexFromName(_ name: String) -> ColorHexTuple? { + + for row in names { + if name == row.key { + return row.value + } + } + + return nil + } } diff --git a/MVMCoreUI/Models/Primitive Models/ColorModel.swift b/MVMCoreUI/Models/Primitive Models/Color.swift similarity index 63% rename from MVMCoreUI/Models/Primitive Models/ColorModel.swift rename to MVMCoreUI/Models/Primitive Models/Color.swift index 68fb16de..cafe5915 100644 --- a/MVMCoreUI/Models/Primitive Models/ColorModel.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -1,5 +1,5 @@ // -// ColorModel.swift +// Color.swift // MVMCoreUI // // Created by Kevin Christiano on 11/26/19. @@ -8,40 +8,49 @@ import UIKit -/** - Allows Hex values to be modeled into a UIColor object with its surrounding metadata. - */ -open class ColorModel: Codable { + +public final class Color: Codable { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - static var identifier: String = "color" - public let uiColor: UIColor - public var hex: String = "" + public private(set) var hex: String = "" + public private(set) var name: String = "" - public var red: CGFloat = 0 - public var green: CGFloat = 0 - public var blue: CGFloat = 0 - public var alpha: CGFloat = 1 + // Color metadata + public private(set) var red: CGFloat = 0 + public private(set) var green: CGFloat = 0 + public private(set) var blue: CGFloat = 0 + public private(set) var alpha: CGFloat = 1 public var hexWithHash: String { return "#" + hex } //-------------------------------------------------- - // MARK: - Class Initializer + // MARK: - Error + //-------------------------------------------------- + + enum ColorError: Error { + case badName(reason: String) + } + + //-------------------------------------------------- + // MARK: - Class Initializers //-------------------------------------------------- init(uiColor: UIColor) { self.uiColor = uiColor - hex = UIColor.hexString(for: uiColor) ?? "" - - if !hex.isEmpty { - determineRGBA() - } + determineRGBA() + } + + init?(name: String) { + guard let colorTuple = UIColor.getColorAndHexFromName(name) else { return nil } + self.uiColor = colorTuple.uiColor + self.hex = colorTuple.hex + determineRGBA() } //-------------------------------------------------- @@ -50,7 +59,15 @@ open class ColorModel: Codable { required public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - hex = try container.decode(String.self).replacingOccurrences(of: "#", with: "") + let colorString = try container.decode(String.self) + + if colorString.hasPrefix("#") { + hex = colorString.replacingOccurrences(of: "#", with: "") + } else { + guard let hex = UIColor.getColorAndHexFromName(colorString)?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") } + self.hex = hex.replacingOccurrences(of: "#", with: "") + name = colorString + } if hex.count == 8 { uiColor = UIColor.getColorWithTransparencyBy(hex: hex) @@ -77,6 +94,8 @@ open class ColorModel: Codable { private func determineRGBA() { + guard !hex.isEmpty else { return } + let redStart = hex.startIndex let redEnd = hex.index(redStart, offsetBy: 2) red = convertHexToFloat(start: redStart, end: redEnd) From b7ff1354b8085724796b755f64776e4314969a91 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 4 Dec 2019 16:21:10 -0500 Subject: [PATCH 11/11] clean up --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++-- MVMCoreUI/Atoms/Views/CaretViewModel.swift | 3 +- MVMCoreUI/Atoms/Views/DashLineModel.swift | 2 +- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 1 + .../Atoms/Views/LabelModel/LabelModel.swift | 3 +- .../Atoms/Views/MultiProgressModel.swift | 1 + .../ViewConstrainingView+ModelExtension.swift | 24 ++++++++------- .../Models/ContainerMoleculeProtocol.swift | 17 +++++++++++ MVMCoreUI/Models/MoleculeProtocol.swift | 30 ------------------- .../Models/Molecules/HeadlineBodyModel.swift | 3 +- MVMCoreUI/Models/Molecules/LineModel.swift | 5 ++-- .../Models/Molecules/ListItemModel.swift | 4 +-- .../Molecules/MoleculeStackItemModel.swift | 5 ++-- .../Models/Molecules/MoleculeStackModel.swift | 4 +-- .../Models/Molecules/SeperatorModel.swift | 1 + .../Models/Molecules/TextFieldModel.swift | 2 ++ 16 files changed, 53 insertions(+), 60 deletions(-) create mode 100644 MVMCoreUI/Models/ContainerMoleculeProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c937cee8..8e1c2a00 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -12,6 +12,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 */; }; 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; }; + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; @@ -85,9 +86,9 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; - D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -247,6 +248,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 = ""; }; 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; @@ -499,6 +501,7 @@ 0AA33B322398134B0067DD0F /* Primitive Models */, 017BEB392360EEB40024EF95 /* PageModel.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, @@ -926,7 +929,7 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, - 94C2D9822386F3E30006CF46 /* LabelModel */, + 94C2D9822386F3E30006CF46 /* LabelModel */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, @@ -1288,6 +1291,7 @@ D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index c0f3ee8c..481d086f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -9,8 +9,9 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { + public static var identifier: String = "caretView" - public var moleculeName: String + public var backgroundColor: String? public var strokeColor: String? public var isHidden: Bool? diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 8fd26fbf..6fff83c7 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -11,8 +11,8 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { public static var identifier: String = "dashLine" public var moleculeName: String + public var backgroundColor: String? public var dashColor: String public var isHidden: Bool? - public var backgroundColor: String? } diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 2c9a6dd4..16c32d8f 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" public var moleculeName: String + public var backgroundColor: String? public var image: String public var accessibilityText: String? diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index cd1c5d12..d2c7947f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -12,10 +12,11 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" public var moleculeName: String? + public var backgroundColor: String? + public var text: String public var accessibilityText: String? public var textColor: String? - public var backgroundColor: String? public var fontStyle: String? public var fontName: String? public var fontSize: CGFloat? diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index d63183e4..25522070 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -17,6 +17,7 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String + public var backgroundColor: String? public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift index 1e4cd849..90377f84 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift @@ -30,18 +30,20 @@ extension ViewConstrainingView { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) } - if let useHorizontalMargins = model?.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - if let useVerticalMargins = model?.useVerticalMargins { - updateViewVerticalDefaults = useVerticalMargins - } + if let containerMoleculeModel = model as? ContainerMoleculeProtocol { + if let useHorizontalMargins = containerMoleculeModel.useHorizontalMargins { + updateViewHorizontalDefaults = useHorizontalMargins + } + if let useVerticalMargins = containerMoleculeModel.useVerticalMargins { + updateViewVerticalDefaults = useVerticalMargins + } - if let horizontalAlignment = model?.horizontalAlignment { - alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) - } - if let verticalAlignment = model?.verticalAlignment { - alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + if let horizontalAlignment = containerMoleculeModel.horizontalAlignment { + alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) + } + if let verticalAlignment = containerMoleculeModel.verticalAlignment { + alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + } } #warning("work on the below") diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift new file mode 100644 index 00000000..be3ffa60 --- /dev/null +++ b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift @@ -0,0 +1,17 @@ +// +// ContainerMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/4/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +protocol ContainerMoleculeProtocol: MoleculeProtocol { + var molecule: MoleculeProtocol? { get } + var useHorizontalMargins: Bool? { get } + var useVerticalMargins: Bool? { get } + var horizontalAlignment: String? { get } + var verticalAlignment: String? { get } +} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index e8120568..53f0fee4 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -4,42 +4,12 @@ public protocol MoleculeProtocol: Model { var moleculeName: String? { get } var backgroundColor: String? { get } var dictionary: [AnyHashable: Any]? { get } - var molecule: MoleculeProtocol? { get } - - var useHorizontalMargins: Bool? { get } - var useVerticalMargins: Bool? { get } - var horizontalAlignment: String? { get } - var verticalAlignment: String? { get } } extension MoleculeProtocol { public var moleculeName: String? { get { return Self.identifier } } - - public var molecule: MoleculeProtocol? { - get { return nil } - } - - public var backgroundColor: String? { - get { return toJSON()?["backgroundColor"] as? String } - } - - public var useHorizontalMargins: Bool? { - get { return toJSON()?["useHorizontalMargins"] as? Bool } - } - - public var useVerticalMargins: Bool? { - get { return toJSON()?["useVerticalMargins"] as? Bool } - } - - public var horizontalAlignment: String? { - get { return toJSON()?["horizontalAlignment"] as? String } - } - - public var verticalAlignment: String? { - get { return toJSON()?["verticalAlignment"] as? String } - } public var dictionary: [AnyHashable: Any]? { return toJSON() diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index 557e74ba..76337703 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -10,12 +10,11 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? + public var backgroundColor: String? public var headline: LabelModel? public init(headline: LabelModel?) { self.headline = headline - self.moleculeName = Self.identifier } } diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index 6266b03e..e00ba1fc 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -10,11 +10,10 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { public static var identifier: String = "line" - public var moleculeName: String? + public var backgroundColor: String? public var type: String? public init(type: String?) { - self.type = type - self.moleculeName = Self.identifier + self.type = type } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index da14a602..cd2fa39f 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -10,14 +10,13 @@ import Foundation @objcMembers public class ListItemModel: MoleculeProtocol { public static var identifier: String = "listItem" - public var moleculeName: String? public var molecule: MoleculeProtocol? + public var backgroundColor: String? public var action: ActionModel? public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { self.molecule = molecule self.action = actionMap - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { @@ -28,7 +27,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 5bceda3e..c1ab6b15 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,12 +10,12 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "stackItem" - public var moleculeName: String? + public var molecule: MoleculeProtocol? + public var backgroundColor: String? public init(molecule: MoleculeProtocol?) { self.molecule = molecule - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { case moleculeName @@ -24,7 +24,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 30c15822..1ca9b9da 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -11,14 +11,13 @@ import Foundation @objcMembers public class MoleculeStackModel: MoleculeProtocol { public static var identifier: String = "moleculeStack" - public var moleculeName: String? + public var backgroundColor: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? public init(axis: String?, molecules: [MoleculeStackItemModel]?) { self.axis = axis self.molecules = molecules - self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { @@ -29,7 +28,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules) self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index 705f904c..4c9689fd 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -10,5 +10,6 @@ import UIKit class SeperatorModel: MoleculeProtocol { public static var identifier: String = "line" + public var backgroundColor: String? public var type: String? } diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index 77454895..f9b11d5f 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -9,7 +9,9 @@ import UIKit @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { + public static var identifier: String = "textField" + public var backgroundColor: String? public var editable = true public var disabled = false