Updated variable name. removed padding if image is not there.
This commit is contained in:
parent
55f20e0633
commit
ae7d757dbc
@ -17,7 +17,7 @@ import UIKit
|
||||
let title = Label.commonLabelH3(true)
|
||||
let message = Label.commonLabelB3(true)
|
||||
let button = PrimaryButton.primaryTinyButton(false)!
|
||||
let imageloader = MFLoadImageView()
|
||||
let imageLoader = MFLoadImageView()
|
||||
let leftContainer = ViewConstrainingView.empty()
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -26,6 +26,7 @@ import UIKit
|
||||
|
||||
var imageWidthConstraint: NSLayoutConstraint?
|
||||
var imageHeightConstraint: NSLayoutConstraint?
|
||||
var imageLeadingConstraint: NSLayoutConstraint?
|
||||
var buttonTopConstraint: NSLayoutConstraint?
|
||||
var messageTopConstraint: NSLayoutConstraint?
|
||||
|
||||
@ -60,11 +61,10 @@ import UIKit
|
||||
guard subviews.isEmpty else { return }
|
||||
|
||||
button.setAsSecondaryCustom()
|
||||
|
||||
imageloader.imageView.contentMode = .scaleAspectFit
|
||||
imageLoader.imageView.contentMode = .scaleAspectFit
|
||||
|
||||
addSubview(leftContainer)
|
||||
addSubview(imageloader)
|
||||
addSubview(imageLoader)
|
||||
leftContainer.addSubview(title)
|
||||
leftContainer.addSubview(message)
|
||||
leftContainer.addSubview(button)
|
||||
@ -94,19 +94,20 @@ import UIKit
|
||||
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
|
||||
imageLoader.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||
layoutMarginsGuide.trailingAnchor.constraint(equalTo: imageLoader.trailingAnchor).isActive = true
|
||||
imageLeadingConstraint = imageLoader.leadingAnchor.constraint(greaterThanOrEqualTo: leftContainer.trailingAnchor, constant: 16)
|
||||
imageLeadingConstraint?.isActive = true
|
||||
imageLoader.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||
|
||||
imageHeightConstraint = imageloader.heightAnchor.constraint(equalToConstant: 0)
|
||||
imageHeightConstraint = imageLoader.heightAnchor.constraint(equalToConstant: 0)
|
||||
imageHeightConstraint?.isActive = true
|
||||
|
||||
imageWidthConstraint = imageloader.widthAnchor.constraint(equalToConstant: 0)
|
||||
|
||||
imageWidthConstraint = imageLoader.widthAnchor.constraint(equalToConstant: 0)
|
||||
imageWidthConstraint?.isActive = true
|
||||
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: imageloader.bottomAnchor).isActive = true
|
||||
let imageloaderBottom = imageloader.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: imageLoader.bottomAnchor).isActive = true
|
||||
let imageloaderBottom = imageLoader.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
imageloaderBottom.priority = UILayoutPriority(249)
|
||||
imageloaderBottom.isActive = true
|
||||
}
|
||||
@ -117,11 +118,15 @@ import UIKit
|
||||
title.updateView(size)
|
||||
message.updateView(size)
|
||||
button.updateView(size)
|
||||
imageloader.updateView(size)
|
||||
imageLoader.updateView(size)
|
||||
leftContainer.updateView(size)
|
||||
|
||||
messageTopConstraint?.constant = title.hasText ? PaddingOne : 0
|
||||
buttonTopConstraint?.constant = message.hasText ? PaddingTwo : (title.hasText ? PaddingOne : 0)
|
||||
|
||||
if imageWidthConstraint?.constant == 0 {
|
||||
imageLeadingConstraint?.constant = 0
|
||||
}
|
||||
}
|
||||
|
||||
override open func reset() {
|
||||
@ -129,8 +134,9 @@ import UIKit
|
||||
|
||||
title.text = ""
|
||||
message.text = ""
|
||||
imageloader.imageView.image = nil
|
||||
imageLoader.imageView.image = nil
|
||||
imageWidthConstraint?.constant = 0
|
||||
imageLeadingConstraint?.constant = 16
|
||||
backgroundColor = nil
|
||||
}
|
||||
|
||||
@ -142,7 +148,7 @@ import UIKit
|
||||
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)
|
||||
imageLoader.setWithJSON(dictionary.optionalDictionaryForKey("image"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
if let imageJSON = dictionary.optionalDictionaryForKey("image") {
|
||||
imageWidthConstraint?.constant = CGFloat(imageJSON.floatForKey("width"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user