From 5a842581c286daedaba91014ad6e76911adf7a3d Mon Sep 17 00:00:00 2001 From: Rebecca Antonelli Date: Fri, 7 Apr 2023 11:40:26 -0500 Subject: [PATCH 01/51] adding badge VDS component --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 50 +++++++++++++++++++ MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 46 +++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 4 files changed, 105 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/Views/Badge.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 104eef80..beb77bd9 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -289,6 +289,8 @@ AF60A7F82892D34D00919EEB /* ActionDismissNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; + B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBC29DF34680005D28B /* Badge.swift */; }; + B4CC8FBF29DF34730005D28B /* BadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBE29DF34730005D28B /* BadgeModel.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -899,6 +901,8 @@ AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionDismissNotificationHandler.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; + B4CC8FBC29DF34680005D28B /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; + B4CC8FBE29DF34730005D28B /* BadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeModel.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -2281,7 +2285,9 @@ AA37CBD42519072F0027344C /* Stars.swift */, AA07EA902510A442009A2AE3 /* StarModel.swift */, AA07EA922510A451009A2AE3 /* Star.swift */, + B4CC8FBC29DF34680005D28B /* Badge.swift */, EA985C3D2970938F00F2FF2E /* Tilelet.swift */, + B4CC8FBE29DF34730005D28B /* BadgeModel.swift */, EA985C3F2970939A00F2FF2E /* TileletModel.swift */, ); path = Views; @@ -3011,6 +3017,7 @@ 27F9736A246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */, + B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */, 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, 3265B30224BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, @@ -3117,6 +3124,7 @@ 0A51F3E32475CB73002E08B6 /* LoadingSpinner.swift in Sources */, BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, + B4CC8FBF29DF34730005D28B /* BadgeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, EA985C852981AA9C00F2FF2E /* VDS-Enums+Codable.swift in Sources */, AAB8549824DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift new file mode 100644 index 00000000..8ec875c7 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -0,0 +1,50 @@ +// +// Badge.swift +// MVMCoreUI +// +// Created by Rebecca Antonelli on 4/6/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore +import VDS +import Combine + +open class Badge: VDS.Badge, VDSMoleculeViewProtocol { + // public typealias ViewModel = type + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var viewModel: BadgeModel! + + public var delegateObject: MVMCoreUIDelegateObject? + + public var additionalData: [AnyHashable : Any]? + + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- +// public convenience required init() { +// self.init(frame: .zero) +// } + + //-------------------------------------------------- + // MARK: - Public + //-------------------------------------------------- + public func viewModelDidUpdate() { +// backgroundColor = viewModel.backgroundColor +// maxWidth = viewModel.maxWidth +// numberOfLines = viewModel.numberOfLines +// fillColor = viewModel.fillColor +// surface = viewModel.surface +// + } + + public func updateView(_ size: CGFloat) { + + } + + +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift new file mode 100644 index 00000000..9aa22cd5 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -0,0 +1,46 @@ +// +// BadgeModel.swift +// MVMCoreUI +// +// Created by Rebecca Antonelli on 4/6/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS + +open class BadgeModel: MoleculeModelProtocol { + + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "badge" + public var backgroundColor: Color? + public var maxWidth: CGFloat? + public var numberOfLines: Int? + public var fillColor = Badge.FillColor.red + public var surface: Surface? + + private enum CodingKeys: String, CodingKey { + case text, fillColor, surface, numberOfLines, maxWidth + } + + required public convenience init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let text = try container.decode(String.self, forKey: .text) + let fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + let surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light + let numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 0 + let maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) + self.init() + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(fillColor, forKey: .fillColor) + try container.encode(surface, forKey: .surface) + try container.encode(numberOfLines, forKey: .numberOfLines) + try container.encodeIfPresent(maxWidth, forKey: .maxWidth) + } +} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index c27553ec..f020dcf7 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -72,6 +72,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: LoadingSpinner.self, for: LoadingSpinnerModel.self) ModelRegistry.register(handler: Video.self, for: VideoModel.self) ModelRegistry.register(handler: Tilelet.self, for: TileletModel.self) + ModelRegistry.register(handler: Badge.self, for: BadgeModel.self) // MARK:- Horizontal Combination Molecules ModelRegistry.register(handler: StringAndMoleculeView.self, for: StringAndMoleculeModel.self) From a8dc76e3e5a1831b62b58500eb8205c75ec2e2ac Mon Sep 17 00:00:00 2001 From: Rebecca Antonelli Date: Mon, 10 Apr 2023 10:50:13 -0500 Subject: [PATCH 02/51] badge updates --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 37 ++++++++++++++++--- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 16 +++++--- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 8ec875c7..7d6110af 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -29,22 +29,47 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { // public convenience required init() { // self.init(frame: .zero) // } + public required init() { + super.init() + } + + required public init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } //-------------------------------------------------- // MARK: - Public //-------------------------------------------------- + + open func set(){ + maxWidth = viewModel.maxWidth + numberOfLines = viewModel.numberOfLines ?? 3 + fillColor = viewModel.fillColor + surface = viewModel.surface ?? .light + } + public func viewModelDidUpdate() { -// backgroundColor = viewModel.backgroundColor -// maxWidth = viewModel.maxWidth -// numberOfLines = viewModel.numberOfLines -// fillColor = viewModel.fillColor -// surface = viewModel.surface -// + // backgroundColor = viewModel.backgroundColor + maxWidth = viewModel.maxWidth + numberOfLines = viewModel.numberOfLines ?? 3 + fillColor = viewModel.fillColor + surface = viewModel.surface ?? .light + } public func updateView(_ size: CGFloat) { } +// open override func setupView() { +// super.setupView() +// backgroundColor = .clear +// widthConstraint = widthAnchor.constraint(equalToConstant: 30) +// widthConstraint?.isActive = true +// heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1) +// heightConstraint?.isActive = true +// isAccessibilityElement = true +// updateAccessibilityLabel() +// } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 9aa22cd5..5a5098b0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -21,19 +21,25 @@ open class BadgeModel: MoleculeModelProtocol { public var numberOfLines: Int? public var fillColor = Badge.FillColor.red public var surface: Surface? + public var text: String = "" private enum CodingKeys: String, CodingKey { case text, fillColor, surface, numberOfLines, maxWidth } +// public convenience init() { +// self.init() +// } + required public convenience init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - let text = try container.decode(String.self, forKey: .text) - let fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red - let surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light - let numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 0 - let maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) self.init() + self.text = try container.decode(String.self, forKey: .text) + self.fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + self.surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light + self.numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1 + self.maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) + } public func encode(to encoder: Encoder) throws { From 60d5c45a397e5f64347837bf4421ebc045182a15 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 10 Apr 2023 11:18:30 -0500 Subject: [PATCH 03/51] update view, removed some un-needed code, added other code Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 53 +++++-------------- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 28 +++++----- 2 files changed, 24 insertions(+), 57 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 7d6110af..0e6d1075 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -22,54 +22,25 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { public var additionalData: [AnyHashable : Any]? - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- -// public convenience required init() { -// self.init(frame: .zero) -// } - public required init() { - super.init() - } - - required public init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - //-------------------------------------------------- // MARK: - Public //-------------------------------------------------- - - open func set(){ - maxWidth = viewModel.maxWidth - numberOfLines = viewModel.numberOfLines ?? 3 - fillColor = viewModel.fillColor - surface = viewModel.surface ?? .light - } public func viewModelDidUpdate() { - // backgroundColor = viewModel.backgroundColor + text = viewModel.text maxWidth = viewModel.maxWidth - numberOfLines = viewModel.numberOfLines ?? 3 + numberOfLines = viewModel.numberOfLines fillColor = viewModel.fillColor - surface = viewModel.surface ?? .light - + surface = viewModel.surface } - public func updateView(_ size: CGFloat) { - - } - -// open override func setupView() { -// super.setupView() -// backgroundColor = .clear -// widthConstraint = widthAnchor.constraint(equalToConstant: 30) -// widthConstraint?.isActive = true -// heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1) -// heightConstraint?.isActive = true -// isAccessibilityElement = true -// updateAccessibilityLabel() -// } - + public func updateView(_ size: CGFloat) {} +} + +//to deal with how it's parent constrains this control +extension Badge: MVMCoreUIViewConstrainingProtocol { + + public func needsToBeConstrained() -> Bool { true } + + public func horizontalAlignment() -> UIStackView.Alignment { .leading } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 5a5098b0..de19faab 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -17,33 +17,29 @@ open class BadgeModel: MoleculeModelProtocol { //-------------------------------------------------- public static var identifier: String = "badge" public var backgroundColor: Color? - public var maxWidth: CGFloat? - public var numberOfLines: Int? - public var fillColor = Badge.FillColor.red - public var surface: Surface? public var text: String = "" + public var maxWidth: CGFloat? + public var numberOfLines: Int = 1 + public var fillColor = Badge.FillColor.red + public var surface: Surface = .light private enum CodingKeys: String, CodingKey { case text, fillColor, surface, numberOfLines, maxWidth } - -// public convenience init() { -// self.init() -// } - + required public convenience init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) self.init() - self.text = try container.decode(String.self, forKey: .text) - self.fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red - self.surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light - self.numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1 - self.maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) - + let container = try decoder.container(keyedBy: CodingKeys.self) + text = try container.decode(String.self, forKey: .text) + fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light + numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1 + maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(text, forKey: .text) try container.encode(fillColor, forKey: .fillColor) try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) From 4c2214d7d4fa1774d687fb46d02d7808484354e5 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 10:37:42 -0400 Subject: [PATCH 04/51] VDS Button to atomic beginning/ --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 18 +- .../Atomic/Atoms/Buttons/PillButton.swift | 195 ++++++------------ .../Atomic/Extensions/VDS-Enums+Codable.swift | 2 + MVMCoreUI/Styles/Styler.swift | 36 ---- 4 files changed, 79 insertions(+), 172 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 08afefde..22ee9b8b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -8,10 +8,10 @@ import UIKit import VDSColorTokens +import VDS public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) - open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol { //-------------------------------------------------- // MARK: - Properties @@ -26,13 +26,13 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Styler.Button.Style? { + public var style: Use? { didSet { guard let style = style else { return } setFacade(by: style) } } - public var size: Styler.Button.Size? = .standard + public var size: ButtonSize = .large public var groupName: String = "" public var inverted: Bool = false @@ -160,14 +160,14 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) } - public func setFacade(by style: Styler.Button.Style) { - + public func setFacade(by style: VDS.Use) { switch style { case .primary: setPrimaryFacade() - case .secondary: setSecondaryFacade() + @unknown default: + setPrimaryFacade() } } @@ -211,17 +211,17 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat action = try typeContainer.decodeModel(codingKey: .action) ///Style captured from the JSON - if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style){ + if let style = try typeContainer.decodeIfPresent(Use.self, forKey: .style) { self.style = style setFacade(by: style) - } else if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style { ///Reading the style param from context which is set is molecules, ex: TwoButtonView + } else if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Use { ///Reading the style param from context which is set is molecules, ex: TwoButtonView self.style = style setFacade(by: style) } else { ///Default style setFacade(by: .primary) } - if let size = try typeContainer.decodeIfPresent(Styler.Button.Size.self, forKey: .size) { + if let size = try typeContainer.decodeIfPresent(VDS.ButtonSize.self, forKey: .size) { self.size = size } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e578fa51..56df2044 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -8,35 +8,19 @@ import UIKit import VDSColorTokens +import VDS -open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { +open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - /// Used to size the button. - var size = MVMCoreUIUtility.getWidth() - + var model: MoleculeModelProtocol? var buttonModel: ButtonModel? { get { model as? ButtonModel } } - /// Need to re-style on set. - open override var isEnabled: Bool { - didSet { style(with: buttonModel) } - } - - open var buttonSize: Styler.Button.Size = .standard { - didSet { buttonModel?.size = buttonSize } - } - - //-------------------------------------------------- - // MARK: - Constraints - //-------------------------------------------------- - - public var widthConstraint: NSLayoutConstraint? - public var minimumWidthConstraint: NSLayoutConstraint? - //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -44,127 +28,29 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { let model = ButtonModel(with: "", action: ActionNoopModel()) model.style = isPrimary ? .primary : .secondary - model.size = istiny ? .tiny : .standard + model.size = istiny ? .small : .large self.init(model: model, nil, nil) } - //-------------------------------------------------- - // MARK: - Computed Properties - //-------------------------------------------------- - - public var enabledTitleColor: UIColor? { - get { titleColor(for: .normal) } - set { setTitleColor(newValue, for: .normal) } - } - - public var disabledTitleColor: UIColor? { - get { titleColor(for: .disabled) } - set { setTitleColor(newValue, for: .disabled) } - } - - public var borderColor: UIColor? { - get { - guard let currentColor = layer.borderColor else { return nil } - return UIColor(cgColor: currentColor) - } - set { layer.borderColor = newValue?.cgColor } - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - /// The primary styling for a button. Should be used for main buttons - public func stylePrimary() { - let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) - style(with: buttonModel) - } - - /// The secondary styling for a button. Should be used for secondary buttons - public func styleSecondary() { - let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) - style(with: buttonModel) - } - - /// Styles the button based on the model style - private func style(with model: ButtonModel?) { - - layer.borderWidth = model?.style == .secondary ? 1 : 0 - - if let titleColor = model?.enabledColors.text { - enabledTitleColor = titleColor - } - - if let disabledTitleColor = model?.disabledColors.text { - self.disabledTitleColor = disabledTitleColor - } - - #if DEBUG - // Useful to detect with isHittable when performing UI testing. - isAccessibilityElement = isEnabled - #endif - - if isEnabled { - if let fillColor = model?.enabledColors.fill { - backgroundColor = fillColor - } - - if let borderColor = model?.enabledColors.border { - self.borderColor = borderColor - } - } else { - if let fillColor = model?.disabledColors.fill { - backgroundColor = fillColor - } - - if let borderColor = model?.disabledColors.border { - self.borderColor = borderColor - } - } - } - - private func getInnerPadding() -> CGFloat { - buttonSize.getHeight() / 2.0 - } - - private func getContentEdgeInsets() -> UIEdgeInsets { - var verticalPadding = 0.0 - var horizontalPadding = 0.0 - switch buttonSize { - case .standard: - verticalPadding = Padding.Three - horizontalPadding = Padding.Five - break - case .small: - verticalPadding = Padding.Two - horizontalPadding = Padding.Four - break - case .tiny: - verticalPadding = Padding.One - horizontalPadding = Padding.Two - break - } - return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) - } - //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - // The button will get styled in the enable check in super. - super.set(with: model, delegateObject, additionalData) - + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? ButtonModel else { return } + self.model = model + + if let accessibilityIdentifier = model.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } setTitle(model.title, for: .normal) if let accessibilityText = model.accessibilityText { accessibilityLabel = accessibilityText } - if let size = model.size { - buttonSize = size - } + isEnabled = model.enabled + size = model.size model.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { @@ -173,7 +59,62 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) + + guard let model = model as? ButtonModelProtocol else { return } + //set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } +} + +open func reset() { + backgroundColor = .clear +} + +// MARK: Overridables +// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. +open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { + model.moleculeName +} + +open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil } + +open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { nil } + +//-------------------------------------------------- +// MARK: - Accessibility +//-------------------------------------------------- + +open override func accessibilityActivate() -> Bool { + guard isEnabled else { return false } + buttonAction?(self) + return buttonAction != nil +} + +} + +// MARK: - MVMCoreViewProtocol +extension Button: MVMCoreViewProtocol { + +open func updateView(_ size: CGFloat) { } + +/// Will be called only once. +open func setupView() { + isAccessibilityElement = true + accessibilityTraits = .button + translatesAutoresizingMaskIntoConstraints = false + insetsLayoutMarginsFromSafeArea = false + titleLabel?.numberOfLines = 0 + titleLabel?.lineBreakMode = .byWordWrapping +} +} + +// MARK: AppleGuidelinesProtocol +extension Button: AppleGuidelinesProtocol { + +override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + Self.acceptablyOutsideBounds(point: point, bounds: bounds) +} +} + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return (model as? ButtonModel)?.size?.getHeight() diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 6c143d9c..b2463ed1 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,3 +16,5 @@ extension Icon.Size: Codable {} extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} +extension ButtonSize: Codable {} +extension Use: Codable {} diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 2cbc9a00..2daac86a 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -159,42 +159,6 @@ open class Styler { } } - public enum Button { - - public enum Style: String, Codable { - case primary - case secondary - } - ///MVA 3.0 - Button sizes are standard(default size), small, Tiny. Tiny button has been depricated as of Rebranding 3.0. - public enum Size: String, Codable { - case standard - case small - case tiny - - func getHeight() -> CGFloat { - switch self { - case .standard: - return 44 - case .small: - return 32 - case .tiny: - return 20 - } - } - - func minimumWidth() -> CGFloat { - switch self { - case .standard: - return 76 - case .small: - return 0 - case .tiny: - return 49 - } - } - } - } - //-------------------------------------------------- // MARK: - Functions //-------------------------------------------------- From 8e35e8036a5bd5a2b5a4bc12c4714d4ecd0a8c41 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 13:55:17 -0400 Subject: [PATCH 05/51] Tiny button to small --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 4 +- .../Atomic/Atoms/Buttons/PillButton.swift | 180 +++++++----------- .../Atomic/Extensions/VDS-Enums+Codable.swift | 21 +- .../ListDeviceComplexButtonMediumModel.swift | 2 +- .../ListDeviceComplexButtonSmallModel.swift | 2 +- ...htVariableButtonAllTextAndLinksModel.swift | 2 +- .../TwoButtonViewModel.swift | 6 +- .../NotificationMoleculeModel.swift | 2 +- .../BGImageHeadlineBodyButtonModel.swift | 2 +- .../HeadlineBodyButtonModel.swift | 2 +- 10 files changed, 105 insertions(+), 118 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 22ee9b8b..b15f8adb 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -32,7 +32,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat setFacade(by: style) } } - public var size: ButtonSize = .large + public var size: VDS.Button.Size = .large public var groupName: String = "" public var inverted: Bool = false @@ -221,7 +221,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat setFacade(by: .primary) } - if let size = try typeContainer.decodeIfPresent(VDS.ButtonSize.self, forKey: .size) { + if let size = try typeContainer.decodeIfPresent(VDS.Button.Size.self, forKey: .size) { self.size = size } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 56df2044..4a812a57 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -9,8 +9,10 @@ import UIKit import VDSColorTokens import VDS +import MVMCore +import Combine -open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol { +open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol, MVMCoreViewProtocol, MFButtonProtocol { //-------------------------------------------------- // MARK: - Properties @@ -21,10 +23,33 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi get { model as? ButtonModel } } + var onClickCancellable: Cancellable? + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + } + + public override init(frame: CGRect) { + super.init(frame: .zero) + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + } + + open override func setup() { + super.setup() + setupView() + } + + //-------------------------------------------------- + // MARK: - Convenience + //-------------------------------------------------- + @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { let model = ButtonModel(with: "", action: ActionNoopModel()) model.style = isPrimary ? .primary : .secondary @@ -32,8 +57,20 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi self.init(model: model, nil, nil) } + /// The primary styling for a button. Should be used for main buttons + public func stylePrimary() { + let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + use = .primary + } + + /// The secondary styling for a button. Should be used for secondary buttons + public func styleSecondary() { + let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + use = .secondary + } + //-------------------------------------------------- - // MARK: - MVMCoreViewProtocol + // MARK: - MoleculeViewProtocol //-------------------------------------------------- open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -51,129 +88,60 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi isEnabled = model.enabled size = model.size +// if let backgroundColor = model.backgroundColor { +// self.backgroundColor = backgroundColor.uiColor +// } model.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { - self?.enableField(model.enabled) + self?.isEnabled = model.enabled }) } FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - guard let model = model as? ButtonModelProtocol else { return } - //set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) - } -} - -open func reset() { - backgroundColor = .clear -} - -// MARK: Overridables -// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. -open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - model.moleculeName -} - -open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil } - -open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { nil } - -//-------------------------------------------------- -// MARK: - Accessibility -//-------------------------------------------------- - -open override func accessibilityActivate() -> Bool { - guard isEnabled else { return false } - buttonAction?(self) - return buttonAction != nil -} - -} - -// MARK: - MVMCoreViewProtocol -extension Button: MVMCoreViewProtocol { - -open func updateView(_ size: CGFloat) { } - -/// Will be called only once. -open func setupView() { - isAccessibilityElement = true - accessibilityTraits = .button - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false - titleLabel?.numberOfLines = 0 - titleLabel?.lineBreakMode = .byWordWrapping -} -} - -// MARK: AppleGuidelinesProtocol -extension Button: AppleGuidelinesProtocol { - -override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - Self.acceptablyOutsideBounds(point: point, bounds: bounds) -} -} - - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return (model as? ButtonModel)?.size?.getHeight() + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } - open override func updateView(_ size: CGFloat) { - super.updateView(size) - self.size = size - - switch buttonSize { - case .tiny: - titleLabel?.font = Styler.Font.BoldMicro.getFont(false) - case .small: - titleLabel?.font = Styler.Font.BoldBodySmall.getFont(false) - case .standard: - titleLabel?.font = Styler.Font.BoldBodyLarge.getFont(false) - } - - layer.cornerRadius = getInnerPadding() - contentEdgeInsets = getContentEdgeInsets() - - if let contraint = buttonModel?.width { - - if widthConstraint == nil { - widthConstraint = widthAnchor.constraint(equalToConstant: contraint) - } else if widthConstraint?.constant != contraint { - widthConstraint?.constant = contraint - } - widthConstraint?.isActive = true - minimumWidthConstraint?.isActive = false - } else { - - if minimumWidthConstraint == nil { - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - } else { - minimumWidthConstraint?.constant = buttonSize.minimumWidth() - } - minimumWidthConstraint?.isActive = true - widthConstraint?.isActive = false - } + //-------------------------------------------------- + // MARK: - MVMCoreViewProtocol + //-------------------------------------------------- + + open override func reset() { + super.reset() + //backgroundColor = .clear } - open override func setupView() { - super.setupView() - - titleLabel?.numberOfLines = 1 - titleLabel?.lineBreakMode = .byTruncatingTail - titleLabel?.textAlignment = .center - contentHorizontalAlignment = .center - stylePrimary() + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return (model as? ButtonModel)?.size.height } + open func updateView(_ size: CGFloat) {} + + open func setupView() {} + //-------------------------------------------------- // MARK: - MVMCoreUIViewConstrainingProtocol //-------------------------------------------------- open func horizontalAlignment() -> UIStackView.Alignment { .center } - public func enableField(_ enable: Bool) { - isEnabled = enable + //-------------------------------------------------- + // MARK: - Action + //-------------------------------------------------- + + open func set(with actionModel: ActionModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + onClickCancellable = onClickSubscriber.publisher.sink { [weak self] _ in + guard let self = self, + let actionModel = self.buttonModel?.action else { return } + Task(priority: .userInitiated) { + try await Self.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.model) + } + } + } + + open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) async throws { + guard delegateObject?.buttonDelegate?.button?(button, shouldPerformActionWithMap: model.toJSON(), additionalData: additionalData) ?? true else { return } + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model, additionalData: MVMCoreUIActionHandler.add(sourceModel: sourceModel, to: additionalData), delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index b2463ed1..ea462930 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,5 +16,24 @@ extension Icon.Size: Codable {} extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} -extension ButtonSize: Codable {} extension Use: Codable {} +extension VDS.Button.Size: Codable { + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let string = try container.decode(String.self) + switch string { + case VDS.Button.Size.large.rawValue: + self = .large + case VDS.Button.Size.small.rawValue, "tiny": + self = .small + default: + self = .large + } + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(self) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonMediumModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonMediumModel.swift index 88f7fe97..54b313e6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonMediumModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonMediumModel.swift @@ -42,7 +42,7 @@ public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelPro override public func setDefaults() { super.setDefaults() - button.size = .tiny + button.size = .small button.style = .secondary } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonSmallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonSmallModel.swift index 13be8c03..d06a3845 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonSmallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Device/ListDeviceComplexButtonSmallModel.swift @@ -42,7 +42,7 @@ public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProt override public func setDefaults() { super.setDefaults() - button.size = .tiny + button.size = .small button.style = .secondary } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index 21a4b08c..30856e55 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -32,7 +32,7 @@ public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, Molecul override public func setDefaults() { super.setDefaults() - self.button.size = .tiny + self.button.size = .small self.button.style = .secondary } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index b5d07c4a..a7b4055c 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDS public class TwoButtonViewModel: ParentMoleculeModelProtocol { //-------------------------------------------------- @@ -56,13 +56,13 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { //set context value for 'primary' style to be set for the primaryButton in case the //property is not returned in the JSON and once decoded, this value is removed from the context - try decoder.setContext(value: Styler.Button.Style.primary, for: "style") { + try decoder.setContext(value: Use.primary, for: "style") { self.primaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .primaryButton) } //set context value for 'secondary' style to be set for the primaryButton in case the //property is not returned in the JSON and once decoded, this value is removed from the context - try decoder.setContext(value: Styler.Button.Style.secondary, for: "style") { + try decoder.setContext(value: Use.secondary, for: "style") { self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift index d26bb06c..27ca95a8 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift @@ -89,7 +89,7 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { } } - button?.size = .tiny + button?.size = .small button?.style = .secondary switch style { case .error, .warning: diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift index 99ee1567..4e2d031a 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift @@ -54,7 +54,7 @@ public class BGImageHeadlineBodyButtonModel: ContainerModel, MoleculeModelProtoc image.height = BGImageHeadlineBodyButton.heightConstant } - button?.size = .tiny + button?.size = .small button?.style = .secondary } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index 1b713720..347277fd 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -38,7 +38,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { /// Defaults to set public func setDefaults() { - button.size = .tiny + button.size = .small button.style = .secondary } From 741bf0501b2f739d8e3bdae9eb5ce6da498480fe Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 14:14:30 -0400 Subject: [PATCH 06/51] Updates to Button --- .../Atomic/Atoms/Buttons/PillButton.swift | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 4a812a57..e8105d3e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -18,12 +18,12 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi // MARK: - Properties //-------------------------------------------------- - var model: MoleculeModelProtocol? - var buttonModel: ButtonModel? { + open var model: MoleculeModelProtocol? + public var buttonModel: ButtonModel? { get { model as? ButtonModel } } - var onClickCancellable: Cancellable? + internal var onClickCancellable: Cancellable? //-------------------------------------------------- // MARK: - Initializers @@ -58,14 +58,14 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi } /// The primary styling for a button. Should be used for main buttons - public func stylePrimary() { - let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + open func stylePrimary() { + model = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) use = .primary } /// The secondary styling for a button. Should be used for secondary buttons - public func styleSecondary() { - let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + open func styleSecondary() { + model = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) use = .secondary } @@ -81,26 +81,25 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi self.accessibilityIdentifier = accessibilityIdentifier } - setTitle(model.title, for: .normal) - if let accessibilityText = model.accessibilityText { - accessibilityLabel = accessibilityText - } - + text = model.title isEnabled = model.enabled size = model.size // if let backgroundColor = model.backgroundColor { // self.backgroundColor = backgroundColor.uiColor // } + if let accessibilityText = model.accessibilityText { + accessibilityLabel = accessibilityText + } + + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) + + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) model.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { self?.isEnabled = model.enabled }) } - - FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } //-------------------------------------------------- From c82a0cd4d60d2ab47aaf2049267d16b22662f841 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 14:49:07 -0400 Subject: [PATCH 07/51] Make PillButton VDSMoleculeViewProtocol --- .../Atomic/Atoms/Buttons/PillButton.swift | 89 +++++++------------ .../Atomic/Extensions/VDS-Enums+Codable.swift | 2 +- 2 files changed, 32 insertions(+), 59 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e8105d3e..2c1c44e7 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -12,40 +12,18 @@ import VDS import MVMCore import Combine -open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol, MVMCoreViewProtocol, MFButtonProtocol { - +open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol, MVMCoreViewProtocol, MFButtonProtocol, VDSMoleculeViewProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var model: MoleculeModelProtocol? - public var buttonModel: ButtonModel? { - get { model as? ButtonModel } - } - + public var viewModel: ButtonModel! + public var delegateObject: MVMCoreUIDelegateObject? + public var additionalData: [AnyHashable: Any]? + internal var onClickCancellable: Cancellable? - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - - required public init() { - super.init(frame: .zero) - } - - public override init(frame: CGRect) { - super.init(frame: .zero) - } - - public required init?(coder: NSCoder) { - super.init(coder: coder) - } - - open override func setup() { - super.setup() - setupView() - } - //-------------------------------------------------- // MARK: - Convenience //-------------------------------------------------- @@ -59,45 +37,45 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi /// The primary styling for a button. Should be used for main buttons open func stylePrimary() { - model = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + viewModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) use = .primary } /// The secondary styling for a button. Should be used for secondary buttons open func styleSecondary() { - model = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + viewModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) use = .secondary } + open override func setup() { + super.setup() + setupView() + } + //-------------------------------------------------- - // MARK: - MoleculeViewProtocol + // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- - open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let model = model as? ButtonModel else { return } - self.model = model - - if let accessibilityIdentifier = model.accessibilityIdentifier { + public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { self.accessibilityIdentifier = accessibilityIdentifier } - text = model.title - isEnabled = model.enabled - size = model.size -// if let backgroundColor = model.backgroundColor { -// self.backgroundColor = backgroundColor.uiColor -// } - if let accessibilityText = model.accessibilityText { + text = viewModel.title + isEnabled = viewModel.enabled + size = viewModel.size + use = viewModel.style ?? .primary + if let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText } - FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) + FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) + set(with: viewModel.action, delegateObject: delegateObject, additionalData: additionalData) - model.updateUI = { [weak self] in + viewModel.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { - self?.isEnabled = model.enabled + self?.viewModelDidUpdate() }) } } @@ -106,11 +84,6 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi // MARK: - MVMCoreViewProtocol //-------------------------------------------------- - open override func reset() { - super.reset() - //backgroundColor = .clear - } - open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return (model as? ButtonModel)?.size.height } @@ -130,13 +103,13 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi //-------------------------------------------------- open func set(with actionModel: ActionModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - onClickCancellable = onClickSubscriber.publisher.sink { [weak self] _ in - guard let self = self, - let actionModel = self.buttonModel?.action else { return } - Task(priority: .userInitiated) { - try await Self.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.model) + onClickSubscriber = publisher(for: .touchUpInside) + .sink {[weak self] control in + guard let self = self else { return } + Task(priority: .userInitiated) { + try await Self.performButtonAction(with: self.viewModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.viewModel) + } } - } } open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) async throws { diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index ea462930..369dbb18 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -22,7 +22,7 @@ extension VDS.Button.Size: Codable { let container = try decoder.singleValueContainer() let string = try container.decode(String.self) switch string { - case VDS.Button.Size.large.rawValue: + case VDS.Button.Size.large.rawValue, "standard": self = .large case VDS.Button.Size.small.rawValue, "tiny": self = .small From a925560ecbb463bad2eabb00a88a540ca7455368 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 16:18:10 -0400 Subject: [PATCH 08/51] RawRepresentableCodable --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../Atomic/Atoms/Buttons/PillButton.swift | 9 +++-- .../Atomic/Extensions/VDS-Enums+Codable.swift | 22 ++-------- .../Utility/RawRepresentableCodable.swift | 40 +++++++++++++++++++ 4 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 MVMCoreUI/Utility/RawRepresentableCodable.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index acb13d9a..964bc30c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -289,6 +289,7 @@ AF766D262A3CD4C600749099 /* UIAccessibilityTraits+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF766D252A3CD4C600749099 /* UIAccessibilityTraits+Codable.swift */; }; AF7E509829E477C1009DC2AD /* AlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF7E509629E477C0009DC2AD /* AlertHandler.swift */; }; AF7E509929E477C1009DC2AD /* AlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF7E509729E477C0009DC2AD /* AlertController.swift */; }; + AF8118302AB39B0900FAD1BA /* RawRepresentableCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF81182F2AB39B0900FAD1BA /* RawRepresentableCodable.swift */; }; AFA4932029E5CA73001A9663 /* AlertOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4931F29E5CA73001A9663 /* AlertOperation.swift */; }; AFA4932229E5EF2E001A9663 /* NotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4932129E5EF2E001A9663 /* NotificationHandler.swift */; }; AFA4933F29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */; }; @@ -875,6 +876,7 @@ AF766D252A3CD4C600749099 /* UIAccessibilityTraits+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAccessibilityTraits+Codable.swift"; sourceTree = ""; }; AF7E509629E477C0009DC2AD /* AlertHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertHandler.swift; sourceTree = ""; }; AF7E509729E477C0009DC2AD /* AlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertController.swift; sourceTree = ""; }; + AF81182F2AB39B0900FAD1BA /* RawRepresentableCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawRepresentableCodable.swift; sourceTree = ""; }; AFA4931F29E5CA73001A9663 /* AlertOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertOperation.swift; sourceTree = ""; }; AFA4932129E5EF2E001A9663 /* NotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationHandler.swift; sourceTree = ""; }; AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUILoggingDelegateProtocol.swift; sourceTree = ""; }; @@ -2152,6 +2154,7 @@ D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */, 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */, 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */, + AF81182F2AB39B0900FAD1BA /* RawRepresentableCodable.swift */, ); path = Utility; sourceTree = ""; @@ -2746,6 +2749,7 @@ 0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, D2E2A9A123E095AB000B42E6 /* ButtonModelProtocol.swift in Sources */, + AF8118302AB39B0900FAD1BA /* RawRepresentableCodable.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */, 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 2c1c44e7..d99b78f4 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -68,16 +68,17 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi if let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText } - - FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) - + set(with: viewModel.action, delegateObject: delegateObject, additionalData: additionalData) viewModel.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { - self?.viewModelDidUpdate() + guard let self = self else { return } + self.isEnabled = self.viewModel.enabled }) } + + FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 369dbb18..ee504e2f 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -17,23 +17,7 @@ extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} extension Use: Codable {} -extension VDS.Button.Size: Codable { - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let string = try container.decode(String.self) - switch string { - case VDS.Button.Size.large.rawValue, "standard": - self = .large - case VDS.Button.Size.small.rawValue, "tiny": - self = .small - default: - self = .large - } - - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(self) - } +extension VDS.Button.Size: RawRepresentableCodable { + public static var mapping: [String : VDS.Button.Size] { ["standard": .large, "tiny": .small] } + public static var defaultValue: VDS.Button.Size? { nil } } diff --git a/MVMCoreUI/Utility/RawRepresentableCodable.swift b/MVMCoreUI/Utility/RawRepresentableCodable.swift new file mode 100644 index 00000000..09441add --- /dev/null +++ b/MVMCoreUI/Utility/RawRepresentableCodable.swift @@ -0,0 +1,40 @@ +// +// RawRepresentableCodable.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 9/14/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol RawRepresentableCodable: RawRepresentable, Codable where RawValue: Hashable & Decodable { + static var mapping: [RawValue: Self] { get } + static var defaultValue: Self? { get } +} + +public enum RawRepresentableCodableError: Swift.Error { + case invalid(value: String) +} + +extension RawRepresentableCodable { + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let rawValue = try container.decode(RawValue.self) + if let found = Self(rawValue: rawValue) { + self = found + } else if let found = Self.mapping[rawValue] { + self = found + } else if let defaultValue = Self.defaultValue { + self = defaultValue + } else { + throw RawRepresentableCodableError.invalid(value: "\(rawValue)") + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(self) + } +} From c2cc637c382f1bed8997c8e465aeebe21dab00c2 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 14 Sep 2023 16:35:44 -0400 Subject: [PATCH 09/51] remove old junk --- .../Atomic/Atoms/Buttons/PillButton.swift | 33 +++---------------- .../TwoButtonView.swift | 7 ++-- .../NotificationMoleculeView.swift | 2 +- .../HeadlineBodyButton.swift | 2 +- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index d99b78f4..ddffb179 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -24,34 +24,6 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi internal var onClickCancellable: Cancellable? - //-------------------------------------------------- - // MARK: - Convenience - //-------------------------------------------------- - - @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { - let model = ButtonModel(with: "", action: ActionNoopModel()) - model.style = isPrimary ? .primary : .secondary - model.size = istiny ? .small : .large - self.init(model: model, nil, nil) - } - - /// The primary styling for a button. Should be used for main buttons - open func stylePrimary() { - viewModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) - use = .primary - } - - /// The secondary styling for a button. Should be used for secondary buttons - open func styleSecondary() { - viewModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) - use = .secondary - } - - open override func setup() { - super.setup() - setupView() - } - //-------------------------------------------------- // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- @@ -91,6 +63,11 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi open func updateView(_ size: CGFloat) {} + open override func setup() { + super.setup() + setupView() + } + open func setupView() {} //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index 5f846730..9a70c12e 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDS @objcMembers open class TwoButtonView: View, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- @@ -29,9 +29,8 @@ import UIKit //-------------------------------------------------- public func setDefaultAppearance() { - - primaryButton.stylePrimary() - secondaryButton.styleSecondary() + primaryButton.use = .primary + secondaryButton.use = .secondary } open override func updateView(_ size: CGFloat) { diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift index c731f6d6..200dea16 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift @@ -15,7 +15,7 @@ import Foundation public let headline = Label(fontStyle: .BoldBodySmall) public let body = Label(fontStyle: .RegularBodySmall) - public let button = PillButton(asPrimaryButton: false, makeTiny: true) + public let button = PillButton() public let closeButton = NotificationXButton() public var labelStack: Stack! public var horizontalStack: Stack! diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift index a40066e2..d7fced36 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButton.swift @@ -64,7 +64,7 @@ headlineBody.headlineLabel.font = Styler.Font.BoldTitleMedium.getFont() headlineBody.messageLabel.font = Styler.Font.RegularMicro.getFont() - button.styleSecondary() + button.use = .secondary button.isHidden = false buttonHeadlinePadding = PaddingTwo } From 34d3386d36b240a7ff3a0399c32e1f4a73477d97 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Sep 2023 16:02:15 -0500 Subject: [PATCH 10/51] updated onClick Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift index 41d68493..32c8015a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift @@ -50,14 +50,13 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{ //setup action if let action = viewModel.action { //add the subscriber - onClickSubscriber = publisher(for: .touchUpInside) - .sink {[weak self] control in - guard let self else { return } - MVMCoreUIActionHandler.performActionUnstructured(with: action, - sourceModel: self.viewModel, - additionalData: self.additionalData, - delegateObject: self.delegateObject) - } + onClick = { [weak self] control in + guard let self, let viewModel = self.viewModel else { return } + MVMCoreUIActionHandler.performActionUnstructured(with: action, + sourceModel: viewModel, + additionalData: self.additionalData, + delegateObject: self.delegateObject) + } } } From fe580d12e4cca358ef6a0c9e4db19b8e0c961839 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Sep 2023 16:02:26 -0500 Subject: [PATCH 11/51] updated onClick Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index ddffb179..c93a22db 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -12,7 +12,7 @@ import VDS import MVMCore import Combine -open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeViewProtocol, MVMCoreViewProtocol, MFButtonProtocol, VDSMoleculeViewProtocol { +open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties @@ -81,13 +81,12 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi //-------------------------------------------------- open func set(with actionModel: ActionModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - onClickSubscriber = publisher(for: .touchUpInside) - .sink {[weak self] control in - guard let self = self else { return } - Task(priority: .userInitiated) { - try await Self.performButtonAction(with: self.viewModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.viewModel) - } + onClick = { [weak self] control in + guard let self = self, let viewModel = self.viewModel else { return } + Task(priority: .userInitiated) { + try await Self.performButtonAction(with: viewModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: viewModel) } + } } open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) async throws { From 917a0f84806045af86189ba07be917146cb68a35 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 15 Sep 2023 12:13:02 -0400 Subject: [PATCH 12/51] PillButton inverted-> surface --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 1 + MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index b15f8adb..94a7778b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -9,6 +9,7 @@ import UIKit import VDSColorTokens import VDS +import MVMCore public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index c93a22db..645c6602 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -37,6 +37,7 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr isEnabled = viewModel.enabled size = viewModel.size use = viewModel.style ?? .primary + surface = viewModel.inverted ? .dark : .light if let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText } From 68ad6595595294b562bc993be60b26570fc44cde Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 15 Sep 2023 12:13:44 -0400 Subject: [PATCH 13/51] pill button open --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index c93a22db..0bfad746 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -18,7 +18,7 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr // MARK: - Properties //-------------------------------------------------- - public var viewModel: ButtonModel! + open var viewModel: ButtonModel! public var delegateObject: MVMCoreUIDelegateObject? public var additionalData: [AnyHashable: Any]? @@ -28,7 +28,7 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- - public func viewModelDidUpdate() { + open func viewModelDidUpdate() { if let accessibilityIdentifier = viewModel.accessibilityIdentifier { self.accessibilityIdentifier = accessibilityIdentifier } From 05069e044cb64ed9c850aeb17874a2d05f68092b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 09:55:56 -0500 Subject: [PATCH 14/51] added helper protocol Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +++++- .../Atomic/Extensions/VDS-Enums+Codable.swift | 2 ++ .../Atomic/Protocols/VDS-Interpreters.swift | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index acb13d9a..a46d3b1a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -587,6 +587,7 @@ EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.swift */; }; + EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */ = {isa = PBXBuildFile; fileRef = EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */; }; FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; }; /* End PBXBuildFile section */ @@ -1174,6 +1175,7 @@ EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = ""; }; + EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Interpreters.swift"; sourceTree = ""; }; FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -2415,6 +2417,7 @@ 011B58EE23A2AA850085F53C /* ModelProtocols */, 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */, + EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */, ); path = Protocols; sourceTree = ""; @@ -2972,6 +2975,7 @@ D28BA741248025A300B75CB8 /* TabBarModel.swift in Sources */, D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */, D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */, + EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, D2FA83D22513EA6900564112 /* NotificationXButton.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 6c143d9c..3f132670 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,3 +16,5 @@ extension Icon.Size: Codable {} extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} +extension VDS.Line.Style: Codable {} +extension VDS.Line.Orientation: Codable {} diff --git a/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift b/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift new file mode 100644 index 00000000..24237527 --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift @@ -0,0 +1,18 @@ +// +// VDS-Interpreters.swift +// MVMCoreUI +// +// Created by Matt Bruce on 9/20/23. +// Copyright © 2023 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS + +public protocol Invertable { + var inverted: Bool { get set } +} + +extension Invertable { + public var surface: Surface { return inverted ? .dark : .light } +} From 470bb160d6f928337d4497bb2f96f1034a3b700f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:25:33 -0500 Subject: [PATCH 15/51] update for VDS Protocol Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift index 41349f2c..fcbd07d1 100644 --- a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift @@ -28,5 +28,9 @@ extension VDSMoleculeViewProtocol { viewModel = castedModel viewModelDidUpdate() } + + public func update(viewModel: ViewModel){ + set(with: viewModel, delegateObject, additionalData) + } } From 099fce290e81b8c2419529244d3e7ff9e10b911b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:26:31 -0500 Subject: [PATCH 16/51] updated LineModel and Line Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 125 +++++++++---------- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 87 +++---------- 2 files changed, 73 insertions(+), 139 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e36c8d23..c527a362 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -7,116 +7,107 @@ // import UIKit +import VDS - -@objcMembers open class Line: View { +@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - var lineModel: LineModel? { - get { return model as? LineModel } - } - - //-------------------------------------------------- - // MARK: - Constraints - //-------------------------------------------------- - - public var heightConstraint: NSLayoutConstraint? - public var widthConstraint: NSLayoutConstraint? - - open func updateLineConstraints(constant: CGFloat) { - if let useVerticalLine = lineModel?.useVerticalLine, useVerticalLine { - heightConstraint?.isActive = false - widthConstraint?.isActive = true - widthConstraint?.constant = constant - } else { - widthConstraint?.isActive = false - heightConstraint?.isActive = true - heightConstraint?.constant = constant + open var line = VDS.Line() + open var viewModel: LineModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? + open var orientation: VDS.Line.Orientation = .horizontal { + didSet { + viewModel.orientation = orientation + update(viewModel: viewModel) } } //-------------------------------------------------- // MARK: - Initializer - //-------------------------------------------------- - + //-------------------------------------------------- public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) { self.init(frame: .zero) addLine(to: view, edge: edge, useMargin: useMargin) } - public init() { - super.init(frame: .zero) - model = LineModel(type: .secondary) - setStyle(.secondary) + public required init() { + super.init() + viewModel = LineModel(type: .primary) } public override init(frame: CGRect) { super.init(frame: frame) - model = LineModel(type: .secondary) - setStyle(.secondary) + viewModel = LineModel(type: .primary) } public required init?(coder: NSCoder) { super.init(coder: coder) - model = LineModel(type: .secondary) - setStyle(.secondary) + viewModel = LineModel(type: .primary) } - public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - super.init(model: model, delegateObject, additionalData) + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func setup() { + super.setup() + addSubview(line) + line.pinToSuperView() } - + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- - - open func setStyle(_ style: LineModel.Style) { - lineModel?.type = style - backgroundColor = lineModel?.backgroundColor?.uiColor - updateLineConstraints(constant: lineModel?.thickness ?? 1) - } - open func shouldBeVisible() -> Bool { - guard let type = lineModel?.type else { return false } + guard let type = viewModel?.type else { return false } return type != .none } - //-------------------------------------------------- - // MARK: - MoleculeViewProtocol - //-------------------------------------------------- + open func setStyle(_ style: LineModel.Style) { + viewModel.type = style + update(viewModel: viewModel) + } open func addLine(to view: UIView, edge: UIRectEdge, useMargin: Bool) { view.addSubview(self) - NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: self, useMargins: useMargin, pinTop: edge != .bottom, pinBottom: edge != .top, pinLeft: edge != .right, pinRight: edge != .left).values)) + NSLayoutConstraint.activate( + Array( + NSLayoutConstraint.pinView(toSuperview: self, + useMargins: useMargin, + pinTop: edge != .bottom, + pinBottom: edge != .top, + pinLeft: edge != .right, + pinRight: edge != .left).values + ) + ) } - open override func setupView() { - super.setupView() - heightConstraint = heightAnchor.constraint(equalToConstant: 1) - heightConstraint?.isActive = true - widthConstraint = widthAnchor.constraint(equalToConstant: 1) - widthConstraint?.isActive = false + //-------------------------------------------------- + // MARK: - VDSMoleculeViewProtocol + //-------------------------------------------------- + open func viewModelDidUpdate() { + surface = viewModel.surface + line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + line.orientation = viewModel.orientation } - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - if let lineModel = model as? LineModel { - setStyle(lineModel.type) - } + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + public func updateView(_ size: CGFloat) { + setNeedsDisplay() } - - open override func reset() { - setStyle(.secondary) - } - - public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return (model as? LineModel)?.thickness ?? 1 + + public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 1 } } +//-------------------------------------------------- +// MARK: - MVMCoreUIViewConstrainingProtocol +//-------------------------------------------------- extension Line: MVMCoreUIViewConstrainingProtocol { open func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 3b4c57e9..ecb39df0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -8,8 +8,9 @@ import UIKit import VDSColorTokens +import VDS -@objcMembers public class LineModel: MoleculeModelProtocol { +@objcMembers public class LineModel: MoleculeModelProtocol, Invertable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -28,23 +29,9 @@ import VDSColorTokens case between } - /** - The style of the line: - - secondary (1 height, silver) - - primary (1 height, black) - - standard (1 height, silver) - deprecated - - thin (1 height, black) - deprecated - - medium (2 height, black) - - heavy (4 height, black) - - none (hidden) - */ public enum Style: String, Codable { case secondary case primary - case standard - case thin - case medium - case heavy case none } @@ -54,53 +41,14 @@ import VDSColorTokens public static var identifier: String = "line" public var id: String = UUID().uuidString - - public var type: Style = .secondary + public var backgroundColor: Color? + + public var type: Style = .primary public var frequency: Frequency? = .allExceptTop - - //TODO: use color insted of backgroundColor. Needs server changes - // public var color: Color? - private var _backgroundColor: Color? - public var backgroundColor: Color? { - get { - if let backgroundColor = _backgroundColor { return backgroundColor } - if inverted { - if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray20) } - return Color(uiColor: VDSColor.elementsPrimaryOndark) - } - if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray85) } - return Color(uiColor: VDSColor.elementsPrimaryOnlight) - } - set { - _backgroundColor = newValue - } - } - - private var _thickness: CGFloat? - public var thickness: CGFloat { - get { - if let thickness = _thickness { return thickness } - switch type { - case .heavy: - return 4 - case .medium: - return 2 - case .none: - return 0 - default: - return 1 - } - } - set { - _thickness = newValue - } - } - + public var inverted: Bool = false - // Use this to show vertical line - // Default is false - public var useVerticalLine: Bool? + public var orientation: VDS.Line.Orientation = .horizontal //-------------------------------------------------- // MARK: - Initializer @@ -108,13 +56,10 @@ import VDSColorTokens public init(type: Style) { self.type = type - self.useVerticalLine = false } public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { self.type = type - self.backgroundColor = backgroundColor - self.useVerticalLine = true } //-------------------------------------------------- @@ -125,13 +70,10 @@ import VDSColorTokens case id case moleculeName case type - case backgroundColor - case backgroundColor_inverted - case color case frequency case inverted case useVerticalLine - case thickness + case orientation } //-------------------------------------------------- @@ -155,9 +97,12 @@ import VDSColorTokens self.inverted = inverted } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) - _thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) + /// adding code to look for the old useVerticalLine or the new orientation + if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) { + orientation = useVerticalLine ? .vertical : .horizontal + }else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { + self.orientation = orientation + } } public func encode(to encoder: Encoder) throws { @@ -167,8 +112,6 @@ import VDSColorTokens try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine) - try container.encodeIfPresent(_thickness, forKey: .thickness) + try container.encodeIfPresent(orientation == .vertical, forKey: .useVerticalLine) } } From 2e03cec5be3ed5ed51c991c56823ed7f7cb0969d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:27:51 -0500 Subject: [PATCH 17/51] updated ListProgressBarThin Signed-off-by: Matt Bruce --- .../Molecules/DesignedComponents/List/ListProgressBarThin.swift | 2 +- .../DesignedComponents/List/ListProgressBarThinModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 9b85dc4f..d9875068 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -102,7 +102,7 @@ leftHeadline.styleB1(true) leftBody.styleB2(true) rightLabel.styleB2(true) - rightBar.setStyle(.medium) + rightBar.setStyle(.primary) } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 52c175df..d6787f52 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -39,7 +39,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() - rightBar.type = .medium + rightBar.type = .primary if rightBar.backgroundColor == nil { rightBar.backgroundColor = Color(uiColor: .gray) From 81a5d5099fe7528dbe7974af702300d9c9bf02ba Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:28:16 -0500 Subject: [PATCH 18/51] updated ListRightVariableTotalData Signed-off-by: Matt Bruce --- .../List/RightVariable/ListRightVariableTotalData.swift | 4 ++-- .../List/RightVariable/ListRightVariableTotalDataModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index a749041a..9845ea16 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -44,7 +44,7 @@ override open func setupView() { super.setupView() - bar.setStyle(.heavy) + bar.setStyle(.primary) bar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) @@ -74,7 +74,7 @@ super.reset() leftLabel.setFontStyle(.BoldBodySmall) rightLabel.setFontStyle(.RegularBodySmall) - bar.setStyle(.heavy) + bar.setStyle(.primary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift index cebaeb34..53ede6e5 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift @@ -24,7 +24,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 - bar.type = .heavy + bar.type = .primary if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .mvmBlue) From aed46d592c86a8860f6d24cf716e2d0d9eaf1378 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:28:38 -0500 Subject: [PATCH 19/51] updated tabs and tabs model Signed-off-by: Matt Bruce --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 2 +- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index e49006fa..bbe17e05 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -50,7 +50,7 @@ import VDSColorTokens setItems(tabs, animated: false) selectedItem = tabs[model.selectedTab] - guard let lineModel = line.lineModel else { return } + guard let lineModel = line.viewModel else { return } lineModel.inverted = model.style == .dark line.set(with: lineModel, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index e5682e71..e6689f3d 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -174,7 +174,7 @@ import VDSColorTokens self.additionalData = additionalData selectedIndex = tabsModel?.selectedIndex ?? 0 selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor - let lineModel = bottomLine.lineModel ?? LineModel(type: .secondary) + let lineModel = bottomLine.viewModel ?? LineModel(type: .secondary) lineModel.inverted = tabsModel?.style == .dark bottomLine.set(with: lineModel, delegateObject, additionalData) reloadData() From 5d9944b5eab6482d78026235a675a31e81738255 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:07:36 -0500 Subject: [PATCH 20/51] subclass line directly Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c527a362..e3195aa2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,22 +9,15 @@ import UIKit import VDS -@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - open var orientation: VDS.Line.Orientation = .horizontal { - didSet { - viewModel.orientation = orientation - update(viewModel: viewModel) - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -47,15 +40,6 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open override func setup() { - super.setup() - addSubview(line) - line.pinToSuperView() - } //-------------------------------------------------- // MARK: - Methods @@ -89,8 +73,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - line.orientation = viewModel.orientation + style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + orientation = viewModel.orientation } //-------------------------------------------------- From 62afe434f9a37c36fb127550b39a3862853f46df Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:07:49 -0500 Subject: [PATCH 21/51] updated to use line properties Signed-off-by: Matt Bruce --- .../UINavigationController+Extension.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 625f0a25..d45ca632 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -81,9 +81,9 @@ public extension UINavigationController { /// Returns a ShadowImage based on the line property of NavigationItemModelProtocol func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let thickness = navigationItemModel.line?.thickness, - let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } - return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) + guard let model = navigationItemModel.line else { return nil } + let line = Line(model: model, nil, nil) + return line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)) } /// Convenience function for setting the navigation bar ui From 10370f3ac6840a89f97b158aecfe4b6691765519 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:35:46 -0500 Subject: [PATCH 22/51] Revert "subclass line directly" This reverts commit 5d9944b5eab6482d78026235a675a31e81738255. --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e3195aa2..c527a362 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,15 +9,22 @@ import UIKit import VDS -@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - + open var orientation: VDS.Line.Orientation = .horizontal { + didSet { + viewModel.orientation = orientation + update(viewModel: viewModel) + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -40,6 +47,15 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func setup() { + super.setup() + addSubview(line) + line.pinToSuperView() + } //-------------------------------------------------- // MARK: - Methods @@ -73,8 +89,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - orientation = viewModel.orientation + line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + line.orientation = viewModel.orientation } //-------------------------------------------------- From b2b33db8a986517997760a7007fef6ce24a83179 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:40:56 -0500 Subject: [PATCH 23/51] Revert "Revert "subclass line directly"" This reverts commit 10370f3ac6840a89f97b158aecfe4b6691765519. --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c527a362..e3195aa2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -9,22 +9,15 @@ import UIKit import VDS -@objcMembers open class Line: VDS.View, VDSMoleculeViewProtocol { +@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var line = VDS.Line() open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? - open var orientation: VDS.Line.Orientation = .horizontal { - didSet { - viewModel.orientation = orientation - update(viewModel: viewModel) - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -47,15 +40,6 @@ import VDS super.init(coder: coder) viewModel = LineModel(type: .primary) } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open override func setup() { - super.setup() - addSubview(line) - line.pinToSuperView() - } //-------------------------------------------------- // MARK: - Methods @@ -89,8 +73,8 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface - line.style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary - line.orientation = viewModel.orientation + style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary + orientation = viewModel.orientation } //-------------------------------------------------- From 6da75b26bd94176658092e2e6baca48486ec3cd2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:51:12 -0500 Subject: [PATCH 24/51] don't call super to draw if model is set to none Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index e3195aa2..c3ce3d7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -68,6 +68,11 @@ import VDS ) } + open override func draw(_ rect: CGRect) { + guard viewModel.type != .none else { return } + super.draw(rect) + } + //-------------------------------------------------- // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- From 2a34fa433dbeb29e0dbbfa1cd63a56bd7f981556 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:51:21 -0500 Subject: [PATCH 25/51] updated for line Signed-off-by: Matt Bruce --- .../Headers/H2/HeadersH2PricingTwoRows.swift | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index 1baf057c..f38793eb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -42,6 +42,13 @@ import Foundation return Stack.createStack(with: [headline, horizontalStack], spacing: 8) }() + + //------------------------------------------------------- + // MARK: - Constraints + //------------------------------------------------------- + public var verticalLine1HeightConstraint: NSLayoutConstraint? + public var verticalLine2HeightConstraint: NSLayoutConstraint? + //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- @@ -51,11 +58,10 @@ import Foundation body.lineBreakMode = .byTruncatingTail body2.lineBreakMode = .byTruncatingTail body3.lineBreakMode = .byTruncatingTail - - verticalLine1.widthConstraint?.isActive = true - verticalLine1.backgroundColor = .mvmBlack - verticalLine2.widthConstraint?.isActive = true - verticalLine2.backgroundColor = .mvmBlack + + // setup lines + verticalLine1.orientation = .vertical + verticalLine2.orientation = .vertical addMolecule(stack) stack.restack() @@ -80,13 +86,13 @@ import Foundation } open func setLineHeight() { - verticalLine1.heightConstraint?.isActive = false - verticalLine1.heightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) - verticalLine1.heightConstraint?.isActive = true + verticalLine1HeightConstraint?.isActive = false + verticalLine1HeightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) + verticalLine1HeightConstraint?.isActive = true - verticalLine2.heightConstraint?.isActive = false - verticalLine2.heightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) - verticalLine2.heightConstraint?.isActive = true + verticalLine2HeightConstraint?.isActive = false + verticalLine2HeightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) + verticalLine2HeightConstraint?.isActive = true } //---------------------------------------------------- From ad3112d984719277908c6482139929e871f965d8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 11:34:28 -0500 Subject: [PATCH 26/51] added id Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index de19faab..cbb9a1b9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -10,12 +10,11 @@ import Foundation import VDS open class BadgeModel: MoleculeModelProtocol { - - //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- public static var identifier: String = "badge" + public var id: String = UUID().uuidString public var backgroundColor: Color? public var text: String = "" public var maxWidth: CGFloat? @@ -24,12 +23,13 @@ open class BadgeModel: MoleculeModelProtocol { public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case text, fillColor, surface, numberOfLines, maxWidth + case id, text, fillColor, surface, numberOfLines, maxWidth } required public convenience init(from decoder: Decoder) throws { self.init() let container = try decoder.container(keyedBy: CodingKeys.self) + id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString text = try container.decode(String.self, forKey: .text) fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light @@ -39,6 +39,7 @@ open class BadgeModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(id, forKey: .id) try container.encode(text, forKey: .text) try container.encode(fillColor, forKey: .fillColor) try container.encode(surface, forKey: .surface) From 8143cc7d9e36a368648637d8de06da7ddae983ea Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 11:34:38 -0500 Subject: [PATCH 27/51] re arranged files Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 46156d9d..d6404d24 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -2220,8 +2220,8 @@ AA07EA902510A442009A2AE3 /* StarModel.swift */, AA07EA922510A451009A2AE3 /* Star.swift */, B4CC8FBC29DF34680005D28B /* Badge.swift */, - EA985C3D2970938F00F2FF2E /* Tilelet.swift */, B4CC8FBE29DF34730005D28B /* BadgeModel.swift */, + EA985C3D2970938F00F2FF2E /* Tilelet.swift */, EA985C3F2970939A00F2FF2E /* TileletModel.swift */, ); path = Views; From 89f65ebe3dbe6785968e2d46cd78e7ce269c106a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 14:41:35 -0500 Subject: [PATCH 28/51] added codable Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 6c143d9c..b3500df1 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,3 +16,4 @@ extension Icon.Size: Codable {} extension TileContainer.BackgroundColor: Codable {} extension TileContainer.Padding: Codable {} extension TileContainer.AspectRatio: Codable {} +extension TextLink.Size: Codable {} From 0f85c96201024930bb272ee85c0e786b318ddefb Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 14:41:42 -0500 Subject: [PATCH 29/51] updated link Signed-off-by: Matt Bruce --- .../Atomic/Atoms/Buttons/Link/Link.swift | 92 +++++++------------ .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 69 ++------------ 2 files changed, 38 insertions(+), 123 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 4f4a8b34..8c1e5f4a 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -8,83 +8,53 @@ import UIKit import VDSColorTokens +import VDS + +@objcMembers open class Link: VDS.TextLink, VDSMoleculeViewProtocol { -@objcMembers open class Link: Button { //-------------------------------------------------- - // MARK: - Draw + // MARK: - Public Properties //-------------------------------------------------- + open var viewModel: LinkModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? - open override func draw(_ rect: CGRect) { + //-------------------------------------------------- + // MARK: - Public Functions + //-------------------------------------------------- + open func viewModelDidUpdate() { + isEnabled = viewModel.enabled + size = viewModel.size + text = viewModel.title - guard let textRect = titleLabel?.frame, - let context = UIGraphicsGetCurrentContext() - else { return } - - // Set line to the same color as the text - if let color = titleLabel?.textColor?.cgColor { - context.setStrokeColor(color) + onClick = { [weak self] control in + guard let self else { return } + MVMCoreUIActionHandler.performActionUnstructured(with: self.viewModel.action, + sourceModel: self.viewModel, + additionalData: self.additionalData, + delegateObject: self.delegateObject) } - - // x should be according to the text, not the button - let x = textRect.origin.x - - // Line is 0 point below the text - let y = textRect.origin.y + textRect.size.height - - context.move(to: CGPoint(x: x, y: y)) - context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) - context.strokePath() } - - open override var intrinsicContentSize: CGSize { - guard let size = titleLabel?.intrinsicContentSize else { return super.intrinsicContentSize } - return CGSize(width: size.width, height: size.height + 1) - } - + //-------------------------------------------------- - // MARK: - MoleculeViewProtocol + // MARK: - Overrides //-------------------------------------------------- - - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) + open override func updateAccessibility() { + super.updateAccessibility() - guard let model = model as? LinkModel else { return } - - setTitle(model.title, for: .normal) - if let accessibilityText = model.accessibilityText { + if let viewModel, let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText } - setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal) - setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) - setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) - isEnabled = model.enabled - titleLabel?.font = model.getFont(model.size) - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 31 } -} + //-------------------------------------------------- + // MARK: - MVMCoreViewProtocol + //-------------------------------------------------- + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 31 } -// MARK: - MVMCoreViewProtocol -extension Link { + open func updateView(_ size: CGFloat) { } - open override func updateView(_ size: CGFloat) { - super.updateView(size) - } - - open override func setupView() { - super.setupView() - backgroundColor = .clear - contentMode = .redraw - setTitleColor(VDSColor.elementsPrimaryOnlight, for: .normal) - setTitleColor(VDSColor.interactiveDisabledOnlight, for: .disabled) - setTitleColor(VDSColor.interactiveActiveOnlight, for: .highlighted) - titleLabel?.numberOfLines = 1 - titleLabel?.lineBreakMode = .byTruncatingTail - titleLabel?.textAlignment = .left - contentHorizontalAlignment = .left - contentVerticalAlignment = .top - } + open func setupView() {} } // MARK: - MVMCoreUIViewConstrainingProtocol diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 62ba0422..7e9a4640 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDS open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -23,15 +23,9 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var accessibilityText: String? public var action: ActionModelProtocol public var enabled = true - public var enabledColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - public var enabledColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - public var disabledColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - public var disabledColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) - public var activeColor = Color(uiColor: VDSColor.interactiveActiveOnlight) - public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false - public var size:linkFontSize = linkFontSize.small + public var size: TextLink.Size = .small public var shouldMaskRecordedView: Bool? = false @@ -57,34 +51,10 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case title case action case enabled - case enabledColor - case enabledColor_inverted - case disabledColor - case disabledColor_inverted - case activeColor - case activeColor_inverted case inverted case size case shouldMaskRecordedView } - - public enum linkFontSize: String, Codable { - case small - case large - } - - //-------------------------------------------------- - // MARK: - Method - //-------------------------------------------------- - - func getFont(_ type: linkFontSize) -> UIFont { - switch type { - case .small: - return MFStyler.fontRegularBodySmall() - case .large: - return MFStyler.fontRegularBodyLarge() - } - } //-------------------------------------------------- // MARK: - Codec @@ -108,30 +78,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode self.inverted = inverted } - if let enabledColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) { - self.enabledColor = enabledColor - } - - if let enabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor_inverted) { - self.enabledColor_inverted = enabledColor_inverted - } - - if let disabledColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) { - self.disabledColor = disabledColor - } - - if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) { - self.disabledColor_inverted = disabledColor_inverted - } - - if let activeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor) { - self.activeColor = activeColor - } - - if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { - self.activeColor_inverted = activeColor_inverted - } - if let size = try typeContainer.decodeIfPresent(linkFontSize.self, forKey: .size) { + if let size = try typeContainer.decodeIfPresent(TextLink.Size.self, forKey: .size) { self.size = size } @@ -148,13 +95,11 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encodeModel(action, forKey: .action) try container.encode(inverted, forKey: .inverted) try container.encode(enabled, forKey: .enabled) - try container.encode(enabledColor, forKey: .enabledColor) - try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted) - try container.encode(disabledColor, forKey: .disabledColor) - try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) - try container.encode(activeColor, forKey: .activeColor) - try container.encode(activeColor_inverted, forKey: .activeColor_inverted) try container.encodeIfPresent(size, forKey: .size) try container.encode(shouldMaskRecordedView, forKey: .shouldMaskRecordedView) } } + +extension LinkModel { + public var surface: Surface { inverted ? .dark : .light } +} From f4221c0215a9cdbfa05633069a0a13c031183af7 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 14:41:50 -0500 Subject: [PATCH 30/51] updated external link Signed-off-by: Matt Bruce --- .../Atoms/Buttons/Link/ExternalLink.swift | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift index e051cf32..9e5cd108 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift @@ -11,29 +11,24 @@ import UIKit open class ExternalLink: Link { //-------------------------------------------------- - // MARK: - Properties + // MARK: - Public Properties //-------------------------------------------------- - - public var exportImageView: UIImageView? - + open var exportImageView: UIImageView? + open var exportImageHeight: NSLayoutConstraint? + open var exportImageWidth: NSLayoutConstraint? + //-------------------------------------------------- - // MARK: - MoleculeViewProtocol + // MARK: - Overrides //-------------------------------------------------- - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - - guard let model = model as? ExternalLinkModel else { return } - - exportImageView?.tintColor = titleColor(for: model.enabled ? .normal : .disabled) + open override func viewModelDidUpdate() { + super.viewModelDidUpdate() + exportImageView?.tintColor = textColor + exportImageWidth?.constant = textStyle.lineHeight + exportImageHeight?.constant = textStyle.lineHeight } - - //-------------------------------------------------- - // MARK: - MVMCoreViewProtocol - //-------------------------------------------------- - - open override func setupView() { - super.setupView() + + open override func setup() { + super.setup() let image = MVMCoreUIUtility.imageNamed("externalLink") exportImageView = UIImageView(image: image?.withRenderingMode(.alwaysTemplate)) @@ -46,10 +41,10 @@ open class ExternalLink: Link { addSubview(exportIcon) trailingAnchor.constraint(greaterThanOrEqualTo: exportIcon.trailingAnchor).isActive = true - if let titleLabel = titleLabel { - let dimension = titleLabel.font.pointSize - exportIcon.heightAnchor.constraint(equalToConstant: dimension).isActive = true - exportIcon.widthAnchor.constraint(equalToConstant: dimension).isActive = true + exportImageHeight = exportIcon.heightAnchor.constraint(equalToConstant: textStyle.pointSize).activate() + exportImageWidth = exportIcon.widthAnchor.constraint(equalToConstant: textStyle.pointSize).activate() + + if let titleLabel { exportIcon.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: 4).isActive = true exportIcon.bottomAnchor.constraint(equalTo: titleLabel.lastBaselineAnchor, constant: 3).isActive = true } From dff7cc6d3120905e78d5e0886bf276fc64afb919 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 14:46:28 -0500 Subject: [PATCH 31/51] updated accessibility Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 8c1e5f4a..86776016 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -26,6 +26,7 @@ import VDS isEnabled = viewModel.enabled size = viewModel.size text = viewModel.title + surface = viewModel.surface onClick = { [weak self] control in guard let self else { return } @@ -42,8 +43,14 @@ import VDS open override func updateAccessibility() { super.updateAccessibility() - if let viewModel, let accessibilityText = viewModel.accessibilityText { - accessibilityLabel = accessibilityText + if let viewModel { + if let accessibilityText = viewModel.accessibilityText { + self.accessibilityLabel = accessibilityText + } + + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } } } From e97582ee1e183993ee4efabc65fc2faad5b7c233 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 21 Sep 2023 14:59:00 -0500 Subject: [PATCH 32/51] added accessibility Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 18 ++++++++++++++++-- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 5 ++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 0e6d1075..1306074f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -14,7 +14,7 @@ import Combine open class Badge: VDS.Badge, VDSMoleculeViewProtocol { // public typealias ViewModel = type //-------------------------------------------------- - // MARK: - Properties + // MARK: - Public Properties //-------------------------------------------------- public var viewModel: BadgeModel! @@ -23,7 +23,7 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { public var additionalData: [AnyHashable : Any]? //-------------------------------------------------- - // MARK: - Public + // MARK: - Public Methods //-------------------------------------------------- public func viewModelDidUpdate() { @@ -35,6 +35,20 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { } public func updateView(_ size: CGFloat) {} + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func updateAccessibility() { + super.updateAccessibility() + + if let viewModel { + if let accessibilityText = viewModel.accessibilityText { + self.accessibilityLabel = accessibilityText + } + } + } + } //to deal with how it's parent constrains this control diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index cbb9a1b9..37344dad 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -17,13 +17,14 @@ open class BadgeModel: MoleculeModelProtocol { public var id: String = UUID().uuidString public var backgroundColor: Color? public var text: String = "" + public var accessibilityText: String? public var maxWidth: CGFloat? public var numberOfLines: Int = 1 public var fillColor = Badge.FillColor.red public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case id, text, fillColor, surface, numberOfLines, maxWidth + case id, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth } required public convenience init(from decoder: Decoder) throws { @@ -31,6 +32,7 @@ open class BadgeModel: MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString text = try container.decode(String.self, forKey: .text) + accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1 @@ -41,6 +43,7 @@ open class BadgeModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(text, forKey: .text) + try container.encode(accessibilityText, forKey: .accessibilityText) try container.encode(fillColor, forKey: .fillColor) try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) From 14391978704da1a57a6ddc15a98b24c054cac5ce Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 27 Sep 2023 09:40:54 -0500 Subject: [PATCH 33/51] marked up Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 37344dad..b739baf7 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -16,6 +16,10 @@ open class BadgeModel: MoleculeModelProtocol { public static var identifier: String = "badge" public var id: String = UUID().uuidString public var backgroundColor: Color? + + //-------------------------------------------------- + // MARK: - VDS Properties + //-------------------------------------------------- public var text: String = "" public var accessibilityText: String? public var maxWidth: CGFloat? From 2d83b8a6ef3d71afb408d0c67eed3116ca99eb06 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 10:22:38 -0400 Subject: [PATCH 34/51] Guard in link code. --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 86776016..5ca77679 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -10,7 +10,7 @@ import UIKit import VDSColorTokens import VDS -@objcMembers open class Link: VDS.TextLink, VDSMoleculeViewProtocol { +open class Link: VDS.TextLink, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Public Properties @@ -43,14 +43,13 @@ import VDS open override func updateAccessibility() { super.updateAccessibility() - if let viewModel { - if let accessibilityText = viewModel.accessibilityText { - self.accessibilityLabel = accessibilityText - } - - if let accessibilityIdentifier = viewModel.accessibilityIdentifier { - self.accessibilityIdentifier = accessibilityIdentifier - } + guard let viewModel = viewModel else { return } + if let accessibilityText = viewModel.accessibilityText { + self.accessibilityLabel = accessibilityText + } + + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier } } From 4d4f7c334d6ebc357ce6222a5578c6107d1387da Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 19:41:06 -0400 Subject: [PATCH 35/51] Code review: Fix data list items and navigation bar. --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 24 +++++++++++---- .../List/ListProgressBarThin.swift | 9 ++++-- .../List/ListProgressBarThinModel.swift | 10 +++---- .../ListRightVariableTotalData.swift | 18 ++++++++---- .../ListRightVariableTotalDataModel.swift | 20 +++++++++---- .../UINavigationController+Extension.swift | 29 +++++++++---------- .../SubNav/SubNavManagerController.swift | 13 +++++---- 7 files changed, 77 insertions(+), 46 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index ecb39df0..a170c4b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -10,7 +10,7 @@ import UIKit import VDSColorTokens import VDS -@objcMembers public class LineModel: MoleculeModelProtocol, Invertable { +public class LineModel: MoleculeModelProtocol, Invertable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -29,9 +29,23 @@ import VDS case between } + /** + The style of the line: + - secondary (VDS Secondary) + - primary (VDS Primary) + - standard (VDS Secondary) - deprecated + - thin (VDS Primar) - deprecated + - medium (VDS Primar) + - heavy (VDS Primar) + - none (hidden) + */ public enum Style: String, Codable { case secondary case primary + case standard + case thin + case medium + case heavy case none } @@ -43,7 +57,7 @@ import VDS public var id: String = UUID().uuidString public var backgroundColor: Color? - public var type: Style = .primary + public var type: Style = .secondary public var frequency: Frequency? = .allExceptTop public var inverted: Bool = false @@ -58,7 +72,7 @@ import VDS self.type = type } - public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { + public init(verticalLineOf type: Style) { self.type = type } @@ -100,7 +114,7 @@ import VDS /// adding code to look for the old useVerticalLine or the new orientation if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) { orientation = useVerticalLine ? .vertical : .horizontal - }else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { + } else if let orientation = try typeContainer.decodeIfPresent(VDS.Line.Orientation.self, forKey: .orientation) { self.orientation = orientation } } @@ -112,6 +126,6 @@ import VDS try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(orientation == .vertical, forKey: .useVerticalLine) + try container.encode(orientation == .vertical, forKey: .useVerticalLine) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index d9875068..e29ef00c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -7,7 +7,7 @@ // -@objcMembers open class ListProgressBarThin: TableViewCell { +open class ListProgressBarThin: TableViewCell { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- @@ -15,7 +15,11 @@ public let progressBar = ProgressBar() public let leftHeadline = Label(fontStyle: .BoldBodySmall) public let leftBody = Label(fontStyle: .BoldBodySmall) - public let rightBar = Line() + public let rightBar: DataLine = { + var line = DataLine() + line.heightConstraint.constant = 2 + return line + }() public let rightLabel = Label(fontStyle: .BoldBodySmall) private let barStackItem: StackItem private let rightLabelStackItem: StackItem @@ -102,7 +106,6 @@ leftHeadline.styleB1(true) leftBody.styleB2(true) rightLabel.styleB2(true) - rightBar.setStyle(.primary) } //------------------------------------------------------ diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index d6787f52..0cc5f172 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -16,14 +16,14 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { public var progressBar: ProgressBarModel public var leftHeadline: LabelModel public var leftBody: LabelModel? - public var rightBar: LineModel + public var rightBar: DataLineModel public var rightLabel: LabelModel //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: LineModel, rightLabel: LabelModel) { + public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: DataLineModel, rightLabel: LabelModel) { self.progressBar = progressBar self.leftHeadline = leftHeadline self.leftBody = leftBody @@ -38,9 +38,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() - - rightBar.type = .primary - + if rightBar.backgroundColor == nil { rightBar.backgroundColor = Color(uiColor: .gray) } @@ -74,7 +72,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) - rightBar = try typeContainer.decode(LineModel.self, forKey: .rightBar) + rightBar = try typeContainer.decode(DataLineModel.self, forKey: .rightBar) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index 9845ea16..6dc1ffe2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -6,15 +6,26 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +open class DataLine: View { + + lazy var heightConstraint = heightAnchor.constraint(equalToConstant: 4) + lazy var widthConstraint = widthAnchor.constraint(equalToConstant: 20) + + open override func setupView() { + super.setupView() + heightConstraint.isActive = true + widthConstraint.isActive = true + } +} -@objcMembers open class ListRightVariableTotalData: TableViewCell { +open class ListRightVariableTotalData: TableViewCell { //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- public let leftLabel = Label(fontStyle: .BoldBodySmall) public let rightLabel = Label(fontStyle: .RegularBodySmall) - public let bar = Line() + public let bar = DataLine() //----------------------------------------------------- // MARK: - Properties @@ -44,8 +55,6 @@ override open func setupView() { super.setupView() - bar.setStyle(.primary) - bar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) addMolecule(stack) stack.restack() @@ -74,7 +83,6 @@ super.reset() leftLabel.setFontStyle(.BoldBodySmall) rightLabel.setFontStyle(.RegularBodySmall) - bar.setStyle(.primary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift index 53ede6e5..28a3a25c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift @@ -6,8 +6,18 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +public struct DataLineModel: Codable, MoleculeModelProtocol { + public var id: String = UUID().uuidString + public static var identifier: String = "line" + public var backgroundColor: Color? + + private enum CodingKeys: String, CodingKey { + case backgroundColor + } +} public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,7 +25,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc public static var identifier: String = "listRVLine" public var leftLabel: LabelModel public var rightLabel: LabelModel - public var bar: LineModel + public var bar: DataLineModel //-------------------------------------------------- // MARK: - Method @@ -24,8 +34,6 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 - bar.type = .primary - if bar.backgroundColor == nil { bar.backgroundColor = Color(uiColor: .mvmBlue) } @@ -35,7 +43,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc // MARK: - Initializer //-------------------------------------------------- - public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: LineModel){ + public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: DataLineModel) { self.leftLabel = leftLabel self.rightLabel = rightlabel self.bar = bar @@ -46,7 +54,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc // MARK: - Keys //-------------------------------------------------- - private enum CodingKeys: String, CodingKey{ + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel case rightLabel @@ -61,7 +69,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc let typeContainer = try decoder.container(keyedBy: CodingKeys.self) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) - bar = try typeContainer.decode(LineModel.self, forKey: .bar) + bar = try typeContainer.decode(DataLineModel.self, forKey: .bar) try super.init(from: decoder) } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ac9684ac..fb1bde79 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -82,13 +82,6 @@ public extension UINavigationController { } } - /// Returns a ShadowImage based on the line property of NavigationItemModelProtocol - func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let model = navigationItemModel.line else { return nil } - let line = Line(model: model, nil, nil) - return line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)) - } - /// Convenience function for setting the navigation bar ui @MainActor func setNavigationBarUI(with model: NavigationItemModelProtocol) { @@ -105,14 +98,7 @@ public extension UINavigationController { appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) appearance.titlePositionAdjustment = model.titleOffset ?? .zero - if let type = model.line?.type, - type != .none, - let color = model.line?.backgroundColor { - appearance.shadowColor = color.uiColor - } else { - appearance.shadowColor = .clear - } - appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate) + appearance.setShadow(for: model.line) navigationBar.standardAppearance = appearance navigationBar.scrollEdgeAppearance = appearance @@ -126,3 +112,16 @@ public extension UINavigationController { return viewController } } + +public extension UINavigationBarAppearance { + func setShadow(for model: LineModel?) { + let model = model ?? LineModel(type: .secondary) + let line = Line(model: model, nil, nil) + if model.type != .none { + shadowColor = line.lineColor + } else { + shadowColor = .clear + } + shadowImage = line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)).withRenderingMode(.alwaysTemplate) + } +} diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 458c0169..7461c93d 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -125,13 +125,14 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Hides/Shows the navigation bar for the page. open func hideNavigationBarLine(_ isHidden: Bool) { guard self == navigationController?.topViewController else { return } - var color = UIColor.clear - if !isHidden, - let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { - color = backgroundColor + var model: LineModel? + if isHidden { + model = LineModel(type: .none) + } else if let lineModel = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line { + model = lineModel } - navigationController?.navigationBar.standardAppearance.shadowColor = color - navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color + navigationController?.navigationBar.standardAppearance.setShadow(for: model) + navigationController?.navigationBar.scrollEdgeAppearance?.setShadow(for: model) } open override func updateViews() { From 1da8a6db77b106baf683f625ab6e4155e7ca065f Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:12:36 -0400 Subject: [PATCH 36/51] Default to secondary --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 6 +++--- .../UINavigationController+Extension.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index c3ce3d7f..2d20d209 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -28,17 +28,17 @@ import VDS public required init() { super.init() - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } public override init(frame: CGRect) { super.init(frame: frame) - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) - viewModel = LineModel(type: .primary) + viewModel = LineModel(type: .secondary) } //-------------------------------------------------- diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index fb1bde79..57aeb02d 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -117,7 +117,7 @@ public extension UINavigationBarAppearance { func setShadow(for model: LineModel?) { let model = model ?? LineModel(type: .secondary) let line = Line(model: model, nil, nil) - if model.type != .none { + if line.shouldBeVisible() { shadowColor = line.lineColor } else { shadowColor = .clear From e5e17a286df55c0bf4a9ef43c9ca0e3ff2ae61e5 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:31:25 -0400 Subject: [PATCH 37/51] fix to vertical lines --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index a170c4b4..8a473016 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -74,6 +74,7 @@ public class LineModel: MoleculeModelProtocol, Invertable { public init(verticalLineOf type: Style) { self.type = type + orientation = .vertical } //-------------------------------------------------- From c3503edecbaf54888b915a29002f21a17ff92baa Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Sep 2023 20:39:50 -0400 Subject: [PATCH 38/51] Changes to ensure line does not stretch --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 2d20d209..ba0af74f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -17,6 +17,22 @@ import VDS open var viewModel: LineModel! open var delegateObject: MVMCoreUIDelegateObject? open var additionalData: [AnyHashable : Any]? + + open override var orientation: Line.Orientation { + didSet { + if orientation == .horizontal { + setContentHuggingPriority(.defaultLow, for: .horizontal) + setContentHuggingPriority(.required, for: .vertical) + setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + setContentCompressionResistancePriority(.required, for: .vertical) + } else { + setContentHuggingPriority(.required, for: .horizontal) + setContentHuggingPriority(.defaultLow, for: .vertical) + setContentCompressionResistancePriority(.required, for: .horizontal) + setContentCompressionResistancePriority(.defaultLow, for: .vertical) + } + } + } //-------------------------------------------------- // MARK: - Initializer From 0afa13392f4faaf80d0678f8340ff5392a6ec47b Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 5 Oct 2023 13:53:19 -0400 Subject: [PATCH 39/51] take into account contentInset when calculating itemWidth --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index ea7d89b8..6b360120 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -384,7 +384,7 @@ open class Carousel: View { extension Carousel: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth = collectionView.bounds.width * itemWidthPercent + let itemWidth = (collectionView.bounds.width - collectionView.contentInset.left - collectionView.contentInset.right) * itemWidthPercent return CGSize(width: itemWidth, height: collectionView.bounds.height) } From 281f1e8f52572d98c59db3a45b07ceb0861e329e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 12 Oct 2023 12:52:23 -0400 Subject: [PATCH 40/51] Fix extra space on the left of title issue for ExternalLink --- MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift index 9e5cd108..3e8fa804 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/ExternalLink.swift @@ -29,7 +29,8 @@ open class ExternalLink: Link { open override func setup() { super.setup() - + contentHorizontalAlignment = .left + let image = MVMCoreUIUtility.imageNamed("externalLink") exportImageView = UIImageView(image: image?.withRenderingMode(.alwaysTemplate)) From c8aac2e5d7056279496ad40bf2cdf5e8aa5f742b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 13 Oct 2023 14:21:22 -0400 Subject: [PATCH 41/51] Updated to get the upcoming view controller navigationBar model --- .../UINavigationController+Extension.swift | 2 +- MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 3372c1ab..2909ce4a 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -119,7 +119,7 @@ public extension UINavigationController { setNavigationBarHidden(model.hidden, animated: true) } - @MainActor + @objc @MainActor func getViewController() -> UIViewController? { guard let topViewController = getViewControllers().last, let viewController = MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) else { return nil } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index e04de6bb..05cd9ae2 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -57,9 +57,10 @@ public extension MVMCoreUIUtility { return findViews(by: type, views: queue) + matching } + @MainActor static func visibleNavigationBarStlye() -> NavigationItemStyle? { - if let vc = MVMCoreUIUtility.getCurrentVisibleController(), - let navController = NavigationController.navigationController(), + if let navController = NavigationController.navigationController(), + let vc = navController.getViewController(), let navigationBar = navController.getNavigationModel(from: vc) as? NavigationItemModel { return navigationBar.style } From 82ba81960cf1d61f2d0db91f4cdf08cec493e624 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 20 Oct 2023 00:12:05 +0530 Subject: [PATCH 42/51] ListStoreLocator component enhancement Updated heart with badge as per new design --- .../List/Miscellaneous/ListStoreLocator.swift | 126 ++++-------------- .../Miscellaneous/ListStoreLocatorModel.swift | 12 +- 2 files changed, 33 insertions(+), 105 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index 1e271e87..5ff57919 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -11,149 +11,77 @@ // MARK: - Outlets //-------------------------------------------------- - public let heart = Heart() - public let leftHeadline = Label(fontStyle: .BoldBodySmall) - public let leftBody = Label(fontStyle: .RegularBodySmall) + public let badge = Badge() + public let leftHeadline = Label(fontStyle: .BoldTitleSmall) + public let leftBody = Label(fontStyle: .RegularMicro) public let leftSubBody = Label(fontStyle: .RegularBodySmall) public let rightLabel = Label(fontStyle: .RegularBodySmall) - private lazy var rightLabelStackItem: StackItem = { - StackItem(andContain: rightLabel) - }() + public var model: ListStoreLocatorModel? public lazy var horizontalStack: Stack = { return Stack(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .fill), - StackItemModel(horizontalAlignment: .trailing)], - axis: .horizontal, spacing: Padding.Two), stackItems: [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem]) + StackItemModel(horizontalAlignment: .trailing, verticalAlignment: .center)], + axis: .horizontal, spacing: Padding.Two), stackItems: [StackItem(andContain: stack), StackItem(andContain: rightLabel)]) }() + public lazy var stack: Stack = { - return Stack.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0) - }() - public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18) + return Stack(with: .init(molecules: [StackItemModel(horizontalAlignment: .leading), + StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill), StackItemModel(horizontalAlignment: .fill)], + axis: .vertical, spacing: Padding.One), stackItems: [StackItem(andContain: badge), StackItem(andContain: leftHeadline), StackItem(andContain: leftBody), StackItem(andContain: leftSubBody)]) + + }() //------------------------------------------------------- // MARK: - Lifecycle //------------------------------------------------------- open override func setupView() { super.setupView() - + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - addMolecule(stack) + addMolecule(horizontalStack) stack.restack() horizontalStack.restack() + leftSubBody.textColor = UIColor.mfTextLightGray() } - public override func updateView(_ size: CGFloat) { - super.updateView(size) - if let dimension = sizeObject?.getValueBased(onSize: size) { - heart.widthConstraint?.constant = dimension - } - } - //------------------------------------------------------ // 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? ListStoreLocatorModel else { return } - horizontalStack.updateContainedMolecules(with: [model.leftHeadline, model.heart, model.rightLabel], delegateObject, additionalData) - leftBody.set(with: model.leftBody, delegateObject, additionalData) - leftSubBody.set(with: model.leftSubBody, delegateObject, additionalData) + stack.updateContainedMolecules(with: [model.badge, model.leftHeadline, model.leftBody, model.leftSubBody], delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + self.model = model updateAccessibilityLabel() } - open override func alignAccessoryToHero() -> CGPoint? { - let heroCenter = super.alignAccessoryToHero() - - if let heroCenter = heroCenter { - let convertedPoint = horizontalStack.convert(heroCenter, from: self) - rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY - } - return heroCenter - } - - public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { - if listItemModel?.action != nil { - super.didSelectCell(at: index, delegateObject: delegateObject, additionalData: additionalData) - } else { - heart.tapAction() - updateAccessibilityLabel() - } - } - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 120 } open override func reset() { super.reset() - leftHeadline.setFontStyle(.BoldBodySmall) - leftBody.setFontStyle(.RegularBodySmall) + leftHeadline.setFontStyle(.BoldTitleSmall) + leftBody.setFontStyle(.RegularMicro) leftSubBody.setFontStyle(.RegularBodySmall) rightLabel.setFontStyle(.RegularBodySmall) + leftSubBody.textColor = UIColor.mfTextLightGray() } - //-------------------------------------------------- - // MARK: - Accessibility - //-------------------------------------------------- - - func getAccessibilityMessage() -> String? { - var message = "" - heart.updateAccessibilityLabel() - - if let leftHeadlineText = leftHeadline.text, !leftHeadlineText.isEmpty { - message += leftHeadlineText + ", " - } - - if let leftBodyText = leftBody.text, !leftBodyText.isEmpty { - message += leftBodyText + ", " - } - - if let leftSubBodyText = leftSubBody.text, !leftSubBodyText.isEmpty { - message += leftSubBodyText + ", " - } - - if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty { - message += rightLabelText - } - return message.count > 0 ? message : nil - } - - func updateAccessibilityLabel() { - let hasHeart = !(horizontalStack.stackModel?.molecules[1].gone ?? true) - if let accessoryView = accessoryView, - hasHeart { - // Both accessory and heart actions. - isAccessibilityElement = false - accessoryView.accessibilityLabel = getAccessibilityMessage() - accessibilityElements = [accessoryView, heart] - } else { - // Make whole cell focusable if no action. - isAccessibilityElement = true - var message = getAccessibilityMessage() - if hasHeart { - accessibilityHint = heart.accessibilityHint - if let heartLabel = heart.accessibilityLabel { - message = (message ?? "") + ", " + heartLabel - } - } else { - accessibilityHint = nil - } - accessibilityLabel = message - } - } - - // Ensures voice over does not read "selected" after user triggers action on cell. override public var accessibilityTraits: UIAccessibilityTraits { get { if (accessoryView != nil) { return .button - } else if (!(horizontalStack.stackModel?.molecules[1].gone ?? true)) { - return heart.accessibilityTraits } else { return .none } } set { } } + + func updateAccessibilityLabel() { + isAccessibilityElement = true + let message = [model?.badge?.text, model?.leftHeadline.text, model?.leftBody.text, model?.leftSubBody.text, model?.rightLabel.text].compactMap { $0 }.joined(separator: ", ") + accessibilityLabel = message + } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 44c4ef90..912d8877 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -12,7 +12,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- public static var identifier = "listStoreLocator" - public var heart: HeartModel? + public var badge: BadgeModel? public var leftHeadline: LabelModel public var leftBody: LabelModel public var leftSubBody: LabelModel @@ -22,8 +22,8 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { // MARK: - Initializer //-------------------------------------------------- - public init(heart: HeartModel?, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) { - self.heart = heart + public init(badge: BadgeModel?, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) { + self.badge = badge self.leftHeadline = leftHeadline self.leftBody = leftBody self.leftSubBody = leftSubBody @@ -49,7 +49,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case moleculeName - case heart + case badge case leftHeadline case leftBody case leftSubBody @@ -62,7 +62,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - heart = try typeContainer.decodeIfPresent(HeartModel.self, forKey:.heart) + badge = try typeContainer.decodeIfPresent(BadgeModel.self, forKey:.badge) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody) leftSubBody = try typeContainer.decode(LabelModel.self, forKey: .leftSubBody) @@ -74,7 +74,7 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(heart, forKey: .heart) + try container.encodeIfPresent(badge, forKey: .badge) try container.encode(leftHeadline, forKey: .leftHeadline) try container.encode(leftBody, forKey: .leftBody) try container.encode(leftSubBody, forKey: .leftSubBody) From b1da7aaeed03b28035f7c95d843a823647185ccd Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 23 Oct 2023 16:41:08 -0400 Subject: [PATCH 43/51] Footer button filled for iphones --- .../Atomic/Molecules/HeadersAndFooters/FooterModel.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift index bab51c2d..dd23035c 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift @@ -24,5 +24,9 @@ if bottomPadding == nil { bottomPadding = PaddingDefaultVerticalSpacing } + guard let _ = molecule as? ButtonModel, + !MVMCoreGetterUtility.isOnIPad(), + horizontalAlignment == nil else { return } + horizontalAlignment = .fill } } From e373aa3b086c8ec4128691319fa50eb77b7339fc Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 23 Oct 2023 17:42:32 -0400 Subject: [PATCH 44/51] Full width foot pill button --- .../Molecules/HeadersAndFooters/FooterModel.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift index dd23035c..93e296f2 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/FooterModel.swift @@ -24,9 +24,14 @@ if bottomPadding == nil { bottomPadding = PaddingDefaultVerticalSpacing } - guard let _ = molecule as? ButtonModel, - !MVMCoreGetterUtility.isOnIPad(), - horizontalAlignment == nil else { return } - horizontalAlignment = .fill + guard !MVMCoreGetterUtility.isOnIPad(), + horizontalAlignment == nil else { return } + + if let _ = molecule as? ButtonModel { + horizontalAlignment = .fill + } else if let model = molecule as? TwoButtonViewModel, + model.primaryButton == nil || model.secondaryButton == nil { + horizontalAlignment = .fill + } } } From 0c4136a6b12ee0b79407f9797460c10e38e2537d Mon Sep 17 00:00:00 2001 From: "Bruce, Matt R" Date: Thu, 26 Oct 2023 15:08:24 +0000 Subject: [PATCH 45/51] removed comment --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 1306074f..5e8c2e25 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -12,7 +12,7 @@ import VDS import Combine open class Badge: VDS.Badge, VDSMoleculeViewProtocol { - // public typealias ViewModel = type + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- From 31a1df7239fe8f8424512fb4f295d6aa1b2ae32c Mon Sep 17 00:00:00 2001 From: "Bruce, Matt R" Date: Thu, 26 Oct 2023 16:27:59 +0000 Subject: [PATCH 46/51] reorder badge/tilelet --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d6404d24..0f1302b1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -295,8 +295,8 @@ AFA4935729EE3DCC001A9663 /* AlertDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; - B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBC29DF34680005D28B /* Badge.swift */; }; B4CC8FBF29DF34730005D28B /* BadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBE29DF34730005D28B /* BadgeModel.swift */; }; + B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBC29DF34680005D28B /* Badge.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -573,8 +573,8 @@ EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */; }; EA7E67742758310500ABF773 /* EnableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67732758310500ABF773 /* EnableFormFieldEffectModel.swift */; }; EA7E67762758365300ABF773 /* UIUpdatableModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67752758365300ABF773 /* UIUpdatableModelProtocol.swift */; }; - EA985C3E2970938F00F2FF2E /* Tilelet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3D2970938F00F2FF2E /* Tilelet.swift */; }; EA985C402970939A00F2FF2E /* TileletModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3F2970939A00F2FF2E /* TileletModel.swift */; }; + EA985C3E2970938F00F2FF2E /* Tilelet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3D2970938F00F2FF2E /* Tilelet.swift */; }; EA985C602970A3F000F2FF2E /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C5F2970A3F000F2FF2E /* VDS.framework */; }; EA985C642970A40E00F2FF2E /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C632970A40E00F2FF2E /* VDSTypographyTokens.xcframework */; }; EA985C852981AA9C00F2FF2E /* VDS-Enums+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C842981AA9C00F2FF2E /* VDS-Enums+Codable.swift */; }; From 5d08807d5d9d7b1561315fff5e80821578cf9a6d Mon Sep 17 00:00:00 2001 From: "Bruce, Matt R" Date: Thu, 26 Oct 2023 16:33:11 +0000 Subject: [PATCH 47/51] Update File order --- MVMCoreUI.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0f1302b1..4511d436 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -883,8 +883,8 @@ AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertDelegateProtocol.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; - B4CC8FBC29DF34680005D28B /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; B4CC8FBE29DF34730005D28B /* BadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeModel.swift; sourceTree = ""; }; + B4CC8FBC29DF34680005D28B /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -2219,10 +2219,10 @@ AA37CBD42519072F0027344C /* Stars.swift */, AA07EA902510A442009A2AE3 /* StarModel.swift */, AA07EA922510A451009A2AE3 /* Star.swift */, - B4CC8FBC29DF34680005D28B /* Badge.swift */, B4CC8FBE29DF34730005D28B /* BadgeModel.swift */, - EA985C3D2970938F00F2FF2E /* Tilelet.swift */, + B4CC8FBC29DF34680005D28B /* Badge.swift */, EA985C3F2970939A00F2FF2E /* TileletModel.swift */, + EA985C3D2970938F00F2FF2E /* Tilelet.swift */, ); path = Views; sourceTree = ""; From 1eb0103744c8458c23c8a4cbf251092e5a661ef8 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 26 Oct 2023 16:39:30 -0400 Subject: [PATCH 48/51] fix stack overflow error on RawRepresentable encoding --- MVMCoreUI/Utility/RawRepresentableCodable.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/MVMCoreUI/Utility/RawRepresentableCodable.swift b/MVMCoreUI/Utility/RawRepresentableCodable.swift index 09441add..128c21c2 100644 --- a/MVMCoreUI/Utility/RawRepresentableCodable.swift +++ b/MVMCoreUI/Utility/RawRepresentableCodable.swift @@ -32,9 +32,4 @@ extension RawRepresentableCodable { throw RawRepresentableCodableError.invalid(value: "\(rawValue)") } } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(self) - } } From 49d6d2bf76a7c6381f6cb5a6b840a8b52b8972f3 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 30 Oct 2023 12:45:12 -0400 Subject: [PATCH 49/51] bugfix for old color properties --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 195 ++++-------------- .../NotificationMoleculeModel.swift | 6 +- 2 files changed, 43 insertions(+), 158 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 94a7778b..38abd4cd 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -27,54 +27,12 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Use? { - didSet { - guard let style = style else { return } - setFacade(by: style) - } - } + public var style: Use = .primary public var size: VDS.Button.Size = .large public var groupName: String = "" public var inverted: Bool = false - - public lazy var enabledColors: FacadeElements = (fill: enabled_fillColor(), - text: enabled_textColor(), - border: enabled_borderColor()) - - public lazy var disabledColors: FacadeElements = (fill: disabled_fillColor(), - text: disabled_textColor(), - border: disabled_borderColor()) - - public var enabledFillColor: Color? - public var enabledTextColor: Color? - public var enabledBorderColor: Color? - - public var enabledFillColor_inverted: Color? - public var enabledTextColor_inverted: Color? - public var enabledBorderColor_inverted: Color? - - public var disabledFillColor: Color? - public var disabledTextColor: Color? - public var disabledBorderColor: Color? - - public var disabledFillColor_inverted: Color? - public var disabledTextColor_inverted: Color? - public var disabledBorderColor_inverted: Color? - - private var _backgroundColor: Color? - public var backgroundColor: Color? { - get { - if let backgroundColor = _backgroundColor { return backgroundColor } - if inverted { - return enabled ? enabledFillColor_inverted : disabledFillColor_inverted - } - return enabled ? enabledFillColor : disabledFillColor - } - set { - _backgroundColor = newValue - } - } - + public var backgroundColor: Color? + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -88,88 +46,18 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action - setFacade(by: .primary) } public init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary - setFacade(by: .secondary) } public init(primaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .primary - setFacade(by: .primary) - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - public func enabled_fillColor() -> UIColor? { - (inverted ? enabledFillColor_inverted : enabledFillColor)?.uiColor - } - - public func enabled_textColor() -> UIColor? { - (inverted ? enabledTextColor_inverted : enabledTextColor)?.uiColor - } - - public func enabled_borderColor() -> UIColor? { - (inverted ? enabledBorderColor_inverted : enabledBorderColor)?.uiColor - } - - public func disabled_fillColor() -> UIColor? { - (inverted ? disabledFillColor_inverted : disabledFillColor)?.uiColor - } - - public func disabled_textColor() -> UIColor? { - (inverted ? disabledTextColor_inverted : disabledTextColor)?.uiColor - } - - public func disabled_borderColor() -> UIColor? { - (inverted ? disabledBorderColor_inverted : disabledBorderColor)?.uiColor - } - - /// Defines the default appearance for the primary style. - func setPrimaryFacade() { - enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - - enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) - disabledFillColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) - disabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) - } - - /// Defines the default appearance for the Secondary style. - func setSecondaryFacade() { - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledFillColor = Color(uiColor: UIColor.clear) - enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - - enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: UIColor.clear) - enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) - disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) - } - - public func setFacade(by style: VDS.Use) { - switch style { - case .primary: - setPrimaryFacade() - case .secondary: - setSecondaryFacade() - @unknown default: - setPrimaryFacade() - } } //-------------------------------------------------- @@ -179,7 +67,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat private enum CodingKeys: String, CodingKey { case id case moleculeName - case backgroundColor case accessibilityIdentifier case accessibilityText case title @@ -189,12 +76,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat case style case size case groupName - case fillColor - case textColor - case borderColor - case disabledFillColor - case disabledTextColor - case disabledBorderColor case width } @@ -214,12 +95,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat ///Style captured from the JSON if let style = try typeContainer.decodeIfPresent(Use.self, forKey: .style) { self.style = style - setFacade(by: style) } else if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Use { ///Reading the style param from context which is set is molecules, ex: TwoButtonView self.style = style - setFacade(by: style) - } else { ///Default style - setFacade(by: .primary) } if let size = try typeContainer.decodeIfPresent(VDS.Button.Size.self, forKey: .size) { @@ -230,40 +107,57 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat self.enabled = enabled } - if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { - self.inverted = inverted - } - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } + width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) + + if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + self.inverted = inverted + } else { + try setInverted(deprecatedFrom: decoder) + } + } + + private enum DeprecatedCodingKeys: String, CodingKey { + case fillColor + case textColor + case borderColor + case backgroundColor + } + + private func setInverted(deprecatedFrom decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: DeprecatedCodingKeys.self) if let enabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .fillColor) { - self.enabledFillColor = enabledFillColor + if (self.style == .secondary) { + self.inverted = enabledFillColor.uiColor.isDark() + } else { + self.inverted = !enabledFillColor.uiColor.isDark() + } } if let enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) { - self.enabledTextColor = enabledTextColor + if (self.style == .secondary) { + self.inverted = !enabledTextColor.uiColor.isDark() + } else { + self.inverted = enabledTextColor.uiColor.isDark() + } } if let enabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) { - self.enabledBorderColor = enabledBorderColor + if (self.style == .secondary) { + self.inverted = !enabledBorderColor.uiColor.isDark() + } } - - if let disabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledFillColor) { - self.disabledFillColor = disabledFillColor + + if let backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) { + if (self.style == .secondary) { + self.inverted = backgroundColor.uiColor.isDark() + } else { + self.inverted = !backgroundColor.uiColor.isDark() + } } - - if let disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor) { - self.disabledTextColor = disabledTextColor - } - - if let disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor) { - self.disabledBorderColor = disabledBorderColor - } - - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } open func encode(to encoder: Encoder) throws { @@ -274,15 +168,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encode(enabled, forKey: .enabled) try container.encode(inverted, forKey: .inverted) try container.encodeModel(action, forKey: .action) - try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) - try container.encodeIfPresent(enabledFillColor, forKey: .fillColor) - try container.encodeIfPresent(enabledTextColor, forKey: .textColor) - try container.encodeIfPresent(enabledBorderColor, forKey: .borderColor) - try container.encodeIfPresent(disabledFillColor, forKey: .disabledFillColor) - try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor) - try container.encodeIfPresent(disabledBorderColor, forKey: .disabledBorderColor) try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(size, forKey: .size) try container.encodeIfPresent(groupName, forKey: .groupName) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift index 27ca95a8..9958b59a 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift @@ -93,11 +93,9 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { button?.style = .secondary switch style { case .error, .warning: - button?.enabledTextColor = Color(uiColor: .mvmBlack) - button?.enabledBorderColor = Color(uiColor: .mvmBlack) + button?.inverted = false default: - button?.enabledTextColor = Color(uiColor: .mvmWhite) - button?.enabledBorderColor = Color(uiColor: .mvmWhite) + button?.inverted = true } if closeButton?.color == nil { From 17a16bf73cf12293dc0a298eecb0216a7d7d8268 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 30 Oct 2023 12:47:53 -0400 Subject: [PATCH 50/51] change encode --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 38abd4cd..b712b04e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -170,8 +170,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encodeModel(action, forKey: .action) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) - try container.encodeIfPresent(style, forKey: .style) - try container.encodeIfPresent(size, forKey: .size) + try container.encode(style, forKey: .style) + try container.encode(size, forKey: .size) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encodeIfPresent(width, forKey: .width) } From 4b9c3860716e0856476108f38813d7c363f9683b Mon Sep 17 00:00:00 2001 From: "Rajendran, Nandhini" Date: Tue, 31 Oct 2023 15:30:39 +0000 Subject: [PATCH 51/51] story: ONEAPP-5868 page control update --- .../Atoms/Views/CarouselIndicator/BarsIndicatorView.swift | 4 +++- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 2eefd716..4cff7bdb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -213,7 +213,9 @@ open class BarsIndicatorView: CarouselIndicator { let accessibleIndex = MVMCoreUIUtility.getOrdinalString(forIndex: NSNumber(value: index + 1)) else { return } - view.accessibilityLabel = String(format: accessibleValueFormat, accessibleIndex, numberOfPages) + let accessibilityValue = String(format: accessibleValueFormat, accessibleIndex, numberOfPages) + view.accessibilityLabel = accessibilityValue + view.accessibilityIdentifier = accessibilityValue } public override func assessTouchOf(_ touchPoint_X: CGFloat) { diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 6b360120..cb618524 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -372,7 +372,9 @@ open class Carousel: View { self.carouselAccessibilityElement = carouselAccessibilityElement } - if let currentCell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)) { + if let currentCell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)), let pagingView = self.pagingView { + _accessibilityElements = [currentCell, carouselAccessibilityElement, pagingView] + } else if let currentCell = collectionView.cellForItem(at: IndexPath(row: currentIndex, section: 0)) { _accessibilityElements = [currentCell, carouselAccessibilityElement] } else { _accessibilityElements = [carouselAccessibilityElement]