Merge branch 'feature/Label-DynamicLines' into 'develop'
Option to set 'numberOfLines' for label from label's json. See merge request BPHV_MIPS/mvm_core_ui!726
This commit is contained in:
commit
71dd0a1e1e
@ -24,7 +24,6 @@ import Foundation
|
||||
super.setupView()
|
||||
layer.borderColor = UIColor.mvmCoolGray6.cgColor
|
||||
layer.borderWidth = 1
|
||||
label.numberOfLines = 1
|
||||
addSubview(label)
|
||||
NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: 13, pinBottom: true, bottomConstant: 13, pinLeft: true, leftConstant: 15, pinRight: true, rightConstant: 15)
|
||||
}
|
||||
|
||||
@ -21,6 +21,12 @@ import Foundation
|
||||
case backgroundColor
|
||||
}
|
||||
|
||||
public func setDefaults() {
|
||||
if label.numberOfLines == nil {
|
||||
label.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
label = try typeContainer.decode(LabelModel.self, forKey: .label)
|
||||
|
||||
@ -315,6 +315,10 @@ public typealias ActionBlock = () -> ()
|
||||
if let color = labelModel.textColor {
|
||||
textColor = color.uiColor
|
||||
}
|
||||
|
||||
if let lines = labelModel.numberOfLines {
|
||||
numberOfLines = lines
|
||||
}
|
||||
|
||||
if let attributes = labelModel.attributes, let labelText = text {
|
||||
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor])
|
||||
@ -790,6 +794,7 @@ extension Label {
|
||||
accessibilityCustomActions = []
|
||||
clauses = []
|
||||
accessibilityTraits = .staticText
|
||||
numberOfLines = 0
|
||||
}
|
||||
|
||||
public func needsToBeConstrained() -> Bool { true }
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
public var html: String?
|
||||
public var hero: Int?
|
||||
public var makeWholeViewClickable: Bool?
|
||||
public var numberOfLines: Int?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
@ -44,12 +45,13 @@
|
||||
case html
|
||||
case hero
|
||||
case makeWholeViewClickable
|
||||
case numberOfLines
|
||||
}
|
||||
|
||||
enum AttributeTypeKey: String, CodingKey {
|
||||
case type
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
@ -76,6 +78,7 @@
|
||||
html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
||||
hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
||||
makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
||||
numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -93,5 +96,6 @@
|
||||
try container.encodeIfPresent(html, forKey: .html)
|
||||
try container.encodeIfPresent(hero, forKey: .hero)
|
||||
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
||||
try container.encodeIfPresent(numberOfLines, forKey: .numberOfLines)
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,11 +48,8 @@ import Foundation
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
setDefaults()
|
||||
body.numberOfLines = 1
|
||||
body.lineBreakMode = .byTruncatingTail
|
||||
body2.numberOfLines = 1
|
||||
body2.lineBreakMode = .byTruncatingTail
|
||||
body3.numberOfLines = 1
|
||||
body3.lineBreakMode = .byTruncatingTail
|
||||
|
||||
verticalLine1.widthConstraint?.isActive = true
|
||||
|
||||
@ -49,6 +49,15 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol {
|
||||
subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)]
|
||||
subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)]
|
||||
subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)]
|
||||
if body.numberOfLines == nil {
|
||||
body.numberOfLines = 1
|
||||
}
|
||||
if body2.numberOfLines == nil {
|
||||
body2.numberOfLines = 1
|
||||
}
|
||||
if body3.numberOfLines == nil {
|
||||
body3.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -50,7 +50,6 @@
|
||||
leftImage.contentMode = .scaleAspectFit
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
@ -31,6 +31,10 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel,
|
||||
image.width = 30
|
||||
image.height = 30
|
||||
}
|
||||
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
@ -55,7 +55,6 @@
|
||||
leftImage.contentMode = .scaleAspectFit
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Mol
|
||||
}
|
||||
headlineBody.style = .item
|
||||
headlineBody.headline?.hero = 0
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
@ -71,7 +71,6 @@
|
||||
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()
|
||||
|
||||
@ -45,6 +45,10 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol {
|
||||
rightBar.backgroundColor = Color(uiColor: .gray)
|
||||
}
|
||||
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
|
||||
leftHeadline.hero = 0
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
horizontalStack.restack()
|
||||
|
||||
@ -38,6 +38,9 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
leftHeadline.hero = 0
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -61,7 +61,6 @@
|
||||
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
@ -17,6 +17,17 @@ public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, Mo
|
||||
public var rightLabel: LabelModel
|
||||
public var arrow: ArrowModel
|
||||
|
||||
//-----------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//-----------------------------------------------------
|
||||
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
|
||||
@ -37,6 +37,9 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM
|
||||
if let headline = headlineBody.headline {
|
||||
headline.hero = 0
|
||||
}
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
super.setupView()
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
@ -16,6 +16,17 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Mol
|
||||
public var rightLabel: LabelModel
|
||||
public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
||||
|
||||
//-----------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//-----------------------------------------------------
|
||||
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -39,9 +39,6 @@
|
||||
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
leftLabel.numberOfLines = 1
|
||||
centerLabel.numberOfLines = 1
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
@ -17,6 +17,23 @@ public class ListThreeColumnBillChangesModel: ListItemModel, MoleculeModelProtoc
|
||||
public var centerLabel: LabelModel
|
||||
public var rightLabel: LabelModel
|
||||
|
||||
//-----------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//-----------------------------------------------------
|
||||
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
if centerLabel.numberOfLines == nil {
|
||||
centerLabel.numberOfLines = 1
|
||||
}
|
||||
if leftLabel.numberOfLines == nil {
|
||||
leftLabel.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -74,9 +74,6 @@
|
||||
view.addSubview(rightVerticalStack)
|
||||
NSLayoutConstraint.pinViews(leftView: leftVerticalStack, rightView: rightVerticalStack, alignTop: true)
|
||||
|
||||
leftHeadline.numberOfLines = 1
|
||||
rightLabel.numberOfLines = 1
|
||||
rightSubLabel.numberOfLines = 1
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
@ -34,6 +34,18 @@ public class ListTwoColumnPriceDescriptionModel: ListItemModel, MoleculeModelPro
|
||||
if rightSubLabel.attributes == nil {
|
||||
rightSubLabel.attributes = [LabelAttributeStrikeThroughModel(0, rightSubLabel.text.count)]
|
||||
}
|
||||
|
||||
if rightLabel.numberOfLines == nil {
|
||||
rightLabel.numberOfLines = 1
|
||||
}
|
||||
|
||||
if rightSubLabel.numberOfLines == nil {
|
||||
rightSubLabel.numberOfLines = 1
|
||||
}
|
||||
|
||||
if leftHeadline.numberOfLines == nil {
|
||||
leftHeadline.numberOfLines = 1
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -64,6 +64,7 @@ open class DoughnutChart: View {
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
titleLabel.reset()
|
||||
titleLabel.numberOfLines = 1
|
||||
subTitleLabel.reset()
|
||||
clearLayers()
|
||||
}
|
||||
|
||||
@ -26,6 +26,9 @@ open class CollapsableNotificationModel: NotificationModel {
|
||||
|
||||
open override func setDefaults() {
|
||||
super.setDefaults()
|
||||
if topLabel.numberOfLines == nil {
|
||||
topLabel.numberOfLines = 1
|
||||
}
|
||||
if topLabel.textColor == nil {
|
||||
topLabel.textColor = Color(uiColor: .white)
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ import Foundation
|
||||
@objcMembers open class CollapsableNotificationTopView: View {
|
||||
public let label: Label = {
|
||||
let label = Label(fontStyle: .BoldBodySmall)
|
||||
label.numberOfLines = 1
|
||||
label.textAlignment = .center
|
||||
label.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
return label
|
||||
|
||||
Loading…
Reference in New Issue
Block a user