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 leftBody2 = Label.commonLabelB2(true)
|
||||||
let bar = Line()
|
let bar = Line()
|
||||||
let rightLabel = Label.commonLabelB2(true)
|
let rightLabel = Label.commonLabelB2(true)
|
||||||
|
private let barStackItem: StackItem
|
||||||
|
private let rightLabelStackItem: StackItem
|
||||||
public var horizontalStack: Stack<StackModel>
|
public var horizontalStack: Stack<StackModel>
|
||||||
public var verticalStack: Stack<StackModel>
|
public var verticalStack: Stack<StackModel>
|
||||||
public var stack: Stack<StackModel>
|
public var stack: Stack<StackModel>
|
||||||
@ -25,14 +27,25 @@ import Foundation
|
|||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
verticalStack = Stack<StackModel>.createStack(with: [(view: leftHeadline, model: StackItemModel(horizontalAlignment: .leading)),
|
//vertical stack with leftHeadline, leftBody, leftBody2
|
||||||
(view: leftBody, model: StackItemModel(horizontalAlignment: .leading)),
|
let verticalStackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading), StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .leading)],
|
||||||
(view: leftBody2, model: StackItemModel(horizontalAlignment: .leading))],
|
|
||||||
axis: .vertical, spacing: 0)
|
axis: .vertical, spacing: 0)
|
||||||
horizontalStack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)),
|
let verticalStackItems = [StackItem(andContain: leftHeadline), StackItem(andContain: leftBody), StackItem(andContain: leftBody2)]
|
||||||
(view: bar, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(spacing: 5, horizontalAlignment: .fill))],
|
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)
|
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)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +55,11 @@ import Foundation
|
|||||||
|
|
||||||
open override func alignAccessoryToHero() -> CGPoint? {
|
open override func alignAccessoryToHero() -> CGPoint? {
|
||||||
let heroCenter = super.alignAccessoryToHero()
|
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
|
return heroCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,9 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
|||||||
if bar.backgroundColor == nil {
|
if bar.backgroundColor == nil {
|
||||||
bar.backgroundColor = Color(uiColor: .gray)
|
bar.backgroundColor = Color(uiColor: .gray)
|
||||||
}
|
}
|
||||||
|
if let leftHeadline = leftHeadline {
|
||||||
|
leftHeadline.hero = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user