diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index 619e31e7..fe902d9f 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -76,7 +76,7 @@ import UIKit override open func setupView() { super.setupView() translatesAutoresizingMaskIntoConstraints = false - backgroundColor = .mfSilver() + backgroundColor = .mfLightSilver() clipsToBounds = true if thicknessConstraint == nil { thicknessConstraint = heightAnchor.constraint(equalToConstant: defaultHeight) @@ -84,6 +84,12 @@ import UIKit } } + open override func reset() { + super.reset() + backgroundColor = .mfLightSilver() + progressList = nil + } + override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) thicknessConstraint?.constant = json?.optionalCGFloatForKey("thickness") ?? defaultHeight diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 5416f0a7..a9333966 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -70,7 +70,7 @@ import Foundation thickness = 8 progress = 0 progressTintColor = UIColor.mfCerulean() - trackTintColor = UIColor.mfSilver() + trackTintColor = UIColor.mfLightSilver() } public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h index a5e359d0..df443afd 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h @@ -34,6 +34,9 @@ @property (nonatomic) BOOL updateViewHorizontalDefaults; @property (nonatomic) BOOL updateViewVerticalDefaults; +@property (nonatomic) CGFloat topMarginPadding; +@property (nonatomic) CGFloat bottomMarginPadding; + /// A molecule if we constrain one. @property (weak, nullable, nonatomic) UIView *molecule; diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index ba5f1bd0..66a3a83d 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -304,18 +304,15 @@ [super setupView]; self.translatesAutoresizingMaskIntoConstraints = NO; self.backgroundColor = [UIColor clearColor]; + self.topMarginPadding = PaddingDefaultVerticalSpacing3; + self.bottomMarginPadding = PaddingDefaultVerticalSpacing3; [MVMCoreUIUtility setMarginsForView:self leading:0 top:0 trailing:0 bottom:0]; } - (void)updateView:(CGFloat)size { [super updateView:size]; - if ([self.constrainedView respondsToSelector:@selector(updateView:)]) { - [((id)self.constrainedView) updateView:size]; - } - if (self.molecule != self.constrainedView) { - [self.molecule updateView:size]; - } - [MFStyler setDefaultMarginsForView:self size:size horizontal:self.updateViewHorizontalDefaults vertical:self.updateViewVerticalDefaults]; + [self.molecule updateView:size]; + [MFStyler setMarginsForView:self size:size defaultHorizontal:self.updateViewHorizontalDefaults top:(self.updateViewVerticalDefaults ? self.topMarginPadding : 0) bottom:(self.updateViewVerticalDefaults ? self.bottomMarginPadding : 0)]; UIEdgeInsets margins = [MVMCoreUIUtility getMarginsForView:self]; if (self.updateViewHorizontalDefaults) { [self setLeftPinConstant:margins.left]; @@ -344,6 +341,8 @@ [super reset]; self.updateViewHorizontalDefaults = NO; self.updateViewVerticalDefaults = NO; + self.topMarginPadding = PaddingDefaultVerticalSpacing3; + self.bottomMarginPadding = PaddingDefaultVerticalSpacing3; if ([self.molecule respondsToSelector:@selector(alignment)]) { [self alignHorizontal:[(UIView *)self.molecule alignment]]; } @@ -354,8 +353,10 @@ } - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; - + // Only treated as a container if we are constraining a molecule. + if (!self.constrainedView) { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; + } [self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if (self.shouldSetupMoleculeFromJSON) { NSDictionary *moleculeJSON = [json dict:KeyMolecule]; diff --git a/MVMCoreUI/Molecules/Scroller.swift b/MVMCoreUI/Molecules/Scroller.swift index cd2949d8..e4289bc3 100644 --- a/MVMCoreUI/Molecules/Scroller.swift +++ b/MVMCoreUI/Molecules/Scroller.swift @@ -19,7 +19,8 @@ import UIKit } translatesAutoresizingMaskIntoConstraints = false scrollView.translatesAutoresizingMaskIntoConstraints = false - addConstrainedView(scrollView) + addSubview(scrollView) + pinView(toSuperView: scrollView) scrollView.addSubview(contentView) NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) let constraint = contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, multiplier: 1.0) diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index f00af028..7734883e 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -11,6 +11,8 @@ import UIKit open class StandardFooterView: ViewConstrainingView { open override func setupView() { super.setupView() + topMarginPadding = PaddingDefaultVerticalSpacing + bottomMarginPadding = PaddingDefaultVerticalSpacing shouldSetupMoleculeFromJSON = true updateViewVerticalDefaults = true updateViewHorizontalDefaults = true diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 093a2e31..12819313 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -22,6 +22,8 @@ public class StandardHeaderView: ViewConstrainingView { shouldSetupMoleculeFromJSON = true updateViewVerticalDefaults = true updateViewHorizontalDefaults = true + topMarginPadding = PaddingDefaultVerticalSpacing + bottomMarginPadding = PaddingDefaultVerticalSpacing if separatorView == nil, let separatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot, withHorizontalPadding: 0) { separatorView.setAsHeavy() addSubview(separatorView) @@ -54,6 +56,8 @@ public class StandardHeaderView: ViewConstrainingView { open override func reset() { super.reset() + topMarginPadding = PaddingDefaultVerticalSpacing + bottomMarginPadding = PaddingDefaultVerticalSpacing separatorView?.setAsHeavy() separatorView?.show() } diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index db30c8d6..e63eb2ba 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -32,6 +32,8 @@ open class HeadlineBody: ViewConstrainingView { stylePageHeader() case "item": styleListItem() + case "itemHeader": + styleListItemDivider() default: break } } @@ -53,6 +55,12 @@ open class HeadlineBody: ViewConstrainingView { messageLabel.styleB2(true) spaceBetweenLabelsConstant = 0 } + + func styleListItemDivider() { + headlineLabel.styleH3(true) + messageLabel.styleB2(true) + spaceBetweenLabelsConstant = 0 + } // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { @@ -80,10 +88,9 @@ open class HeadlineBody: ViewConstrainingView { headlineLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) messageLabel.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) - setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) + view.setContentHuggingPriority(UILayoutPriority.required, for: NSLayoutConstraint.Axis.vertical) - topPin = headlineLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 0) - topPin?.isActive = true + headlineLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true spaceBetweenLabels = messageLabel.topAnchor.constraint(equalTo: headlineLabel.bottomAnchor, constant: spaceBetweenLabelsConstant) spaceBetweenLabels?.isActive = true @@ -100,8 +107,7 @@ open class HeadlineBody: ViewConstrainingView { rightConstraintMessage = view.rightAnchor.constraint(equalTo: messageLabel.rightAnchor) rightConstraintMessage?.isActive = true - bottomPin = view.bottomAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 0) - bottomPin?.isActive = true + view.bottomAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 0).isActive = true } // MARK: - Constraining