removing preferred width in update
This commit is contained in:
parent
29ba657433
commit
64d858571e
@ -12,10 +12,10 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public let headlineBody = HeadlineBody(frame: .zero)
|
public let headlineBody = HeadlineBody()
|
||||||
public let buttons = TwoButtonView(frame: .zero)
|
public let buttons = TwoButtonView()
|
||||||
public lazy var stack: Stack<StackModel> = {
|
public lazy var stack: Stack<StackModel> = {
|
||||||
return Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen)
|
Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
@ -31,16 +31,15 @@ import Foundation
|
|||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// MARK: - Molecule
|
// MARK: - Molecule
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
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? HeadersH1ButtonModel else { return }
|
guard let model = model as? HeadersH1ButtonModel else { return }
|
||||||
|
|
||||||
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
||||||
buttons.set(with: model.buttons, delegateObject, additionalData)
|
buttons.set(with: model.buttons, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 121 }
|
||||||
return 121
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol {
|
public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -19,6 +18,7 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) {
|
public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) {
|
||||||
self.headlineBody = headlineBody
|
self.headlineBody = headlineBody
|
||||||
self.buttons = buttons
|
self.buttons = buttons
|
||||||
@ -28,6 +28,7 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case headlineBody
|
case headlineBody
|
||||||
|
|||||||
@ -17,12 +17,13 @@ import Foundation
|
|||||||
public let subHeadline = Label(fontStyle: .BoldBodySmall)
|
public let subHeadline = Label(fontStyle: .BoldBodySmall)
|
||||||
public let body = Label(fontStyle: .RegularBodySmall)
|
public let body = Label(fontStyle: .RegularBodySmall)
|
||||||
public let link = Link()
|
public let link = Link()
|
||||||
public let buttons = TwoButtonView(frame: .zero)
|
public let buttons = TwoButtonView()
|
||||||
public var stack: Stack<StackModel>!
|
public var stack: Stack<StackModel>!
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
let spacingBetweenHeadlineHeadline2: CGFloat = 16.0
|
let spacingBetweenHeadlineHeadline2: CGFloat = 16.0
|
||||||
let spacingBetweenHeadline2subHeadline: CGFloat = 32.0
|
let spacingBetweenHeadline2subHeadline: CGFloat = 32.0
|
||||||
let spacingBetweenSubHeadlineBodyLink: CGFloat = 8.0
|
let spacingBetweenSubHeadlineBodyLink: CGFloat = 8.0
|
||||||
@ -45,7 +46,8 @@ import Foundation
|
|||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// MARK: - Molecule
|
// MARK: - Molecule
|
||||||
//------------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
||||||
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? HeadersH1LandingPageHeaderModel else { return }
|
guard let model = model as? HeadersH1LandingPageHeaderModel else { return }
|
||||||
@ -57,9 +59,7 @@ import Foundation
|
|||||||
buttons.set(with: model.buttons, delegateObject, additionalData)
|
buttons.set(with: model.buttons, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 121 }
|
||||||
return 121
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|||||||
@ -12,7 +12,8 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public let headlineBody = HeadlineBody(frame: .zero)
|
|
||||||
|
public let headlineBody = HeadlineBody()
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
@ -26,15 +27,14 @@ import Foundation
|
|||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// MARK: - Molecule
|
// MARK: - Molecule
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
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? HeadersH1NoButtonsBodyTextModel else { return }
|
guard let model = model as? HeadersH1NoButtonsBodyTextModel else { return }
|
||||||
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 121 }
|
||||||
return 121
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|||||||
@ -6,18 +6,20 @@
|
|||||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol {
|
public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "headerH1"
|
public static var identifier: String = "headerH1"
|
||||||
public var headlineBody: HeadlineBodyModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(headlineBody: HeadlineBodyModel) {
|
public init(headlineBody: HeadlineBodyModel) {
|
||||||
self.headlineBody = headlineBody
|
self.headlineBody = headlineBody
|
||||||
super.init()
|
super.init()
|
||||||
|
|||||||
@ -9,12 +9,23 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class ImageHeadlineBody: View {
|
@objcMembers open class ImageHeadlineBody: View {
|
||||||
let headlineBody = HeadlineBody(frame: .zero)
|
//--------------------------------------------------
|
||||||
|
// MARK: - Outlets
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
let headlineBody = HeadlineBody()
|
||||||
let imageView = LoadImageView(pinnedEdges: .all)
|
let imageView = LoadImageView(pinnedEdges: .all)
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
var constraintBetweenImageLabelsConstant: CGFloat = 16
|
var constraintBetweenImageLabelsConstant: CGFloat = 16
|
||||||
var constraintBetweenImageLabels: NSLayoutConstraint?
|
var constraintBetweenImageLabels: NSLayoutConstraint?
|
||||||
|
|
||||||
// MARK: - MFViewProtocol
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
@ -26,8 +37,8 @@ import UIKit
|
|||||||
addSubview(imageView)
|
addSubview(imageView)
|
||||||
|
|
||||||
NSLayoutConstraint.pinViewsVerticalExpandableAlignCenter([imageView, headlineBody])
|
NSLayoutConstraint.pinViewsVerticalExpandableAlignCenter([imageView, headlineBody])
|
||||||
rightAnchor.constraint(equalTo: headlineBody.rightAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: headlineBody.trailingAnchor).isActive = true
|
||||||
imageView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
|
imageView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
|
|
||||||
constraintBetweenImageLabels = headlineBody.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: constraintBetweenImageLabelsConstant)
|
constraintBetweenImageLabels = headlineBody.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: constraintBetweenImageLabelsConstant)
|
||||||
constraintBetweenImageLabels?.isActive = true
|
constraintBetweenImageLabels?.isActive = true
|
||||||
@ -48,14 +59,17 @@ import UIKit
|
|||||||
imageView.reset()
|
imageView.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK:- MoleculeViewProtocol
|
//--------------------------------------------------
|
||||||
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
// MARK: - MoleculeViewProtocol
|
||||||
return 95
|
//--------------------------------------------------
|
||||||
}
|
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 95 }
|
||||||
|
|
||||||
|
public 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? ImageHeadlineBodyModel else { return }
|
guard let model = model as? ImageHeadlineBodyModel else { return }
|
||||||
|
|
||||||
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
||||||
imageView.set(with: model.image, delegateObject, additionalData)
|
imageView.set(with: model.image, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,12 +9,20 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ImageHeadlineBodyModel: MoleculeModelProtocol {
|
public struct ImageHeadlineBodyModel: MoleculeModelProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "imageHeadlineBody"
|
public static var identifier: String = "imageHeadlineBody"
|
||||||
public var moleculeName: String = ImageHeadlineBodyModel.identifier
|
public var moleculeName: String = ImageHeadlineBodyModel.identifier
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var image: ImageViewModel
|
public var image: ImageViewModel
|
||||||
public var headlineBody: HeadlineBodyModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Init
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(image: ImageViewModel, headlineBody: HeadlineBodyModel) {
|
public init(image: ImageViewModel, headlineBody: HeadlineBodyModel) {
|
||||||
self.image = image
|
self.image = image
|
||||||
self.headlineBody = headlineBody
|
self.headlineBody = headlineBody
|
||||||
|
|||||||
@ -30,7 +30,10 @@ open class HeadlineBody: View {
|
|||||||
headlineLabel.hasText || messageLabel.hasText
|
headlineLabel.hasText || messageLabel.hasText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
// MARK: - Styling
|
// MARK: - Styling
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
func style(with style: HeadlineBodyModel.Style?) {
|
func style(with style: HeadlineBodyModel.Style?) {
|
||||||
|
|
||||||
switch style {
|
switch style {
|
||||||
@ -113,10 +116,6 @@ open class HeadlineBody: View {
|
|||||||
setSpacing()
|
setSpacing()
|
||||||
headlineLabel.updateView(size)
|
headlineLabel.updateView(size)
|
||||||
messageLabel.updateView(size)
|
messageLabel.updateView(size)
|
||||||
|
|
||||||
// Provide the label additional size information to help calculate its intrinsic height.
|
|
||||||
let padding = MFStyler.defaultHorizontalPadding(forSize: size) * 2
|
|
||||||
messageLabel.preferredMaxLayoutWidth = size - padding
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -6,8 +6,6 @@
|
|||||||
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class HeadlineBodyModel: ParentMoleculeModelProtocol {
|
@objcMembers open class HeadlineBodyModel: ParentMoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -22,7 +20,7 @@ import Foundation
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var children: [MoleculeModelProtocol] {
|
public var children: [MoleculeModelProtocol] {
|
||||||
return [headline, body].compactMap { $0 }
|
[headline, body].compactMap { $0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
public extension NSLayoutConstraint {
|
public extension NSLayoutConstraint {
|
||||||
|
|
||||||
@ -34,6 +33,7 @@ public extension NSLayoutConstraint {
|
|||||||
static func pinViewsVerticalExpandableAlignTop(_ views: [UIView], topAnchor: NSLayoutYAxisAnchor? = nil, bottomAnchor: NSLayoutYAxisAnchor? = nil, constant: CGFloat = 0) {
|
static func pinViewsVerticalExpandableAlignTop(_ views: [UIView], topAnchor: NSLayoutYAxisAnchor? = nil, bottomAnchor: NSLayoutYAxisAnchor? = nil, constant: CGFloat = 0) {
|
||||||
for view in views {
|
for view in views {
|
||||||
guard let superView = view.superview else { return }
|
guard let superView = view.superview else { return }
|
||||||
|
|
||||||
let top = topAnchor ?? superView.layoutMarginsGuide.topAnchor
|
let top = topAnchor ?? superView.layoutMarginsGuide.topAnchor
|
||||||
let bottom = bottomAnchor ?? superView.layoutMarginsGuide.bottomAnchor
|
let bottom = bottomAnchor ?? superView.layoutMarginsGuide.bottomAnchor
|
||||||
view.topAnchor.constraint(equalTo: top).isActive = true
|
view.topAnchor.constraint(equalTo: top).isActive = true
|
||||||
@ -48,11 +48,13 @@ public extension NSLayoutConstraint {
|
|||||||
/// Pins a view to the left and a view to the right, flexible space in between. The super can expand depending on the taller view. Shorter views are aligned top if alignTop true, else aligned center.
|
/// Pins a view to the left and a view to the right, flexible space in between. The super can expand depending on the taller view. Shorter views are aligned top if alignTop true, else aligned center.
|
||||||
static func pinViews(leftView: UIView, rightView: UIView, alignTop: Bool, topAnchor: NSLayoutYAxisAnchor? = nil, bottomAnchor: NSLayoutYAxisAnchor? = nil, constant: CGFloat = 0) {
|
static func pinViews(leftView: UIView, rightView: UIView, alignTop: Bool, topAnchor: NSLayoutYAxisAnchor? = nil, bottomAnchor: NSLayoutYAxisAnchor? = nil, constant: CGFloat = 0) {
|
||||||
guard let superView = leftView.superview else { return }
|
guard let superView = leftView.superview else { return }
|
||||||
|
|
||||||
if alignTop {
|
if alignTop {
|
||||||
pinViewsVerticalExpandableAlignTop([leftView, rightView], topAnchor: topAnchor, bottomAnchor: bottomAnchor, constant: constant)
|
pinViewsVerticalExpandableAlignTop([leftView, rightView], topAnchor: topAnchor, bottomAnchor: bottomAnchor, constant: constant)
|
||||||
} else {
|
} else {
|
||||||
pinViewsVerticalExpandableAlignCenter([leftView, rightView], topAnchor: topAnchor, bottomAnchor: bottomAnchor, constant: constant)
|
pinViewsVerticalExpandableAlignCenter([leftView, rightView], topAnchor: topAnchor, bottomAnchor: bottomAnchor, constant: constant)
|
||||||
}
|
}
|
||||||
|
|
||||||
leftView.leadingAnchor.constraint(equalTo: superView.layoutMarginsGuide.leadingAnchor).isActive = true
|
leftView.leadingAnchor.constraint(equalTo: superView.layoutMarginsGuide.leadingAnchor).isActive = true
|
||||||
superView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightView.trailingAnchor).isActive = true
|
superView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightView.trailingAnchor).isActive = true
|
||||||
rightView.leftAnchor.constraint(greaterThanOrEqualTo: leftView.rightAnchor, constant: Padding.Component.gutterForApplicationWidth).isActive = true
|
rightView.leftAnchor.constraint(greaterThanOrEqualTo: leftView.rightAnchor, constant: Padding.Component.gutterForApplicationWidth).isActive = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user