Merge branch 'feature/atomic_vds_line' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/vds_batch_one

This commit is contained in:
Scott Pfeil 2023-09-28 19:42:04 -04:00
commit e32941af39
7 changed files with 77 additions and 46 deletions

View File

@ -10,7 +10,7 @@ import UIKit
import VDSColorTokens import VDSColorTokens
import VDS import VDS
@objcMembers public class LineModel: MoleculeModelProtocol, Invertable { public class LineModel: MoleculeModelProtocol, Invertable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Enums // MARK: - Enums
//-------------------------------------------------- //--------------------------------------------------
@ -29,9 +29,23 @@ import VDS
case between 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 { public enum Style: String, Codable {
case secondary case secondary
case primary case primary
case standard
case thin
case medium
case heavy
case none case none
} }
@ -43,7 +57,7 @@ import VDS
public var id: String = UUID().uuidString public var id: String = UUID().uuidString
public var backgroundColor: Color? public var backgroundColor: Color?
public var type: Style = .primary public var type: Style = .secondary
public var frequency: Frequency? = .allExceptTop public var frequency: Frequency? = .allExceptTop
public var inverted: Bool = false public var inverted: Bool = false
@ -58,7 +72,7 @@ import VDS
self.type = type self.type = type
} }
public init(verticalLineOf type: Style, backgroundColor: Color? = nil) { public init(verticalLineOf type: Style) {
self.type = type self.type = type
} }
@ -100,7 +114,7 @@ import VDS
/// adding code to look for the old useVerticalLine or the new orientation /// adding code to look for the old useVerticalLine or the new orientation
if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) { if let useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) {
orientation = useVerticalLine ? .vertical : .horizontal 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 self.orientation = orientation
} }
} }
@ -112,6 +126,6 @@ import VDS
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(orientation == .vertical, forKey: .useVerticalLine) try container.encode(orientation == .vertical, forKey: .useVerticalLine)
} }
} }

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(.primary)
} }
//------------------------------------------------------ //------------------------------------------------------

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 = .primary
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(.primary)
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(.primary)
} }
//-------------------------------------------------- //--------------------------------------------------

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 = .primary
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

@ -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 /// 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 model.type != .none {
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() {