updated file name.
This commit is contained in:
parent
ce1a8c3598
commit
1bfbe95b68
@ -1,158 +0,0 @@
|
|||||||
//
|
|
||||||
// StandardListItemWithImage.swift
|
|
||||||
// MVMCoreUI
|
|
||||||
//
|
|
||||||
// Created by Christiano, Kevin on 6/20/19.
|
|
||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class StandardListItemWithImage: ViewConstrainingView {
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Outlets
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
let title = Label.commonLabelH3(true)
|
|
||||||
let message = Label.commonLabelB3(true)
|
|
||||||
let button = PrimaryButton.primaryTinyButton(false)!
|
|
||||||
let imageloader = MFLoadImageView()
|
|
||||||
let leftContainer = ViewConstrainingView.empty()
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Constraints
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
var imageWidthConstraint: NSLayoutConstraint?
|
|
||||||
var imageHeightConstraint: NSLayoutConstraint?
|
|
||||||
var buttonTopConstraint: NSLayoutConstraint?
|
|
||||||
var messageTopConstraint: NSLayoutConstraint?
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Initialization
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
public init() {
|
|
||||||
super.init(frame: .zero)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override init(frame: CGRect) {
|
|
||||||
super.init(frame: frame)
|
|
||||||
}
|
|
||||||
|
|
||||||
required public init?(coder aDecoder: NSCoder) {
|
|
||||||
super.init(coder: aDecoder)
|
|
||||||
}
|
|
||||||
|
|
||||||
public convenience init(json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
self.init()
|
|
||||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - View Lifecycle
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
override open func setupView() {
|
|
||||||
super.setupView()
|
|
||||||
|
|
||||||
guard subviews.isEmpty else { return }
|
|
||||||
|
|
||||||
button.setAsSecondaryCustom()
|
|
||||||
|
|
||||||
imageloader.imageView.contentMode = .scaleAspectFit
|
|
||||||
|
|
||||||
addSubview(leftContainer)
|
|
||||||
addSubview(imageloader)
|
|
||||||
leftContainer.addSubview(title)
|
|
||||||
leftContainer.addSubview(message)
|
|
||||||
leftContainer.addSubview(button)
|
|
||||||
|
|
||||||
leftContainer.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
||||||
leftContainer.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
|
|
||||||
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true
|
|
||||||
let leftContainerBottom = leftContainer.bottomAnchor.constraint(equalTo: bottomAnchor)
|
|
||||||
leftContainerBottom.priority = UILayoutPriority(249)
|
|
||||||
leftContainerBottom.isActive = true
|
|
||||||
|
|
||||||
title.topAnchor.constraint(equalTo: leftContainer.topAnchor).isActive = true
|
|
||||||
title.leadingAnchor.constraint(equalTo: leftContainer.leadingAnchor).isActive = true
|
|
||||||
title.trailingAnchor.constraint(equalTo: leftContainer.trailingAnchor).isActive = true
|
|
||||||
|
|
||||||
messageTopConstraint = message.topAnchor.constraint(equalTo: title.bottomAnchor, constant: PaddingOne)
|
|
||||||
messageTopConstraint?.isActive = true
|
|
||||||
|
|
||||||
message.leadingAnchor.constraint(equalTo: leftContainer.leadingAnchor).isActive = true
|
|
||||||
message.trailingAnchor.constraint(equalTo: leftContainer.trailingAnchor).isActive = true
|
|
||||||
|
|
||||||
buttonTopConstraint = button.topAnchor.constraint(equalTo: message.bottomAnchor, constant: PaddingTwo)
|
|
||||||
buttonTopConstraint?.isActive = true
|
|
||||||
|
|
||||||
button.leadingAnchor.constraint(equalTo: leftContainer.leadingAnchor).isActive = true
|
|
||||||
button.bottomAnchor.constraint(equalTo: leftContainer.bottomAnchor).isActive = true
|
|
||||||
leftContainer.trailingAnchor.constraint(greaterThanOrEqualTo: button.trailingAnchor).isActive = true
|
|
||||||
|
|
||||||
imageloader.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
|
||||||
layoutMarginsGuide.trailingAnchor.constraint(equalTo: imageloader.trailingAnchor).isActive = true
|
|
||||||
imageloader.leadingAnchor.constraint(equalTo: leftContainer.trailingAnchor, constant: 16).isActive = true
|
|
||||||
imageloader.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
|
||||||
|
|
||||||
imageHeightConstraint = imageloader.heightAnchor.constraint(equalToConstant: 0)
|
|
||||||
imageHeightConstraint?.isActive = true
|
|
||||||
|
|
||||||
imageWidthConstraint = imageloader.widthAnchor.constraint(equalToConstant: 0)
|
|
||||||
imageWidthConstraint?.isActive = true
|
|
||||||
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: imageloader.bottomAnchor).isActive = true
|
|
||||||
let imageloaderBottom = imageloader.bottomAnchor.constraint(equalTo: bottomAnchor)
|
|
||||||
imageloaderBottom.priority = UILayoutPriority(249)
|
|
||||||
imageloaderBottom.isActive = true
|
|
||||||
|
|
||||||
title.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 901), for: .horizontal)
|
|
||||||
message.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 902), for: .horizontal)
|
|
||||||
|
|
||||||
title.setContentHuggingPriority(.required, for: .vertical)
|
|
||||||
message.setContentHuggingPriority(.required, for: .vertical)
|
|
||||||
}
|
|
||||||
|
|
||||||
override open func updateView(_ size: CGFloat) {
|
|
||||||
super.updateView(size)
|
|
||||||
|
|
||||||
title.updateView(size)
|
|
||||||
message.updateView(size)
|
|
||||||
button.updateView(size)
|
|
||||||
imageloader.updateView(size)
|
|
||||||
leftContainer.updateView(size)
|
|
||||||
|
|
||||||
messageTopConstraint?.constant = title.hasText ? PaddingOne : 0
|
|
||||||
buttonTopConstraint?.constant = message.hasText ? PaddingTwo : (title.hasText ? PaddingOne : 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override open func reset() {
|
|
||||||
super.reset()
|
|
||||||
|
|
||||||
title.text = ""
|
|
||||||
message.text = ""
|
|
||||||
imageloader.imageView.image = nil
|
|
||||||
imageWidthConstraint?.constant = 0
|
|
||||||
backgroundColor = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
|
|
||||||
guard let dictionary = json else { return }
|
|
||||||
|
|
||||||
title.setWithJSON(dictionary.optionalDictionaryForKey("title"), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
message.setWithJSON(dictionary.optionalDictionaryForKey("message"), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
button.setWithJSON(dictionary.optionalDictionaryForKey("button"), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
imageloader.setWithJSON(dictionary.optionalDictionaryForKey("image"), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
|
|
||||||
if let imageJSON = dictionary.optionalDictionaryForKey("image") {
|
|
||||||
imageWidthConstraint?.constant = CGFloat(imageJSON.floatForKey("width"))
|
|
||||||
imageHeightConstraint?.constant = CGFloat(imageJSON.floatForKey("height"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user