Code changes for aligning rightlabel with leftheadline.
This commit is contained in:
parent
8bada91766
commit
3fce526c90
@ -17,6 +17,8 @@ import Foundation
|
||||
let leftBody2 = Label.commonLabelB2(true)
|
||||
let bar = Line()
|
||||
let rightLabel = Label.commonLabelB2(true)
|
||||
private let barStackItem: StackItem
|
||||
private let rightLabelStackItem: StackItem
|
||||
public var horizontalStack: Stack<StackModel>
|
||||
public var verticalStack: Stack<StackModel>
|
||||
public var stack: Stack<StackModel>
|
||||
@ -25,14 +27,25 @@ import Foundation
|
||||
// MARK: - Initializers
|
||||
//------------------------------------------------------
|
||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
verticalStack = Stack<StackModel>.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .leading)),
|
||||
(view: leftBody, model: StackItemModel(horizontalAlignment: .leading)),
|
||||
(view: leftBody2, model: StackItemModel(horizontalAlignment: .leading))],
|
||||
//vertical stack with leftHeadline, leftBody, leftBody2
|
||||
let verticalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading), StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .leading)],
|
||||
axis: .vertical, spacing: 0)
|
||||
horizontalStack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)),
|
||||
(view: bar, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(spacing: 5, horizontalAlignment: .fill))],
|
||||
let verticalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: leftBody), StackItem(andContain: leftBody2)]
|
||||
verticalStack = Stack<StackModel>(with: verticalStackModel, stackItems: verticalStackItems)
|
||||
|
||||
//horizontal stack with leftHeadline, leftBody, leftBody2, bar, rightLabel
|
||||
let horizontalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), StackItemModel(spacing: 5, horizontalAlignment: .fill)],
|
||||
axis: .horizontal)
|
||||
stack = Stack<StackModel>.createStack(with: [(view: horizontalStack, model: StackItemModel(horizontalAlignment: .fill)), (view: progressBar, model: StackItemModel(spacing: 20, horizontalAlignment: .fill))], axis: .vertical)
|
||||
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
|
||||
let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .fill),
|
||||
StackItemModel(spacing: 20, horizontalAlignment: .fill)], axis: .vertical)
|
||||
let stackItems = [StackItem(andContain: horizontalStack), StackItem(andContain: progressBar)]
|
||||
stack = Stack<StackModel>(with: stackModel, stackItems: stackItems)
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
}
|
||||
|
||||
@ -42,6 +55,11 @@ import Foundation
|
||||
|
||||
open override func alignAccessoryToHero() -> CGPoint? {
|
||||
let heroCenter = super.alignAccessoryToHero()
|
||||
if let heroCenter = heroCenter {
|
||||
let convertedPoint = horizontalStack.convert(heroCenter, from: self)
|
||||
barStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY
|
||||
rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY
|
||||
}
|
||||
return heroCenter
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,9 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
||||
if bar.backgroundColor == nil {
|
||||
bar.backgroundColor = Color(uiColor: .gray)
|
||||
}
|
||||
if let leftHeadline = leftHeadline {
|
||||
leftHeadline.hero = 0
|
||||
}
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user