updates made to padding and reset/module functionality.
This commit is contained in:
parent
57f82aa60a
commit
fd8b8fb7b7
@ -24,7 +24,7 @@ import UIKit
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
var titlePadding: CGFloat = PaddingOne
|
var bottomTitlePadding: CGFloat = PaddingOne
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
@ -64,10 +64,7 @@ import UIKit
|
|||||||
|
|
||||||
guard subviews.isEmpty else { return }
|
guard subviews.isEmpty else { return }
|
||||||
|
|
||||||
button.setAsSecondaryCustom()
|
setDefaultState()
|
||||||
button.isHidden = false
|
|
||||||
imageLoader.imageView.contentMode = .scaleAspectFit
|
|
||||||
imageLoader.addSizeConstraintsForAspectRatio = true
|
|
||||||
|
|
||||||
addSubview(leftContainer)
|
addSubview(leftContainer)
|
||||||
addSubview(imageLoader)
|
addSubview(imageLoader)
|
||||||
@ -121,9 +118,11 @@ import UIKit
|
|||||||
imageLoader.updateView(size)
|
imageLoader.updateView(size)
|
||||||
leftContainer.updateView(size)
|
leftContainer.updateView(size)
|
||||||
|
|
||||||
let topPadding = title.hasText ? titlePadding : 0
|
let titleMessagePadding = title.hasText ? bottomTitlePadding : 0
|
||||||
messageTopConstraint?.constant = topPadding
|
let messageButtonPadding = message.hasText ? titleMessagePadding : 0
|
||||||
buttonTopConstraint?.constant = message.hasText ? PaddingTwo : topPadding
|
|
||||||
|
messageTopConstraint?.constant = messageButtonPadding
|
||||||
|
buttonTopConstraint?.constant = message.hasText ? PaddingTwo : messageButtonPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
public override static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
public override static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
@ -134,17 +133,38 @@ import UIKit
|
|||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
private func setDefaultState() {
|
||||||
|
|
||||||
|
title.font = MFStyler.fontH3()
|
||||||
|
message.font = MFStyler.fontB3()
|
||||||
|
button.setAsSecondaryCustom()
|
||||||
|
button.isHidden = false
|
||||||
|
imageLoader.imageView.contentMode = .scaleAspectFit
|
||||||
|
imageLoader.addSizeConstraintsForAspectRatio = true
|
||||||
|
bottomTitlePadding = PaddingOne
|
||||||
|
}
|
||||||
|
|
||||||
override open func reset() {
|
override open func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
title.text = ""
|
title.reset()
|
||||||
message.text = ""
|
message.reset()
|
||||||
|
button.reset()
|
||||||
imageLeadingConstraint?.constant = 16
|
imageLeadingConstraint?.constant = 16
|
||||||
imageLoader.reset()
|
imageLoader.reset()
|
||||||
|
|
||||||
|
setDefaultState()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setAsMolecule() {
|
open override func setAsMolecule() {
|
||||||
super.setAsMolecule()
|
super.setAsMolecule()
|
||||||
|
|
||||||
|
title.setAsMolecule()
|
||||||
|
message.setAsMolecule()
|
||||||
|
button.setAsMolecule()
|
||||||
|
imageLoader.setAsMolecule()
|
||||||
|
|
||||||
|
setDefaultState()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
@ -152,8 +172,8 @@ import UIKit
|
|||||||
|
|
||||||
guard let dictionary = json else { return }
|
guard let dictionary = json else { return }
|
||||||
|
|
||||||
if let padding = dictionary.optionalCGFloatForKey("titlePadding") {
|
if let padding = dictionary.optionalCGFloatForKey("bottomTitlePadding") {
|
||||||
titlePadding = padding
|
bottomTitlePadding = padding
|
||||||
}
|
}
|
||||||
|
|
||||||
title.setWithJSON(dictionary.optionalDictionaryForKey("title"), delegateObject: delegateObject, additionalData: additionalData)
|
title.setWithJSON(dictionary.optionalDictionaryForKey("title"), delegateObject: delegateObject, additionalData: additionalData)
|
||||||
@ -161,7 +181,6 @@ import UIKit
|
|||||||
imageLoader.setWithJSON(dictionary.optionalDictionaryForKey("image"), delegateObject: delegateObject, additionalData: additionalData)
|
imageLoader.setWithJSON(dictionary.optionalDictionaryForKey("image"), delegateObject: delegateObject, additionalData: additionalData)
|
||||||
if let buttonDictionary = dictionary.optionalDictionaryForKey("button") {
|
if let buttonDictionary = dictionary.optionalDictionaryForKey("button") {
|
||||||
button.setWithJSON(buttonDictionary, delegateObject: delegateObject, additionalData: additionalData)
|
button.setWithJSON(buttonDictionary, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
button.isHidden = false
|
|
||||||
} else {
|
} else {
|
||||||
button.isHidden = true
|
button.isHidden = true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user