Merge branch 'develop' into 'feature/atomic_vds_textLink'
# Conflicts: # MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift
This commit is contained in:
commit
5d347ffaaf
@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 52;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@ -588,6 +588,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 */
|
||||
|
||||
@ -1176,6 +1177,7 @@
|
||||
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>"; };
|
||||
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>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -2418,6 +2420,7 @@
|
||||
011B58EE23A2AA850085F53C /* ModelProtocols */,
|
||||
27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */,
|
||||
EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */,
|
||||
EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */,
|
||||
);
|
||||
path = Protocols;
|
||||
sourceTree = "<group>";
|
||||
@ -2976,6 +2979,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 */,
|
||||
|
||||
@ -7,116 +7,112 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import VDS
|
||||
|
||||
|
||||
@objcMembers open class Line: View {
|
||||
@objcMembers open class Line: VDS.Line, VDSMoleculeViewProtocol {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
open var viewModel: LineModel!
|
||||
open var delegateObject: MVMCoreUIDelegateObject?
|
||||
open var additionalData: [AnyHashable : Any]?
|
||||
|
||||
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 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
|
||||
//--------------------------------------------------
|
||||
|
||||
//--------------------------------------------------
|
||||
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: .secondary)
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
model = LineModel(type: .secondary)
|
||||
setStyle(.secondary)
|
||||
viewModel = LineModel(type: .secondary)
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
model = LineModel(type: .secondary)
|
||||
setStyle(.secondary)
|
||||
viewModel = LineModel(type: .secondary)
|
||||
}
|
||||
|
||||
public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.init(model: model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// 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
|
||||
open override func draw(_ rect: CGRect) {
|
||||
guard viewModel.type != .none else { return }
|
||||
super.draw(rect)
|
||||
}
|
||||
|
||||
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() {
|
||||
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 {
|
||||
|
||||
@ -8,8 +8,9 @@
|
||||
|
||||
import UIKit
|
||||
import VDSColorTokens
|
||||
import VDS
|
||||
|
||||
@objcMembers public class LineModel: MoleculeModelProtocol {
|
||||
public class LineModel: MoleculeModelProtocol, Invertable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
@ -30,12 +31,12 @@ import VDSColorTokens
|
||||
|
||||
/**
|
||||
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)
|
||||
- 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 {
|
||||
@ -54,53 +55,14 @@ import VDSColorTokens
|
||||
|
||||
public static var identifier: String = "line"
|
||||
public var id: String = UUID().uuidString
|
||||
|
||||
public var backgroundColor: Color?
|
||||
|
||||
public var type: Style = .secondary
|
||||
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 +70,11 @@ import VDSColorTokens
|
||||
|
||||
public init(type: Style) {
|
||||
self.type = type
|
||||
self.useVerticalLine = false
|
||||
}
|
||||
|
||||
public init(verticalLineOf type: Style, backgroundColor: Color? = nil) {
|
||||
public init(verticalLineOf type: Style) {
|
||||
self.type = type
|
||||
self.backgroundColor = backgroundColor
|
||||
self.useVerticalLine = true
|
||||
orientation = .vertical
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -125,13 +85,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 +112,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 +127,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.encode(orientation == .vertical, forKey: .useVerticalLine)
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@ extension TileContainer.BackgroundColor: Codable {}
|
||||
extension TileContainer.Padding: Codable {}
|
||||
extension TileContainer.AspectRatio: Codable {}
|
||||
extension TextLink.Size: Codable {}
|
||||
extension VDS.Line.Style: Codable {}
|
||||
extension VDS.Line.Orientation: Codable {}
|
||||
extension Use: Codable {}
|
||||
extension VDS.Button.Size: RawRepresentableCodable {
|
||||
public static var mapping: [String : VDS.Button.Size] { ["standard": .large, "tiny": .small] }
|
||||
|
||||
@ -42,6 +42,13 @@ import Foundation
|
||||
return Stack<StackModel>.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
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
@ -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(.medium)
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
@ -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 = .medium
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -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(.heavy)
|
||||
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(.heavy)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -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 = .heavy
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
18
MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift
Normal file
18
MVMCoreUI/Atomic/Protocols/VDS-Interpreters.swift
Normal 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 }
|
||||
}
|
||||
@ -28,5 +28,9 @@ extension VDSMoleculeViewProtocol {
|
||||
viewModel = castedModel
|
||||
viewModelDidUpdate()
|
||||
}
|
||||
|
||||
public func update(viewModel: ViewModel){
|
||||
set(with: viewModel, delegateObject, additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
@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 line.shouldBeVisible() {
|
||||
shadowColor = line.lineColor
|
||||
} else {
|
||||
shadowColor = .clear
|
||||
}
|
||||
shadowImage = line.lineColor.image(CGSize(width: line.lineWidth, height: line.lineWidth)).withRenderingMode(.alwaysTemplate)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user