line fix, small clean
This commit is contained in:
parent
77a99e99c9
commit
b49579d059
@ -11,15 +11,15 @@ import Foundation
|
||||
//--------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//--------------------------------------------------
|
||||
let progressBar = ProgressBar()
|
||||
let leftHeadline = Label.commonLabelB1(true)
|
||||
let leftBody = Label.commonLabelB2(true)
|
||||
let bar = Line()
|
||||
let rightLabel = Label.commonLabelB2(true)
|
||||
public let progressBar = ProgressBar()
|
||||
public let leftHeadline = Label.commonLabelB1(true)
|
||||
public let leftBody = Label.commonLabelB2(true)
|
||||
public let rightBar = Line()
|
||||
public let rightLabel = Label.commonLabelB2(true)
|
||||
private let barStackItem: StackItem
|
||||
private let rightLabelStackItem: StackItem
|
||||
public var labelStack: Stack<StackModel>
|
||||
public var horizontalStack: Stack<StackModel>
|
||||
public var verticalStack: Stack<StackModel>
|
||||
public var stack: Stack<StackModel>
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -27,14 +27,14 @@ import Foundation
|
||||
//------------------------------------------------------
|
||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
//vertical stack with leftHeadline, leftBody
|
||||
verticalStack = Stack<StackModel>.createStack(with: [leftHeadline, leftBody], axis: .vertical, spacing: 2)
|
||||
labelStack = Stack<StackModel>.createStack(with: [leftHeadline, leftBody], axis: .vertical, spacing: 2)
|
||||
|
||||
//horizontal stack with leftHeadline, leftBody, bar, rightLabel
|
||||
barStackItem = StackItem(andContain: rightBar)
|
||||
rightLabelStackItem = StackItem(andContain: rightLabel)
|
||||
let horizontalStackItems = [StackItem(andContain: labelStack), barStackItem, rightLabelStackItem]
|
||||
let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 5, horizontalAlignment: .fill)],
|
||||
axis: .horizontal)
|
||||
barStackItem = StackItem(andContain: bar)
|
||||
rightLabelStackItem = StackItem(andContain: rightLabel)
|
||||
let horizontalStackItems = [StackItem(andContain: verticalStack), barStackItem, rightLabelStackItem]
|
||||
horizontalStack = Stack<StackModel>(with: horizontalStackModel, stackItems: horizontalStackItems)
|
||||
|
||||
//stack with all components
|
||||
@ -47,6 +47,7 @@ import Foundation
|
||||
}
|
||||
|
||||
open override func alignAccessoryToHero() -> CGPoint? {
|
||||
// Ensures that the right items are centered with the arrow.
|
||||
let heroCenter = super.alignAccessoryToHero()
|
||||
if let heroCenter = heroCenter {
|
||||
let convertedPoint = horizontalStack.convert(heroCenter, from: self)
|
||||
@ -61,14 +62,14 @@ import Foundation
|
||||
//-------------------------------------------------------
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
bar.widthAnchor.constraint(equalToConstant: 20).isActive = true
|
||||
rightBar.widthAnchor.constraint(equalToConstant: 20).isActive = true
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
horizontalStack.restack()
|
||||
verticalStack.restack()
|
||||
labelStack.restack()
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -77,10 +78,10 @@ import Foundation
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? ListProgressBarThinModel else { return }
|
||||
verticalStack.updateContainedMolecules(with: [model.leftHeadline,
|
||||
labelStack.updateContainedMolecules(with: [model.leftHeadline,
|
||||
model.leftBody], delegateObject, additionalData)
|
||||
progressBar.set(with: model.progressBar, delegateObject, additionalData)
|
||||
bar.set(with: model.bar, delegateObject, additionalData)
|
||||
rightBar.set(with: model.rightBar, delegateObject, additionalData)
|
||||
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
@ -93,6 +94,6 @@ import Foundation
|
||||
leftHeadline.styleB1(true)
|
||||
leftBody.styleB2(true)
|
||||
rightLabel.styleB2(true)
|
||||
bar.setStyle(.medium)
|
||||
rightBar.setStyle(.medium)
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,23 +12,23 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
||||
public var progressBar: ProgressBarModel
|
||||
public var leftHeadline: LabelModel
|
||||
public var leftBody: LabelModel?
|
||||
public var bar: LineModel
|
||||
public var rightBar: LineModel
|
||||
public var rightLabel: LabelModel
|
||||
|
||||
public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, bar: LineModel, rightLabel: LabelModel) {
|
||||
public init(progressBar: ProgressBarModel, leftHeadline: LabelModel, leftBody: LabelModel? = nil, rightBar: LineModel, rightLabel: LabelModel) {
|
||||
self.progressBar = progressBar
|
||||
self.leftHeadline = leftHeadline
|
||||
self.leftBody = leftBody
|
||||
self.bar = bar
|
||||
self.rightBar = rightBar
|
||||
self.rightLabel = rightLabel
|
||||
super.init()
|
||||
}
|
||||
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
bar.type = .medium
|
||||
if bar.backgroundColor == nil {
|
||||
bar.backgroundColor = Color(uiColor: .gray)
|
||||
rightBar.type = .medium
|
||||
if rightBar.backgroundColor == nil {
|
||||
rightBar.backgroundColor = Color(uiColor: .gray)
|
||||
}
|
||||
leftHeadline.hero = 0
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
||||
case progressBar
|
||||
case leftHeadline
|
||||
case leftBody
|
||||
case line
|
||||
case rightBar
|
||||
case rightLabel
|
||||
}
|
||||
|
||||
@ -47,7 +47,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)
|
||||
bar = try typeContainer.decode(LineModel.self, forKey: .line)
|
||||
rightBar = try typeContainer.decode(LineModel.self, forKey: .rightBar)
|
||||
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
@ -59,7 +59,7 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
||||
try container.encode(progressBar, forKey: .progressBar)
|
||||
try container.encode(leftHeadline, forKey: .leftHeadline)
|
||||
try container.encodeIfPresent(leftBody, forKey: .leftBody)
|
||||
try container.encode(bar, forKey: .line)
|
||||
try container.encode(rightBar, forKey: .rightBar)
|
||||
try container.encode(rightLabel, forKey: .rightLabel)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user