Merge branch 'develop' into 'feature/atomic_vds_textLink'

# Conflicts:
#   MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift
This commit is contained in:
Bruce, Matt R 2023-10-25 20:40:04 +00:00
commit 5d347ffaaf
15 changed files with 192 additions and 187 deletions

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 52; objectVersion = 54;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@ -588,6 +588,7 @@
EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; };
EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; };
EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.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 */; }; FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -1176,6 +1177,7 @@
EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = "<group>"; }; EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = "<group>"; };
EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = "<group>"; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = "<group>"; };
EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = "<group>"; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = "<group>"; };
EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Interpreters.swift"; sourceTree = "<group>"; };
FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = "<group>"; }; FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -2418,6 +2420,7 @@
011B58EE23A2AA850085F53C /* ModelProtocols */, 011B58EE23A2AA850085F53C /* ModelProtocols */,
27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */,
EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */, EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */,
EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */,
); );
path = Protocols; path = Protocols;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2976,6 +2979,7 @@
D28BA741248025A300B75CB8 /* TabBarModel.swift in Sources */, D28BA741248025A300B75CB8 /* TabBarModel.swift in Sources */,
D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */, D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */,
D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */, D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */,
EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */,
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */,
0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */,
D2FA83D22513EA6900564112 /* NotificationXButton.swift in Sources */, D2FA83D22513EA6900564112 /* NotificationXButton.swift in Sources */,

View File

@ -7,116 +7,112 @@
// //
import UIKit import UIKit
import VDS
@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol {
@objcMembers open class Line: View {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
open var viewModel: LineModel!
open var delegateObject: MVMCoreUIDelegateObject?
open var additionalData: [AnyHashable : Any]?
var lineModel: LineModel? { open override var orientation: Line.Orientation {
get { return model as? LineModel } didSet {
} if orientation == .horizontal {
setContentHuggingPriority(.defaultLow, for: .horizontal)
//-------------------------------------------------- setContentHuggingPriority(.required, for: .vertical)
// MARK: - Constraints setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
//-------------------------------------------------- setContentCompressionResistancePriority(.required, for: .vertical)
} else {
public var heightConstraint: NSLayoutConstraint? setContentHuggingPriority(.required, for: .horizontal)
public var widthConstraint: NSLayoutConstraint? setContentHuggingPriority(.defaultLow, for: .vertical)
setContentCompressionResistancePriority(.required, for: .horizontal)
open func updateLineConstraints(constant: CGFloat) { setContentCompressionResistancePriority(.defaultLow, for: .vertical)
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
} }
} }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) { public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) {
self.init(frame: .zero) self.init(frame: .zero)
addLine(to: view, edge: edge, useMargin: useMargin) addLine(to: view, edge: edge, useMargin: useMargin)
} }
public init() { public required init() {
super.init(frame: .zero) super.init()
model = LineModel(type: .secondary) viewModel = LineModel(type: .secondary)
setStyle(.secondary)
} }
public override init(frame: CGRect) { public override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
model = LineModel(type: .secondary) viewModel = LineModel(type: .secondary)
setStyle(.secondary)
} }
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
model = LineModel(type: .secondary) viewModel = LineModel(type: .secondary)
setStyle(.secondary)
} }
public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.init(model: model, delegateObject, additionalData)
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Methods // MARK: - Methods
//-------------------------------------------------- //--------------------------------------------------
open func setStyle(_ style: LineModel.Style) {
lineModel?.type = style
backgroundColor = lineModel?.backgroundColor?.uiColor
updateLineConstraints(constant: lineModel?.thickness ?? 1)
}
open func shouldBeVisible() -> Bool { open func shouldBeVisible() -> Bool {
guard let type = lineModel?.type else { return false } guard let type = viewModel?.type else { return false }
return type != .none return type != .none
} }
//-------------------------------------------------- open func setStyle(_ style: LineModel.Style) {
// MARK: - MoleculeViewProtocol viewModel.type = style
//-------------------------------------------------- update(viewModel: viewModel)
}
open func addLine(to view: UIView, edge: UIRectEdge, useMargin: Bool) { open func addLine(to view: UIView, edge: UIRectEdge, useMargin: Bool) {
view.addSubview(self) 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() { open override func draw(_ rect: CGRect) {
super.setupView() guard viewModel.type != .none else { return }
heightConstraint = heightAnchor.constraint(equalToConstant: 1) super.draw(rect)
heightConstraint?.isActive = true
widthConstraint = widthAnchor.constraint(equalToConstant: 1)
widthConstraint?.isActive = false
} }
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { //--------------------------------------------------
super.set(with: model, delegateObject, additionalData) // MARK: - VDSMoleculeViewProtocol
//--------------------------------------------------
open func viewModelDidUpdate() {
surface = viewModel.surface
style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary
orientation = viewModel.orientation
}
if let lineModel = model as? LineModel { //--------------------------------------------------
setStyle(lineModel.type) // MARK: - MoleculeViewProtocol
} //--------------------------------------------------
public func updateView(_ size: CGFloat) {
setNeedsDisplay()
} }
open override func reset() { public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
setStyle(.secondary) return 1
}
public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return (model as? LineModel)?.thickness ?? 1
} }
} }
//--------------------------------------------------
// MARK: - MVMCoreUIViewConstrainingProtocol
//--------------------------------------------------
extension Line: MVMCoreUIViewConstrainingProtocol { extension Line: MVMCoreUIViewConstrainingProtocol {
open func needsToBeConstrained() -> Bool { open func needsToBeConstrained() -> Bool {

View File

@ -8,8 +8,9 @@
import UIKit import UIKit
import VDSColorTokens import VDSColorTokens
import VDS
@objcMembers public class LineModel: MoleculeModelProtocol { public class LineModel: MoleculeModelProtocol, Invertable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Enums // MARK: - Enums
//-------------------------------------------------- //--------------------------------------------------
@ -30,12 +31,12 @@ import VDSColorTokens
/** /**
The style of the line: The style of the line:
- secondary (1 height, silver) - secondary (VDS Secondary)
- primary (1 height, black) - primary (VDS Primary)
- standard (1 height, silver) - deprecated - standard (VDS Secondary) - deprecated
- thin (1 height, black) - deprecated - thin (VDS Primar) - deprecated
- medium (2 height, black) - medium (VDS Primar)
- heavy (4 height, black) - heavy (VDS Primar)
- none (hidden) - none (hidden)
*/ */
public enum Style: String, Codable { public enum Style: String, Codable {
@ -54,53 +55,14 @@ import VDSColorTokens
public static var identifier: String = "line" public static var identifier: String = "line"
public var id: String = UUID().uuidString public var id: String = UUID().uuidString
public var backgroundColor: Color?
public var type: Style = .secondary public var type: Style = .secondary
public var frequency: Frequency? = .allExceptTop 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 public var inverted: Bool = false
// Use this to show vertical line public var orientation: VDS.Line.Orientation = .horizontal
// Default is false
public var useVerticalLine: Bool?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
@ -108,13 +70,11 @@ import VDSColorTokens
public init(type: Style) { public init(type: Style) {
self.type = type self.type = type
self.useVerticalLine = false
} }
public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { public init(verticalLineOf type: Style) {
self.type = type self.type = type
self.backgroundColor = backgroundColor orientation = .vertical
self.useVerticalLine = true
} }
//-------------------------------------------------- //--------------------------------------------------
@ -125,13 +85,10 @@ import VDSColorTokens
case id case id
case moleculeName case moleculeName
case type case type
case backgroundColor
case backgroundColor_inverted
case color
case frequency case frequency
case inverted case inverted
case useVerticalLine case useVerticalLine
case thickness case orientation
} }
//-------------------------------------------------- //--------------------------------------------------
@ -155,9 +112,12 @@ import VDSColorTokens
self.inverted = inverted self.inverted = inverted
} }
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) /// adding code to look for the old useVerticalLine or the new orientation
useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) {
_thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) 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 { public func encode(to encoder: Encoder) throws {
@ -167,8 +127,6 @@ import VDSColorTokens
try container.encode(type, forKey: .type) try container.encode(type, forKey: .type)
try container.encode(inverted, forKey: .inverted) try container.encode(inverted, forKey: .inverted)
try container.encodeIfPresent(frequency, forKey: .frequency) try container.encodeIfPresent(frequency, forKey: .frequency)
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encode(orientation == .vertical, forKey: .useVerticalLine)
try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine)
try container.encodeIfPresent(_thickness, forKey: .thickness)
} }
} }

View File

@ -17,6 +17,8 @@ extension TileContainer.BackgroundColor: Codable {}
extension TileContainer.Padding: Codable {} extension TileContainer.Padding: Codable {}
extension TileContainer.AspectRatio: Codable {} extension TileContainer.AspectRatio: Codable {}
extension TextLink.Size: Codable {} extension TextLink.Size: Codable {}
extension VDS.Line.Style: Codable {}
extension VDS.Line.Orientation: Codable {}
extension Use: Codable {} extension Use: Codable {}
extension VDS.Button.Size: RawRepresentableCodable { extension VDS.Button.Size: RawRepresentableCodable {
public static var mapping: [String : VDS.Button.Size] { ["standard": .large, "tiny": .small] } public static var mapping: [String : VDS.Button.Size] { ["standard": .large, "tiny": .small] }

View File

@ -42,6 +42,13 @@ import Foundation
return Stack<StackModel>.createStack(with: [headline, horizontalStack], spacing: 8) return Stack<StackModel>.createStack(with: [headline, horizontalStack], spacing: 8)
}() }()
//-------------------------------------------------------
// MARK: - Constraints
//-------------------------------------------------------
public var verticalLine1HeightConstraint: NSLayoutConstraint?
public var verticalLine2HeightConstraint: NSLayoutConstraint?
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - Lifecycle // MARK: - Lifecycle
//------------------------------------------------------- //-------------------------------------------------------
@ -51,11 +58,10 @@ import Foundation
body.lineBreakMode = .byTruncatingTail body.lineBreakMode = .byTruncatingTail
body2.lineBreakMode = .byTruncatingTail body2.lineBreakMode = .byTruncatingTail
body3.lineBreakMode = .byTruncatingTail body3.lineBreakMode = .byTruncatingTail
verticalLine1.widthConstraint?.isActive = true // setup lines
verticalLine1.backgroundColor = .mvmBlack verticalLine1.orientation = .vertical
verticalLine2.widthConstraint?.isActive = true verticalLine2.orientation = .vertical
verticalLine2.backgroundColor = .mvmBlack
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
@ -80,13 +86,13 @@ import Foundation
} }
open func setLineHeight() { open func setLineHeight() {
verticalLine1.heightConstraint?.isActive = false verticalLine1HeightConstraint?.isActive = false
verticalLine1.heightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1) verticalLine1HeightConstraint = verticalLine1.heightAnchor.constraint(equalTo: body2.heightAnchor, multiplier: 1)
verticalLine1.heightConstraint?.isActive = true verticalLine1HeightConstraint?.isActive = true
verticalLine2.heightConstraint?.isActive = false verticalLine2HeightConstraint?.isActive = false
verticalLine2.heightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1) verticalLine2HeightConstraint = verticalLine2.heightAnchor.constraint(equalTo: body3.heightAnchor, multiplier: 1)
verticalLine2.heightConstraint?.isActive = true verticalLine2HeightConstraint?.isActive = true
} }
//---------------------------------------------------- //----------------------------------------------------

View File

@ -7,7 +7,7 @@
// //
@objcMembers open class ListProgressBarThin: TableViewCell { open class ListProgressBarThin: TableViewCell {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
@ -15,7 +15,11 @@
public let progressBar = ProgressBar() public let progressBar = ProgressBar()
public let leftHeadline = Label(fontStyle: .BoldBodySmall) public let leftHeadline = Label(fontStyle: .BoldBodySmall)
public let leftBody = 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) public let rightLabel = Label(fontStyle: .BoldBodySmall)
private let barStackItem: StackItem private let barStackItem: StackItem
private let rightLabelStackItem: StackItem private let rightLabelStackItem: StackItem
@ -102,7 +106,6 @@
leftHeadline.styleB1(true) leftHeadline.styleB1(true)
leftBody.styleB2(true) leftBody.styleB2(true)
rightLabel.styleB2(true) rightLabel.styleB2(true)
rightBar.setStyle(.medium)
} }
//------------------------------------------------------ //------------------------------------------------------

View File

@ -16,14 +16,14 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
public var progressBar: ProgressBarModel public var progressBar: ProgressBarModel
public var leftHeadline: LabelModel public var leftHeadline: LabelModel
public var leftBody: LabelModel? public var leftBody: LabelModel?
public var rightBar: LineModel public var rightBar: DataLineModel
public var rightLabel: LabelModel public var rightLabel: LabelModel
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // 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.progressBar = progressBar
self.leftHeadline = leftHeadline self.leftHeadline = leftHeadline
self.leftBody = leftBody self.leftBody = leftBody
@ -38,9 +38,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
rightBar.type = .medium
if rightBar.backgroundColor == nil { if rightBar.backgroundColor == nil {
rightBar.backgroundColor = Color(uiColor: .gray) rightBar.backgroundColor = Color(uiColor: .gray)
} }
@ -74,7 +72,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar) progressBar = try typeContainer.decode(ProgressBarModel.self, forKey:.progressBar)
leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline)
leftBody = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .leftBody) 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) rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
try super.init(from: decoder) try super.init(from: decoder)
} }

View File

@ -6,15 +6,26 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // 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 // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
public let leftLabel = Label(fontStyle: .BoldBodySmall) public let leftLabel = Label(fontStyle: .BoldBodySmall)
public let rightLabel = Label(fontStyle: .RegularBodySmall) public let rightLabel = Label(fontStyle: .RegularBodySmall)
public let bar = Line() public let bar = DataLine()
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -44,8 +55,6 @@
override open func setupView() { override open func setupView() {
super.setupView() super.setupView()
bar.setStyle(.heavy)
bar.widthAnchor.constraint(equalToConstant: 20).isActive = true
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
@ -74,7 +83,6 @@
super.reset() super.reset()
leftLabel.setFontStyle(.BoldBodySmall) leftLabel.setFontStyle(.BoldBodySmall)
rightLabel.setFontStyle(.RegularBodySmall) rightLabel.setFontStyle(.RegularBodySmall)
bar.setStyle(.heavy)
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -6,8 +6,18 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // 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 { public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -15,7 +25,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc
public static var identifier: String = "listRVLine" public static var identifier: String = "listRVLine"
public var leftLabel: LabelModel public var leftLabel: LabelModel
public var rightLabel: LabelModel public var rightLabel: LabelModel
public var bar: LineModel public var bar: DataLineModel
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Method // MARK: - Method
@ -24,8 +34,6 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
rightLabel.hero = 0 rightLabel.hero = 0
bar.type = .heavy
if bar.backgroundColor == nil { if bar.backgroundColor == nil {
bar.backgroundColor = Color(uiColor: .mvmBlue) bar.backgroundColor = Color(uiColor: .mvmBlue)
} }
@ -35,7 +43,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: LineModel){ public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: DataLineModel) {
self.leftLabel = leftLabel self.leftLabel = leftLabel
self.rightLabel = rightlabel self.rightLabel = rightlabel
self.bar = bar self.bar = bar
@ -46,7 +54,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc
// MARK: - Keys // MARK: - Keys
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey{ private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case leftLabel case leftLabel
case rightLabel case rightLabel
@ -61,7 +69,7 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) 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) try super.init(from: decoder)
} }

View File

@ -50,7 +50,7 @@ import VDSColorTokens
setItems(tabs, animated: false) setItems(tabs, animated: false)
selectedItem = tabs[model.selectedTab] selectedItem = tabs[model.selectedTab]
guard let lineModel = line.lineModel else { return } guard let lineModel = line.viewModel else { return }
lineModel.inverted = model.style == .dark lineModel.inverted = model.style == .dark
line.set(with: lineModel, delegateObject, additionalData) line.set(with: lineModel, delegateObject, additionalData)
} }

View File

@ -174,7 +174,7 @@ import VDSColorTokens
self.additionalData = additionalData self.additionalData = additionalData
selectedIndex = tabsModel?.selectedIndex ?? 0 selectedIndex = tabsModel?.selectedIndex ?? 0
selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor
let lineModel = bottomLine.lineModel ?? LineModel(type: .secondary) let lineModel = bottomLine.viewModel ?? LineModel(type: .secondary)
lineModel.inverted = tabsModel?.style == .dark lineModel.inverted = tabsModel?.style == .dark
bottomLine.set(with: lineModel, delegateObject, additionalData) bottomLine.set(with: lineModel, delegateObject, additionalData)
reloadData() reloadData()

View File

@ -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 }
}

View File

@ -28,5 +28,9 @@ extension VDSMoleculeViewProtocol {
viewModel = castedModel viewModel = castedModel
viewModelDidUpdate() viewModelDidUpdate()
} }
public func update(viewModel: ViewModel){
set(with: viewModel, delegateObject, additionalData)
}
} }

View File

@ -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 thickness = navigationItemModel.line?.thickness,
let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil }
return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness))
}
/// Convenience function for setting the navigation bar ui /// Convenience function for setting the navigation bar ui
@MainActor @MainActor
func setNavigationBarUI(with model: NavigationItemModelProtocol) { func setNavigationBarUI(with model: NavigationItemModelProtocol) {
@ -105,14 +98,7 @@ public extension UINavigationController {
appearance.backgroundColor = backgroundColor appearance.backgroundColor = backgroundColor
appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor)
appearance.titlePositionAdjustment = model.titleOffset ?? .zero appearance.titlePositionAdjustment = model.titleOffset ?? .zero
if let type = model.line?.type, appearance.setShadow(for: model.line)
type != .none,
let color = model.line?.backgroundColor {
appearance.shadowColor = color.uiColor
} else {
appearance.shadowColor = .clear
}
appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate)
navigationBar.standardAppearance = appearance navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance navigationBar.scrollEdgeAppearance = appearance
@ -126,3 +112,16 @@ public extension UINavigationController {
return viewController return viewController
} }
} }
public extension UINavigationBarAppearance {
func setShadow(for model: LineModel?) {
let model = model ?? LineModel(type: .secondary)
let line = Line(model: model, nil, nil)
if line.shouldBeVisible() {
shadowColor = line.lineColor
} else {
shadowColor = .clear
}
shadowImage = line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)).withRenderingMode(.alwaysTemplate)
}
}

View File

@ -125,13 +125,14 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
/// Hides/Shows the navigation bar for the page. /// Hides/Shows the navigation bar for the page.
open func hideNavigationBarLine(_ isHidden: Bool) { open func hideNavigationBarLine(_ isHidden: Bool) {
guard self == navigationController?.topViewController else { return } guard self == navigationController?.topViewController else { return }
var color = UIColor.clear var model: LineModel?
if !isHidden, if isHidden {
let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { model = LineModel(type: .none)
color = backgroundColor } else if let lineModel = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line {
model = lineModel
} }
navigationController?.navigationBar.standardAppearance.shadowColor = color navigationController?.navigationBar.standardAppearance.setShadow(for: model)
navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color navigationController?.navigationBar.scrollEdgeAppearance?.setShadow(for: model)
} }
open override func updateViews() { open override func updateViews() {