From 57f82aa60a78eaae5e590a0d6282132c4de752f0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 12 Aug 2019 09:40:15 -0400 Subject: [PATCH] Call super reset in vcv. Further adjustments to atom. --- .../Atoms/Views/ActionDetailWithImage.swift | 23 ++++++++++++------- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ActionDetailWithImage.swift b/MVMCoreUI/Atoms/Views/ActionDetailWithImage.swift index b1b092ec..5e32bc00 100644 --- a/MVMCoreUI/Atoms/Views/ActionDetailWithImage.swift +++ b/MVMCoreUI/Atoms/Views/ActionDetailWithImage.swift @@ -24,7 +24,7 @@ import UIKit // MARK: - Properties //------------------------------------------------------ - var textPadding: CGFloat = PaddingOne + var titlePadding: CGFloat = PaddingOne //------------------------------------------------------ // MARK: - Constraints @@ -62,12 +62,12 @@ import UIKit override open func setupView() { super.setupView() - imageLoader.addSizeConstraintsForAspectRatio = true - guard subviews.isEmpty else { return } button.setAsSecondaryCustom() + button.isHidden = false imageLoader.imageView.contentMode = .scaleAspectFit + imageLoader.addSizeConstraintsForAspectRatio = true addSubview(leftContainer) addSubview(imageLoader) @@ -121,9 +121,9 @@ import UIKit imageLoader.updateView(size) leftContainer.updateView(size) - let titlePadding = title.hasText ? textPadding : 0 - messageTopConstraint?.constant = titlePadding - buttonTopConstraint?.constant = message.hasText ? PaddingTwo : titlePadding + let topPadding = title.hasText ? titlePadding : 0 + messageTopConstraint?.constant = topPadding + buttonTopConstraint?.constant = message.hasText ? PaddingTwo : topPadding } public override static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { @@ -152,11 +152,18 @@ import UIKit guard let dictionary = json else { return } - textPadding = dictionary.optionalCGFloatForKey("textPadding") ?? 0.0 + if let padding = dictionary.optionalCGFloatForKey("titlePadding") { + titlePadding = padding + } 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 buttonDictionary = dictionary.optionalDictionaryForKey("button") { + button.setWithJSON(buttonDictionary, delegateObject: delegateObject, additionalData: additionalData) + button.isHidden = false + } else { + button.isHidden = true + } } } diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index f46916b3..dff48826 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -336,6 +336,7 @@ } - (void)reset { + [super reset]; self.updateViewHorizontalDefaults = NO; self.updateViewVerticalDefaults = NO; if ([self.molecule respondsToSelector:@selector(alignment)]) {