hero fixes
headlineBody update instead of eyebrowheadlinebody
This commit is contained in:
parent
09769a3bc6
commit
9cff0f15f7
@ -1103,8 +1103,6 @@
|
|||||||
AA4FC2A323F4F69600E251DB /* RightVariable */ = {
|
AA4FC2A323F4F69600E251DB /* RightVariable */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
BB55B51E244482D2002001AD /* ListRightVariablePriceChangeBodyTextModel.swift */,
|
|
||||||
BB55B51C244482C0002001AD /* ListRightVariablePriceChangeBodyText.swift */,
|
|
||||||
BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */,
|
BB54C51F2434D92F0038326C /* ListRightVariableButtonAllTextAndLinksModel.swift */,
|
||||||
BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */,
|
BB54C51E2434D92F0038326C /* ListRightVariableButtonAllTextAndLinks.swift */,
|
||||||
BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */,
|
BB2C968D24330EA7006FF80C /* ListRightVariableTextLinkAllTextAndLinksModel.swift */,
|
||||||
@ -1113,6 +1111,8 @@
|
|||||||
AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */,
|
AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */,
|
||||||
8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */,
|
8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */,
|
||||||
8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */,
|
8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */,
|
||||||
|
BB55B51E244482D2002001AD /* ListRightVariablePriceChangeBodyTextModel.swift */,
|
||||||
|
BB55B51C244482C0002001AD /* ListRightVariablePriceChangeBodyText.swift */,
|
||||||
8D8067D02444472F00203BE8 /* ListRightVariablePriceChangeAllTextAndLinksModel.swift */,
|
8D8067D02444472F00203BE8 /* ListRightVariablePriceChangeAllTextAndLinksModel.swift */,
|
||||||
8D8067D22444473A00203BE8 /* ListRightVariablePriceChangeAllTextAndLinks.swift */,
|
8D8067D22444473A00203BE8 /* ListRightVariablePriceChangeAllTextAndLinks.swift */,
|
||||||
C7F8012223E846C300396FBD /* ListRVWheelModel.swift */,
|
C7F8012223E846C300396FBD /* ListRVWheelModel.swift */,
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class ListRightVariablePriceChangeAllTextAndLinks: TableViewCell {
|
@objcMembers open class ListRightVariablePriceChangeAllTextAndLinks: TableViewCell {
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
@ -26,7 +26,7 @@ import Foundation
|
|||||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading),
|
let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading),
|
||||||
StackItemModel(horizontalAlignment: .fill),
|
StackItemModel(horizontalAlignment: .fill),
|
||||||
StackItemModel(spacing: 8, horizontalAlignment: .fill)],
|
StackItemModel(spacing: 6, horizontalAlignment: .fill)],
|
||||||
axis: .horizontal)
|
axis: .horizontal)
|
||||||
arrowStackItem = StackItem(andContain: arrow)
|
arrowStackItem = StackItem(andContain: arrow)
|
||||||
rightLabelStackItem = StackItem(andContain: rightLabel)
|
rightLabelStackItem = StackItem(andContain: rightLabel)
|
||||||
@ -43,18 +43,19 @@ import Foundation
|
|||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
public override func alignAccessoryToHero() {
|
open override func alignAccessoryToHero() -> CGPoint? {
|
||||||
super.alignAccessoryToHero()
|
let heroCenter = super.alignAccessoryToHero()
|
||||||
|
|
||||||
// Aligns the center of the right side items to the headline.
|
// Aligns the center of the right side items to the headline.
|
||||||
if let heroCenter = heroAccessoryCenter {
|
if let heroCenter = heroCenter {
|
||||||
let convertedPoint = stack.convert(heroCenter, from: self)
|
let convertedPoint = stack.convert(heroCenter, from: self)
|
||||||
arrowStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY
|
arrowStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY
|
||||||
rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY
|
rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY
|
||||||
}
|
}
|
||||||
|
return heroCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol {
|
public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "listRVArwAll"
|
public static var identifier: String = "listRVArwAll"
|
||||||
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
||||||
public var rightLabel: LabelModel
|
public var rightLabel: LabelModel
|
||||||
|
|||||||
@ -12,19 +12,20 @@ import Foundation
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
public var stack: Stack<StackModel>
|
private let stack: Stack<StackModel>
|
||||||
public let headlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
|
public let headlineBody = HeadlineBody(frame: .zero)
|
||||||
public let rightLabel = Label.commonLabelB2(true)
|
|
||||||
public let arrow = Arrow(frame: .zero)
|
public let arrow = Arrow(frame: .zero)
|
||||||
|
public let rightLabel = Label.commonLabelB2(true)
|
||||||
let arrowAndRightLabelStack: Stack<StackModel>
|
let arrowAndRightLabelStack: Stack<StackModel>
|
||||||
|
|
||||||
|
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
arrowAndRightLabelStack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)),
|
arrowAndRightLabelStack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)),
|
||||||
(view: rightLabel, model: StackItemModel(horizontalAlignment: .leading))],
|
(view: rightLabel, model: StackItemModel(horizontalAlignment: .fill))],
|
||||||
axis: .horizontal, spacing: 6)
|
axis: .horizontal, spacing: 6)
|
||||||
stack = Stack<StackModel>.createStack(with: [(view: headlineBodyLink, model: StackItemModel(percent:70,horizontalAlignment: .leading)),
|
stack = Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)),
|
||||||
(view: arrowAndRightLabelStack, model: StackItemModel(percent:30,horizontalAlignment: .trailing,verticalAlignment: .top))],
|
(view: arrowAndRightLabelStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))],
|
||||||
axis: .horizontal)
|
axis: .horizontal)
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
}
|
}
|
||||||
@ -36,8 +37,14 @@ import Foundation
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
override open func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
headlineBody.styleListItem()
|
||||||
|
|
||||||
|
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
|
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||||
|
rightLabel.numberOfLines = 1
|
||||||
|
|
||||||
arrow.pinHeightAndWidth()
|
arrow.pinHeightAndWidth()
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
@ -47,17 +54,17 @@ import Foundation
|
|||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
guard let model = model as? ListRightVariablePriceChangeBodyTextModel else { return }
|
guard let model = model as? ListRightVariablePriceChangeBodyTextModel else { return }
|
||||||
headlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
|
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
||||||
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
||||||
arrow.set(with: model.arrow, delegateObject, additionalData)
|
arrow.set(with: model.arrow, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
return 120
|
return 80
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
rightLabel.styleB2(true)
|
headlineBody.styleListItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,27 +9,35 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeModelProtocol {
|
public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeModelProtocol {
|
||||||
public static var identifier: String = "listRVArwBdy"
|
public static var identifier: String = "listRVArwBdy"
|
||||||
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
public var rightLabel: LabelModel
|
public var rightLabel: LabelModel
|
||||||
public var arrow: ArrowModel
|
public var arrow: ArrowModel
|
||||||
|
|
||||||
public init(eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel,rightLabel: LabelModel,arrow: ArrowModel) {
|
public init(headlineBody: HeadlineBodyModel,rightLabel: LabelModel,arrow: ArrowModel) {
|
||||||
self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink
|
self.headlineBody = headlineBody
|
||||||
self.rightLabel = rightLabel
|
self.rightLabel = rightLabel
|
||||||
self.arrow = arrow
|
self.arrow = arrow
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defaults to set
|
||||||
|
public override func setDefaults() {
|
||||||
|
super.setDefaults()
|
||||||
|
if let headline = headlineBody.headline {
|
||||||
|
headline.hero = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case eyebrowHeadlineBodyLink
|
case headlineBody
|
||||||
case rightLabel
|
case rightLabel
|
||||||
case arrow
|
case arrow
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink)
|
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
|
||||||
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||||
arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow)
|
arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
@ -39,7 +47,7 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM
|
|||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink)
|
try container.encode(headlineBody, forKey: .headlineBody)
|
||||||
try container.encode(rightLabel, forKey: .rightLabel)
|
try container.encode(rightLabel, forKey: .rightLabel)
|
||||||
try container.encode(arrow, forKey: .arrow)
|
try container.encode(arrow, forKey: .arrow)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,7 @@ import UIKit
|
|||||||
|
|
||||||
// Ensures accessory view aligns to the center y derived from the
|
// Ensures accessory view aligns to the center y derived from the
|
||||||
if let _ = heroAccessoryCenter {
|
if let _ = heroAccessoryCenter {
|
||||||
alignAccessoryToHero()
|
_ = alignAccessoryToHero()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,14 +215,16 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE: Should only be called when displayed or about to be displayed.
|
/// NOTE: Should only be called when displayed or about to be displayed.
|
||||||
public func alignAccessoryToHero() {
|
public func alignAccessoryToHero() -> CGPoint? {
|
||||||
|
|
||||||
// Layout call required to force draw in memory to get dimensions of subviews.
|
// Layout call required to force draw in memory to get dimensions of subviews.
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return }
|
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return nil }
|
||||||
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
||||||
accessoryView?.center.y = convert(UIView(frame: rect).center, from: heroLabel).y
|
let y = convert(UIView(frame: rect).center, from: heroLabel).y
|
||||||
|
accessoryView?.center.y = y
|
||||||
heroAccessoryCenter = accessoryView?.center
|
heroAccessoryCenter = accessoryView?.center
|
||||||
|
return heroAccessoryCenter ?? CGPoint(x: 0, y: y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Traverses the view hierarchy for a 🦸♂️ heroic Label.
|
/// Traverses the view hierarchy for a 🦸♂️ heroic Label.
|
||||||
@ -269,7 +271,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func willDisplay() {
|
public func willDisplay() {
|
||||||
alignAccessoryToHero()
|
_ = alignAccessoryToHero()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Separator
|
// MARK: - Separator
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user