From b5bd23c38c2f32af5b97e977987f9eb502b0f70a Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 21 May 2020 15:41:24 +0530 Subject: [PATCH 01/12] 21042(iOS - List - Left Variable - Icon - With Right Caret - Body Text) initial commit. Added model and molecule class files. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...ftVariableIconWithRightCaretBodyText.swift | 78 +++++++++++++++++++ ...iableIconWithRightCaretBodyTextModel.swift | 56 +++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ba954d23..1238577b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -181,6 +181,8 @@ 94CA227D24058534002D6750 /* VerizonNHGeDS-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227924058533002D6750 /* VerizonNHGeDS-Regular.otf */; }; 94CA227E24058534002D6750 /* VerizonNHGeDS-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227A24058533002D6750 /* VerizonNHGeDS-Bold.otf */; }; 94F6516D2437954100631BF9 /* Tabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94F6516C2437954100631BF9 /* Tabs.swift */; }; + AA0A257824766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */; }; + AA0A257A24766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */; }; AA104B1A24474A66004D2810 /* HeadersH2Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA104B1924474A66004D2810 /* HeadersH2Buttons.swift */; }; AA104B1C24474A76004D2810 /* HeadersH2ButtonsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA104B1B24474A76004D2810 /* HeadersH2ButtonsModel.swift */; }; AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; @@ -600,6 +602,8 @@ 94CA227A24058533002D6750 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = ""; }; 94CA227B24058533002D6750 /* VerizonNHGeTX-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Regular.otf"; sourceTree = ""; }; 94F6516C2437954100631BF9 /* Tabs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tabs.swift; sourceTree = ""; }; + AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretBodyTextModel.swift; sourceTree = ""; }; + AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretBodyText.swift; sourceTree = ""; }; AA104B1924474A66004D2810 /* HeadersH2Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2Buttons.swift; sourceTree = ""; }; AA104B1B24474A76004D2810 /* HeadersH2ButtonsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2ButtonsModel.swift; sourceTree = ""; }; AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; @@ -1289,6 +1293,8 @@ 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */, AA99724F2475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift */, AA997251247530B100FC7472 /* ListLeftVariableIconAllTextLinks.swift */, + AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */, + AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */, ); path = LeftVariable; sourceTree = ""; @@ -1943,6 +1949,7 @@ files = ( AAC6F167243332E400F295C1 /* RadioSwatchesModel.swift in Sources */, 5248BFED23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift in Sources */, + AA0A257824766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift in Sources */, 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */, 943784F5236B77BB006A1E82 /* Wheel.swift in Sources */, @@ -2309,6 +2316,7 @@ 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */, + AA0A257A24766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift in Sources */, 011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, 0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index e46cfed0..d29b652a 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -147,6 +147,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxBodyText.self, viewModelClass: ListLeftVariableCheckboxBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconAllTextLinks.self, viewModelClass: ListLeftVariableIconAllTextLinksModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaretBodyText.self, viewModelClass: ListLeftVariableIconWithRightCaretBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableTotalData.self, viewModelClass: ListRightVariableTotalDataModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift new file mode 100644 index 00000000..626d9c19 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -0,0 +1,78 @@ +// +// ListLeftVariableIconWithRightCaretBodyText.swift +// MVMCoreUI +// +// Created by Lekshmi S on 21/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListLeftVariableIconWithRightCaretBodyText: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public let leftImage = LoadImageView() + public let headlineBody = HeadlineBody() + public let rightLabel = Label.commonLabelB2(true) + private let rightLabelStackItem: StackItem + public var stack: Stack + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + rightLabelStackItem = StackItem(andContain: rightLabel) + let stackItems = [StackItem(andContain: leftImage), StackItem(andContain: headlineBody), rightLabelStackItem] + let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 4, horizontalAlignment: .trailing)], axis: .horizontal) + stack = Stack(with: stackModel, stackItems: stackItems) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func alignAccessoryToHero() -> CGPoint? { + // Ensures that the right label is centered vertically with headline. + let heroCenter = super.alignAccessoryToHero() + if let heroCenter = heroCenter { + let convertedPoint = stack.convert(heroCenter, from: self) + rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY + } + return heroCenter + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + override open func setupView() { + super.setupView() + leftImage.addSizeConstraintsForAspectRatio = true + leftImage.contentMode = .scaleAspectFit + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.numberOfLines = 1 + 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? ListLeftVariableIconWithRightCaretBodyTextModel else { return} + leftImage.set(with: model.image, delegateObject, additionalData) + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + rightLabel.styleB2(true) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift new file mode 100644 index 00000000..e2bd5d90 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -0,0 +1,56 @@ +// +// ListLeftVariableIconWithRightCaretBodyTextModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 21/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "listLVImgBdy" + public var image: ImageViewModel + public var headlineBody: HeadlineBodyModel + public var rightLabel: LabelModel + + override public func setDefaults() { + super.setDefaults() + if image.width == nil, image.height == nil { + image.width = 30 + image.height = 30 + } + headlineBody.style = .item + headlineBody.headline?.hero = 0 + } + + public init(image: ImageViewModel, headlineBody: HeadlineBodyModel, rightLabel: LabelModel) { + self.image = image + self.headlineBody = headlineBody + self.rightLabel = rightLabel + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case image + case headlineBody + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + image = try typeContainer.decode(ImageViewModel.self, forKey: .image) + headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + 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(image, forKey: .image) + try container.encode(headlineBody, forKey: .headlineBody) + try container.encode(rightLabel, forKey: .rightLabel) + } +} From 729a73a1a0f7ad94631477e30e7468c42eaf32a7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 10:51:23 -0400 Subject: [PATCH 02/12] remove panel from navigation setting. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ---- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../NavigationBar/NavigationItemModel.swift | 12 +----------- .../PanelNavigationItemModelProtocol.swift | 14 -------------- MVMCoreUI/BaseControllers/ViewController.swift | 6 ++++-- MVMCoreUI/Containers/NavigationController.swift | 6 ------ 6 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Protocols/ModelProtocols/PanelNavigationItemModelProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9079fc39..b532841b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -273,7 +273,6 @@ D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; }; D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; - D23EA7E82473654300D60C34 /* PanelNavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA7E72473654300D60C34 /* PanelNavigationItemModelProtocol.swift */; }; D23EA7FB2475F09800D60C34 /* CarouselItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA7FA2475F09800D60C34 /* CarouselItemProtocol.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D2509ED12472ED9B001BFB9D /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */; }; @@ -699,7 +698,6 @@ D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = ""; }; D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; - D23EA7E72473654300D60C34 /* PanelNavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanelNavigationItemModelProtocol.swift; sourceTree = ""; }; D23EA7FA2475F09800D60C34 /* CarouselItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemProtocol.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; @@ -884,7 +882,6 @@ D2E2A9A223E096B1000B42E6 /* DisableableModelProtocol.swift */, D2092354244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift */, D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */, - D23EA7E72473654300D60C34 /* PanelNavigationItemModelProtocol.swift */, ); path = ModelProtocols; sourceTree = ""; @@ -2124,7 +2121,6 @@ 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, - D23EA7E82473654300D60C34 /* PanelNavigationItemModelProtocol.swift in Sources */, 94F6516D2437954100631BF9 /* Tabs.swift in Sources */, 5248BFEC23F12E350059236A /* ListThreeColumnPlanDataDivider.swift in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 18b3fee7..42b700ac 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -134,6 +134,7 @@ import Foundation // Other Molecules MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self) + try? ModelRegistry.register(NavigationItemModel.self) // Other Organisms MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 41a35182..b62bb399 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -8,7 +8,7 @@ import Foundation -public class NavigationItemModel: NavigationItemModelProtocol, PanelNavigationItemModelProtocol, MoleculeModelProtocol { +public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtocol { public class var identifier: String { return "navigationBar" } @@ -22,17 +22,11 @@ public class NavigationItemModel: NavigationItemModelProtocol, PanelNavigationIt public var additionalLeftButtons: [NavigationItemButtonModel]? public var additionalRightButtons: [NavigationItemButtonModel]? - // Legacy, will remove once menu is gone. - public var showLeftPanelButton: Bool - public var showRightPanelButton: Bool - public init() { hidden = false backgroundColor = Color(uiColor: .white) tintColor = Color(uiColor: .black) line = LineModel(type: .standard) - showLeftPanelButton = true - showRightPanelButton = true backButton = NavigationItemButtonModel(with: "back", action: ActionBackModel()) } @@ -57,8 +51,6 @@ public class NavigationItemModel: NavigationItemModelProtocol, PanelNavigationIt tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) backButton = try typeContainer.decodeIfPresent(NavigationItemButtonModel.self, forKey: .backButton) ?? NavigationItemButtonModel(with: "back", action: ActionBackModel()) - showLeftPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showLeftPanelButton) ?? true - showRightPanelButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .showRightPanelButton) ?? true additionalLeftButtons = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalLeftButtons) additionalRightButtons = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalRightButtons) } @@ -71,8 +63,6 @@ public class NavigationItemModel: NavigationItemModelProtocol, PanelNavigationIt try container.encode(tintColor, forKey: .tintColor) try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(backButton, forKey: .backButton) - try container.encode(showLeftPanelButton, forKey: .showLeftPanelButton) - try container.encode(showRightPanelButton, forKey: .showRightPanelButton) try container.encodeIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons) try container.encodeIfPresent(additionalRightButtons, forKey: .additionalRightButtons) } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PanelNavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PanelNavigationItemModelProtocol.swift deleted file mode 100644 index 8f599be4..00000000 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PanelNavigationItemModelProtocol.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// PanelNavigationItemModelProtocol.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 5/18/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -public protocol PanelNavigationItemModelProtocol { - var showLeftPanelButton: Bool { get set } - var showRightPanelButton: Bool { get set } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 782deae2..eb92dd85 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -163,8 +163,6 @@ import UIKit open func createDefaultLegacyNavigationModel() -> NavigationItemModel { let navigationModel = NavigationItemModel() navigationModel.title = pageModel?.screenHeading - navigationModel.showLeftPanelButton = isMasterInitiallyAccessible() - navigationModel.showRightPanelButton = isSupportInitiallyAccessible() if /*(self as? MVMCoreUITabBarPageControlViewController) != nil ||*/ manager != nil || loadObject?.requestParameters?.tabWasPressed ?? false == true { navigationModel.line = LineModel(type: .none) } @@ -203,6 +201,10 @@ import UIKit showBottomProgressBar() } NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + + // TODO: Legacy Update Panels. Change how this is done. + MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(isMasterInitiallyAccessible(), for: viewController) + MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(isSupportInitiallyAccessible(), for: viewController) } // Eventually will be moved to server diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 4367f2e1..0b2d1546 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -95,11 +95,5 @@ import UIKit // Update icons if main navigation controller. MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) - - // Update Panels - if let model = navigationItemModel as? PanelNavigationItemModelProtocol { - MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(model.showLeftPanelButton, for: viewController) - MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(model.showRightPanelButton, for: viewController) - } } } From abbe26b4bdd3b3009feab63c0ea28535dba88582 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 14:05:48 -0400 Subject: [PATCH 03/12] Move enable able from button protocol added navigation button atoms and protocol. Changed the way split handles additional buttons --- MVMCoreUI.xcodeproj/project.pbxproj | 32 +++++++++++-- .../Atomic/Atoms/Buttons/ButtonModel.swift | 2 +- .../Atomic/Atoms/Buttons/CaretLinkModel.swift | 2 +- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 2 +- .../Buttons/ImageBarButtonItem.swift | 45 +++++++++++++++++ .../Buttons/LabelBarButtonItem.swift | 44 +++++++++++++++++ .../NavigationButtomModelProtocol.swift | 15 ++++++ .../NavigationImageButtonModel.swift} | 11 +++-- .../Buttons/NavigationLabelButtonModel.swift | 44 +++++++++++++++++ .../NavigationBar/NavigationItemModel.swift | 20 ++++---- .../ModelProtocols/ButtonModelProtocol.swift | 2 +- .../NavigationItemModelProtocol.swift | 6 +-- MVMCoreUI/BaseClasses/BarButtonItem.swift | 40 ++-------------- MVMCoreUI/BaseClasses/Button.swift | 6 ++- .../BaseControllers/ViewController.swift | 22 +++++---- .../Containers/NavigationController.swift | 14 ++---- .../MVMCoreUISplitViewController.m | 48 +------------------ 17 files changed, 227 insertions(+), 128 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift rename MVMCoreUI/Atomic/Molecules/NavigationBar/{NavigationItemButtonModel.swift => Buttons/NavigationImageButtonModel.swift} (74%) create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b532841b..0ebd9799 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -274,9 +274,12 @@ D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; D23EA7FB2475F09800D60C34 /* CarouselItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA7FA2475F09800D60C34 /* CarouselItemProtocol.swift */; }; + D23EA7FE247EBBB700D60C34 /* NavigationLabelButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA7FD247EBBB700D60C34 /* NavigationLabelButtonModel.swift */; }; + D23EA800247EBD6C00D60C34 /* LabelBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA7FF247EBD6C00D60C34 /* LabelBarButtonItem.swift */; }; + D23EA802247EBED400D60C34 /* ImageBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23EA801247EBED400D60C34 /* ImageBarButtonItem.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; D2509ED12472ED9B001BFB9D /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */; }; - D2509ED62472EE2F001BFB9D /* NavigationItemButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2509ED52472EE2F001BFB9D /* NavigationItemButtonModel.swift */; }; + D2509ED62472EE2F001BFB9D /* NavigationImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2509ED52472EE2F001BFB9D /* NavigationImageButtonModel.swift */; }; D253BB8A24574CC5002DE544 /* StackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106423D0CEA700764D80 /* StackModel.swift */; }; D253BB9C245874F8002DE544 /* BGImageMolecule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D253BB9B245874F8002DE544 /* BGImageMolecule.swift */; }; D253BB9E2458751F002DE544 /* BGImageMoleculeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D253BB9D2458751F002DE544 /* BGImageMoleculeModel.swift */; }; @@ -323,6 +326,7 @@ D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; }; D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */; }; D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */; }; + D28BA730247EC2EB00B75CB8 /* NavigationButtomModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28BA72F247EC2EB00B75CB8 /* NavigationButtomModelProtocol.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */; }; D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29C94D4242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift */; }; @@ -699,9 +703,12 @@ D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; D23EA7FA2475F09800D60C34 /* CarouselItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemProtocol.swift; sourceTree = ""; }; + D23EA7FD247EBBB700D60C34 /* NavigationLabelButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationLabelButtonModel.swift; sourceTree = ""; }; + D23EA7FF247EBD6C00D60C34 /* LabelBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelBarButtonItem.swift; sourceTree = ""; }; + D23EA801247EBED400D60C34 /* ImageBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageBarButtonItem.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; D2509ED02472ED9B001BFB9D /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; - D2509ED52472EE2F001BFB9D /* NavigationItemButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationItemButtonModel.swift; sourceTree = ""; }; + D2509ED52472EE2F001BFB9D /* NavigationImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationImageButtonModel.swift; sourceTree = ""; }; D253BB9B245874F8002DE544 /* BGImageMolecule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageMolecule.swift; sourceTree = ""; }; D253BB9D2458751F002DE544 /* BGImageMoleculeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageMoleculeModel.swift; sourceTree = ""; }; D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; @@ -746,6 +753,7 @@ D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = ""; }; D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerLabelsModel.swift; sourceTree = ""; }; D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyCaretLinkImageModel.swift; sourceTree = ""; }; + D28BA72F247EC2EB00B75CB8 /* NavigationButtomModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationButtomModelProtocol.swift; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMolecule.swift; sourceTree = ""; }; D29C94D4242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUICommonViewsUtility+Extension.swift"; sourceTree = ""; }; @@ -1361,10 +1369,22 @@ path = TwoColumn; sourceTree = ""; }; + D23EA7FC247EBB7500D60C34 /* Buttons */ = { + isa = PBXGroup; + children = ( + D28BA72F247EC2EB00B75CB8 /* NavigationButtomModelProtocol.swift */, + D2509ED52472EE2F001BFB9D /* NavigationImageButtonModel.swift */, + D23EA801247EBED400D60C34 /* ImageBarButtonItem.swift */, + D23EA7FD247EBBB700D60C34 /* NavigationLabelButtonModel.swift */, + D23EA7FF247EBD6C00D60C34 /* LabelBarButtonItem.swift */, + ); + path = Buttons; + sourceTree = ""; + }; D2509ED42472EE0B001BFB9D /* NavigationBar */ = { isa = PBXGroup; children = ( - D2509ED52472EE2F001BFB9D /* NavigationItemButtonModel.swift */, + D23EA7FC247EBB7500D60C34 /* Buttons */, D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */, ); path = NavigationBar; @@ -1976,7 +1996,7 @@ 8D3BA9BF2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift in Sources */, 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */, D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, - D2509ED62472EE2F001BFB9D /* NavigationItemButtonModel.swift in Sources */, + D2509ED62472EE2F001BFB9D /* NavigationImageButtonModel.swift in Sources */, 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, @@ -2153,7 +2173,9 @@ BB54C5212434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift in Sources */, D2092349244A51D40044AD09 /* RadioSwatchModel.swift in Sources */, 8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */, + D23EA802247EBED400D60C34 /* ImageBarButtonItem.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, + D23EA800247EBD6C00D60C34 /* LabelBarButtonItem.swift in Sources */, 01EB368F23609801006832FA /* LabelModel.swift in Sources */, 0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */, AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */, @@ -2223,6 +2245,7 @@ BBAA4F03243D8E3B005AAD5F /* RadioBoxes.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, + D28BA730247EC2EB00B75CB8 /* NavigationButtomModelProtocol.swift in Sources */, 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */, D20FB165241A5D75004AFC3A /* NavigationItemModel.swift in Sources */, AA2AD118244EE48C00BBFFE3 /* ListDeviceComplexLinkMediumModel.swift in Sources */, @@ -2291,6 +2314,7 @@ 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, + D23EA7FE247EBBB700D60C34 /* NavigationLabelButtonModel.swift in Sources */, D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index b0e4d54d..0881af71 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -11,7 +11,7 @@ import UIKit public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) -public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol { +public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift index 5a4a4c14..a37baeca 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift @@ -10,7 +10,7 @@ import Foundation import MVMCore -public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol { +public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index d51bddf4..bd1b601d 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -9,7 +9,7 @@ import UIKit -open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol { +open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift new file mode 100644 index 00000000..564b9f42 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -0,0 +1,45 @@ +// +// ImageBarButtonItem.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 5/27/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ImageBarButtonItem: BarButtonItem { + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public static func create(with image: UIImage?) -> Self { + let actionObject = ActionDelegate() + let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:))) + button.actionDelegate = actionObject + return button + } + + /// Creates the item with the passed in action. + public static func create(with image: UIImage?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + let button = create(with: image) + button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) + return button + } + + /// Creates the item with the passed in action map. + public static func create(with image: UIImage?, actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + let button = create(with: image) + button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + return button + } + + /// Creates the item with the passed in action. + public static func create(with image: UIImage?, action: @escaping BarButtonAction) -> Self { + let button = create(with: image) + button.actionDelegate?.buttonAction = action + return button + } +} + diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift new file mode 100644 index 00000000..4d31a84c --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/LabelBarButtonItem.swift @@ -0,0 +1,44 @@ +// +// LabelBarButtonItem.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 5/27/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class LabelBarButtonItem: BarButtonItem { + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public static func create(with title: String?) -> Self { + let actionObject = ActionDelegate() + let button = self.init(title: title, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:))) + button.actionDelegate = actionObject + return button + } + + /// Creates the item with the passed in action. + public static func create(with title: String?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + let button = create(with: title) + button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) + return button + } + + /// Creates the item with the passed in action map. + public static func create(with title: String?, actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { + let button = create(with: title) + button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) + return button + } + + /// Creates the item with the passed in action. + public static func create(with title: String?, action: @escaping BarButtonAction) -> Self { + let button = create(with: title) + button.actionDelegate?.buttonAction = action + return button + } +} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift new file mode 100644 index 00000000..3f38ce43 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift @@ -0,0 +1,15 @@ +// +// NavigationButtomModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 5/27/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol NavigationButtomModelProtocol: ButtonModelProtocol { + //var color: Color? { get set } + + func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem +} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift similarity index 74% rename from MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemButtonModel.swift rename to MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index 26be6952..b4173e8b 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -7,9 +7,12 @@ import Foundation -public class NavigationItemButtonModel: Codable { - var imageName: String - var action: ActionModelProtocol +public class NavigationImageButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol { + public var backgroundColor: Color? + public static var identifier: String = "navigationImageButton" + + public var imageName: String + public var action: ActionModelProtocol public init(with imageName: String, action: ActionModelProtocol) { self.imageName = imageName @@ -36,6 +39,6 @@ public class NavigationItemButtonModel: Codable { /// Convenience function that creates a BarButtonItem for the model. public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> BarButtonItem { let image = UIImage(named: imageName, in: MVMCoreCache.shared()?.bundleToUseForImages(), compatibleWith: nil) - return BarButtonItem.create(with: image, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + return ImageBarButtonItem.create(with: image, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift new file mode 100644 index 00000000..6b253459 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift @@ -0,0 +1,44 @@ +// +// NavigationLabelButtonModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 5/27/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class NavigationLabelButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol { + public var backgroundColor: Color? + public static var identifier: String = "navigationLabelButton" + + public var title: String + public var action: ActionModelProtocol + + public init(with title: String, action: ActionModelProtocol) { + self.title = title + self.action = action + } + + private enum CodingKeys: String, CodingKey { + case title + case action + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decode(String.self, forKey: .title) + action = try typeContainer.decodeModel(codingKey: .action) + } + + open func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(title, forKey: .title) + try container.encodeModel(action, forKey: .action) + } + + /// Convenience function that creates a BarButtonItem for the model. + public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> BarButtonItem { + return LabelBarButtonItem.create(with: title, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index b62bb399..f29f1e38 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -18,16 +18,16 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt public var backgroundColor: Color? public var tintColor: Color public var line: LineModel? - public var backButton: NavigationItemButtonModel? - public var additionalLeftButtons: [NavigationItemButtonModel]? - public var additionalRightButtons: [NavigationItemButtonModel]? + public var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)? + public var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? + public var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? public init() { hidden = false backgroundColor = Color(uiColor: .white) tintColor = Color(uiColor: .black) line = LineModel(type: .standard) - backButton = NavigationItemButtonModel(with: "back", action: ActionBackModel()) + backButton = NavigationImageButtonModel(with: "back", action: ActionBackModel()) } private enum CodingKeys: String, CodingKey { @@ -50,9 +50,9 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white) tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - backButton = try typeContainer.decodeIfPresent(NavigationItemButtonModel.self, forKey: .backButton) ?? NavigationItemButtonModel(with: "back", action: ActionBackModel()) - additionalLeftButtons = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalLeftButtons) - additionalRightButtons = try typeContainer.decodeIfPresent([NavigationItemButtonModel].self, forKey: .additionalRightButtons) + backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) ?? NavigationImageButtonModel(with: "back", action: ActionBackModel()) + additionalLeftButtons = try typeContainer.decodeModels(codingKey: .additionalLeftButtons) + additionalRightButtons = try typeContainer.decodeModels(codingKey: .additionalRightButtons) } open func encode(to encoder: Encoder) throws { @@ -62,8 +62,8 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt try container.encode(backgroundColor, forKey: .backgroundColor) try container.encode(tintColor, forKey: .tintColor) try container.encodeIfPresent(line, forKey: .line) - try container.encodeIfPresent(backButton, forKey: .backButton) - try container.encodeIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons) - try container.encodeIfPresent(additionalRightButtons, forKey: .additionalRightButtons) + try container.encodeModelIfPresent(backButton, forKey: .backButton) + try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons) + try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons) } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift index 1288f4e3..71c3b232 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/ButtonModelProtocol.swift @@ -8,6 +8,6 @@ import Foundation -public protocol ButtonModelProtocol: EnableableModelProtocol { +public protocol ButtonModelProtocol { var action: ActionModelProtocol { get set } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index 0bd192e3..e6491ac3 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -14,7 +14,7 @@ public protocol NavigationItemModelProtocol { var backgroundColor: Color? { get set } var tintColor: Color { get set } var line: LineModel? { get set } - var backButton: NavigationItemButtonModel? { get set } - var additionalLeftButtons: [NavigationItemButtonModel]? { get set } - var additionalRightButtons: [NavigationItemButtonModel]? { get set } + var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)? { get set } + var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set } + var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set } } diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index ac26c040..f2da9c7c 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -8,9 +8,9 @@ public typealias BarButtonAction = (BarButtonItem) -> () -@objc fileprivate class ActionDelegate: NSObject { - fileprivate var buttonAction: BarButtonAction? - @objc fileprivate func callActionBlock(_ sender: BarButtonItem) { +@objc internal class ActionDelegate: NSObject { + internal var buttonAction: BarButtonAction? + @objc internal func callActionBlock(_ sender: BarButtonItem) { buttonAction?(sender) } } @@ -22,39 +22,7 @@ public typealias BarButtonAction = (BarButtonItem) -> () //-------------------------------------------------- open weak var buttonDelegate: ButtonDelegateProtocol? - private var actionDelegate: ActionDelegate? - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - public static func create(with image: UIImage?) -> Self { - let actionObject = ActionDelegate() - let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:))) - button.actionDelegate = actionObject - return button - } - - /// Creates the item with the passed in action. - public static func create(with image: UIImage?, actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: image) - button.set(with: actionModel, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action map. - public static func create(with image: UIImage?, actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: image) - button.set(with: actionMap, delegateObject: delegateObject, additionalData: additionalData) - return button - } - - /// Creates the item with the passed in action. - public static func create(with image: UIImage?, action: @escaping BarButtonAction) -> Self { - let button = create(with: image) - button.actionDelegate?.buttonAction = action - return button - } + internal var actionDelegate: ActionDelegate? //-------------------------------------------------- // MARK: - Methods diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index f4ab51c6..5d42c5fb 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -94,9 +94,11 @@ public typealias ButtonAction = (Button) -> () self.backgroundColor = backgroundColor.uiColor } - guard let model = model as? ButtonModelProtocol else { return } + if let model = model as? EnableableModelProtocol { + isEnabled = model.enabled + } - isEnabled = model.enabled + guard let model = model as? ButtonModelProtocol else { return } set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index eb92dd85..0e313ac8 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -189,22 +189,28 @@ import UIKit // MARK: - Navigation Item (Move to model base) open func setNavigationController() { + let viewController = manager ?? self guard let navigationItemModel = pageModel?.navigationItem, - let navigationController = manager?.navigationController ?? navigationController else { + let navigationController = viewController.navigationController else { MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return } - let viewController = manager ?? self - if navigationController == MVMCoreUISplitViewController.main()?.navigationController, - navigationController.topViewController == viewController { - MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() - showBottomProgressBar() - } + + // We additionally want our left items + navigationItem.leftItemsSupplementBackButton = true + NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - // TODO: Legacy Update Panels. Change how this is done. + // Special logic when using the split view controller. Legacy Update Panels. Change how this is done. + guard navigationController == MVMCoreUISplitViewController.main()?.navigationController, + navigationController.topViewController == viewController else { return } + + MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels() + showBottomProgressBar() + MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(isMasterInitiallyAccessible(), for: viewController) MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(isSupportInitiallyAccessible(), for: viewController) + MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(navigationItemModel.tintColor.uiColor) } // Eventually will be moved to server diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 0b2d1546..ab57f9f8 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -84,16 +84,8 @@ import UIKit if let navigationController = navigationController as? NavigationController { navigationController.separatorView?.isHidden = navigationItemModel.line?.type ?? .standard == .none } - - // Let legacy splitview controller handle buttons for now. - guard navigationController == MVMCoreUISplitViewController.main()?.navigationController, - navigationController.topViewController == viewController else { - // Not the main split view controller, add buttons. - setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - return - } - - // Update icons if main navigation controller. - MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(tint) + + // Sets up the navigation buttons. + setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index d9814a1f..0ce218b2 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -107,29 +107,12 @@ CGFloat const PanelAnimationDuration = 0.2; return (width > 2000 ? MFTwoDrawer : (width > 1000 ? MFOneDrawer : MFNoDrawer)); } -- (nullable UIBarButtonItem *)getBackButtonForViewController:(nonnull UIViewController *)viewController { - if (![viewController conformsToProtocol:@protocol(MVMCoreViewControllerProtocol)]) { return self.backButton; } - UIViewController *controller = (UIViewController *)viewController; - NSDictionary *item = [controller.loadObject.pageJSON dictWithChainOfKeysOrIndexes:@[@"navigationItem",@"backButton"]]; - if (!item) { return self.backButton; } - DelegateObject *delegate = [controller delegateObject]; - return [self createNavigationItemButtonFrom:item delegateObject:[delegate isKindOfClass:[MVMCoreUIDelegateObject class]] ? (MVMCoreUIDelegateObject *)delegate : nil]; -} - - (nullable NSArray *)additionalLeftButtonsForViewController:(nonnull UIViewController *)viewController { - if (![viewController conformsToProtocol:@protocol(MVMCoreViewControllerProtocol)]) { return nil; } - UIViewController *controller = (UIViewController *)viewController; - NSArray *items = [controller.loadObject.pageJSON arrayForChainOfKeysOrIndexes:@[@"navigationItem",@"additionalLeftButtons"]]; - DelegateObject *delegate = [controller delegateObject]; - return [self createNavigationItemButtonsFrom:items delegateObject:[delegate isKindOfClass:[MVMCoreUIDelegateObject class]] ? (MVMCoreUIDelegateObject *)delegate : nil]; + return viewController.navigationItem.leftBarButtonItems; } - (nullable NSArray *)additionalRightButtonsForViewController:(nonnull UIViewController *)viewController { - if (![viewController conformsToProtocol:@protocol(MVMCoreViewControllerProtocol)]) { return nil; } - UIViewController *controller = (UIViewController *)viewController; - NSArray *items = [controller.loadObject.pageJSON arrayForChainOfKeysOrIndexes:@[@"navigationItem",@"additionalRightButtons"]]; - DelegateObject *delegate = [controller delegateObject]; - return [self createNavigationItemButtonsFrom:items delegateObject:[delegate isKindOfClass:[MVMCoreUIDelegateObject class]] ? (MVMCoreUIDelegateObject *)delegate : nil]; + return viewController.navigationItem.rightBarButtonItems; } - (CGFloat)leftPanelExtendedWidth { @@ -251,15 +234,6 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { NSMutableArray *leftBarButtonItems = [NSMutableArray array]; - if ([viewController.navigationController.viewControllers count] > 1) { - UIBarButtonItem *button = [self getBackButtonForViewController:viewController]; - if (button) { - viewController.navigationItem.hidesBackButton = YES; - [leftBarButtonItems addObject:button]; - } else { - viewController.navigationItem.hidesBackButton = NO; - } - } if ((accessible && !extended) && self.leftPanelButton) { [leftBarButtonItems addObject:self.leftPanelButton]; } @@ -625,24 +599,6 @@ CGFloat const PanelAnimationDuration = 0.2; #pragma mark - Other Panel Functions -/// Convenience function, creates a BarButtonItem from button json -- (nonnull UIBarButtonItem *)createNavigationItemButtonFrom:(nonnull NSDictionary *)JSON delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject { - UIImage *image = [UIImage imageNamed:[JSON string:@"imageName"] inBundle:[[MVMCoreCache sharedCache] bundleToUseForImages] compatibleWithTraitCollection:nil]; - BarButtonItem *item = [BarButtonItem createWith:image actionMap:[JSON dict:@"action"] delegateObject:delegateObject additionalData:nil]; - return item; -} - -/// Convenience function, creates a list of BarButtonItems list of json -- (nullable NSArray *)createNavigationItemButtonsFrom:(nullable NSArray *)JSONlist delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject { - if (JSONlist.count == 0) { return nil; } - NSMutableArray *items = [NSMutableArray arrayWithCapacity:JSONlist.count]; - for (NSDictionary *itemData in JSONlist) { - UIBarButtonItem *item = [self createNavigationItemButtonFrom:itemData delegateObject:delegateObject]; - [items addObject:item]; - } - return items; -} - - (void)forceHideBothDrawers { [self hideBothDrawersShouldForceHide:YES]; } From 51b327a6d64a3f471b124c3bc3e4b95c9677c703 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 14:21:14 -0400 Subject: [PATCH 04/12] fixes for decoding --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 6 +++++- .../Buttons/NavigationButtomModelProtocol.swift | 4 ++-- .../Buttons/NavigationImageButtonModel.swift | 2 +- .../Buttons/NavigationLabelButtonModel.swift | 2 +- .../NavigationBar/NavigationItemModel.swift | 15 ++++++++------- .../NavigationItemModelProtocol.swift | 6 +++--- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 42b700ac..b968cecc 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -134,8 +134,12 @@ import Foundation // Other Molecules MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self) - try? ModelRegistry.register(NavigationItemModel.self) + // Navigation Molecules + try? ModelRegistry.register(NavigationItemModel.self) + try? ModelRegistry.register(NavigationImageButtonModel.self) + try? ModelRegistry.register(NavigationLabelButtonModel.self) + // Other Organisms MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self) MoleculeObjectMapping.shared()?.register(viewClass: BarsIndicatorView.self, viewModelClass: BarsCarouselIndicatorModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift index 3f38ce43..057f2bf5 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift @@ -1,5 +1,5 @@ // -// NavigationButtomModelProtocol.swift +// NavigationButtonModelProtocol.swift // MVMCoreUI // // Created by Scott Pfeil on 5/27/20. @@ -8,7 +8,7 @@ import Foundation -public protocol NavigationButtomModelProtocol: ButtonModelProtocol { +public protocol NavigationButtonModelProtocol: ButtonModelProtocol { //var color: Color? { get set } func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index b4173e8b..be820ec9 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -7,7 +7,7 @@ import Foundation -public class NavigationImageButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol { +public class NavigationImageButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "navigationImageButton" diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift index 6b253459..699b1ed0 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift @@ -8,7 +8,7 @@ import Foundation -public class NavigationLabelButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol { +public class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { public var backgroundColor: Color? public static var identifier: String = "navigationLabelButton" diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index f29f1e38..05aec0a3 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -18,16 +18,15 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt public var backgroundColor: Color? public var tintColor: Color public var line: LineModel? - public var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)? - public var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? - public var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? + public var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? = NavigationImageButtonModel(with: "back", action: ActionBackModel()) + public var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? + public var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? public init() { hidden = false backgroundColor = Color(uiColor: .white) tintColor = Color(uiColor: .black) line = LineModel(type: .standard) - backButton = NavigationImageButtonModel(with: "back", action: ActionBackModel()) } private enum CodingKeys: String, CodingKey { @@ -50,9 +49,11 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white) tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) ?? NavigationImageButtonModel(with: "back", action: ActionBackModel()) - additionalLeftButtons = try typeContainer.decodeModels(codingKey: .additionalLeftButtons) - additionalRightButtons = try typeContainer.decodeModels(codingKey: .additionalRightButtons) + if let backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol) = try typeContainer.decodeModelIfPresent(codingKey: .backButton) { + self.backButton = backButton + } + additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons) + additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index e6491ac3..e4017428 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -14,7 +14,7 @@ public protocol NavigationItemModelProtocol { var backgroundColor: Color? { get set } var tintColor: Color { get set } var line: LineModel? { get set } - var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)? { get set } - var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set } - var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set } + var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set } + var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } + var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } } From 27e7235e0b6f65e15b52a34671d7621d94b73796 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 14:39:57 -0400 Subject: [PATCH 05/12] fixes for navigation item setter --- MVMCoreUI/Containers/NavigationController.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index ab57f9f8..6f3bf06f 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -46,23 +46,25 @@ import UIKit /// 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 - var items: [UIBarButtonItem] = [] + var leftItems: [UIBarButtonItem] = [] if let backButtonModel = navigationItemModel.backButton, navigationController.viewControllers.count > 1 { - items.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) } if let leftItemModels = navigationItemModel.additionalLeftButtons { for item in leftItemModels { - items.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) } - viewController.navigationItem.leftBarButtonItems = items } + viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil + + var rightItems: [UIBarButtonItem] = [] if let rightItemModels = navigationItemModel.additionalRightButtons { for item in rightItemModels { - items.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) } - viewController.navigationItem.rightBarButtonItems = items } + viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil } /// Convenience function for setting navigation bar with model. From db3f8a5becd62892407672f82f0930dabbb2395e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 14:45:35 -0400 Subject: [PATCH 06/12] ordering of left buttons --- .../SplitViewController/MVMCoreUISplitViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 0ce218b2..414895dc 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -234,13 +234,13 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { NSMutableArray *leftBarButtonItems = [NSMutableArray array]; - if ((accessible && !extended) && self.leftPanelButton) { - [leftBarButtonItems addObject:self.leftPanelButton]; - } NSArray *extraButtons = [self additionalLeftButtonsForViewController:viewController]; if (extraButtons) { [leftBarButtonItems addObjectsFromArray:extraButtons]; } + if ((accessible && !extended) && self.leftPanelButton) { + [leftBarButtonItems addObject:self.leftPanelButton]; + } [viewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; } From 632f6a825c88b13fc7d7cd30013963cb49f86da2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 15:58:31 -0400 Subject: [PATCH 07/12] comment --- .../NavigationBar/Buttons/NavigationButtomModelProtocol.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift index 057f2bf5..e43f4664 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift @@ -9,6 +9,7 @@ import Foundation public protocol NavigationButtonModelProtocol: ButtonModelProtocol { + // TODO: add color setting to models and items //var color: Color? { get set } func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem From f2498a53f9a2446840e748ca4dfd6989a198998d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 16:00:46 -0400 Subject: [PATCH 08/12] comment --- .../NavigationBar/Buttons/NavigationButtomModelProtocol.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift index e43f4664..50870172 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationButtomModelProtocol.swift @@ -12,5 +12,6 @@ public protocol NavigationButtonModelProtocol: ButtonModelProtocol { // TODO: add color setting to models and items //var color: Color? { get set } - func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem + /// Returns a bar button item created using data from the model. + func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> UIBarButtonItem } From bf6a81f367a252556aeac645004b440d9789c004 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 16:12:43 -0400 Subject: [PATCH 09/12] remove excess internal --- MVMCoreUI/BaseClasses/BarButtonItem.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index f2da9c7c..cbb6ba2d 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -8,9 +8,9 @@ public typealias BarButtonAction = (BarButtonItem) -> () -@objc internal class ActionDelegate: NSObject { - internal var buttonAction: BarButtonAction? - @objc internal func callActionBlock(_ sender: BarButtonItem) { +@objc class ActionDelegate: NSObject { + var buttonAction: BarButtonAction? + @objc func callActionBlock(_ sender: BarButtonItem) { buttonAction?(sender) } } @@ -22,7 +22,7 @@ public typealias BarButtonAction = (BarButtonItem) -> () //-------------------------------------------------- open weak var buttonDelegate: ButtonDelegateProtocol? - internal var actionDelegate: ActionDelegate? + var actionDelegate: ActionDelegate? //-------------------------------------------------- // MARK: - Methods From 336a0bb98356b9cf0b0eb3a355a6f72fa5fa4bc4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 16:13:20 -0400 Subject: [PATCH 10/12] fix return type --- .../NavigationBar/Buttons/NavigationImageButtonModel.swift | 2 +- .../NavigationBar/Buttons/NavigationLabelButtonModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index be820ec9..aff9c58f 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -37,7 +37,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule } /// Convenience function that creates a BarButtonItem for the model. - public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> BarButtonItem { + public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { let image = UIImage(named: imageName, in: MVMCoreCache.shared()?.bundleToUseForImages(), compatibleWith: nil) return ImageBarButtonItem.create(with: image, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift index 699b1ed0..e113c1f6 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationLabelButtonModel.swift @@ -38,7 +38,7 @@ public class NavigationLabelButtonModel: NavigationButtonModelProtocol, Molecule } /// Convenience function that creates a BarButtonItem for the model. - public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> BarButtonItem { + public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { return LabelBarButtonItem.create(with: title, actionModel: action, delegateObject: delegateObject, additionalData: additionalData) } } From 4be261e3184656d61b10025df83b91777a51062d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 17:37:17 -0400 Subject: [PATCH 11/12] update to match documentation --- .../Protocols/ModelProtocols/PageModelProtocol.swift | 2 +- MVMCoreUI/Atomic/Templates/TemplateModel.swift | 8 ++++---- MVMCoreUI/BaseControllers/ViewController.swift | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift index ec2bead8..275b17a1 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/PageModelProtocol.swift @@ -13,5 +13,5 @@ public protocol PageModelProtocol { /// Temporary: for legacy response var screenHeading: String? { get set } var backgroundColor: Color? { get set } - var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } + var navigationBar: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } } diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/TemplateModel.swift index e8992e58..b478167d 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/TemplateModel.swift @@ -26,7 +26,7 @@ import Foundation public var backgroundColor: Color? public var screenHeading: String? - public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? + public var navigationBar: (NavigationItemModelProtocol & MoleculeModelProtocol)? public var formRules: [FormGroupRule]? public var behaviors: [PageBehaviorProtocol]? @@ -49,7 +49,7 @@ import Foundation case backgroundColor case formRules case behaviors - case navigationItem + case navigationBar } //-------------------------------------------------- @@ -63,7 +63,7 @@ import Foundation backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) behaviors = try typeContainer.decodeModelsIfPresent(codingKey: .behaviors) - navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) + navigationBar = try typeContainer.decodeModelIfPresent(codingKey: .navigationBar) } public func encode(to encoder: Encoder) throws { @@ -73,6 +73,6 @@ import Foundation try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(formRules, forKey: .formRules) - try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) + try container.encodeModelIfPresent(navigationBar, forKey: .navigationBar) } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 0e313ac8..6ec63c24 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -172,9 +172,9 @@ 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?.navigationItem == nil { + if pageModel?.navigationBar == nil { let navigationItem = createDefaultLegacyNavigationModel() - pageModel?.navigationItem = navigationItem + pageModel?.navigationBar = navigationItem } if formValidator == nil { @@ -190,7 +190,7 @@ import UIKit // MARK: - Navigation Item (Move to model base) open func setNavigationController() { let viewController = manager ?? self - guard let navigationItemModel = pageModel?.navigationItem, + guard let navigationItemModel = pageModel?.navigationBar, let navigationController = viewController.navigationController else { MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() return From 50a87cd864155d3b6c07d9d4ed1592c593bc64e2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 27 May 2020 18:35:05 -0400 Subject: [PATCH 12/12] code simplification --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- ...ftVariableIconWithRightCaretBodyText.swift | 24 +++++-------------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c6f97754..f44a799d 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1306,14 +1306,14 @@ 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */, 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */, 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, + AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */, + AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */, 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */, 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */, AA99724F2475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift */, AA997251247530B100FC7472 /* ListLeftVariableIconAllTextLinks.swift */, 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */, 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */, - AA0A257724766C8A00862F64 /* ListLeftVariableIconWithRightCaretBodyTextModel.swift */, - AA0A257924766CA200862F64 /* ListLeftVariableIconWithRightCaretBodyText.swift */, ); path = LeftVariable; sourceTree = ""; diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index b4819234..89949f4a 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -142,12 +142,12 @@ import Foundation // 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) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxBodyText.self, viewModelClass: ListLeftVariableCheckboxBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconAllTextLinks.self, viewModelClass: ListLeftVariableIconAllTextLinksModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconWithRightCaretBodyText.self, viewModelClass: ListLeftVariableIconWithRightCaretBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableNumberedListAllTextAndLinks.self, viewModelClass: ListLeftVariableNumberedListAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index 626d9c19..d05fea10 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -13,18 +13,16 @@ import Foundation //------------------------------------------------------- public let leftImage = LoadImageView() public let headlineBody = HeadlineBody() - public let rightLabel = Label.commonLabelB2(true) - private let rightLabelStackItem: StackItem + public let rightLabel = Label.createLabelRegularBodySmall(true) public var stack: Stack //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - rightLabelStackItem = StackItem(andContain: rightLabel) - let stackItems = [StackItem(andContain: leftImage), StackItem(andContain: headlineBody), rightLabelStackItem] - let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 4, horizontalAlignment: .trailing)], axis: .horizontal) - stack = Stack(with: stackModel, stackItems: stackItems) + stack = Stack.createStack(with: [(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), + (view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)), + (view: rightLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -32,16 +30,6 @@ import Foundation fatalError("init(coder:) has not been implemented") } - open override func alignAccessoryToHero() -> CGPoint? { - // Ensures that the right label is centered vertically with headline. - let heroCenter = super.alignAccessoryToHero() - if let heroCenter = heroCenter { - let convertedPoint = stack.convert(heroCenter, from: self) - rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY - } - return heroCenter - } - //----------------------------------------------------- // MARK: - View Lifecycle //------------------------------------------------------- @@ -61,7 +49,7 @@ import Foundation //------------------------------------------------------ open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListLeftVariableIconWithRightCaretBodyTextModel else { return} + guard let model = model as? ListLeftVariableIconWithRightCaretBodyTextModel else { return } leftImage.set(with: model.image, delegateObject, additionalData) headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) @@ -73,6 +61,6 @@ import Foundation open override func reset() { super.reset() - rightLabel.styleB2(true) + rightLabel.styleRegularBodySmall(true) } }