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