From ba55ec7575725f82846b577508b6062977a35f9d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 11 Mar 2019 13:52:34 -0400 Subject: [PATCH 1/4] text button molecule standardFooter molecule --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atoms/Buttons/MFTextButton.h | 2 +- MVMCoreUI/Atoms/Buttons/MFTextButton.m | 17 +++ MVMCoreUI/Atoms/Views/LabelView.h | 2 +- MVMCoreUI/Atoms/Views/LabelView.m | 5 + MVMCoreUI/Atoms/Views/MFView.m | 2 + MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 6 + .../ThreeLayerViewController.swift | 6 +- MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift | 1 - .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 5 + MVMCoreUI/Molecules/PrimaryButtonView.m | 4 +- MVMCoreUI/Molecules/StandardFooterView.swift | 111 ++++++++++++++++++ .../MVMCoreUIMoleculeMappingObject.m | 13 +- MVMCoreUI/Utility/MVMCoreUIUtility.m | 2 + 14 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 MVMCoreUI/Molecules/StandardFooterView.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 856b15bb..2a45ba3b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */; }; D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */; }; + D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D28B4F8A21FF967C00712C7A /* MVMCoreUIObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; @@ -174,6 +175,7 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISwitch.m; sourceTree = ""; }; D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = ""; }; D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = ""; }; + D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = ""; }; D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIObject.h; sourceTree = ""; }; D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIObject.m; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; @@ -424,6 +426,7 @@ D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */, D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, D2A5145E2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift */, + D274CA322236A78900B01B62 /* StandardFooterView.swift */, ); path = Molecules; sourceTree = ""; @@ -886,6 +889,7 @@ D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, D29DF26121E6A985003B2FB9 /* MFLoadImageView.m in Sources */, + D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.h b/MVMCoreUI/Atoms/Buttons/MFTextButton.h index ef24ea2d..ec37589b 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.h @@ -10,7 +10,7 @@ #import @class MFSizeObject; -@interface MFTextButton : MFCustomButton +@interface MFTextButton : MFCustomButton @property (nonnull, strong, nonatomic) MFSizeObject *sizeObject; diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index f9423c30..ff4c372c 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -11,8 +11,10 @@ #import #import "UIColor+MFConvenience.h" #import "MVMCoreUISplitViewController.h" +#import "MVMCoreUIConstants.h" @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreGetterUtility; +@import MVMCore.NSDictionary_MFConvenience; @interface MFTextButton () @@ -124,4 +126,19 @@ return theButton; } +#pragma mark - MVMCoreUIMoleculeViewProtocol + +- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { + NSString *color = [json string:KeyTextColor]; + if (color) { + [self setTitleColor:[UIColor mfGetColorForHex:color] forState:UIControlStateNormal]; + } + [self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; + if ([self titleForState:UIControlStateNormal].length == 0) { + self.heightConstraint.constant = 0; + } else { + self.heightConstraint.constant = self.sizeObject.standardSize; + } +} + @end diff --git a/MVMCoreUI/Atoms/Views/LabelView.h b/MVMCoreUI/Atoms/Views/LabelView.h index 6e20d0b6..b5c259e3 100644 --- a/MVMCoreUI/Atoms/Views/LabelView.h +++ b/MVMCoreUI/Atoms/Views/LabelView.h @@ -10,7 +10,7 @@ #import #import -@interface LabelView : ViewConstrainingView +@interface LabelView : ViewConstrainingView // Customize the label. @property (nullable, weak, nonatomic) MFLabel *label; diff --git a/MVMCoreUI/Atoms/Views/LabelView.m b/MVMCoreUI/Atoms/Views/LabelView.m index 6136e897..f1d7b2f0 100644 --- a/MVMCoreUI/Atoms/Views/LabelView.m +++ b/MVMCoreUI/Atoms/Views/LabelView.m @@ -72,6 +72,11 @@ } } +- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegate:delegate additionalData:additionalData]; + [self.label setWithJSON:json delegate:delegate additionalData:additionalData]; +} + - (void)alignLeft { self.alignCenterPin.active = NO; self.alignCenterLeftPin.active = NO; diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Atoms/Views/MFView.m index afe3476a..40df33a2 100644 --- a/MVMCoreUI/Atoms/Views/MFView.m +++ b/MVMCoreUI/Atoms/Views/MFView.m @@ -41,6 +41,8 @@ - (void)updateView:(CGFloat)size { } +#pragma mark - MVMCoreUIMoleculeViewProtocol + - (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { } diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index c8ecd3d6..a88b61c3 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -135,4 +135,10 @@ } } +#pragma mark - MVMCoreUIMoleculeViewProtocol + +- (void)setAsMolecule { + self.updateViewHorizontalDefaults = YES; +} + @end diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index 5d802e7b..6675b766 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -181,7 +181,7 @@ extension ThreeLayerViewController { contentView.addSubview(bottomSpacer) bottomSpacer.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true contentView.rightAnchor.constraint(equalTo: bottomSpacer.rightAnchor).isActive = true - bottomSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: PaddingDefaultVerticalSpacing).isActive = true + bottomSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true middleView.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: spaceAbove).isActive = true bottomSpacer.topAnchor.constraint(equalTo: middleView.bottomAnchor).isActive = true bottomView.topAnchor.constraint(equalTo: bottomSpacer.bottomAnchor).isActive = true @@ -191,7 +191,7 @@ extension ThreeLayerViewController { contentView.addSubview(topSpacer) topSpacer.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true contentView.rightAnchor.constraint(equalTo: topSpacer.rightAnchor).isActive = true - topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: PaddingDefaultVerticalSpacing).isActive = true + topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true topSpacer.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true middleView.topAnchor.constraint(equalTo: topSpacer.bottomAnchor).isActive = true bottomView.topAnchor.constraint(equalTo: middleView.bottomAnchor, constant: spaceBelow).isActive = true @@ -206,7 +206,7 @@ extension ThreeLayerViewController { bottomSpacer.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true contentView.rightAnchor.constraint(equalTo: bottomSpacer.rightAnchor).isActive = true topSpacer.heightAnchor.constraint(equalTo: bottomSpacer.heightAnchor).isActive = true - topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: PaddingDefaultVerticalSpacing).isActive = true + topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true topSpacer.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true middleView.topAnchor.constraint(equalTo: topSpacer.bottomAnchor).isActive = true bottomSpacer.topAnchor.constraint(equalTo: middleView.bottomAnchor).isActive = true diff --git a/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift b/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift index a1a0ffba..c8ca1b9b 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift +++ b/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift @@ -33,7 +33,6 @@ public class MVMCoreUIHeaderView: ViewConstrainingView { translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear clipsToBounds = true - updateViewHorizontalDefaults = true addSubview(headlineLabel) addSubview(messageLabel) diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index cfb28c3f..3dd8de67 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -13,6 +13,11 @@ // Sets up the ui based on the json - (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; +@optional + +// Called after init to provide an early setter for any molecule specific logic +- (void)setAsMolecule; + @end diff --git a/MVMCoreUI/Molecules/PrimaryButtonView.m b/MVMCoreUI/Molecules/PrimaryButtonView.m index 818f6785..16ce03ed 100644 --- a/MVMCoreUI/Molecules/PrimaryButtonView.m +++ b/MVMCoreUI/Molecules/PrimaryButtonView.m @@ -42,7 +42,7 @@ if (backgroundColorString) { self.backgroundColor = [UIColor mfGetColorForHex:backgroundColorString]; } - [self setupWithFirstButtonJSON:[json dict:@"FirstButton"] secondButtonJSON:[json dict:@"SecondButton"] additionalData:nil actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; + [self setupWithFirstButtonJSON:[json dict:@"firstButton"] secondButtonJSON:[json dict:@"secondButton"] additionalData:nil actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; } #pragma mark - Inits @@ -115,7 +115,7 @@ } - (void)setupWithFirstButtonJSON:(nullable NSDictionary *)firstButtonJSON secondButtonJSON:(nullable NSDictionary *)secondButtonJSON additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject *)actionDelegate buttonDelegate:(nullable id )buttonDelegate { - [self setupWithPrimaryButtonMap:firstButtonJSON secondaryButtonMap:secondButtonJSON additionalData:additionalData actionDelegate:actionDelegate buttonDelegate:buttonDelegate legacyJSON:NO]; + [self setupWithPrimaryButtonMap:secondButtonJSON secondaryButtonMap:firstButtonJSON additionalData:additionalData actionDelegate:actionDelegate buttonDelegate:buttonDelegate legacyJSON:NO]; } - (void)setupWithPrimaryButtonMap:(nullable NSDictionary *)primaryButtonMap secondaryButtonMap:(nullable NSDictionary *)secondaryButtonMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate { diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift new file mode 100644 index 00000000..a0b42bbd --- /dev/null +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -0,0 +1,111 @@ +// +// StandardFooterView.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/11/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +public class StandardFooterView: ViewConstrainingView { + let twoButtonView = PrimaryButtonView(frame: .zero) + var textButton = MFTextButton(nil, constrainHeight: true, forWidth: MVMCoreUIUtility.getWidth()) + var spaceBetweenButtons: NSLayoutConstraint? + var leftConstraintTwoButton: NSLayoutConstraint? + var rightConstraintTwoButton: NSLayoutConstraint? + var leftConstraintTextButton: NSLayoutConstraint? + var rightConstraintTextButton: NSLayoutConstraint? + var centerAlignTextButton: NSLayoutConstraint? + private var heightConstraint: NSLayoutConstraint? + + public override func updateView(_ size: CGFloat) { + super.updateView(size) + twoButtonView.updateView(size) + textButton.updateView(size) + setSpacing() + } + + public override func setupView() { + super.setupView() + if subviews.count == 0 { + translatesAutoresizingMaskIntoConstraints = false + backgroundColor = .clear + clipsToBounds = true + + addSubview(twoButtonView) + addSubview(textButton) + + topPin = twoButtonView.topAnchor.constraint(equalTo: topAnchor, constant: PaddingDefaultVerticalSpacing) + topPin?.isActive = true + + spaceBetweenButtons = textButton.topAnchor.constraint(equalTo: twoButtonView.bottomAnchor, constant: PaddingTwo) + spaceBetweenButtons?.isActive = true + + leftConstraintTwoButton = twoButtonView.leftAnchor.constraint(equalTo: leftAnchor) + leftConstraintTwoButton?.isActive = true + + rightConstraintTwoButton = rightAnchor.constraint(equalTo: twoButtonView.rightAnchor) + rightConstraintTwoButton?.isActive = true + + leftConstraintTextButton = textButton.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor) + leftConstraintTextButton?.isActive = true + + rightConstraintTextButton = rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor) + rightConstraintTextButton?.isActive = true + + centerAlignTextButton = textButton.centerXAnchor.constraint(equalTo: centerXAnchor) + centerAlignTextButton?.isActive = true + + bottomPin = bottomAnchor.constraint(equalTo: textButton.bottomAnchor, constant: PaddingDefaultVerticalSpacing) + bottomPin?.isActive = true + + heightConstraint = heightAnchor.constraint(equalToConstant: 0) + } + } + + public func setSpacing() { + if twoButtonView.subviews.count > 0 && textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 { + spaceBetweenButtons?.constant = PaddingTwo + show() + } else if twoButtonView.subviews.count > 0 || textButton.title(for: UIControl.State.normal)?.count ?? 0 > 0 { + spaceBetweenButtons?.constant = 0 + show() + } else { + hide() + } + } + + public override func show() { + super.show() + heightConstraint?.isActive = false + topPin?.isActive = true + layoutIfNeeded() + } + + public override func hide() { + super.hide() + heightConstraint?.isActive = true + topPin?.isActive = false + layoutIfNeeded() + } + + public override func setLeftPinConstant(_ constant: CGFloat) { + leftConstraintTwoButton?.constant = constant + leftConstraintTextButton?.constant = constant + } + + public override func setRightPinConstant(_ constant: CGFloat) { + rightConstraintTwoButton?.constant = constant + rightConstraintTextButton?.constant = constant + } + + public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { + backgroundColor = .mfGet(forHex: colorString) + } + twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegate: delegate, additionalData: additionalData) + textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegate: delegate, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index a18be0a4..fcd8eb7b 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -21,9 +21,14 @@ static NSMutableDictionary *mapping; dispatch_once(&onceToken, ^{ mapping = [@{ + @"label": LabelView.class, + @"separator": SeparatorView.class, + @"button": MFCustomButton.class, + @"textButton": MFTextButton.class, @"standardHeader": MVMCoreUIHeaderView.class, @"moleculeStack": MVMCoreUIMoleculeStackView.class, - @"twoButtonView": PrimaryButtonView.class + @"twoButtonView": PrimaryButtonView.class, + @"standardFooter": StandardFooterView.class } mutableCopy]; }); return mapping; @@ -37,7 +42,11 @@ - (nullable UIView *)getMoleculeForName:(nonnull NSString *)name { Class class = [self.moleculeMapping objectForKey:name]; if (class) { - return [[class alloc] init]; + UIView *view = [[class alloc] init]; + if ([view respondsToSelector:@selector(setAsMolecule)]) { + [view setAsMolecule]; + } + return view; } return nil; } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index c0135d4f..1afabeab 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -9,6 +9,8 @@ #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" #import "MVMCoreUISession.h" +#import "MVMCoreUINavigationController.h" +#import "MVMCoreUISplitViewController.h" @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; From eabb0c0384ca7b78b6b1fb4cf3689a32f87b6d39 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 11 Mar 2019 14:08:28 -0400 Subject: [PATCH 2/4] file name fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 24 +++++++++---------- ...tackView.swift => MoleculeStackView.swift} | 4 ++-- ...derView.swift => StandardHeaderView.swift} | 4 ++-- .../MVMCoreUIMoleculeMappingObject.m | 4 ++-- .../MVMCoreUIViewControllerMappingObject.m | 2 +- .../MoleculeStackCenteredTemplate.swift | 2 +- .../Templates/MoleculeStackTemplate.swift | 2 +- ... => TextFieldListFormViewController.swift} | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) rename MVMCoreUI/Molecules/{MVMCoreUIMoleculeStackView.swift => MoleculeStackView.swift} (97%) rename MVMCoreUI/Molecules/{MVMCoreUIHeaderView.swift => StandardHeaderView.swift} (98%) rename MVMCoreUI/Templates/{MVMCoreUITextFieldListFormViewController.swift => TextFieldListFormViewController.swift} (94%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2a45ba3b..bae49737 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; - 01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */; }; + 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -151,10 +151,10 @@ D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; }; D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D2A5145F2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5145E2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift */; }; + D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */; }; D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */; }; D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */; }; - D2A514672213885800345BFB /* MVMCoreUIHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */; }; + D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A514662213885800345BFB /* StandardHeaderView.swift */; }; D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; @@ -164,7 +164,7 @@ /* Begin PBXFileReference section */ 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; - 01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVMCoreUITextFieldListFormViewController.swift; sourceTree = ""; }; + 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D22D1F18220341F50077CEC0 /* MVMCoreUICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICheckBox.h; sourceTree = ""; }; @@ -311,10 +311,10 @@ D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = ""; }; D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = ""; }; D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; sourceTree = ""; }; - D2A5145E2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIMoleculeStackView.swift; sourceTree = ""; }; + D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackView.swift; sourceTree = ""; }; D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackTemplate.swift; sourceTree = ""; }; D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackCenteredTemplate.swift; sourceTree = ""; }; - D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIHeaderView.swift; sourceTree = ""; }; + D2A514662213885800345BFB /* StandardHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardHeaderView.swift; sourceTree = ""; }; D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; @@ -389,7 +389,7 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( - 01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */, + 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, ); @@ -423,9 +423,9 @@ D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */, D29770F721F7C73800B2F0D0 /* PrimaryButtonView.m */, - D2A514662213885800345BFB /* MVMCoreUIHeaderView.swift */, + D2A514662213885800345BFB /* StandardHeaderView.swift */, D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, - D2A5145E2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift */, + D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D274CA322236A78900B01B62 /* StandardFooterView.swift */, ); path = Molecules; @@ -871,15 +871,15 @@ D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, - 01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */, - D2A5145F2211DDC100345BFB /* MVMCoreUIMoleculeStackView.swift in Sources */, + 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, + D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D29DF26521E6A9D9003B2FB9 /* MFTransparentGIFView.m in Sources */, - D2A514672213885800345BFB /* MVMCoreUIHeaderView.swift in Sources */, + D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeStackView.swift b/MVMCoreUI/Molecules/MoleculeStackView.swift similarity index 97% rename from MVMCoreUI/Molecules/MVMCoreUIMoleculeStackView.swift rename to MVMCoreUI/Molecules/MoleculeStackView.swift index e8f6cc26..a9ea7d8e 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeStackView.swift +++ b/MVMCoreUI/Molecules/MoleculeStackView.swift @@ -1,5 +1,5 @@ // -// MVMCoreUIMoleculeStackView.swift +// MoleculeStackView.swift // MVMCoreUI // // Created by Scott Pfeil on 2/11/19. @@ -8,7 +8,7 @@ import UIKit -public class MVMCoreUIMoleculeStackView: MFView { +public class MoleculeStackView: MFView { var spacingBlock: ((Any) -> UIEdgeInsets)? var moleculesArray: [UIView]? diff --git a/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift similarity index 98% rename from MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift rename to MVMCoreUI/Molecules/StandardHeaderView.swift index c8ca1b9b..8c05a4c6 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -1,5 +1,5 @@ // -// MVMCoreUIHeaderView.swift +// StandardHeaderView.swift // MVMCoreUI // // Created by Scott Pfeil on 2/12/19. @@ -8,7 +8,7 @@ import UIKit -public class MVMCoreUIHeaderView: ViewConstrainingView { +public class StandardHeaderView: ViewConstrainingView { let headlineLabel = MFLabel.commonLabelH2(true) let messageLabel = MFLabel.commonLabelB2(true) var separatorView: SeparatorView? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index fcd8eb7b..3c36a612 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -25,8 +25,8 @@ @"separator": SeparatorView.class, @"button": MFCustomButton.class, @"textButton": MFTextButton.class, - @"standardHeader": MVMCoreUIHeaderView.class, - @"moleculeStack": MVMCoreUIMoleculeStackView.class, + @"standardHeader": StandardHeaderView.class, + @"moleculeStack": MoleculeStackView.class, @"twoButtonView": PrimaryButtonView.class, @"standardFooter": StandardFooterView.class } mutableCopy]; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 2e135ece..841a7e60 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -19,7 +19,7 @@ static NSMutableDictionary *viewControllerMapping; dispatch_once(&onceToken, ^{ viewControllerMapping = [@{ - @"textFieldListForm" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MVMCoreUITextFieldListFormViewController class]], + @"textFieldListForm" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[TextFieldListFormViewController class]], @"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]] } mutableCopy]; diff --git a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift index 2a81afaa..7f7411a3 100644 --- a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift @@ -12,7 +12,7 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { public override func viewForMiddle() -> UIView? { let molecule = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") - let moleculeStack = MVMCoreUIMoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil) + let moleculeStack = MoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil) return moleculeStack } diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index b2349d70..2910782d 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -26,7 +26,7 @@ public class MoleculeStackTemplate: ThreeLayerViewController { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") else { return nil } - return MVMCoreUIMoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil) + return MoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil) } override public func viewForBottom() -> UIView? { diff --git a/MVMCoreUI/Templates/MVMCoreUITextFieldListFormViewController.swift b/MVMCoreUI/Templates/TextFieldListFormViewController.swift similarity index 94% rename from MVMCoreUI/Templates/MVMCoreUITextFieldListFormViewController.swift rename to MVMCoreUI/Templates/TextFieldListFormViewController.swift index 6225e429..bf3b0bea 100644 --- a/MVMCoreUI/Templates/MVMCoreUITextFieldListFormViewController.swift +++ b/MVMCoreUI/Templates/TextFieldListFormViewController.swift @@ -8,7 +8,7 @@ import UIKit -public class MVMCoreUITextFieldListFormViewController: TopLabelsAndBottomButtonsViewController { +public class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewController { public var textFieldListView: MFTextFieldListView? From bf656cffea81d9325c8e421b9ad6d17420d10827 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 11 Mar 2019 14:41:33 -0400 Subject: [PATCH 3/4] Padding two --- MVMCoreUI/Atoms/Views/LabelView.h | 2 +- MVMCoreUI/BaseControllers/ThreeLayerViewController.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LabelView.h b/MVMCoreUI/Atoms/Views/LabelView.h index b5c259e3..6e20d0b6 100644 --- a/MVMCoreUI/Atoms/Views/LabelView.h +++ b/MVMCoreUI/Atoms/Views/LabelView.h @@ -10,7 +10,7 @@ #import #import -@interface LabelView : ViewConstrainingView +@interface LabelView : ViewConstrainingView // Customize the label. @property (nullable, weak, nonatomic) MFLabel *label; diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index 6675b766..756dd8e8 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -191,7 +191,7 @@ extension ThreeLayerViewController { contentView.addSubview(topSpacer) topSpacer.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true contentView.rightAnchor.constraint(equalTo: topSpacer.rightAnchor).isActive = true - topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true + topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: PaddingTwo).isActive = true topSpacer.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true middleView.topAnchor.constraint(equalTo: topSpacer.bottomAnchor).isActive = true bottomView.topAnchor.constraint(equalTo: middleView.bottomAnchor, constant: spaceBelow).isActive = true @@ -206,7 +206,7 @@ extension ThreeLayerViewController { bottomSpacer.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true contentView.rightAnchor.constraint(equalTo: bottomSpacer.rightAnchor).isActive = true topSpacer.heightAnchor.constraint(equalTo: bottomSpacer.heightAnchor).isActive = true - topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true + topSpacer.heightAnchor.constraint(greaterThanOrEqualToConstant: PaddingTwo).isActive = true topSpacer.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true middleView.topAnchor.constraint(equalTo: topSpacer.bottomAnchor).isActive = true bottomSpacer.topAnchor.constraint(equalTo: middleView.bottomAnchor).isActive = true From be045ac4a9ad4866503805cb26f8c028df801b6b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 11 Mar 2019 14:45:21 -0400 Subject: [PATCH 4/4] Guard --- MVMCoreUI/Molecules/StandardFooterView.swift | 67 ++++++++++---------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index a0b42bbd..1e1f7b76 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -28,40 +28,41 @@ public class StandardFooterView: ViewConstrainingView { public override func setupView() { super.setupView() - if subviews.count == 0 { - translatesAutoresizingMaskIntoConstraints = false - backgroundColor = .clear - clipsToBounds = true - - addSubview(twoButtonView) - addSubview(textButton) - - topPin = twoButtonView.topAnchor.constraint(equalTo: topAnchor, constant: PaddingDefaultVerticalSpacing) - topPin?.isActive = true - - spaceBetweenButtons = textButton.topAnchor.constraint(equalTo: twoButtonView.bottomAnchor, constant: PaddingTwo) - spaceBetweenButtons?.isActive = true - - leftConstraintTwoButton = twoButtonView.leftAnchor.constraint(equalTo: leftAnchor) - leftConstraintTwoButton?.isActive = true - - rightConstraintTwoButton = rightAnchor.constraint(equalTo: twoButtonView.rightAnchor) - rightConstraintTwoButton?.isActive = true - - leftConstraintTextButton = textButton.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor) - leftConstraintTextButton?.isActive = true - - rightConstraintTextButton = rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor) - rightConstraintTextButton?.isActive = true - - centerAlignTextButton = textButton.centerXAnchor.constraint(equalTo: centerXAnchor) - centerAlignTextButton?.isActive = true - - bottomPin = bottomAnchor.constraint(equalTo: textButton.bottomAnchor, constant: PaddingDefaultVerticalSpacing) - bottomPin?.isActive = true - - heightConstraint = heightAnchor.constraint(equalToConstant: 0) + guard subviews.count == 0 else { + return } + translatesAutoresizingMaskIntoConstraints = false + backgroundColor = .clear + clipsToBounds = true + + addSubview(twoButtonView) + addSubview(textButton) + + topPin = twoButtonView.topAnchor.constraint(equalTo: topAnchor, constant: PaddingDefaultVerticalSpacing) + topPin?.isActive = true + + spaceBetweenButtons = textButton.topAnchor.constraint(equalTo: twoButtonView.bottomAnchor, constant: PaddingTwo) + spaceBetweenButtons?.isActive = true + + leftConstraintTwoButton = twoButtonView.leftAnchor.constraint(equalTo: leftAnchor) + leftConstraintTwoButton?.isActive = true + + rightConstraintTwoButton = rightAnchor.constraint(equalTo: twoButtonView.rightAnchor) + rightConstraintTwoButton?.isActive = true + + leftConstraintTextButton = textButton.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor) + leftConstraintTextButton?.isActive = true + + rightConstraintTextButton = rightAnchor.constraint(greaterThanOrEqualTo: textButton.rightAnchor) + rightConstraintTextButton?.isActive = true + + centerAlignTextButton = textButton.centerXAnchor.constraint(equalTo: centerXAnchor) + centerAlignTextButton?.isActive = true + + bottomPin = bottomAnchor.constraint(equalTo: textButton.bottomAnchor, constant: PaddingDefaultVerticalSpacing) + bottomPin?.isActive = true + + heightConstraint = heightAnchor.constraint(equalToConstant: 0) } public func setSpacing() {