diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index fc52bc65..88dc904d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -22,11 +22,12 @@ 012A88DA238ED42E00FE3DA1 /* StackPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */; }; 012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AE238C626E00FE3DA1 /* CarouselModel.swift */; }; 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88EB238F084D00FE3DA1 /* FooterModel.swift */; }; + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */; }; + 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; }; 012CA9DE2388723E003F810F /* ListPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */; }; 012CA9E223888AED003F810F /* StackCenteredPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */; }; 012CA9E423888B1B003F810F /* ThreeLayerPageTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9E323888B1B003F810F /* ThreeLayerPageTemplateModel.swift */; }; @@ -61,6 +62,7 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; }; @@ -97,6 +99,8 @@ D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; + D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; }; + D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -265,11 +269,12 @@ 012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMoleculeModel.swift; sourceTree = ""; }; 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeDelegateProtocol.swift; sourceTree = ""; }; 012A88EB238F084D00FE3DA1 /* FooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterModel.swift; sourceTree = ""; }; + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerMoleculeProtocol.swift; sourceTree = ""; }; + 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = ""; }; 012CA9DD2388723E003F810F /* ListPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPageTemplateModel.swift; sourceTree = ""; }; 012CA9DF23888AC8003F810F /* StackPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackPageTemplateModel.swift; sourceTree = ""; }; 012CA9E123888AED003F810F /* StackCenteredPageTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackCenteredPageTemplateModel.swift; sourceTree = ""; }; @@ -305,6 +310,7 @@ 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = ""; }; @@ -340,6 +346,8 @@ D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = ""; }; D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = ""; }; D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = ""; }; + D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = ""; }; + D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = ""; }; D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = ""; }; D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = ""; }; @@ -524,15 +532,24 @@ path = Template; sourceTree = ""; }; + 012A88EF23985E0100FE3DA1 /* Primitive Models */ = { + isa = PBXGroup; + children = ( + 012A88F023985E0100FE3DA1 /* Color.swift */, + ); + path = "Primitive Models"; + sourceTree = ""; + }; 01509D96232803B200EF99AA /* Models */ = { isa = PBXGroup; children = ( + 012A88EF23985E0100FE3DA1 /* Primitive Models */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, + 012A88ED239858E300FE3DA1 /* ContainerMoleculeProtocol.swift */, 012A88B0238C880100FE3DA1 /* PagingMoleculeProtocol.swift */, 012A88C3238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift */, 012A889A238898C600FE3DA1 /* Template */, - 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); @@ -622,6 +639,12 @@ D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF15921E697DA003B2FB9 /* SeparatorView.h */, D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, + D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */, + D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */, + D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */, + D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, + 0198F7A02256A80A0066C936 /* MFRadioButton.h */, + 0198F7A22256A80A0066C936 /* MFRadioButton.m */, ); path = Views; sourceTree = ""; @@ -681,6 +704,7 @@ D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */, D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */, + D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */, ); path = Items; sourceTree = ""; @@ -825,6 +849,7 @@ D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */, D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */, + 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */, ); path = Categories; sourceTree = ""; @@ -936,23 +961,18 @@ D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, + D268C711238D6699007F2C1C /* DropDown.swift */, D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */, D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */, D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */, - D22D1F1C220343560077CEC0 /* MVMCoreUICheckMarkView.h */, - D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */, - D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */, - D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */, D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, DB891E822253FA8500022516 /* Label.swift */, 94C2D9822386F3E30006CF46 /* LabelModel */, - 0198F7A02256A80A0066C936 /* MFRadioButton.h */, - 0198F7A22256A80A0066C936 /* MFRadioButton.m */, 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, @@ -1251,11 +1271,11 @@ D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, - 012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, 94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */, 012CA98923849699003F810F /* SeperatorModel.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, + 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, @@ -1265,6 +1285,7 @@ D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, + D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, @@ -1318,6 +1339,7 @@ D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, + 012A88EE239858E300FE3DA1 /* ContainerMoleculeProtocol.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, @@ -1382,11 +1404,13 @@ D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, + D268C712238D6699007F2C1C /* DropDown.swift in Sources */, 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */, D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */, D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 8ccbe22e..aa3ab573 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -74,6 +74,7 @@ //default error message @property (nullable, strong, nonatomic) NSString *errMessage; +@property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *errorHeightConstraint; @property (nullable, copy, nonatomic) void (^editCompleteAction)(NSString * _Nullable text); diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index cfef9090..fec796bf 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -558,6 +558,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:delegateObject.formValidationProtocol]; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index cb9821f1..c11beb5c 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -15,6 +13,7 @@ + diff --git a/MVMCoreUI/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atoms/Views/CaretViewModel.swift index c0f3ee8c..481d086f 100644 --- a/MVMCoreUI/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CaretViewModel.swift @@ -9,8 +9,9 @@ import Foundation @objcMembers public class CaretViewModel: MoleculeProtocol { + public static var identifier: String = "caretView" - public var moleculeName: String + public var backgroundColor: String? public var strokeColor: String? public var isHidden: Bool? diff --git a/MVMCoreUI/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atoms/Views/DashLineModel.swift index 8fd26fbf..6fff83c7 100644 --- a/MVMCoreUI/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atoms/Views/DashLineModel.swift @@ -11,8 +11,8 @@ import Foundation @objcMembers public class DashLineModel: MoleculeProtocol { public static var identifier: String = "dashLine" public var moleculeName: String + public var backgroundColor: String? public var dashColor: String public var isHidden: Bool? - public var backgroundColor: String? } diff --git a/MVMCoreUI/Atoms/Views/DropDown.swift b/MVMCoreUI/Atoms/Views/DropDown.swift new file mode 100644 index 00000000..929bd67f --- /dev/null +++ b/MVMCoreUI/Atoms/Views/DropDown.swift @@ -0,0 +1,55 @@ +// +// DropDown.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class DropDown: MFTextField { + let picker = MVMCoreUICommonViewsUtility.commonPickerView()! + + public override func getNib() -> UINib? { + return UINib(nibName: String(describing: MFTextField.self), bundle: MVMCoreUIUtility.bundleForMVMCoreUI()) + } + + public override func setupView() { + super.setupView() + dropDownCarrotWidth?.isActive = false + errorHeightConstraint?.constant = 0 + } + + override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + guard let textField = textField, textField.inputView == nil else { return } + picker.delegate = self + picker.dataSource = self + picker.tag = textField.tag + textField.inputView = picker + picker.reloadAllComponents() + MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: delegateObject?.uiTextFieldDelegate) + textField.text = json?.stringWithChainOfKeysOrIndexes(["options",picker.selectedRow(inComponent: 0)]) + } +} + +extension DropDown: UIPickerViewDelegate { + public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return json?.stringWithChainOfKeysOrIndexes(["options",row]) + } + + public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + textField?.text = json?.stringWithChainOfKeysOrIndexes(["options",row]) + } +} + +extension DropDown: UIPickerViewDataSource { + public func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 1 + } + + public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return json?.optionalArrayForKey("options")?.count ?? 0 + } +} diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index 0a828259..ca63c67f 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -93,8 +93,8 @@ public struct GraphObject { mutating func updateSize() { switch size { case .small: - diameter = MFSizeObject(standardSize: 24)?.getValueBasedOnApplicationWidth() ?? 24 - lineWidth = MFSizeObject(standardSize: 5)?.getValueBasedOnApplicationWidth() ?? 5 + diameter = MFSizeObject(standardSize: 20)?.getValueBasedOnApplicationWidth() ?? 20 + lineWidth = MFSizeObject(standardSize: 4)?.getValueBasedOnApplicationWidth() ?? 4 break case .medium: diameter = MFSizeObject(standardSize: 100)?.getValueBasedOnApplicationWidth() ?? 100 diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 2c9a6dd4..16c32d8f 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,6 +11,7 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeProtocol { public static var identifier: String = "image" public var moleculeName: String + public var backgroundColor: String? public var image: String public var accessibilityText: String? diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 388f40cb..ca112b9a 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -319,9 +319,12 @@ public typealias ActionBlock = () -> () } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - guard let label = label else { return } - label.attributedText = nil + + // Some properties can only be set on Label. + // Label fonts should not be scaled because it will be scaled in updateView. + let mvmLabel = label as? Label + label.text = json?.optionalStringForKey(KeyText) setLabel(label, withHTML: json?.optionalStringForKey("html")) @@ -337,9 +340,7 @@ public typealias ActionBlock = () -> () } } - if let wholeViewIsClickable = json?.boolForKey("makeWholeViewClickable") { - (label as? Label)?.makeWholeViewClickable = wholeViewIsClickable - } + mvmLabel?.makeWholeViewClickable = json?.boolForKey("makeWholeViewClickable") ?? false if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor), !backgroundColorHex.isEmpty { label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) @@ -348,12 +349,16 @@ public typealias ActionBlock = () -> () label.accessibilityLabel = json?.optionalStringForKey("accessibilityText") if let fontStyle = json?.optionalStringForKey("fontStyle") { - MFStyler.styleLabel(label, withStyle: fontStyle) + MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil) + mvmLabel?.standardFontSize = label.font.pointSize } else { let fontSize = json?["fontSize"] as? CGFloat + if let fontSize = fontSize { + mvmLabel?.standardFontSize = fontSize + } if let fontName = json?.optionalStringForKey("fontName") { - label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize) + label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { label.font = label.font.withSize(fontSize) } @@ -363,8 +368,8 @@ public typealias ActionBlock = () -> () label.textColor = UIColor.mfGet(forHex: textColorHex) } - if let attributes = json?.arrayForKey("attributes"), let labelText = label.text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as UIFont, + if let attributes = json?.optionalArrayForKey("attributes"), let labelText = label.text { + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: mvmLabel?.font.withSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, NSAttributedString.Key.foregroundColor: label.textColor as UIColor]) for case let attribute as [String: Any] in attributes { guard let attributeType = attribute.optionalStringForKey(KeyType), @@ -405,7 +410,7 @@ public typealias ActionBlock = () -> () case "font": if let fontStyle = attribute.optionalStringForKey("style") { - let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) + let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle, genericScaling: mvmLabel == nil) attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range) @@ -414,7 +419,7 @@ public typealias ActionBlock = () -> () var font: UIFont? if let fontName = attribute.optionalStringForKey("name") { - font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize) + font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { font = label.font.withSize(fontSize) } @@ -437,6 +442,7 @@ public typealias ActionBlock = () -> () } } label.attributedText = attributedString + mvmLabel?.originalAttributedString = attributedString } } @@ -526,7 +532,7 @@ public typealias ActionBlock = () -> () if let floatScale = scaleSize?.floatValue { updateView(CGFloat(floatScale)) } else { - updateView(MVMCoreUISplitViewController.getApplicationViewWidth()) + updateView(MVMCoreUIUtility.getWidth()) } } else { standardFontSize = 0 @@ -688,8 +694,6 @@ extension Label { @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { clauses = [] Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) - originalAttributedString = attributedText - hero = json?["hero"] as? Int } diff --git a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift index cd1c5d12..d2c7947f 100644 --- a/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/LabelModel/LabelModel.swift @@ -12,10 +12,11 @@ import Foundation @objcMembers public class LabelModel: MoleculeProtocol { public static var identifier: String = "label" public var moleculeName: String? + public var backgroundColor: String? + public var text: String public var accessibilityText: String? public var textColor: String? - public var backgroundColor: String? public var fontStyle: String? public var fontName: String? public var fontSize: CGFloat? diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index f7a81ac5..d5f4f4b6 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -38,8 +38,6 @@ import UIKit case .none: heightConstraint?.constant = 0 } - setNeedsLayout() - layoutIfNeeded() } } diff --git a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift index d63183e4..25522070 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgressModel.swift @@ -17,6 +17,7 @@ import Foundation @objcMembers public class MultiProgressBarModel: MoleculeProtocol { public static var identifier: String = "multiProgressBar" public var moleculeName: String + public var backgroundColor: String? public var progressList: [SingleProgressBarModel] public var thickness: CGFloat? public var roundedRect: Bool? diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift index 1e4cd849..181a187d 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView+ModelExtension.swift @@ -16,7 +16,7 @@ extension ViewConstrainingView { } if shouldSetupMoleculeFromJSON, - let moleculeObject = (model as? ConstrainingMoleculeProtocol)?.molecule { + let moleculeObject = (model as? ContainerMoleculeProtocol)?.molecule { if molecule != nil { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeObject, delegateObject, additionalData) } else { @@ -30,18 +30,20 @@ extension ViewConstrainingView { (molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) } - if let useHorizontalMargins = model?.useHorizontalMargins { - updateViewHorizontalDefaults = useHorizontalMargins - } - if let useVerticalMargins = model?.useVerticalMargins { - updateViewVerticalDefaults = useVerticalMargins - } + if let containerMoleculeModel = model as? ContainerMoleculeProtocol { + if let useHorizontalMargins = containerMoleculeModel.useHorizontalMargins { + updateViewHorizontalDefaults = useHorizontalMargins + } + if let useVerticalMargins = containerMoleculeModel.useVerticalMargins { + updateViewVerticalDefaults = useVerticalMargins + } - if let horizontalAlignment = model?.horizontalAlignment { - alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) - } - if let verticalAlignment = model?.verticalAlignment { - alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + if let horizontalAlignment = containerMoleculeModel.horizontalAlignment { + alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill)) + } + if let verticalAlignment = containerMoleculeModel.verticalAlignment { + alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill)) + } } #warning("work on the below") diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.m b/MVMCoreUI/BaseControllers/MFScrollingViewController.m index 56019cb7..67e01d93 100644 --- a/MVMCoreUI/BaseControllers/MFScrollingViewController.m +++ b/MVMCoreUI/BaseControllers/MFScrollingViewController.m @@ -91,7 +91,7 @@ static NSTimeInterval const HandScrollAnimationTiming = 7.f; - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - BOOL automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; + BOOL automaticInset = self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; // Takes into account the navigation bar. if (!automaticInset && (self.edgesForExtendedLayout & UIRectEdgeTop)) { diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift new file mode 100644 index 00000000..fab1ae6f --- /dev/null +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -0,0 +1,210 @@ +// +// UIColor+Extension.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + + +import UIKit + +public typealias ColorHexTuple = (uiColor: UIColor, hex: String) + +extension UIColor { + + /// Dictionary to access brand approved colors by name. + public static let names: [String: ColorHexTuple] = ["black": (.mvmBlack, "#000000"), + "white": (.mvmWhite, "#FFFFFF"), + "red": (.mvmRed, "#D52B1E"), + "orange": (.mvmOrange, "#CC4D0F"), + "green": (.mvmGreen, "#008631"), + "blue": (.mvmBlue, "#007AB8"), + "blueGradient": (.mvmBlueGradient, "#007AB8"), + "yellow": (.mvmYellow, "#FFBC3D"), + "coolGray1": (.mvmCoolGray1, "#F6F6F6"), + "coolGray3": (.mvmCoolGray3, "#D8DADA"), + "coolGray6": (.mvmCoolGray6, "#747676"), + "vzupGold": (.vzupGold, "#B89B56"), + "vzupYellow1": (.vzupYellow1, "#F9D542"), + "vzupYellow2": (.vzupYellow2, "#F4CA53"), + "vzupYellow3": (.vzupYellow3, "#CC9B2D")] + + //-------------------------------------------------- + // MARK: - Brand + //-------------------------------------------------- + + /// HEX: #000000 + public static let mvmBlack = UIColor.black + + /// HEX: #FFFFFF + public static let mvmWhite = UIColor.white + + /// HEX: #D52B1E + public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) + + /// HEX: #CC4D0F + public static let mvmOrange = UIColor.color8Bits(red: 204, green: 77, blue: 15) + + /// HEX: #008631 + public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 49) + + /// HEX: #007AB8 + public static let mvmBlue = UIColor.color8Bits(red: 0, green: 122, blue: 184) + + /// HEX: #007AB8 + public static let mvmBlueGradient = UIColor.color8Bits(red: 0, green: 122, blue: 184) + + /// HEX: #FFBC3D + public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) + + /// HEX: #F6F6F6 + public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) + + /// HEX: #D8DADA + public static let mvmCoolGray3 = UIColor.color8Bits(red: 216, green: 218, blue: 218) + + /// HEX: #747676 + public static let mvmCoolGray6 = UIColor.color8Bits(red: 116, green: 118, blue: 118) + + //-------------------------------------------------- + // MARK: - VZ UP Brand + //-------------------------------------------------- + + /// HEX: #B89B56 + public static let vzupGold = UIColor.color8Bits(red: 184, green: 155, blue: 68) + + /// HEX: #F9D542 + public static let vzupYellow1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) + + /// HEX: #F4CA53 + public static let vzupYellow2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) + + /// HEX: #CC9B2D + public static let vzupYellow3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) + + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + /// Convenience to get a grayscale UIColor where the same value is used for red, green, and blue. + public class func grayscale(rgb: Int, alpha: CGFloat = 1.0) -> UIColor { + + let grayscale = CGFloat(rgb) / 255.0 + return UIColor(red: grayscale, green: grayscale, blue: grayscale, alpha: alpha) + } + + /// Convenience to get a UIColor. + public class func color8Bits(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: alpha) + } + + /// Convenience to get a UIColor. + public class func color8Bits(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor { + + return UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha) + } + + /// Gets UIColor via an 8 digit hex string. + public class func getColorBy(hex: String) -> UIColor { + + var hexint: UInt64 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt64(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + green: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + blue: (CGFloat(hexint & 0xFF)) / 255, + alpha: 1) + } + + /// Gets UIColor via an 8 digit hex string. The last two being the alpha channel. + public class func getColorWithTransparencyBy(hex: String) -> UIColor { + + var hexint: UInt64 = 0 + + let scanner = Scanner(string: hex) + scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#") + scanner.scanHexInt64(&hexint) + + return UIColor(red: (CGFloat((hexint & 0xFF000000) >> 24)) / 255, + green: (CGFloat((hexint & 0xFF0000) >> 16)) / 255, + blue: (CGFloat((hexint & 0xFF00) >> 8)) / 255, + alpha: (CGFloat(hexint & 0xFF)) / 255) + } + + public class func gradientColor(_ color: UIColor?) -> UIColor { + + var h: CGFloat = 0 + var s: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + + if color?.getHue(&h, saturation: &s, brightness: &b, alpha: &a) ?? false { + return UIColor(hue: h, saturation: max(s - 0.17, 0.0), brightness: min(b - 0.03, 1.0), alpha: a) + } + + return .white + } + + public class func setBackgroundColor(forNavigationBar color: UIColor, navigationBar: UINavigationBar, transparent: Bool) { + + DispatchQueue.main.async { + + let view = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1)) + view.backgroundColor = color + + UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0) + + if let context = UIGraphicsGetCurrentContext() { + view.layer.render(in: context) + } + + let image = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + + if transparent { + navigationBar.setBackgroundImage(UIImage(), for: .default) + navigationBar.isTranslucent = false + } else { + navigationBar.setBackgroundImage(image, for: .default) + } + } + } + + /// - parameter color: The UIColor intended to retrieve its hex value. + public class func hexString(for color: UIColor) -> String? { + + guard let components = color.cgColor.components else { return nil } + + if color.cgColor.numberOfComponents >= 3 { + let r = Int(CGFloat(components[0]) * 255) + let g = Int(CGFloat(components[1]) * 255) + let b = Int(CGFloat(components[2]) * 255) + + // If alpha of color is less than 1.0 then alpha hex is relevant. + if color.cgColor.numberOfComponents == 4 && components[3] < 1.0 { + let a = Int(CGFloat(components[3]) * 255) + return String(format: "%02X%02X%02X%02X", r, g, b, a) + } + + return String(format: "%02X%02X%02X", r, g, b) + } + + return nil + } + + public class func getColorAndHexFromName(_ name: String) -> ColorHexTuple? { + + for row in names { + if name == row.key { + return row.value + } + } + + return nil + } +} diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 038769fb..377508c7 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -16,7 +16,9 @@ NS_ASSUME_NONNULL_BEGIN @optional - (void)panelWillAppear:(nonnull NSObject *)panel; +- (void)panelWillAppear:(nonnull NSObject *)panel overtakingDetail:(BOOL)willOvertake; - (void)panelDidAppear:(nonnull NSObject *)panel; +- (void)panelDidAppear:(nonnull NSObject *)panel overtakingDetail:(BOOL)didOvertake; - (void)panelWillDisappear:(nonnull NSObject *)panel; - (void)panelDidDisappear:(nonnull NSObject *)panel; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index b529ac19..b5177b9b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -357,16 +357,19 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewLeading.constant < .1) { + BOOL shouldExtendLeftPanel = [self shouldExtendLeftPanel]; + if (explict) { self.explictlyShowingPanel = self.leftPanel; } + void (^animations)(void) = [self getLeftPanelShowAnimationBlock]; void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.leftPanel animated:animated]; + [self panelDidAppear:self.leftPanel didExtend:shouldExtendLeftPanel animated:animated]; }; - if (![self shouldExtendLeftPanel]) { + if (!shouldExtendLeftPanel) { if ([self.leftPanel respondsToSelector:@selector(showArrow)]){ [self.leftPanel showArrow]; } @@ -389,7 +392,7 @@ CGFloat const PanelAnimationDuration = 0.2; } self.mainViewCoverView.hidden = NO; - [self panelWillAppear:self.leftPanel animated:animated]; + [self panelWillAppear:self.leftPanel willExtend:shouldExtendLeftPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; } else { @@ -547,19 +550,22 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewTrailing.constant < .1) { + BOOL shouldExtendRightPanel = [self shouldExtendRightPanel]; + if (explict) { self.explictlyShowingPanel = self.rightPanel; } + void (^animations)(void) = [self getRightPanelShowAnimationBlock]; void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.rightPanel animated:animated]; + [self panelDidAppear:self.rightPanel didExtend:shouldExtendRightPanel animated:animated]; self.mainView.accessibilityElementsHidden = YES; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.rightPanel); }; self.mainViewCoverView.hidden = NO; - if (![self shouldExtendRightPanel]) { + if (!shouldExtendRightPanel) { if ([self.rightPanel respondsToSelector:@selector(showArrow)]){ [self.rightPanel showArrow]; } @@ -579,7 +585,7 @@ CGFloat const PanelAnimationDuration = 0.2; self.rightPanelSeparator = rightPanelSeparator; } - [self panelWillAppear:self.rightPanel animated:animated]; + [self panelWillAppear:self.rightPanel willExtend:shouldExtendRightPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; } else { @@ -612,7 +618,7 @@ CGFloat const PanelAnimationDuration = 0.2; [self hideRightPanelIfNeededAnimated:YES]; } -- (void)panelWillAppear:(UIViewController *)panel animated:(BOOL)animated { +- (void)panelWillAppear:(UIViewController *)panel willExtend:(BOOL)willExtend animated:(BOOL)animated { if ([panel respondsToSelector:@selector(willAppear:)]) { [panel willAppear:animated]; } else { @@ -621,13 +627,15 @@ CGFloat const PanelAnimationDuration = 0.2; UIViewController *controller = [self getCurrentDetailViewController]; if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { + if ([protocolController respondsToSelector:@selector(panelWillAppear:overtakingDetail:)]) { + [protocolController panelWillAppear:panel overtakingDetail:!willExtend]; + } else if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { [protocolController panelWillAppear:panel]; } } } -- (void)panelDidAppear:(UIViewController *)panel animated:(BOOL)animated { +- (void)panelDidAppear:(UIViewController *)panel didExtend:(BOOL)didExtend animated:(BOOL)animated { if ([panel respondsToSelector:@selector(didAppear:)]) { [panel didAppear:animated]; } else { @@ -636,7 +644,9 @@ CGFloat const PanelAnimationDuration = 0.2; UIViewController *controller = [self getCurrentDetailViewController]; if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { + if ([protocolController respondsToSelector:@selector(panelDidAppear:overtakingDetail:)]) { + [protocolController panelDidAppear:panel overtakingDetail:!didExtend]; + } else if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { [protocolController panelDidAppear:panel]; } } diff --git a/MVMCoreUI/Atoms/Views/MFRadioButton.h b/MVMCoreUI/Legacy/Views/MFRadioButton.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MFRadioButton.h rename to MVMCoreUI/Legacy/Views/MFRadioButton.h diff --git a/MVMCoreUI/Atoms/Views/MFRadioButton.m b/MVMCoreUI/Legacy/Views/MFRadioButton.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MFRadioButton.m rename to MVMCoreUI/Legacy/Views/MFRadioButton.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.h rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckBox.m diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.h b/MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.h rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.h diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.m b/MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MVMCoreUICheckMarkView.m rename to MVMCoreUI/Legacy/Views/MVMCoreUICheckMarkView.m diff --git a/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift b/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift index a6a6d95d..e18c8907 100644 --- a/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift +++ b/MVMCoreUI/Models/CollectionCellMoleculeProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol CollectionCellMoleculeProtocol: MoleculeProtocol { +public protocol CollectionCellMoleculeProtocol: ContainerMoleculeProtocol { var peakingUI: Bool? {get} var peakingArrowColor: String? {get} } diff --git a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift b/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift deleted file mode 100644 index 91d4a566..00000000 --- a/MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ConstrainingMoleculeProtocol.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 11/20/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol ConstrainingMoleculeProtocol: MoleculeProtocol { - var molecule: MoleculeProtocol? {get} -} - -extension ConstrainingMoleculeProtocol { - public var molecule: MoleculeProtocol? { - get { return nil } - } -} diff --git a/MVMCoreUI/Models/ContainerMoleculeProtocol.swift b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift new file mode 100644 index 00000000..f6ff152e --- /dev/null +++ b/MVMCoreUI/Models/ContainerMoleculeProtocol.swift @@ -0,0 +1,45 @@ +// +// ContainerMoleculeProtocol.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 12/4/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol ContainerMoleculeProtocol: MoleculeProtocol { + var molecule: MoleculeProtocol? { get } + var useHorizontalMargins: Bool? { get } + var useVerticalMargins: Bool? { get } + var horizontalAlignment: String? { get } + var verticalAlignment: String? { get } +} + +extension ContainerMoleculeProtocol { + + public var molecule: MoleculeProtocol? { + get { return nil } + } + + public var backgroundColor: String? { + get { return nil } + } + + public var useHorizontalMargins: Bool? { + get { return nil } + } + + public var useVerticalMargins: Bool? { + get { return nil } + } + + public var horizontalAlignment: String? { + get { return nil } + } + + public var verticalAlignment: String? { + get { return nil } + } +} + diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 2ddc4061..53f0fee4 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -1,45 +1,15 @@ import Foundation public protocol MoleculeProtocol: Model { - var moleculeName: String? {get} - var backgroundColor: String? {get} - var dictionary: [AnyHashable: Any]? {get} - var molecule: MoleculeProtocol? {get} - - var useHorizontalMargins: Bool? {get} - var useVerticalMargins: Bool? {get} - var horizontalAlignment: String? {get} - var verticalAlignment: String? {get} + var moleculeName: String? { get } + var backgroundColor: String? { get } + var dictionary: [AnyHashable: Any]? { get } } extension MoleculeProtocol { public var moleculeName: String? { get { return Self.identifier } } - - public var molecule: MoleculeProtocol? { - get { return nil } - } - - public var backgroundColor: String? { - get { return toJSON()?["backgroundColor"] as? String } - } - - public var useHorizontalMargins: Bool? { - get { return toJSON()?["useHorizontalMargins"] as? Bool } - } - - public var useVerticalMargins: Bool? { - get { return toJSON()?["useVerticalMargins"] as? Bool } - } - - public var horizontalAlignment: String? { - get { return toJSON()?["horizontalAlignment"] as? String } - } - - public var verticalAlignment: String? { - get { return toJSON()?["verticalAlignment"] as? String } - } public var dictionary: [AnyHashable: Any]? { return toJSON() diff --git a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift index a2359f03..58aa737f 100644 --- a/MVMCoreUI/Models/Molecules/CarouselItemModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselItemModel.swift @@ -9,17 +9,14 @@ import Foundation -@objcMembers public class CarouselItemModel: MoleculeProtocol { +@objcMembers public class CarouselItemModel: ContainerMoleculeProtocol { public static var identifier: String = "carouselItem" - public var moleculeName: String public var backgroundColor: String? - public var molecule: MoleculeProtocol? - public init(molecule: MoleculeProtocol?, backgroundColor: String?) { - self.molecule = molecule - self.moleculeName = Self.identifier + public init(backgroundColor: String?) { self.backgroundColor = backgroundColor } + enum CodingKeys: String, CodingKey { case moleculeName case molecule @@ -28,8 +25,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) self.backgroundColor = try typeContainer.decode(String.self, forKey: .backgroundColor) } diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 9fce489a..60f2b27c 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -9,9 +9,8 @@ import UIKit @objcMembers public class CarouselModel: MoleculeProtocol { - public static var identifier: String = "carousel" - public var moleculeName: String + public var backgroundColor: String? public var molecules: [CarouselItemModel] public var spacing: Float? @@ -22,8 +21,7 @@ import UIKit public var itemAlignment: String? public var pagingMolecule: PagingMoleculeProtocol? - public init(molecules: [CarouselItemModel], spacing: Float?, border: Bool?, loop: Bool?, height: Float?, itemWidthPercent: Float?, itemAlignment: String?, pagingMolecule: PagingMoleculeProtocol?){ - self.moleculeName = Self.identifier + public init(molecules: [CarouselItemModel], spacing: Float?, border: Bool?, loop: Bool?, height: Float?, itemWidthPercent: Float?, itemAlignment: String?, pagingMolecule: PagingMoleculeProtocol?, backgroundColor: String?){ self.molecules = molecules self.spacing = spacing self.border = border @@ -32,6 +30,7 @@ import UIKit self.itemWidthPercent = itemWidthPercent self.itemAlignment = itemAlignment self.pagingMolecule = pagingMolecule + self.backgroundColor = backgroundColor } enum CodingKeys: String, CodingKey { @@ -48,7 +47,6 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) self.spacing = try typeContainer.decode(Float.self, forKey: .spacing) self.border = try typeContainer.decode(Bool.self, forKey: .border) diff --git a/MVMCoreUI/Models/Molecules/FooterModel.swift b/MVMCoreUI/Models/Molecules/FooterModel.swift index 38d55edd..95a45422 100644 --- a/MVMCoreUI/Models/Molecules/FooterModel.swift +++ b/MVMCoreUI/Models/Molecules/FooterModel.swift @@ -9,7 +9,7 @@ import Foundation -@objcMembers public class FooterModel: ConstrainingMoleculeProtocol { +@objcMembers public class FooterModel: ContainerMoleculeProtocol { public static var identifier: String = "footer" public var moleculeName: String? public var backgroundColor: String? @@ -17,7 +17,6 @@ import Foundation public init(molecule: MoleculeProtocol?, backgroundColor: String?){ self.molecule = molecule - self.moleculeName = Self.identifier self.backgroundColor = backgroundColor } diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift index 4cd76354..aa298716 100644 --- a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -9,7 +9,7 @@ import Foundation public protocol FormModelProtocol: Model { - var required: Bool? {get} - var fieldKey: String? {get} - var groupName: String? {get} + var required: Bool? { get } + var fieldKey: String? { get } + var groupName: String? { get } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index a1cd7cec..9016184b 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class HeaderModel: ConstrainingMoleculeProtocol { +@objcMembers public class HeaderModel: ContainerMoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? public var backgroundColor: String? @@ -17,7 +17,6 @@ import Foundation public init(molecule: MoleculeProtocol?, backgroundColor: String?, seperator: SeperatorModel?){ self.molecule = molecule - self.moleculeName = Self.identifier self.backgroundColor = backgroundColor self.seperator = seperator } @@ -45,4 +44,3 @@ import Foundation try container.encodeIfPresent(self.seperator, forKey: .separator) } } - diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index f4a8a0f3..0e4f22f6 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -10,39 +10,16 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? - public var style: String? public var headline: LabelModel public var body: LabelModel + public var style: String? + public var backgroundColor: String? - public init(style: String?, headline: LabelModel, body: LabelModel) { - self.moleculeName = Self.identifier - self.style = style + public init(headline: LabelModel, body: LabelModel, style: String?, backgroundColor: String?) { self.headline = headline self.body = body - } - - enum CodingKeys: String, CodingKey { - case moleculeName - case style - case headline - case body - } - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) - self.headline = try typeContainer.decode(LabelModel.self, forKey: .headline) - self.body = try typeContainer.decode(LabelModel.self, forKey: .body) - self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(moleculeName, forKey: .moleculeName) - try container.encode(headline, forKey: .headline) - try container.encode(body, forKey: .body) - try container.encodeIfPresent(self.style, forKey: .style) + self.style = style + self.backgroundColor = backgroundColor } } diff --git a/MVMCoreUI/Models/Molecules/LineModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift index 6266b03e..e00ba1fc 100644 --- a/MVMCoreUI/Models/Molecules/LineModel.swift +++ b/MVMCoreUI/Models/Molecules/LineModel.swift @@ -10,11 +10,10 @@ import UIKit @objcMembers public class LineModel: MoleculeProtocol { public static var identifier: String = "line" - public var moleculeName: String? + public var backgroundColor: String? public var type: String? public init(type: String?) { - self.type = type - self.moleculeName = Self.identifier + self.type = type } } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 4c7d01cf..9bfe704a 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -8,10 +8,10 @@ import Foundation -@objcMembers public class ListItemModel: MoleculeProtocol { +@objcMembers public class ListItemModel: ContainerMoleculeProtocol { public static var identifier: String = "listItem" - public var moleculeName: String? public var molecule: MoleculeProtocol? + public var backgroundColor: String? public var action: ActionModel? public var hideArrow: Bool? @@ -21,7 +21,6 @@ import Foundation public init(molecule: MoleculeProtocol?, actionMap: ActionModel?, hideArrow: Bool?, separator: SeperatorModel?, style: String?) { self.molecule = molecule self.action = actionMap - self.moleculeName = Self.identifier self.hideArrow = hideArrow self.separator = separator self.style = style @@ -38,7 +37,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 15ce347f..e01d3def 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -11,4 +11,5 @@ import Foundation class ModuleMoleculeModel: MoleculeProtocol { public static var identifier: String = "moduleMolecule" public var moduleName: String + public var backgroundColor: String? } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index ea01c844..1a7e6f73 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -10,8 +10,9 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "stackItem" - public var moleculeName: String + public var molecule: MoleculeProtocol? + public var backgroundColor: String? public var spacing: CGFloat? public var percentage: Int? @@ -21,8 +22,6 @@ import Foundation public init(molecule: MoleculeProtocol?, spacing: CGFloat?, percentage: Int?, verticalAlignment: String?, horizontalAlignment: String?, gone: Bool = false) { self.molecule = molecule - self.moleculeName = Self.identifier - self.spacing = spacing self.percentage = percentage self.verticalAlignment = verticalAlignment @@ -41,7 +40,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) self.spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 088a2733..9c462339 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class MoleculeStackModel: MoleculeProtocol { public static var identifier: String = "moleculeStack" - public var moleculeName: String? + public var backgroundColor: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? public var spacing: Float? @@ -19,7 +19,6 @@ import Foundation public init(axis: String?, molecules: [MoleculeStackItemModel]?, spacing: Float?) { self.axis = axis self.molecules = molecules - self.moleculeName = Self.identifier self.spacing = spacing } @@ -32,7 +31,6 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecules = try typeContainer.decodeIfPresent([MoleculeStackItemModel].self, forKey: .molecules) self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis) self.spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index 55f2ae75..b58c7602 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -10,5 +10,6 @@ import UIKit @objcMembers public class SeperatorModel: MoleculeProtocol { public static var identifier: String = "line" - public var type: String + public var backgroundColor: String? + public var type: String? } diff --git a/MVMCoreUI/Models/Molecules/TextFieldModel.swift b/MVMCoreUI/Models/Molecules/TextFieldModel.swift index 77454895..f9b11d5f 100644 --- a/MVMCoreUI/Models/Molecules/TextFieldModel.swift +++ b/MVMCoreUI/Models/Molecules/TextFieldModel.swift @@ -9,7 +9,9 @@ import UIKit @objcMembers public class TextFieldModel: MoleculeProtocol, FormModelProtocol { + public static var identifier: String = "textField" + public var backgroundColor: String? public var editable = true public var disabled = false diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift new file mode 100644 index 00000000..cafe5915 --- /dev/null +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -0,0 +1,114 @@ +// +// Color.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 11/26/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +public final class Color: Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public let uiColor: UIColor + public private(set) var hex: String = "" + public private(set) var name: String = "" + + // Color metadata + public private(set) var red: CGFloat = 0 + public private(set) var green: CGFloat = 0 + public private(set) var blue: CGFloat = 0 + public private(set) var alpha: CGFloat = 1 + + public var hexWithHash: String { + return "#" + hex + } + + //-------------------------------------------------- + // MARK: - Error + //-------------------------------------------------- + + enum ColorError: Error { + case badName(reason: String) + } + + //-------------------------------------------------- + // MARK: - Class Initializers + //-------------------------------------------------- + + init(uiColor: UIColor) { + self.uiColor = uiColor + hex = UIColor.hexString(for: uiColor) ?? "" + determineRGBA() + } + + init?(name: String) { + guard let colorTuple = UIColor.getColorAndHexFromName(name) else { return nil } + self.uiColor = colorTuple.uiColor + self.hex = colorTuple.hex + determineRGBA() + } + + //-------------------------------------------------- + // MARK: - Codable Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let colorString = try container.decode(String.self) + + if colorString.hasPrefix("#") { + hex = colorString.replacingOccurrences(of: "#", with: "") + } else { + guard let hex = UIColor.getColorAndHexFromName(colorString)?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") } + self.hex = hex.replacingOccurrences(of: "#", with: "") + name = colorString + } + + if hex.count == 8 { + uiColor = UIColor.getColorWithTransparencyBy(hex: hex) + } else { + uiColor = UIColor.getColorBy(hex: hex) + } + + determineRGBA() + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(hexWithHash) + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func convertHexToFloat(start: String.Index, end: String.Index) -> CGFloat { + + return CGFloat(Int(hex[start.. String? { - guard let moleculeModel = molecule?.molecule else { + guard let moleculeModel = (molecule as? ContainerMoleculeProtocol)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 4b0e75cf..ffaefcb5 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -197,7 +197,7 @@ import UIKit } public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let moleculeModel = molecule?.molecule, + guard let moleculeModel = (molecule as? ContainerMoleculeProtocol)?.molecule, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else { return 80 diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index 7f179a07..1ce3ceb2 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -35,7 +35,7 @@ import UIKit setUpWithModel(model, delegateObject, additionalData) guard let model = model, - let moleculeModel = (model as? ConstrainingMoleculeProtocol)?.molecule else { + let moleculeModel = (model as? ContainerMoleculeProtocol)?.molecule else { return } diff --git a/MVMCoreUI/Organisms/MoleculeStackView.swift b/MVMCoreUI/Organisms/MoleculeStackView.swift index fd6896e4..dc5db34f 100644 --- a/MVMCoreUI/Organisms/MoleculeStackView.swift +++ b/MVMCoreUI/Organisms/MoleculeStackView.swift @@ -280,7 +280,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol } else if let previousView = stackItems.last(where: { stackItem in return !stackItem.gone })?.view { - _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: true) + view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0) @@ -297,7 +297,7 @@ public class MoleculeStackView: ViewConstrainingView, ModelMoleculeViewProtocol } else if let previousView = stackItems.last(where: { stackItem in return !stackItem.gone })?.view { - _ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: false) + view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true } pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0) pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 44bb0a56..a7b8e586 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -36,10 +36,11 @@ @"footer": StandardFooterView.class, @"caretView": CaretView.class, @"caretButton": CaretButton.class, - @"textField" : MFTextField.class, - @"digitTextField" : MFDigitTextField.class, - @"checkbox" : Checkbox.class, - @"checkboxWithLabel" : CheckboxWithLabelView.class, + @"textField": MFTextField.class, + @"dropDown": DropDown.class, + @"digitTextField": MFDigitTextField.class, + @"checkbox": Checkbox.class, + @"checkboxWithLabel": CheckboxWithLabelView.class, @"cornerLabels" : CornerLabels.class, @"progressbar": ProgressBar.class, @"circleProgress": GraphView.class, @@ -64,6 +65,7 @@ @"headlineBodyTextButton": HeadlineBodyTextButton.class, @"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class, @"tabsListItem": TabsTableViewCell.class, + @"dropDownListItem": DropDownFilterTableViewCell.class, @"headlineBodyButton": HeadlineBodyButton.class, @"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class } mutableCopy]; diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index 5b73c8e2..bdef57ba 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -210,6 +210,7 @@ B3 -> Legal /// Will style the label based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20 + (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style; ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelH1:(nonnull UILabel *)label; @@ -258,6 +259,7 @@ B3 -> Legal /// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20 + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style; ++ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string; @@ -266,6 +268,14 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; ++ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + (nonnull NSAttributedString *)styleGetDisabledB2AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 18246f7f..c3dc8946 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -516,26 +516,30 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 2.0 Styles -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style { ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { if ([style isEqualToString:@"H1"]) { - [self styleLabelH1:label]; + [self styleLabelH1:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H2"]) { - [self styleLabelH2:label]; + [self styleLabelH2:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H3"]) { - [self styleLabelH3:label]; + [self styleLabelH3:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"H32"]) { - [self styleLabelH32:label]; + [self styleLabelH32:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B1"]) { - [self styleLabelB1:label]; + [self styleLabelB1:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B3"]) { - [self styleLabelB3:label]; + [self styleLabelB3:label genericScaling:genericScaling]; } else if ([style isEqualToString:@"B20"]) { - [self styleLabelB20:label]; + [self styleLabelB20:label genericScaling:genericScaling]; } else { - [self styleLabelB2:label]; + [self styleLabelB2:label genericScaling:genericScaling]; } } ++ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style { + [self styleLabel:label withStyle:style genericScaling:YES]; +} + + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontH1:genericScaling]; label.textColor = [UIColor blackColor]; @@ -656,22 +660,26 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - Attributed Strings + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style { + return [self styleGetAttributedString:string withStyle:style genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { if ([style isEqualToString:@"H1"]) { - return [self styleGetH1AttributedString:string]; + return [self styleGetH1AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H2"]) { - return [self styleGetH2AttributedString:string]; + return [self styleGetH2AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H3"]) { - return [self styleGetH3AttributedString:string]; + return [self styleGetH3AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"H32"]) { - return [self styleGetH32AttributedString:string]; + return [self styleGetH32AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B1"]) { - return [self styleGetB1AttributedString:string]; + return [self styleGetB1AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B3"]) { - return [self styleGetB3AttributedString:string]; + return [self styleGetB3AttributedString:string genericScaling:genericScaling]; } else if ([style isEqualToString:@"B20"]) { - return [self styleGetB20AttributedString:string]; + return [self styleGetB20AttributedString:string genericScaling:genericScaling]; } else { - return [self styleGetB2AttributedString:string]; + return [self styleGetB2AttributedString:string genericScaling:genericScaling]; } } @@ -690,35 +698,67 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1] color:[UIColor blackColor]]; + return [MFStyler styleGetH1AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor blackColor]]; + return [MFStyler styleGetH2AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]]; + return [MFStyler styleGetH3AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32] color:[UIColor blackColor]]; + return [MFStyler styleGetH32AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor blackColor]]; + return [MFStyler styleGetB1AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor blackColor]]; + return [MFStyler styleGetB2AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfBattleshipGrey]]; + return [MFStyler styleGetB3AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3:genericScaling] color:[UIColor mfBattleshipGrey]]; } + (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string { - return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20] color:[UIColor blackColor]]; + return [MFStyler styleGetB20AttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20:genericScaling] color:[UIColor blackColor]]; } + (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string {