diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b6dd6768..fceb829b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -74,6 +74,8 @@ 0A25209824645B76000FA9F6 /* TextViewEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; + 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */; }; + 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; 0A6682A22434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */; }; 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */; }; @@ -82,6 +84,7 @@ 0A6682B5243769C700AD3CA1 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682B3243769C700AD3CA1 /* TextView.swift */; }; 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; + 0A6C1FC324927E2E00E64B52 /* colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A6C1FC224927E2E00E64B52 /* colors.xcassets */; }; 0A775F2624893916009EFB58 /* ThreeHeadlineBodyLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */; }; 0A775F2824893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; @@ -230,6 +233,8 @@ AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C10724346F4B00151545 /* RadioSwatches.swift */; }; AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C109243496DD00151545 /* RadioSwatch.swift */; }; AAC6F167243332E400F295C1 /* RadioSwatchesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */; }; + AAE7270C24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */; }; + AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -533,6 +538,8 @@ 0A25209724645B76000FA9F6 /* TextViewEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewEntryFieldModel.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; + 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinnerModel.swift; sourceTree = ""; }; + 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingSpinner.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyText.swift; sourceTree = ""; }; 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyTextModel.swift; sourceTree = ""; }; @@ -541,6 +548,7 @@ 0A6682B3243769C700AD3CA1 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = ""; }; 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; + 0A6C1FC224927E2E00E64B52 /* colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = colors.xcassets; path = MVMCoreUI/Categories/colors.xcassets; sourceTree = SOURCE_ROOT; }; 0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeHeadlineBodyLink.swift; sourceTree = ""; }; 0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeHeadlineBodyLinkModel.swift; sourceTree = ""; }; 0A7918F423F5E7EA00772FF4 /* ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = ""; }; @@ -692,6 +700,8 @@ AAB9C10724346F4B00151545 /* RadioSwatches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatches.swift; sourceTree = ""; }; AAB9C109243496DD00151545 /* RadioSwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchesModel.swift; sourceTree = ""; }; + AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLinkModel.swift; sourceTree = ""; }; + AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1552,6 +1562,8 @@ AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */, AA71AD3D24A32FCE00ACA76F /* HeadersH2LinkModel.swift */, AA71AD3F24A32FE700ACA76F /* HeadersH2Link.swift */, + AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */, + AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */, ); path = H2; sourceTree = ""; @@ -1810,6 +1822,8 @@ 94382085243238D100B43AF3 /* WebViewModel.swift */, 943820832432382400B43AF3 /* WebView.swift */, D20492A524329CE200A5EED6 /* LoadImageView.swift */, + 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */, + 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */, ); path = Views; sourceTree = ""; @@ -1894,6 +1908,7 @@ D29DF26621E6A9E4003B2FB9 /* ThirdParty */, D29DF31521ECECC0003B2FB9 /* Fonts */, D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */, + 0A6C1FC224927E2E00E64B52 /* colors.xcassets */, ); path = SupportingFiles; sourceTree = ""; @@ -2112,6 +2127,7 @@ files = ( 94CA227C24058534002D6750 /* VerizonNHGeTX-Bold.otf in Resources */, D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */, + 0A6C1FC324927E2E00E64B52 /* colors.xcassets in Resources */, 94CA227D24058534002D6750 /* VerizonNHGeDS-Regular.otf in Resources */, D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */, 94CA227E24058534002D6750 /* VerizonNHGeDS-Bold.otf in Resources */, @@ -2395,6 +2411,7 @@ 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */, BB6C6AC0242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTallModel.swift in Sources */, 8DEFA95E243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift in Sources */, + AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, 324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, @@ -2426,6 +2443,7 @@ 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */, D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */, 0AE14F64238315D2005417F8 /* TextField.swift in Sources */, + 0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */, 0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */, BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */, D253BB9C245874F8002DE544 /* BGImageMolecule.swift in Sources */, @@ -2455,6 +2473,7 @@ 0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */, 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */, D28A837D23CCA86A00DFE4FC /* TabsListItemModel.swift in Sources */, + 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */, BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, @@ -2496,6 +2515,7 @@ D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */, AA104B1C24474A76004D2810 /* HeadersH2ButtonsModel.swift in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, + AAE7270C24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift in Sources */, BB6C6AC824225290005F7224 /* ListOneColumnTextWithWhitespaceDividerShort.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, D21B7F73243BAC6800051ABF /* CollectionItemModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitEntryField.swift index 18f61b2d..b1f202a8 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/DigitEntryField.swift @@ -25,12 +25,9 @@ import UIKit if numberOfDigits > 0 { var digitBoxes = [DigitBox]() - let ordinalFormatter = NumberFormatter() - ordinalFormatter.numberStyle = .ordinal - for i in 0.. CGFloat? { + return 40.0 + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift new file mode 100644 index 00000000..bdef3c86 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift @@ -0,0 +1,65 @@ +// +// LoadingSpinnerModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 5/20/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +open class LoadingSpinnerModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var backgroundColor: Color? + public static var identifier: String = "loadingSpinner" + public var strokeColor = Color(uiColor: .mvmBlack) + public var lineWidth: CGFloat = 4 + public var diameter: CGFloat = 40 + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case strokeColor + case lineWidth + case diameter + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + + if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) { + self.diameter = diameter + } + + if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) { + self.strokeColor = strokeColor + } + + if let lineWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .lineWidth) { + self.lineWidth = lineWidth + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(diameter, forKey: .diameter) + try container.encode(strokeColor, forKey: .strokeColor) + try container.encode(lineWidth, forKey: .lineWidth) + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 02373958..dfffcded 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -392,8 +392,23 @@ public typealias ActionBlockConfirmation = () -> (Bool) accessibilityLabel = accessibileString } - if let actionMap = model.action?.toJSON() { - didToggleAction = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } + let actionMap = model.action?.toJSON() + let alternateActionMap = model.alternateAction?.toJSON() + if actionMap != nil || alternateActionMap != nil { + didToggleAction = { [weak self] in + guard let self = self else { return } + if self.isOn { + if actionMap != nil { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } else { + if alternateActionMap != nil { + MVMCoreActionHandler.shared()?.handleAction(with: alternateActionMap, additionalData: additionalData, delegateObject: delegateObject) + } else if actionMap != nil { + MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) + } + } + } } } diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index fbb2fe8c..5a3a3a1f 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -48,12 +48,12 @@ import Foundation /// Call to register all of the CoreUI molecules. public static func registerObjects() { - // Stacks + // MARK:- Stacks MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: StackModel.self) MoleculeObjectMapping.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self) MoleculeObjectMapping.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self) - // Label + // MARK:- Label MoleculeObjectMapping.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self) // need to move labelattributemodel to different method try? ModelRegistry.register(LabelAttributeFontModel.self) @@ -63,24 +63,24 @@ import Foundation try? ModelRegistry.register(LabelAttributeStrikeThroughModel.self) try? ModelRegistry.register(LabelAttributeActionModel.self) - // TextView + // MARK:- TextView MoleculeObjectMapping.shared()?.register(viewClass: TextViewEntryField.self, viewModelClass: TextViewEntryFieldModel.self) - // Buttons + // MARK:- Buttons MoleculeObjectMapping.shared()?.register(viewClass: PillButton.self, viewModelClass: ButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: TwoButtonView.self, viewModelClass: TwoButtonViewModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ExternalLink.self, viewModelClass: ExternalLinkModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Link.self, viewModelClass: LinkModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CaretLink.self, viewModelClass: CaretLinkModel.self) - // Entry Field + // MARK:- Entry Field MoleculeObjectMapping.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextEntryFieldModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self) MoleculeObjectMapping.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self) MoleculeObjectMapping.shared()?.register(viewClass: DateDropdownEntryField.self, viewModelClass: DateDropdownEntryFieldModel.self) - // Selectors + // MARK:- Selectors MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioBoxes.self, viewModelClass: RadioBoxesModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self) @@ -90,7 +90,7 @@ import Foundation - // Other Atoms + // MARK:- Other Atoms MoleculeObjectMapping.shared()?.register(viewClass: ProgressBar.self, viewModelClass: ProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MultiProgress.self, viewModelClass: MultiProgressBarModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CaretView.self, viewModelClass: CaretViewModel.self) @@ -103,14 +103,15 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self) MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self) - - // Horizontal Combination Molecules + MoleculeObjectMapping.shared()?.register(viewClass: LoadingSpinner.self, viewModelClass: LoadingSpinnerModel.self) + + // MARK:- Horizontal Combination Molecules MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ImageHeadlineBody.self, viewModelClass: ImageHeadlineBodyModel.self) MoleculeObjectMapping.shared()?.register(viewClass: Tabs.self, viewModelClass: TabsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: TwoLinkView.self, viewModelClass: TwoLinkViewModel.self) - // Vertical Combination Molecules + // MARK:- Vertical Combination Molecules MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadLineBodyCaretLinkImage.self, viewModelClass: HeadlineBodyCaretLinkImageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: EyebrowHeadlineBodyLink.self, viewModelClass: EyebrowHeadlineBodyLinkModel.self) @@ -119,7 +120,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: BGImageHeadlineBodyButton.self, viewModelClass: BGImageHeadlineBodyButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ThreeHeadlineBodyLink.self, viewModelClass: ThreeHeadlineBodyLinkModel.self) - // Left Right Molecules + // MARK:- Left Right Molecules MoleculeObjectMapping.shared()?.register(viewClass: CornerLabels.self, viewModelClass: CornerLabelsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: LeftRightLabelView.self, viewModelClass: LeftRightLabelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: LabelToggle.self, viewModelClass: LabelToggleModel.self) @@ -127,21 +128,21 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - // List items + // MARK:- List items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: DropDownFilterTableViewCell.self, viewModelClass: DropDownListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: AccordionMoleculeTableViewCell.self, viewModelClass: AccordionListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: TabsTableViewCell.self, viewModelClass: TabsListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarData.self, viewModelClass: ListProgressBarDataModel.self) - // Other Items + // MARK:- Other Items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: MoleculeCollectionItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CarouselItem.self, viewModelClass: CarouselItemModel.self) - // Other Container Molecules + // MARK:- Other Container Molecules MoleculeObjectMapping.shared()?.register(viewClass: MoleculeContainer.self, viewModelClass: MoleculeContainerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MoleculeHeaderView.self, viewModelClass: MoleculeHeaderModel.self) MoleculeObjectMapping.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self) @@ -149,7 +150,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ModuleMolecule.self, viewModelClass: ModuleMoleculeModel.self) MoleculeObjectMapping.shared()?.register(viewClass: BGImageMolecule.self, viewModelClass: BGImageMoleculeModel.self) - // Other Molecules + // MARK:- Other Molecules MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self) // Navigation Molecules @@ -157,12 +158,12 @@ import Foundation try? ModelRegistry.register(NavigationImageButtonModel.self) try? ModelRegistry.register(NavigationLabelButtonModel.self) - // Other Organisms + // MARK:- Other Organisms MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self) MoleculeObjectMapping.shared()?.register(viewClass: BarsIndicatorView.self, viewModelClass: BarsCarouselIndicatorModel.self) MoleculeObjectMapping.shared()?.register(viewClass: NumericIndicatorView.self, viewModelClass: NumericCarouselIndicatorModel.self) - // Designed List Items + // MARK:- Designed List Items MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaretBodyText.self, viewModelClass: ListLeftVariableIconWithRightCaretBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) @@ -192,7 +193,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarThin.self, viewModelClass: ListProgressBarThinModel.self) - // Designed Section Dividers + // MARK:- Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self) @@ -204,7 +205,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillChangesDivider.self, viewModelClass: ListThreeColumnBillChangesDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsageDivider.self, viewModelClass: ListThreeColumnDataUsageDividerModel.self) - // Designed Headers + // MARK:- Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH1Button.self, viewModelClass: HeadersH1ButtonModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH1LandingPageHeader.self, viewModelClass: HeadersH1LandingPageHeaderModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self) @@ -212,15 +213,16 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2Buttons.self, viewModelClass: HeadersH2ButtonsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2PricingTwoRows.self, viewModelClass: HeadersH2PricingTwoRowsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2Link.self, viewModelClass: HeadersH2LinkModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2CaretLink.self, viewModelClass: HeadersH2CaretLinkModel.self) - // Device Items + // MARK:- Device Items MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonMedium.self, viewModelClass: ListDeviceComplexButtonMediumModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexButtonSmall.self, viewModelClass: ListDeviceComplexButtonSmallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkSmall.self, viewModelClass: ListDeviceComplexLinkSmallModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self) - // Helper models + // MARK:- Helper models try? ModelRegistry.register(RuleRequiredModel.self) try? ModelRegistry.register(RuleAnyRequiredModel.self) try? ModelRegistry.register(RuleAnyValueChangedModel.self) @@ -229,12 +231,12 @@ import Foundation try? ModelRegistry.register(RuleEqualsIgnoreCaseModel.self) try? ModelRegistry.register(RuleRegexModel.self) - // Actions + // MARK:- Actions try? ModelRegistry.register(ActionTopAlertModel.self) try? ModelRegistry.register(ActionCollapseNotificationModel.self) try? ModelRegistry.register(ActionOpenPanelModel.self) - // Behaviors + // MARK:- Behaviors try? ModelRegistry.register(ScreenBrightnessModifierBehavior.self) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift new file mode 100644 index 00000000..1aaf092f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLink.swift @@ -0,0 +1,58 @@ +// +// HeadersH2CaretLink.swift +// MVMCoreUI +// +// Created by Lekshmi S on 01/07/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class HeadersH2CaretLink: HeaderView { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + public let headlineBody = HeadlineBody() + public let caretLink = CaretLink() + public let stack: Stack + + //------------------------------------------------------- + // MARK: - Initializers + //------------------------------------------------------- + public override init(frame: CGRect) { + stack = Stack.createStack(with: [headlineBody, caretLink]) + super.init(frame: frame) + } + + public required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + headlineBody.stylePageHeader() + addMolecule(stack) + stack.restack() + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? HeadersH2CaretLinkModel else { return } + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + caretLink.set(with: model.caretLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 121 + } + + open override func reset() { + super.reset() + headlineBody.stylePageHeader() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift new file mode 100644 index 00000000..9d56118e --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift @@ -0,0 +1,66 @@ +// +// HeadersH2CaretLinkModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 01/07/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "headerH2CrtBtn" + public var headlineBody: HeadlineBodyModel + public var caretLink: CaretLinkModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(headlineBody: HeadlineBodyModel, caretLink: CaretLinkModel) { + self.headlineBody = headlineBody + self.caretLink = caretLink + super.init() + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public override func setDefaults() { + if topPadding == nil { + topPadding = Padding.Component.VerticalMarginSpacing + } + if bottomPadding == nil { + bottomPadding = Padding.Component.VerticalMarginSpacing + } + super.setDefaults() + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case headlineBody + case caretLink + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) + caretLink = try typeContainer.decode(CaretLinkModel.self, forKey: .caretLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(headlineBody, forKey: .headlineBody) + try container.encode(caretLink, forKey: .caretLink) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift index 86dee27a..97582574 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift @@ -33,10 +33,9 @@ public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtoco //-------------------------------------------------- override public func setDefaults() { + style = ListItemStyle.none super.setDefaults() - - style = "none" - + if leftLabel.textColor == nil { leftLabel.textColor = Color(uiColor: .mvmCoolGray6) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift index 1c161bd4..a094f91c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/FourColumn/ListFourColumnDataUsageDividerModel.swift @@ -33,8 +33,8 @@ public class ListFourColumnDataUsageDividerModel: ListItemModel, MoleculeModelPr } override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift index 34687957..063c8cfa 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnFullWidthTextDividerSubsectionModel.swift @@ -33,8 +33,8 @@ public class ListOneColumnFullWidthTextDividerSubsectionModel: ListItemModel, Mo //-------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift index d63ea18b..f6303a85 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift @@ -33,8 +33,8 @@ public class ListOneColumnTextWithWhitespaceDividerShortModel: ListItemModel, Mo //-------------------------------------------------- override public func setDefaults() { + style = .shortDivider super.setDefaults() - style = "shortDivider" } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift index d8119802..e3bb634d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -33,8 +33,8 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol //-------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift index 6f824fff..965de291 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillChangesDividerModel.swift @@ -35,8 +35,8 @@ public class ListThreeColumnBillChangesDividerModel: ListItemModel, MoleculeMode //----------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift index 93efb963..268e68e9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnDataUsageDividerModel.swift @@ -35,8 +35,8 @@ public class ListThreeColumnDataUsageDividerModel: ListItemModel, MoleculeModelP //----------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift index b4909581..f7df0c3a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift @@ -35,8 +35,8 @@ public class ListThreeColumnInternationalDataDividerModel: ListItemModel, Molecu //------------------------------------------------------ override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift index 6b29f58e..84357252 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnPlanDataDividerModel.swift @@ -35,8 +35,8 @@ public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelPr //----------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" leftHeadlineBody.style = .itemHeader centerHeadlineBody.style = .itemHeader rightHeadlineBody.style = .itemHeader diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift index 0e627c2a..fa7ad9f7 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnSpeedTestDividerModel.swift @@ -35,8 +35,8 @@ public class ListThreeColumnSpeedTestDividerModel: ListItemModel, MoleculeModelP //----------------------------------------------------- override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift index 0cb938ad..407764f2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/TwoColumn/ListTwoColumnSubsectionDividerModel.swift @@ -33,8 +33,8 @@ public class ListTwoColumnSubsectionDividerModel: ListItemModel, MoleculeModelPr //------------------------------------------------------ override public func setDefaults() { + style = .tallDivider super.setDefaults() - style = "tallDivider" } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift index deb2374b..693874e6 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownListItemModel.swift @@ -24,10 +24,10 @@ import Foundation /// Defaults to set public override func setDefaults() { + style = .sectionFooter super.setDefaults() hideArrow = true line = LineModel(type: .none) - style = "sectionFooter" } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift index 81b896f0..fcee1166 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -19,7 +20,7 @@ import Foundation public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? - public var style: String? + public var style: ListItemStyle? = .standard //-------------------------------------------------- // MARK: - Keys @@ -39,17 +40,39 @@ import Foundation /// Defaults to set open override func setDefaults() { - if useHorizontalMargins == nil { - useHorizontalMargins = true + setByStyle() + } + + /// Convenience function to set common values. + open func set(useHorizontalMargins: Bool? = true, useVerticalMargins: Bool? = true, topPadding: CGFloat? = nil, bottomPadding: CGFloat? = nil) { + if self.useHorizontalMargins == nil { + self.useHorizontalMargins = useHorizontalMargins } - if useVerticalMargins == nil { - useVerticalMargins = true + if self.useVerticalMargins == nil { + self.useVerticalMargins = useVerticalMargins } - if topPadding == nil { - topPadding = 24 + if self.topPadding == nil { + self.topPadding = topPadding } - if bottomPadding == nil { - bottomPadding = 24 + if self.bottomPadding == nil { + self.bottomPadding = bottomPadding + } + } + + /// Convenience function to set common values based on style. + open func setByStyle() { + guard let style = style else { return } + switch style { + case .standard: + set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing) + case .shortDivider: + set(topPadding: Padding.Component.LargeVerticalMarginSpacing, bottomPadding: Padding.Four) + case .tallDivider: + set(topPadding: Padding.Twelve, bottomPadding: Padding.Four) + case .sectionFooter: + set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: 0) + case ListItemStyle.none: + set(topPadding: 0, bottomPadding: 0) } } @@ -57,6 +80,12 @@ import Foundation // MARK: - Initializer //-------------------------------------------------- + public init(style: ListItemStyle? = .standard, action: ActionModelProtocol?) { + self.style = style + self.action = action + super.init() + } + public override init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil, useHorizontalMargins: Bool? = nil, leftPadding: CGFloat? = nil, rightPadding: CGFloat? = nil, useVerticalMargins: Bool? = nil, topPadding: CGFloat? = nil, bottomPadding: CGFloat? = nil) { super.init(horizontalAlignment: horizontalAlignment, verticalAlignment: verticalAlignment, useHorizontalMargins: useHorizontalMargins, leftPadding: leftPadding, rightPadding: rightPadding, useVerticalMargins: useVerticalMargins, topPadding: topPadding, bottomPadding: bottomPadding) } @@ -75,7 +104,9 @@ import Foundation action = try typeContainer.decodeModelIfPresent(codingKey: .action) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + if let style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style) { + self.style = style + } try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift index 5d0fee08..b13ff039 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ListItemModelProtocol.swift @@ -8,12 +8,19 @@ import Foundation +public enum ListItemStyle: String, Codable { + case standard + case shortDivider + case tallDivider + case sectionFooter + case none +} public protocol ListItemModelProtocol: ContainerModelProtocol { var line: LineModel? { get set } var action: ActionModelProtocol? { get set } var hideArrow: Bool? { get set } - var style: String? { get set } + var style: ListItemStyle? { get set } } // Not a strict requirement. @@ -24,7 +31,7 @@ public extension ListItemModelProtocol { set { } } - var style: String? { + var style: ListItemStyle? { get { return nil } set { } } diff --git a/MVMCoreUI/Atomic/Protocols/TabBarProtocol.swift b/MVMCoreUI/Atomic/Protocols/TabBarProtocol.swift index 1bf79795..19c7e107 100644 --- a/MVMCoreUI/Atomic/Protocols/TabBarProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TabBarProtocol.swift @@ -9,6 +9,9 @@ import Foundation @objc public protocol TabBarProtocol { + + var delegateObject: MVMCoreUIDelegateObject? { get set } + /// Should visually select the given tab index. @objc func highlightTab(at index: Int) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 04280042..4696ce38 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -11,16 +11,23 @@ import Foundation public protocol TemplateProtocol: AnyObject { associatedtype TemplateModel: TemplateModelProtocol var templateModel: TemplateModel? { get set } + + func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel } public extension TemplateProtocol where Self: ViewController { + func parseTemplate(json: [AnyHashable: Any]?) throws { guard let pageJSON = json else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() try decoder.add(delegateObject: delegateObjectIVar) - let templateModel = try decoder.decode(TemplateModel.self, from: data) - self.templateModel = templateModel + self.templateModel = try decodeTemplate(using: decoder, from: data) self.pageModel = templateModel as? MVMControllerModelProtocol } + + func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel { + return try decoder.decode(TemplateModel.self, from: data) + } + } diff --git a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift index b239bd81..b2b52573 100644 --- a/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ListPageTemplateModel.swift @@ -8,12 +8,12 @@ import Foundation -@objcMembers public class ListPageTemplateModel: ThreeLayerModelBase { +@objcMembers open class ListPageTemplateModel: ThreeLayerModelBase { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public override class var identifier: String { + open override class var identifier: String { return "list" } public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? @@ -49,7 +49,7 @@ import Foundation try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModelsIfPresent(molecules, forKey: .molecules) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 4be4e025..372ae778 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -28,6 +28,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol try super.parsePageJSON() } + // For subclassing the model. + open func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ListPageTemplateModel { + return try decoder.decode(ListPageTemplateModel.self, from: data) + } + open override var loadObject: MVMCoreLoadObject? { didSet { guard loadObject != oldValue else { return } diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index 01753414..bb8bb104 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -9,7 +9,8 @@ import Foundation -@objcMembers public class TemplateModel: MVMControllerModelProtocol, TabPageModelProtocol { +@objcMembers open class TemplateModel: MVMControllerModelProtocol, TabPageModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift index f0276979..1120b0e7 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ThreeLayerModelBase: TemplateModel, ThreeLayerTemplateModelProtocol { +@objcMembers open class ThreeLayerModelBase: TemplateModel, ThreeLayerTemplateModelProtocol { public var anchorHeader: Bool = false public var header: MoleculeModelProtocol? public var anchorFooter: Bool = false diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 300150e8..bb5871d0 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -31,60 +31,33 @@ import UIKit private var initialSetupPerformed = false // MARK: - Styling - open func style(with styleString: String?) { - guard let styleString = styleString else { - return - } - switch styleString { - case "standard": - styleStandard() - case "shortDivider": - styleShortDivider() - case "tallDivider": - styleTallDivider() - case "sectionFooter": - styleFooter() - case "none": - styleNone() + open func styleLine(with style: ListItemStyle?) { + switch style { + case .standard?: + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.standard) + case .shortDivider?: + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.thin) + case .tallDivider?: + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.thin) + case .sectionFooter?: + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.none) + case ListItemStyle.none?: + topSeparatorView?.setStyle(.none) + bottomSeparatorView?.setStyle(.none) default: break } } + /// Default state. open func styleStandard() { - listItemModel?.topPadding = 24 - listItemModel?.bottomPadding = 24 - topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.standard) + MFStyler.setMarginsFor(self, size: MVMCoreUIUtility.getWidth(), defaultHorizontal: true, top: Padding.Component.VerticalMarginSpacing, bottom: Padding.Component.VerticalMarginSpacing) + styleLine(with: .standard) } - - open func styleTallDivider() { - listItemModel?.topPadding = 48 - listItemModel?.bottomPadding = 16 - topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.thin) - } - - open func styleShortDivider() { - listItemModel?.topPadding = 32 - listItemModel?.bottomPadding = 16 - topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.thin) - } - - open func styleFooter() { - listItemModel?.topPadding = 24 - listItemModel?.bottomPadding = 0 - topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.none) - } - - open func styleNone() { - listItemModel?.topPadding = 0 - listItemModel?.bottomPadding = 0 - topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.none) - } - + /// Adds the molecule to the view. open func addMolecule(_ molecule: MoleculeViewProtocol) { contentView.addSubview(molecule) @@ -156,7 +129,7 @@ import UIKit guard let model = model as? ListItemModelProtocol else { return } self.listItemModel = model - style(with: model.style) + styleLine(with: model.style) // Add the caret if there is an action and it's not declared hidden. if !customAccessoryView { diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 8c63ed51..228dbdcb 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -94,9 +94,10 @@ import UIKit try parsePageJSON() MVMCoreDispatchUtility.performBlock(onMainThread: { self.handleNewDataAndUpdateUI() - // If the screen is showing, can update the navigation controller. - if MVMCoreUIUtility.getCurrentVisibleController() == self.manager ?? self { - self.setNavigationController() + + // Update navigation bar if showing. + if MVMCoreUIUtility.getCurrentVisibleController() == self { + self.setNavigationBar() } }) } catch { @@ -157,7 +158,7 @@ import UIKit open func parsePageJSON() throws { } - + open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: AutoreleasingUnsafeMutablePointer) -> Bool { guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType), !modulesRequired.isEmpty else { return true } @@ -196,12 +197,6 @@ import UIKit /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { - // TODO: remove legacy. Temporary, convert legacy to navigation model. - if pageModel?.navigationBar == nil { - let navigationItem = createDefaultLegacyNavigationModel() - pageModel?.navigationBar = navigationItem - } - if formValidator == nil { let rules = pageModel?.formRules formValidator = FormValidator(rules) @@ -210,20 +205,43 @@ import UIKit if let backgroundColor = pageModel?.backgroundColor { view.backgroundColor = backgroundColor.uiColor } + + // Sets up the navigation item based on the data. + setNavigationItem() } // MARK: - Navigation Item (Move to model base) - open func setNavigationController() { + + open func getNavigationModel() -> NavigationItemModelProtocol? { + // TODO: remove legacy. Temporary, convert legacy to navigation model. + if pageModel?.navigationBar == nil { + let navigationItem = createDefaultLegacyNavigationModel() + pageModel?.navigationBar = navigationItem + } + return pageModel?.navigationBar + } + + /// Sets the navigation item for this view controller. + open func setNavigationItem() { + guard let navigationItemModel = getNavigationModel(), + let navigationController = navigationController else { return } + + // We additionally want our left items + navigationItem.leftItemsSupplementBackButton = true + + // Utilize helper function to set the navigation item state. + NavigationController.setNavigationItem(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: self) + } + + /// Sets the appearance of the navigation bar based on the model. + open func setNavigationBar() { let viewController = manager ?? self - guard let navigationItemModel = pageModel?.navigationBar, + guard let navigationItemModel = getNavigationModel(), let navigationController = viewController.navigationController else { MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return } - // We additionally want our left items - navigationItem.leftItemsSupplementBackButton = true - // Utilize helper function to set the split view and navigation item state. MVMCoreUISplitViewController.setSplitViewController(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel, leftPanelAccessible: isMasterInitiallyAccessible(), rightPanelAccessible: isSupportInitiallyAccessible(), progress: bottomProgress() ?? 0) } @@ -277,6 +295,7 @@ import UIKit open func updateTabBar() { guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self, let tabModel = pageModel as? TabPageModelProtocol else { return } + MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar if let index = tabModel.tabBarIndex { MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) } @@ -336,7 +355,7 @@ import UIKit open func pageShown() { // Update the navigation bar ui when view is appearing. - setNavigationController() + setNavigationBar() // Update tab if needed. updateTabBar() @@ -453,7 +472,7 @@ import UIKit // Reset the navigation state. public func splitViewDidReset() { - setNavigationController() + setNavigationBar() } // MARK: - UITextFieldDelegate (Check if this is still needed) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 7c82788c..580a6ed6 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -71,149 +71,153 @@ extension UIColor { //-------------------------------------------------- /// HEX: #D52B1E - public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) + public static let mvmRed = UIColor.assetColor(named: "red") //-------------------------------------------------- // MARK: - Pink //-------------------------------------------------- /// HEX: #D90368 - public static let mvmPink = UIColor.color8Bits(red: 217, green: 3, blue: 104) + public static let mvmPink = UIColor.assetColor(named: "pink") /// HEX: #F2ABCD - public static let mvmPink33 = UIColor.color8Bits(red: 242, green: 171, blue: 205) + public static let mvmPink33 = UIColor.assetColor(named: "pink33") /// HEX: #E6589B - public static let mvmPink66 = UIColor.color8Bits(red: 230, green: 88, blue: 155) + public static let mvmPink66 = UIColor.assetColor(named: "pink66") /// HEX: #B31C63 - public static let mvmPinkShade1 = UIColor.color8Bits(red: 179, green: 28, blue: 99) + public static let mvmPinkShade1 = UIColor.assetColor(named: "pinkShade1") /// HEX: #830842 - public static let mvmPinkShade2 = UIColor.color8Bits(red: 131, green: 8, blue: 66) + public static let mvmPinkShade2 = UIColor.assetColor(named: "pinkShade2") //-------------------------------------------------- // MARK: - Purple //-------------------------------------------------- /// HEX: #8C00AC - public static let mvmPurple = UIColor.color8Bits(red: 140, green: 0, blue: 172) + public static let mvmPurple = UIColor.assetColor(named: "purple") /// HEX: #D9ABE4 - public static let mvmPurple33 = UIColor.color8Bits(red: 217, green: 171, blue: 228) + public static let mvmPurple33 = UIColor.assetColor(named: "purple33") /// HEX: #B356C8 - public static let mvmPurple66 = UIColor.color8Bits(red: 179, green: 86, blue: 200) + public static let mvmPurple66 = UIColor.assetColor(named: "purple66") /// HEX: #6C177F - public static let mvmPurpleShade1 = UIColor.color8Bits(red: 108, green: 23, blue: 127) + public static let mvmPurpleShade1 = UIColor.assetColor(named: "purpleShade1") /// HEX: #4A0E58 - public static let mvmPurpleShade2 = UIColor.color8Bits(red: 74, green: 14, blue: 88) + public static let mvmPurpleShade2 = UIColor.assetColor(named: "purpleShade2") //-------------------------------------------------- // MARK: - Orange //-------------------------------------------------- /// HEX: #ED7000 - public static let mvmOrange = UIColor.color8Bits(red: 237, green: 112, blue: 0) + public static let mvmOrange = UIColor.assetColor(named: "orange") /// HEX: #CC4D0F - public static let mvmOrangeAA = UIColor.color8Bits(red: 204, green: 77, blue: 15) + public static let mvmOrangeAA = UIColor.assetColor(named: "orangeAA") /// HEX: #F9D0AB - public static let mvmOrange33 = UIColor.color8Bits(red: 249, green: 208, blue: 171) + public static let mvmOrange33 = UIColor.assetColor(named: "orange33") /// HEX: #F3A157 - public static let mvmOrange66 = UIColor.color8Bits(red: 243, green: 161, blue: 87) + public static let mvmOrange66 = UIColor.assetColor(named: "orange66") /// HEX: #CB5F00 - public static let mvmOrangeShade1 = UIColor.color8Bits(red: 203, green: 95, blue: 0) + public static let mvmOrangeShade1 = UIColor.assetColor(named: "orangeShade1") /// HEX: #984700 - public static let mvmOrangeShade2 = UIColor.color8Bits(red: 152, green: 71, blue: 0) + public static let mvmOrangeShade2 = UIColor.assetColor(named: "orangeShade2") //-------------------------------------------------- // MARK: - Green //-------------------------------------------------- /// HEX: #008330 - public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 48) + public static let mvmGreen = UIColor.assetColor(named: "green") /// HEX: #ABE4BF - public static let mvmGreen33 = UIColor.color8Bits(red: 171, green: 228, blue: 191) + public static let mvmGreen33 = UIColor.assetColor(named: "green33") /// HEX: #57C880 - public static let mvmGreen66 = UIColor.color8Bits(red: 87, green: 200, blue: 128) + public static let mvmGreen66 = UIColor.assetColor(named: "green66") /// HEX: #0F5B25 - public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37) + public static let mvmGreenShade2 = UIColor.assetColor(named: "greenShade2") /// HEX: #00AC3E - public static let mvmGreenInverted = UIColor.color8Bits(red: 0, green: 172, blue: 62) + public static let mvmGreenInverted = UIColor.assetColor(named: "greenInverted") //-------------------------------------------------- // MARK: - Blue //-------------------------------------------------- /// HEX: #0077B4 - public static let mvmBlue = UIColor.color8Bits(red: 0, green: 119, blue: 180) + public static let mvmBlue = UIColor.assetColor(named: "blue") /// HEX: #ABD8EF - public static let mvmBlue33 = UIColor.color8Bits(red: 171, green: 216, blue: 239) + public static let mvmBlue33 = UIColor.assetColor(named: "blue33") /// HEX: #57B1DF - public static let mvmBlue66 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + public static let mvmBlue66 = UIColor.assetColor(named: "blue66") /// HEX: #136598 - public static let mvmBlueShade1 = UIColor.color8Bits(red: 19, green: 101, blue: 152) + public static let mvmBlueShade1 = UIColor.assetColor(named: "blueShade1") /// HEX: #0B4467 - public static let mvmBlueShade2 = UIColor.color8Bits(red: 11, green: 68, blue: 103) + public static let mvmBlueShade2 = UIColor.assetColor(named: "blueShade2") /// HEX: #0088CE - public static let mvmBlueInverted = UIColor.color8Bits(red: 0, green: 136, blue: 206) + public static let mvmBlueInverted = UIColor.assetColor(named: "blueInverted") //-------------------------------------------------- // MARK: - Yellow //-------------------------------------------------- /// HEX: #FFBC3D - public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) + public static let mvmYellow = UIColor.assetColor(named: "yellow") //-------------------------------------------------- // MARK: - Gray //-------------------------------------------------- /// HEX: #F6F6F6 - public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) + public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") /// HEX: #D8DADA - public static let mvmCoolGray3 = UIColor.color8Bits(red: 216, green: 218, blue: 218) + public static let mvmCoolGray3 = UIColor.assetColor(named: "coolGray3") /// HEX: #747676 - public static let mvmCoolGray6 = UIColor.color8Bits(red: 116, green: 118, blue: 118) + public static let mvmCoolGray6 = UIColor.assetColor(named: "coolGray6") /// HEX: #333333 - public static let mvmCoolGray10 = UIColor.grayscale(rgb: 51) + public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- /// HEX: #F9D542 - public static let vzupGold1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) + public static let vzupGold1 = UIColor.assetColor(named: "upGold1") /// HEX: #F4CA53 - public static let vzupGold2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) + public static let vzupGold2 = UIColor.assetColor(named: "upGold2") /// HEX: #CC9B2D - public static let vzupGold3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) + public static let vzupGold3 = UIColor.assetColor(named: "upGold3") //-------------------------------------------------- // MARK: - Functions //-------------------------------------------------- + public static func assetColor(named name: String) -> UIColor { + return UIColor(named: name, in: MVMCoreUIUtility.bundleForMVMCoreUI(), compatibleWith: nil)! + } + /// 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 { @@ -299,7 +303,7 @@ extension UIColor { } else if numberOfComponents == 2 { // Monochromatic color space let value = Int(CGFloat(components[0]) * 255) - + // If alpha of color is less than 1.0 then alpha hex is relevant. if components[1] < 1.0 { let alpha = Int(CGFloat(components[1]) * 255) diff --git a/MVMCoreUI/Categories/colors.xcassets/Contents.json b/MVMCoreUI/Categories/colors.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blue.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blue.colorset/Contents.json new file mode 100644 index 00000000..8629132f --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0xB4", + "green" : "0x77" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blue33.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blue33.colorset/Contents.json new file mode 100644 index 00000000..834857fe --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blue33.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xAB", + "alpha" : "1.000", + "blue" : "0xEF", + "green" : "0xD8" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blue66.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blue66.colorset/Contents.json new file mode 100644 index 00000000..37fcdd6f --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blue66.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x57", + "alpha" : "1.000", + "blue" : "0xDF", + "green" : "0xB1" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blueInverted.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blueInverted.colorset/Contents.json new file mode 100644 index 00000000..ca54d6ce --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blueInverted.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0xCE", + "green" : "0x88" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blueShade1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blueShade1.colorset/Contents.json new file mode 100644 index 00000000..0153330a --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blueShade1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x13", + "alpha" : "1.000", + "blue" : "0x98", + "green" : "0x65" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/blueShade2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/blueShade2.colorset/Contents.json new file mode 100644 index 00000000..bae4fe1c --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/blueShade2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x0B", + "alpha" : "1.000", + "blue" : "0x67", + "green" : "0x44" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/coolGray1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/coolGray1.colorset/Contents.json new file mode 100644 index 00000000..18db9a3d --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/coolGray1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF6", + "alpha" : "1.000", + "blue" : "0xF6", + "green" : "0xF6" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/coolGray10.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/coolGray10.colorset/Contents.json new file mode 100644 index 00000000..f9b0b98b --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/coolGray10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x33", + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x33" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/coolGray3.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/coolGray3.colorset/Contents.json new file mode 100644 index 00000000..3082b216 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/coolGray3.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xD8", + "alpha" : "1.000", + "blue" : "0xDA", + "green" : "0xDA" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/coolGray6.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/coolGray6.colorset/Contents.json new file mode 100644 index 00000000..3c1ebf6d --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/coolGray6.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x74", + "alpha" : "1.000", + "blue" : "0x76", + "green" : "0x76" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/green.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/green.colorset/Contents.json new file mode 100644 index 00000000..40987eb7 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/green.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0x30", + "green" : "0x83" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/green33.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/green33.colorset/Contents.json new file mode 100644 index 00000000..63d79fa1 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/green33.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xAB", + "alpha" : "1.000", + "blue" : "0xBF", + "green" : "0xE4" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/green66.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/green66.colorset/Contents.json new file mode 100644 index 00000000..af8c1094 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/green66.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x57", + "alpha" : "1.000", + "blue" : "0x80", + "green" : "0xC8" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/greenInverted.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/greenInverted.colorset/Contents.json new file mode 100644 index 00000000..b2a48b0f --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/greenInverted.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0x3E", + "green" : "0xAC" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/greenShade2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/greenShade2.colorset/Contents.json new file mode 100644 index 00000000..00dc90da --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/greenShade2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x0F", + "alpha" : "1.000", + "blue" : "0x25", + "green" : "0x5B" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orange.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orange.colorset/Contents.json new file mode 100644 index 00000000..e5415e4b --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orange.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xED", + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x70" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orange33.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orange33.colorset/Contents.json new file mode 100644 index 00000000..4c9e04e4 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orange33.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF9", + "alpha" : "1.000", + "blue" : "0xAB", + "green" : "0xD0" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orange66.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orange66.colorset/Contents.json new file mode 100644 index 00000000..67424977 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orange66.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF3", + "alpha" : "1.000", + "blue" : "0x57", + "green" : "0xA1" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orangeAA.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orangeAA.colorset/Contents.json new file mode 100644 index 00000000..56f98a12 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orangeAA.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xCC", + "alpha" : "1.000", + "blue" : "0x0F", + "green" : "0x4D" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orangeShade1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orangeShade1.colorset/Contents.json new file mode 100644 index 00000000..6cf34c78 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orangeShade1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xCB", + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x5F" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/orangeShade2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/orangeShade2.colorset/Contents.json new file mode 100644 index 00000000..1fcbe3a4 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/orangeShade2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x98", + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x47" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/pink.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/pink.colorset/Contents.json new file mode 100644 index 00000000..4cc87bd4 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/pink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xD9", + "alpha" : "1.000", + "blue" : "0x68", + "green" : "0x03" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/pink33.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/pink33.colorset/Contents.json new file mode 100644 index 00000000..2d85dd8f --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/pink33.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF2", + "alpha" : "1.000", + "blue" : "0xCD", + "green" : "0xAB" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/pink66.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/pink66.colorset/Contents.json new file mode 100644 index 00000000..c05eef33 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/pink66.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xE6", + "alpha" : "1.000", + "blue" : "0x9B", + "green" : "0x58" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/pinkShade1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/pinkShade1.colorset/Contents.json new file mode 100644 index 00000000..59e8780d --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/pinkShade1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xB3", + "alpha" : "1.000", + "blue" : "0x63", + "green" : "0x1C" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/pinkShade2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/pinkShade2.colorset/Contents.json new file mode 100644 index 00000000..1dcdecbe --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/pinkShade2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x83", + "alpha" : "1.000", + "blue" : "0x42", + "green" : "0x08" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/purple.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/purple.colorset/Contents.json new file mode 100644 index 00000000..49d87c9e --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/purple.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x8C", + "alpha" : "1.000", + "blue" : "0xAC", + "green" : "0x00" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/purple33.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/purple33.colorset/Contents.json new file mode 100644 index 00000000..95cac70e --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/purple33.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xD9", + "alpha" : "1.000", + "blue" : "0xE4", + "green" : "0xAB" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/purple66.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/purple66.colorset/Contents.json new file mode 100644 index 00000000..95e75564 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/purple66.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xB3", + "alpha" : "1.000", + "blue" : "0xC8", + "green" : "0x56" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/purpleShade1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/purpleShade1.colorset/Contents.json new file mode 100644 index 00000000..689b7838 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/purpleShade1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x6C", + "alpha" : "1.000", + "blue" : "0x7F", + "green" : "0x17" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/purpleShade2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/purpleShade2.colorset/Contents.json new file mode 100644 index 00000000..d71ec372 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/purpleShade2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x4A", + "alpha" : "1.000", + "blue" : "0x58", + "green" : "0x0E" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/red.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/red.colorset/Contents.json new file mode 100644 index 00000000..536ccc9b --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/red.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xD5", + "alpha" : "1.000", + "blue" : "0x1E", + "green" : "0x2B" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/upGold1.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/upGold1.colorset/Contents.json new file mode 100644 index 00000000..90ccb299 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/upGold1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF9", + "alpha" : "1.000", + "blue" : "0x42", + "green" : "0xD5" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/upGold2.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/upGold2.colorset/Contents.json new file mode 100644 index 00000000..6389c7a8 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/upGold2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF4", + "alpha" : "1.000", + "blue" : "0x53", + "green" : "0xCA" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/upGold3.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/upGold3.colorset/Contents.json new file mode 100644 index 00000000..e25cb46f --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/upGold3.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xCC", + "alpha" : "1.000", + "blue" : "0x2D", + "green" : "0x9B" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Categories/colors.xcassets/yellow.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/yellow.colorset/Contents.json new file mode 100644 index 00000000..5c00b5eb --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/yellow.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xFF", + "alpha" : "1.000", + "blue" : "0x3D", + "green" : "0xBC" + } + } + } + ] +} \ No newline at end of file diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 2803792f..0cad62c5 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -43,6 +43,14 @@ import UIKit return navigationController } + /// Convenience function for setting the navigation item. + public static func setNavigationItem(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { + viewController.navigationItem.title = navigationItemModel.title + viewController.navigationItem.accessibilityLabel = navigationItemModel.title + viewController.navigationItem.hidesBackButton = (navigationItemModel.backButton != nil) + setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + } + /// Convenience function for setting the navigation buttons. public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject @@ -70,11 +78,7 @@ import UIKit } /// Convenience function for setting the navigation bar ui, except for the buttons. - public static func setNavigationUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - viewController.navigationItem.title = navigationItemModel.title - viewController.navigationItem.accessibilityLabel = navigationItemModel.title - viewController.navigationItem.hidesBackButton = (navigationItemModel.backButton != nil) - + public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) navigationController.navigationBar.barTintColor = navigationItemModel.backgroundColor?.uiColor ?? .white @@ -90,17 +94,19 @@ import UIKit } } - /// Convenience function for setting navigation bar with model. - public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - setNavigationUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - } - /// Convenience setter for legacy files - public static func set(navigationController: UINavigationController, navigationJSON: [String: Any], viewController: UIViewController) throws { + public static func setNavigationItem(navigationController: UINavigationController, navigationJSON: [String: Any], viewController: UIViewController) throws { guard let barModel = try MoleculeObjectMapping.shared()?.getMoleculeModelForJSON(navigationJSON) as? (MoleculeModelProtocol & NavigationItemModelProtocol) else { throw ModelRegistry.Error.decoderOther(message: "Model not a bar model") } - set(navigationController: navigationController, navigationItemModel: barModel, viewController: viewController) + setNavigationItem(navigationController: navigationController, navigationItemModel: barModel, viewController: viewController) + } + + /// Convenience setter for legacy files + public static func setNavigationBarUI(navigationController: UINavigationController, navigationJSON: [String: Any], viewController: UIViewController) throws { + guard let barModel = try MoleculeObjectMapping.shared()?.getMoleculeModelForJSON(navigationJSON) as? (MoleculeModelProtocol & NavigationItemModelProtocol) else { + throw ModelRegistry.Error.decoderOther(message: "Model not a bar model") + } + setNavigationBarUI(navigationController: navigationController, navigationItemModel: barModel, viewController: viewController) } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index e62efa29..963834ff 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -15,7 +15,7 @@ public extension MVMCoreUISplitViewController { guard let splitView = MVMCoreUISplitViewController.main(), navigationController == splitView.navigationController, navigationController.topViewController == viewController else { - NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) return } splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel, leftPanelAccessible: leftPanelAccessible, rightPanelAccessible: rightPanelAccessible, progress: progress) @@ -27,7 +27,7 @@ public extension MVMCoreUISplitViewController { // Setup the panels. setupPanels() - NavigationController.setNavigationUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) setLeftPanelIsAccessible(leftPanelAccessible ?? leftPanelIsAccessible, for: viewController, updateNavigationButtons: false) setRightPanelIsAccessible(rightPanelAccessible ?? rightPanelIsAccessible, for: viewController, updateNavigationButtons: false) @@ -117,7 +117,7 @@ public extension MVMCoreUISplitViewController { guard let splitView = MVMCoreUISplitViewController.main(), navigationController == splitView.navigationController, navigationController.topViewController == viewController else { - NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) return } let progress = progress?.floatValue diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h index 9fec90f5..14da21ad 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h @@ -17,8 +17,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)defaultLogPageStateForController:(nonnull id )controller; // Action Logging -- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (void)defaultLogActionForController:(nullable id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nullable id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; @end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m index 0c694cce..45a13acf 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m @@ -13,10 +13,10 @@ - (void)defaultLogPageStateForController:(nonnull id )controller { } -- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (void)defaultLogActionForController:(nullable id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { } -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nullable id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { return nil; } diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index 74b907e3..c280b737 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -10,6 +10,7 @@ "AccCloseButton" = "Close"; "swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select."; "AccDisabled" = "Disabled"; +"index_string_of_total" = "%@ of %d"; // MARK: Tab "AccTab" = ", tab"; @@ -59,7 +60,6 @@ "radio_not_selected_state" = "Not Selected"; "radio_desc_state" = "Option"; - // MARK: Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; "Toggle_buttonlabel" = "Toggle Button"; diff --git a/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings index b3b6298c..f21df078 100644 --- a/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings @@ -9,6 +9,7 @@ // Accessibility "swipe_to_select_with_action_hint" = "deslízate hacia arriba o hacia abajo para seleccionar la acción, luego toca dos veces para seleccionar."; "AccDisabled" = "desactivado"; +"index_string_of_total" = "%@ de %d"; "AccCloseButton" = "Cerrar"; // Tab diff --git a/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings index 8e0dbd02..47d124a9 100644 --- a/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings @@ -9,6 +9,7 @@ // Accessibility "swipe_to_select_with_action_hint" = "deslízate hacia arriba o hacia abajo para seleccionar la acción, luego toca dos veces para seleccionar."; "AccDisabled" = "desactivado"; +"index_string_of_total" = "%@ de %d"; "AccCloseButton" = "Cerrar"; // Tab diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 3d15652c..ed9f5271 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -374,6 +374,7 @@ weakSelf.shortViewHeight.active = NO; } completion:^(BOOL finished) { [weakSelf.viewToLayout layoutIfNeeded]; + weakSelf.accessibilityElements = @[weakSelf.shortView.label]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); [MVMCoreDispatchUtility performBlockInBackground:^{ // Must notify animation delegate when animating finished. diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 21c92c38..78c2608b 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -46,6 +46,9 @@ NS_ASSUME_NONNULL_BEGIN // Removes any format. + (nullable NSString *)removeMdnFormat:(nullable NSString *)mdn; +/// Returns an ordinal formatted string for a number. ++ (nullable NSString *)getOrdinalStringForIndex:(nonnull NSNumber *)number; + #pragma mark - Validations // Will validate passed string on corresponding regular expression diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 0841e248..cd9e041e 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -113,6 +113,12 @@ return mdn; } ++ (nullable NSString *)getOrdinalStringForIndex:(nonnull NSNumber *)number { + NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + formatter.numberStyle = NSNumberFormatterOrdinalStyle; + return [formatter stringFromNumber:number]; +} + #pragma mark - Validations + (BOOL)validateString:(nonnull NSString *)string withRegularExpression:(nonnull NSString *)regExpression {