From 2c539b695d69000806f51c1a0a6acb12f76f4301 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 4 Feb 2019 09:25:17 -0500 Subject: [PATCH] strip some base classes to separate ou legacy logic --- MVMCoreUI.xcodeproj/project.pbxproj | 36 +++- ...r.h => MVMCoreUIStackableViewController.h} | 22 +-- ...r.m => MVMCoreUIStackableViewController.m} | 88 ++++----- ....h => MVMCoreUIThreeLayerViewController.h} | 27 ++- ....m => MVMCoreUIThreeLayerViewController.m} | 181 +++++++----------- .../StackableViewController.h | 23 +++ .../StackableViewController.m | 43 +++++ ...abelsAndBottomButtonsTableViewController.h | 0 ...abelsAndBottomButtonsTableViewController.m | 0 .../TopLabelsAndBottomButtonsViewController.h | 28 +++ .../TopLabelsAndBottomButtonsViewController.m | 92 +++++++++ MVMCoreUI/MVMCoreUI.h | 2 + .../MVMCoreUILargeHeaderSingleLabelTemplate.h | 7 +- .../MVMCoreUILargeHeaderSingleLabelTemplate.m | 13 +- MVMCoreUI/Utility/MVMCoreUIUtility.h | 3 + MVMCoreUI/Utility/MVMCoreUIUtility.m | 10 + 16 files changed, 366 insertions(+), 209 deletions(-) rename MVMCoreUI/BaseControllers/{StackableViewController.h => MVMCoreUIStackableViewController.h} (75%) rename MVMCoreUI/BaseControllers/{StackableViewController.m => MVMCoreUIStackableViewController.m} (83%) rename MVMCoreUI/BaseControllers/{TopLabelsAndBottomButtonsViewController.h => MVMCoreUIThreeLayerViewController.h} (77%) rename MVMCoreUI/BaseControllers/{TopLabelsAndBottomButtonsViewController.m => MVMCoreUIThreeLayerViewController.m} (79%) create mode 100644 MVMCoreUI/LegacyControllers/StackableViewController.h create mode 100644 MVMCoreUI/LegacyControllers/StackableViewController.m rename MVMCoreUI/{BaseControllers => LegacyControllers}/TopLabelsAndBottomButtonsTableViewController.h (100%) rename MVMCoreUI/{BaseControllers => LegacyControllers}/TopLabelsAndBottomButtonsTableViewController.m (100%) create mode 100644 MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h create mode 100644 MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index c66ec7af..aed43ac1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -17,6 +17,10 @@ D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */; }; D22D1F46220496A30077CEC0 /* MVMCoreUISwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */; settings = {ATTRIBUTES = (Public, ); }; }; 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 */; }; + D22D1F5B2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F592204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D22D1F5C2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F5A2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.m */; }; 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 */; }; @@ -164,6 +168,10 @@ D22D1F1D220343560077CEC0 /* MVMCoreUICheckMarkView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICheckMarkView.m; sourceTree = ""; }; D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUISwitch.h; sourceTree = ""; }; 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 = ""; }; + D22D1F592204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIThreeLayerViewController.h; sourceTree = ""; }; + D22D1F5A2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIThreeLayerViewController.m; 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 = ""; }; @@ -317,6 +325,19 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + D22D1F582204D2590077CEC0 /* LegacyControllers */ = { + isa = PBXGroup; + children = ( + D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, + D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, + D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, + D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, + D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, + D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */, + ); + path = LegacyControllers; + sourceTree = ""; + }; D29DF0C221E404D4003B2FB9 = { isa = PBXGroup; children = ( @@ -343,6 +364,7 @@ D29DF13321E68604003B2FB9 /* Styles */, D29DF11021E6805F003B2FB9 /* Categories */, D29DF11921E68467003B2FB9 /* Containers */, + D22D1F582204D2590077CEC0 /* LegacyControllers */, D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, D29DF10D21E67A70003B2FB9 /* Atoms */, @@ -406,14 +428,12 @@ D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */, D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */, D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */, - D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, - D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, + D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */, + D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */, D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */, D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, - D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, - D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, - D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, - D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */, + D22D1F592204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.h */, + D22D1F5A2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.m */, ); path = BaseControllers; sourceTree = ""; @@ -690,8 +710,10 @@ D29DF2BC21E7BEA4003B2FB9 /* TopTabbar.h in Headers */, D29DF25921E6A22D003B2FB9 /* MFButtonProtocol.h in Headers */, D22D1F46220496A30077CEC0 /* MVMCoreUISwitch.h in Headers */, + D22D1F5B2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.h in Headers */, D22D1F1E220343560077CEC0 /* MVMCoreUICheckMarkView.h in Headers */, D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */, + D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */, D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */, D29DF12A21E6851E003B2FB9 /* MVMCoreUITopAlertView.h in Headers */, D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, @@ -833,6 +855,7 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, + D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, 01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, @@ -843,6 +866,7 @@ D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, + D22D1F5C2204D2C00077CEC0 /* MVMCoreUIThreeLayerViewController.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, diff --git a/MVMCoreUI/BaseControllers/StackableViewController.h b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h similarity index 75% rename from MVMCoreUI/BaseControllers/StackableViewController.h rename to MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h index ceab058f..9e7d352e 100644 --- a/MVMCoreUI/BaseControllers/StackableViewController.h +++ b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h @@ -1,15 +1,14 @@ // -// StackableViewController.h -// myverizon +// MVMCoreUIStackableViewController.h +// MVMCoreUI // -// Created by Scott Pfeil on 3/26/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 2/1/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. // -// This view controller is here to enable faster development of standard form screens. Put all ui objects that you want to be displayed in a top down order in an array and then call the generateFormWithUIArray. Any type can go in it. #import -@interface StackableViewController : ProgrammaticScrollViewController +@interface MVMCoreUIStackableViewController : ProgrammaticScrollViewController // An array of ui elements that will be spaced out on the screen top to bottom from index 0 to formUIArray.count. @property (nullable, strong, nonatomic) NSArray *formUIArray; @@ -17,12 +16,9 @@ // Generates the form view with the passed in form ui array. - (void)generateFormViewWithUIArray:(nullable NSArray *)formUIArray; - (void)generateFormView:(nullable UIView *)view withUIArrayForConstrainingViews:(nullable NSArray *)formUIArray; - -// Returns the spacing that should surround the passed in item. Subclass this to change spacing. -- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object; -// When using constraining views in the form array, resets the space that should surround each element. -- (void)resetSpaceForFormArrayWithConstrainingViews; +// Returns the spacing that should surround the passed in item. Subclass this to change spacing. +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object size:(CGFloat)size; // Removes all the subviews in the form ui array. - (void)removeUIViews; @@ -31,8 +27,8 @@ + (void)removeUIViews:(nullable NSArray *)views; // Returns the standard space around ui objects. -+ (UIEdgeInsets)standardSpaceAroundUIObject; - ++ (UIEdgeInsets)standardSpaceAroundUIObjectForSize:(CGFloat)size; + // Consolidates generateFormViewWithUIArray and spaceArroundUIObject into one class object so other view controllers can take advantage of these functions. + (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; + (void)populateViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock; diff --git a/MVMCoreUI/BaseControllers/StackableViewController.m b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m similarity index 83% rename from MVMCoreUI/BaseControllers/StackableViewController.m rename to MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m index a1bc78d1..86f4ebfe 100644 --- a/MVMCoreUI/BaseControllers/StackableViewController.m +++ b/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m @@ -1,20 +1,30 @@ // -// StackableViewController.m -// myverizon +// MVMCoreUIMVMCoreUIStackableViewController.m +// MVMCoreUI // -// Created by Scott Pfeil on 3/26/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 2/1/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. // -#import "StackableViewController.h" +#import "MVMCoreUIStackableViewController.h" #import "MFStyler.h" #import "ViewConstrainingView.h" - -@interface StackableViewController () +#import "MVMCoreUIUtility.h" +@interface MVMCoreUIStackableViewController () @end -@implementation StackableViewController +@implementation MVMCoreUIStackableViewController + +- (void)updateViews { + [super updateViews]; + for (UIView *view in self.formUIArray) { + CGFloat size = CGRectGetWidth(self.view.bounds); + ViewConstrainingView *constrainingView = (ViewConstrainingView *)view.superview; + [constrainingView setPinConstantsWithInsets:[self spaceAroundUIObject:view size:size]]; + [constrainingView updateView:size]; + } +} - (void)newDataBuildScreen { [super newDataBuildScreen]; @@ -24,33 +34,31 @@ } - (void)generateFormViewWithUIArray:(nullable NSArray *)formUIArray { - self.formUIArray = formUIArray; - [StackableViewController populateView:self.contentView withUIArray:formUIArray withSpacingBlock:^UIEdgeInsets(id _Nullable object) { - return [self spaceAroundUIObject:object]; - }]; -} - -- (void)generateFormView:(nullable UIView *)view withUIArrayForConstrainingViews:(nullable NSArray *)formUIArray { - self.formUIArray = formUIArray; - [StackableViewController populateView:view withUIArrayForConstrainingViews:formUIArray withSpacingBlock:^UIEdgeInsets(id _Nullable object) { - return [self spaceAroundUIObject:object]; + [MVMCoreUIStackableViewController populateView:self.contentView withUIArray:formUIArray withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + return [self spaceAroundUIObject:object size:[MVMCoreUIUtility getWidth]]; }]; } -- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object { - - UIEdgeInsets insets = [StackableViewController standardSpaceAroundUIObject]; +- (void)generateFormView:(nullable UIView *)view withUIArrayForConstrainingViews:(nullable NSArray *)formUIArray { + self.formUIArray = formUIArray; + [MVMCoreUIStackableViewController populateView:view withUIArrayForConstrainingViews:formUIArray withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + return [self spaceAroundUIObject:object size:[MVMCoreUIUtility getWidth]]; + }]; +} + +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object size:(CGFloat)size { + UIEdgeInsets insets = [MVMCoreUIStackableViewController standardSpaceAroundUIObjectForSize:size]; if (object == [self.formUIArray lastObject]) { // The last object should have space from the bottom - insets.bottom = [MFStyler defaultVerticalPaddingForApplicationWidth]; + insets.bottom = [MFStyler defaultVerticalPaddingForSize:size]; } return insets; } - (void)removeUIViews { - [StackableViewController removeUIViews:self.formUIArray]; + [MVMCoreUIStackableViewController removeUIViews:self.formUIArray]; } + (void)removeUIViews:(nullable NSArray *)views { @@ -61,44 +69,34 @@ } + (void)populateView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { - if ([formUIArray count] > 0) { - for (UIView *subview in formUIArray) { [view addSubview:subview]; } - - [StackableViewController autoLayoutView:view withUIArray:formUIArray withSpacingBlock:spacingBlock]; + [MVMCoreUIStackableViewController autoLayoutView:view withUIArray:formUIArray withSpacingBlock:spacingBlock]; } } + (void)populateViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { - if ([formUIArray count] > 0) { - for (UIView *subview in formUIArray) { [view addSubview:subview]; } - - [StackableViewController autoLayoutViewHorizontally:view withUIArray:formUIArray withSpacingBlock:spacingBlock]; + [MVMCoreUIStackableViewController autoLayoutViewHorizontally:view withUIArray:formUIArray withSpacingBlock:spacingBlock]; } } - + + (void)populateView:(nonnull UIView *)view withUIArrayForConstrainingViews:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { - if ([formUIArray count] > 0) { - for (UIView *subview in formUIArray) { ViewConstrainingView *constrainingView = [ViewConstrainingView viewConstrainingView:subview]; [view addSubview:constrainingView]; } - - [StackableViewController autoLayoutViewWithConstrainingViewsWithUIArray:formUIArray withSpacingBlock:spacingBlock]; + [MVMCoreUIStackableViewController autoLayoutViewWithConstrainingViewsWithUIArray:formUIArray withSpacingBlock:spacingBlock]; } } + (void)autoLayoutView:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { - if ([formUIArray count] > 0) { // Adds the first object to the view and pins it to the top of the content view. @@ -127,7 +125,6 @@ } + (void)autoLayoutViewHorizontally:(nonnull UIView *)view withUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { - if ([formUIArray count] > 0) { // Adds the first object to the view and pins it to the top and left of the content view. @@ -154,7 +151,7 @@ [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[previousUIObject]-right-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:@{@"right":@(spaceAroundObjectPrevious.right)} views:NSDictionaryOfVariableBindings(previousUIObject)]]; } } - + + (void)autoLayoutViewWithConstrainingViewsWithUIArray:(nonnull NSArray *)formUIArray withSpacingBlock:(nonnull UIEdgeInsets (^) (id _Nullable object))spacingBlock { if ([formUIArray count] > 0) { @@ -188,16 +185,9 @@ } } -- (void)resetSpaceForFormArrayWithConstrainingViews { - for (UIView *view in self.formUIArray) { - ViewConstrainingView *constrainingView = (ViewConstrainingView *)view.superview; - [constrainingView setPinConstantsWithInsets:[self spaceAroundUIObject:view]]; - } -} - -+ (UIEdgeInsets)standardSpaceAroundUIObject { - CGFloat horizontal = [MFStyler defaultHorizontalPaddingForApplicationWidth]; - CGFloat vertical = [MFStyler defaultVerticalPaddingForApplicationWidth]; ++ (UIEdgeInsets)standardSpaceAroundUIObjectForSize:(CGFloat)size { + CGFloat horizontal = [MFStyler defaultHorizontalPaddingForSize:size]; + CGFloat vertical = [MFStyler defaultVerticalPaddingForSize:size]; return UIEdgeInsetsMake(vertical, horizontal, 0, horizontal); } diff --git a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.h similarity index 77% rename from MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.h rename to MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.h index 7d15d543..4304fd23 100644 --- a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.h @@ -1,20 +1,16 @@ // -// TopLabelsAndBottomButtonsViewController.h -// myverizon +// MVMCoreUIThreeLayerViewController.h +// MVMCoreUI // -// Created by Scott Pfeil on 1/26/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 2/1/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. // -// Has top labels docked on top, buttons docked on bottom, and anything you'd like in between when subclassed. -#import -#import -#import - -@class LabelView; +#import +@class TopLabelsView; @class PrimaryButton; -@interface TopLabelsAndBottomButtonsViewController : StackableViewController +@interface MVMCoreUIThreeLayerViewController : MVMCoreUIStackableViewController @property (nullable, weak, nonatomic) TopLabelsView *topLabelsView; @property (nullable, weak, nonatomic) PrimaryButton *primaryButton; @@ -24,6 +20,7 @@ @property (nullable, weak, nonatomic) UIView *viewInScroll; @property (nullable, weak, nonatomic) UIView *viewOutOfScroll; @property (nullable, strong, nonatomic) UIView *safeAreaView; +@property (nonatomic, readonly) BOOL customBottomView; // Set to overwrite which view is the top edge and/or bottom edge of the between view. must be added to the ui and constrained before buildViewsBetweenLabelsAndButtons. // Use these to create views that are pinned near the labels or buttons and are separate from any centered content. Add and set in buildInAdditionalViewsBeforeCenteredContent. @@ -33,13 +30,11 @@ // The constraint connecting the topLabelsView to the content view. @property (nullable, strong, nonatomic) NSLayoutConstraint *topConstraintForTopView; -// Can override. This is put in because to cover 90% of the screens for initial ipad release, need to rebuild ui (newDataBuildScreen) of size of view change in updateViews. Disable this to handle manually with more finess. -@property (nonatomic) BOOL rebuildUIOnSizeChange; - #pragma mark - Subclass // Allow you to add any additional ui before buildViewsBetweenLabelsAndButtons gets called. Can use this to set the topBetweenEdgeView or bottomBetweenEdgeView - (void)buildInAdditionalViewsBeforeCenteredContent; + // For subclassing. Should return all the views that will be in between labels and buttons. Override standardSpaceAroundUIObject to handle spacing. - (nullable NSArray *)buildViewsBetweenLabelsAndButtons; @@ -53,8 +48,8 @@ - (nullable NSNumber *)spaceBelowBetweenView; // Can overwrite the default padding for labels and buttons. -- (UIEdgeInsets)paddingForTopLabels; -- (UIEdgeInsets)paddingForBottomButtons; +- (void)updateTopLabelsPadding:(CGFloat)size; +- (void)updateBottomButtonsPadding:(CGFloat)size; // default button map will automatically get from response, you can also overide this to have your own button map - (nullable NSDictionary *)secondaryButtonMap; diff --git a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.m similarity index 79% rename from MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.m rename to MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.m index cc7cd627..532515ad 100644 --- a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/BaseControllers/MVMCoreUIThreeLayerViewController.m @@ -1,32 +1,29 @@ // -// TopLabelsAndBottomButtonsViewController.m -// myverizon +// MVMCoreUIThreeLayerViewController.m +// MVMCoreUI // -// Created by Scott Pfeil on 1/26/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. +// Created by Scott Pfeil on 2/1/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. // -#import "TopLabelsAndBottomButtonsViewController.h" -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import - +#import "MVMCoreUIThreeLayerViewController.h" +#import "ViewConstrainingView.h" +#import "MFStyler.h" +#import "MFSizeObject.h" +#import "TopLabelsView.h" +#import "PrimaryButtonView.h" +#import "MVMCoreUICommonViewsUtility.h" +#import "UIColor+MFConvenience.h" +#import "NSLayoutConstraint+MFConvenience.h" +#import "MVMCoreUIConstants.h" @import MVMAnimationFramework; -@interface TopLabelsAndBottomButtonsViewController () +@interface MVMCoreUIThreeLayerViewController () @property (nullable, strong, nonatomic) NSLayoutConstraint *heightConstraint; @property (nullable, weak, nonatomic) UIView *topView; @property (nullable, weak, nonatomic) UIView *bottomView; -@property (nonatomic) BOOL customBottemView; +@property (nonatomic, readwrite) BOOL customBottomView; @property (nullable, weak, nonatomic) NSArray *middleViews; @property (nullable, weak, nonatomic) UIView *betweenView; @@ -38,55 +35,46 @@ @end -@implementation TopLabelsAndBottomButtonsViewController - -- (void)initialLoad { - [super initialLoad]; - self.rebuildUIOnSizeChange = YES; -} +@implementation MVMCoreUIThreeLayerViewController - (void)updateViews { [super updateViews]; - if ([self screenSizeChanged]) { - if (self.rebuildUIOnSizeChange) { - - // If the screen size changed.... just rebuild everything.... this will cover all sizes and help for ipad slide over. - [self newDataBuildScreen]; - } else { - - // Update top labels and bottom buttons. - CGFloat width = CGRectGetWidth(self.view.bounds); - if ([self.topView respondsToSelector:@selector(updateView:)]) { - [((UIView *)self.topView) updateView:width]; - } - if ([self.bottomView respondsToSelector:@selector(updateView:)]) { - [((UIView *)self.bottomView) updateView:width]; - } - [self updateTopLabelsBottomButtonsPadding]; - [self.bottomAccessoryView updateView:width]; - [self resetSpaceForFormArrayWithConstrainingViews]; - } + // Update top labels and bottom buttons. + CGFloat width = CGRectGetWidth(self.view.bounds); + if ([self.topView respondsToSelector:@selector(updateView:)]) { + [((UIView *)self.topView) updateView:width]; + } + if ([self.bottomView respondsToSelector:@selector(updateView:)]) { + [((UIView *)self.bottomView) updateView:width]; + } + [self updateTopLabelsPadding:width]; + [self updateBottomButtonsPadding:width]; + [self.bottomAccessoryView updateView:width]; + [self.bottomAccessoryView setPinConstantsWithInsets:[self spaceAroundUIObject:self.bottomAccessoryView size:width]]; + +} + +- (void)updateTopLabelsPadding:(CGFloat)size { + if (self.topLabelsView) { + CGFloat horizontalPadding = [MFStyler defaultHorizontalPaddingForSize:size]; + self.topLabelsView.topLabelConstraint.constant = PaddingFive; + self.topLabelsView.bottomLabelConstraint.constant = PaddingFive; + [self.topLabelsView setLeftConstant:horizontalPadding]; + [self.topLabelsView setRightConstant:horizontalPadding]; } } -- (void)updateTopLabelsBottomButtonsPadding { - if (self.topLabelsView) { - UIEdgeInsets paddingForTopLabels = [self paddingForTopLabels]; - self.topLabelsView.topLabelConstraint.constant = paddingForTopLabels.top; - self.topLabelsView.bottomLabelConstraint.constant = paddingForTopLabels.bottom; - [self.topLabelsView setLeftConstant:paddingForTopLabels.left]; - [self.topLabelsView setRightConstant:paddingForTopLabels.right]; - } - - if (!self.customBottemView) { +- (void)updateBottomButtonsPadding:(CGFloat)size { + if (!self.customBottomView) { PrimaryButtonView *buttonView = (PrimaryButtonView *)self.bottomView; if (self.secondaryButton || self.primaryButton) { - UIEdgeInsets paddingForBottomButtons = [self paddingForBottomButtons]; - buttonView.leftPin.constant = paddingForBottomButtons.left; - buttonView.rightPin.constant = paddingForBottomButtons.right; - buttonView.topPin.constant = paddingForBottomButtons.top; - buttonView.bottomPin.constant = paddingForBottomButtons.bottom; + // Smaller space for smaller devices. Also, top is 0 by default when in scroll. + CGFloat verticalSpacing = [[MFSizeObject sizeObjectWithStandardSize:PaddingDefaultVerticalSpacing smalliPhoneSize:PaddingDefault] getValueBasedOnScreenSize]; + buttonView.leftPin.constant = PaddingDefaultHorizontalSpacing; + buttonView.rightPin.constant = PaddingDefaultHorizontalSpacing; + buttonView.topPin.constant = [self bottomViewOutsideOfScroll] ? verticalSpacing : 0; + buttonView.bottomPin.constant = verticalSpacing; } else { buttonView.topPin.constant = 0; buttonView.bottomPin.constant = 0; @@ -101,7 +89,7 @@ // Removes the bottom view out of scroll if it is there. [self.viewOutOfScroll removeFromSuperview]; - [StackableViewController removeUIViews:[self.contentView subviews]]; + [MVMCoreUIStackableViewController removeUIViews:[self.contentView subviews]]; // Checks if we are using a different object than top labels. UIView *topView = [self useCustomViewInsteadOfLabels]; @@ -112,7 +100,7 @@ topLabelsView.separatorView.hidden = NO; self.topLabelsView = topLabelsView; topView = topLabelsView; - self.topView = topView; + self.topView = topView; [topLabelsView setWithJSON:[self mapForTopLabels]]; } [self.contentView addSubview:topView]; @@ -122,8 +110,8 @@ // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; - self.customBottemView = (bottomView != nil); - if (!self.customBottemView) { + self.customBottomView = (bottomView != nil); + if (!self.customBottomView) { // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; @@ -133,21 +121,20 @@ self.primaryButton = buttonView.primaryButton; bottomView = buttonView; self.bottomView = bottomView; - } else { - self.bottomView = bottomView; - } - [self updateTopLabelsBottomButtonsPadding]; + } else { + self.bottomView = bottomView; + } // Adds the bottom view outside the scroll if directed. [self.safeAreaView removeFromSuperview]; if ([self bottomViewOutsideOfScroll]) { - if (!self.customBottemView) { + if (!self.customBottomView) { bottomView.backgroundColor = [UIColor mfBackgroundGray]; } [self addViewOutsideOfScrollView:bottomView]; self.viewOutOfScroll = bottomView; - + // Sets this so that the button view added to the content view will be empty. bottomView = [ViewConstrainingView emptyView]; } @@ -159,7 +146,7 @@ // Allows addition of any custom ui before custom center view. [self buildInAdditionalViewsBeforeCenteredContent]; - + // Positions the views in between the labels and buttons. UIView *viewBetween = nil; @@ -221,18 +208,18 @@ NSLayoutConstraint *sameHeightSpacer = [NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:bottomSpacer attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]; sameHeightSpacer.active = YES; - + NSLayoutConstraint *minimumHeightSpacer = [NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:PaddingDefaultVerticalSpacing]; minimumHeightSpacer.active = YES; - + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topBetweenEdgeView]-0-[topSpacer]-0-[viewBetween]-0-[bottomSpacer]-0-[bottomBetweenEdgeView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topBetweenEdgeView,topSpacer,viewBetween,bottomSpacer,bottomBetweenEdgeView)]]; } else if (spaceAbove) { - + // Space above is set, space below is free. UIView *bottomSpacer = [MVMCoreUICommonViewsUtility commonView]; [self.contentView addSubview:bottomSpacer]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[bottomSpacer]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(bottomSpacer)]]; - + NSLayoutConstraint *bottomSpacerHeight = [NSLayoutConstraint constraintWithItem:bottomSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:PaddingDefaultVerticalSpacing]; bottomSpacerHeight.active = YES; @@ -244,7 +231,7 @@ UIView *topSpacer = [MVMCoreUICommonViewsUtility commonView]; [self.contentView addSubview:topSpacer]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topSpacer]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topSpacer)]]; - + NSLayoutConstraint *topSpacerHeight = [NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:PaddingDefaultVerticalSpacing]; topSpacerHeight.active = YES; @@ -258,7 +245,7 @@ UIView *spacer = [MVMCoreUICommonViewsUtility commonView]; [self.contentView addSubview:spacer]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[spacer]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(spacer)]]; - + // Needs the height constraint heightConstraint.active = YES; @@ -286,19 +273,14 @@ // Do any additional setup after loading the view. } -- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object { - CGFloat horizontal = [MFStyler defaultHorizontalPaddingForApplicationWidth]; +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object size:(CGFloat)size { + CGFloat horizontal = [MFStyler defaultHorizontalPaddingForSize:size]; if (self.bottomAccessoryView == object) { return UIEdgeInsetsMake(0, horizontal, PaddingDefaultVerticalSpacing, horizontal); } return UIEdgeInsetsMake(0, horizontal, 0, horizontal); } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - (void)addViewToContentView:(UIView *)bottomView { self.bottomConstraint.active = YES; @@ -313,10 +295,10 @@ - (void)addViewOutsideOfScrollView:(UIView *)bottomView { self.bottomConstraint.active = NO; - + // Buttons will be outside of the scrolling view. [self.view addSubview:bottomView]; - + UIScrollView *scrollview = self.scrollView; if (@available(iOS 11.0, *)) { [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[scrollview]-0-[bottomView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(scrollview,bottomView)]]; @@ -334,7 +316,6 @@ #pragma mark - Can Subclass These - - (nullable UIView *)buttonsAccessoryView { return nil; } @@ -349,8 +330,6 @@ [self.contentView addSubview:constrainingView]; self.bottomBetweenEdgeView = constrainingView; self.bottomAccessoryView = constrainingView; - - [constrainingView setPinConstantsWithInsets:[self spaceAroundUIObject:constrainingView]]; [NSLayoutConstraint constraintPinLeftSubview:constrainingView leftConstant:0]; [NSLayoutConstraint constraintPinRightSubview:constrainingView rightConstant:0]; @@ -373,23 +352,12 @@ return nil; } -- (UIEdgeInsets)paddingForTopLabels { - return UIEdgeInsetsMake(PaddingFive, [MFStyler defaultHorizontalPaddingForApplicationWidth], PaddingDefaultVerticalSpacing, [MFStyler defaultHorizontalPaddingForApplicationWidth]); -} - -- (UIEdgeInsets)paddingForBottomButtons { - - // Smaller space for smaller devices. Also, top is 0 by default when in scroll. - CGFloat verticalSpacing = [[MFSizeObject sizeObjectWithStandardSize:PaddingDefaultVerticalSpacing smalliPhoneSize:PaddingDefault] getValueBasedOnScreenSize]; - return UIEdgeInsetsMake(([self bottomViewOutsideOfScroll] ? verticalSpacing : 0), PaddingDefaultHorizontalSpacing, verticalSpacing, PaddingDefaultHorizontalSpacing); -} - -- (NSDictionary*)primaryButtonMap { +- (NSDictionary *)primaryButtonMap { NSDictionary *buttonMap = [self.loadObject.pageJSON dict:KeyButtonMap]; return [buttonMap dict:KeyPrimaryButton]; } -- (NSDictionary*)secondaryButtonMap { +- (NSDictionary *)secondaryButtonMap { NSDictionary *buttonMap = [self.loadObject.pageJSON dict:KeyButtonMap]; return [buttonMap dict:KeySecondaryButton]; } @@ -410,10 +378,8 @@ return NO; } - - #pragma mark - Animations --(void)setupIntroAnimations { +- (void)setupIntroAnimations { if (self.topView.subviews) { [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topView]]; } @@ -422,13 +388,6 @@ [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topBetweenEdgeView]]; } -// NSMutableArray *centerAnimationObjects = [NSMutableArray new]; -// for (int i = 0; i < self.middleViews.count; i++) { -// MVMAnimationObject *aobj =[MVMAnimations fadeUpAnimationWithView:self.middleViews[i]]; -// [centerAnimationObjects addObject:aobj]; -// } -// [self.introAnimationManager addAnimationGroupWithAnimations:centerAnimationObjects]; - [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.betweenView]]; if (self.bottomBetweenEdgeView.subviews.count) { diff --git a/MVMCoreUI/LegacyControllers/StackableViewController.h b/MVMCoreUI/LegacyControllers/StackableViewController.h new file mode 100644 index 00000000..49984150 --- /dev/null +++ b/MVMCoreUI/LegacyControllers/StackableViewController.h @@ -0,0 +1,23 @@ +// +// StackableViewController.h +// myverizon +// +// Created by Scott Pfeil on 3/26/14. +// Copyright (c) 2014 Verizon Wireless. All rights reserved. +// +// This view controller is here to enable faster development of standard form screens. Put all ui objects that you want to be displayed in a top down order in an array and then call the generateFormWithUIArray. Any type can go in it. + +#import + +@interface StackableViewController : MVMCoreUIStackableViewController + +// Returns the spacing that should surround the passed in item. Subclass this to change spacing. +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object; + +// When using constraining views in the form array, resets the space that should surround each element. +- (void)resetSpaceForFormArrayWithConstrainingViews; + +// Returns the standard space around ui objects. ++ (UIEdgeInsets)standardSpaceAroundUIObject; + +@end diff --git a/MVMCoreUI/LegacyControllers/StackableViewController.m b/MVMCoreUI/LegacyControllers/StackableViewController.m new file mode 100644 index 00000000..f2dd9fe1 --- /dev/null +++ b/MVMCoreUI/LegacyControllers/StackableViewController.m @@ -0,0 +1,43 @@ +// +// StackableViewController.m +// myverizon +// +// Created by Scott Pfeil on 3/26/14. +// Copyright (c) 2014 Verizon Wireless. All rights reserved. +// + +#import "StackableViewController.h" +#import "MFStyler.h" +#import "ViewConstrainingView.h" +#import "MVMCoreUIUtility.h" + +@interface StackableViewController () + +@end + +@implementation StackableViewController + +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object { + return [super spaceAroundUIObject:object size:[MVMCoreUIUtility getWidth]]; +} + +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object size:(CGFloat)size { + return [self spaceAroundUIObject:object]; +} + +- (void)resetSpaceForFormArrayWithConstrainingViews { + for (UIView *view in self.formUIArray) { + ViewConstrainingView *constrainingView = (ViewConstrainingView *)view.superview; + [constrainingView setPinConstantsWithInsets:[self spaceAroundUIObject:view]]; + } +} + ++ (UIEdgeInsets)standardSpaceAroundUIObject { + return [super standardSpaceAroundUIObjectForSize:[MVMCoreUIUtility getWidth]]; +} + ++ (UIEdgeInsets)standardSpaceAroundUIObjectForSize:(CGFloat)size { + return [self standardSpaceAroundUIObject]; +} + +@end diff --git a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsTableViewController.h rename to MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h diff --git a/MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/TopLabelsAndBottomButtonsTableViewController.m rename to MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h new file mode 100644 index 00000000..82fb809a --- /dev/null +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -0,0 +1,28 @@ +// +// TopLabelsAndBottomButtonsViewController.h +// myverizon +// +// Created by Scott Pfeil on 1/26/16. +// Copyright © 2016 Verizon Wireless. All rights reserved. +// +// Has top labels docked on top, buttons docked on bottom, and anything you'd like in between when subclassed. + +#import +#import +#import +#import +@class LabelView; + +@interface TopLabelsAndBottomButtonsViewController : MVMCoreUIThreeLayerViewController + +// Can override. This is put in because to cover 90% of the screens for initial ipad release, need to rebuild ui (newDataBuildScreen) of size of view change in updateViews. Disable this to handle manually with more finess. +@property (nonatomic) BOOL rebuildUIOnSizeChange; + +// Can overwrite the default padding for labels and buttons. +- (UIEdgeInsets)paddingForTopLabels; +- (UIEdgeInsets)paddingForBottomButtons; + +// Returns the spacing that should surround the passed in item. Subclass this to change spacing. +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object; + +@end diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m new file mode 100644 index 00000000..2f169286 --- /dev/null +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -0,0 +1,92 @@ +// +// TopLabelsAndBottomButtonsViewController.m +// myverizon +// +// Created by Scott Pfeil on 1/26/16. +// Copyright © 2016 Verizon Wireless. All rights reserved. +// + +#import "TopLabelsAndBottomButtonsViewController.h" +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +@import MVMAnimationFramework; + +@interface TopLabelsAndBottomButtonsViewController () + +@end + +@implementation TopLabelsAndBottomButtonsViewController + +- (void)initialLoad { + [super initialLoad]; + self.rebuildUIOnSizeChange = YES; +} + +- (void)updateViews { + if ([self screenSizeChanged] && self.rebuildUIOnSizeChange) { + + // If the screen size changed.... just rebuild everything.... this will cover all sizes and help for ipad slide over. + [self newDataBuildScreen]; + } + [super updateViews]; +} + +- (UIEdgeInsets)spaceAroundUIObject:(nullable id)object { + return [super spaceAroundUIObject:object size:[MVMCoreUIUtility getWidth]]; +} + +- (UIEdgeInsets)spaceAroundUIObject:(id)object size:(CGFloat)size { + return [self spaceAroundUIObject:object]; +} + +- (UIEdgeInsets)paddingForTopLabels { + return UIEdgeInsetsMake(PaddingFive, [MFStyler defaultHorizontalPaddingForApplicationWidth], PaddingDefaultVerticalSpacing, [MFStyler defaultHorizontalPaddingForApplicationWidth]); +} + +- (UIEdgeInsets)paddingForBottomButtons { + // Smaller space for smaller devices. Also, top is 0 by default when in scroll. + CGFloat verticalSpacing = [[MFSizeObject sizeObjectWithStandardSize:PaddingDefaultVerticalSpacing smalliPhoneSize:PaddingDefault] getValueBasedOnScreenSize]; + return UIEdgeInsetsMake(([self bottomViewOutsideOfScroll] ? verticalSpacing : 0), PaddingDefaultHorizontalSpacing, verticalSpacing, PaddingDefaultHorizontalSpacing); +} + +- (void)updateTopLabelsPadding:(CGFloat)size { + if (self.topLabelsView) { + UIEdgeInsets paddingForTopLabels = [self paddingForTopLabels]; + self.topLabelsView.topLabelConstraint.constant = paddingForTopLabels.top; + self.topLabelsView.bottomLabelConstraint.constant = paddingForTopLabels.bottom; + [self.topLabelsView setLeftConstant:paddingForTopLabels.left]; + [self.topLabelsView setRightConstant:paddingForTopLabels.right]; + } +} + +- (void)updateBottomButtonsPadding:(CGFloat)size { + if (!self.customBottomView) { + PrimaryButtonView *buttonView = (PrimaryButtonView *)self.bottomView; + if (self.secondaryButton || self.primaryButton) { + UIEdgeInsets paddingForBottomButtons = [self paddingForBottomButtons]; + buttonView.leftPin.constant = paddingForBottomButtons.left; + buttonView.rightPin.constant = paddingForBottomButtons.right; + buttonView.topPin.constant = paddingForBottomButtons.top; + buttonView.bottomPin.constant = paddingForBottomButtons.bottom; + } else { + buttonView.topPin.constant = 0; + buttonView.bottomPin.constant = 0; + buttonView.leftPin.constant = 0; + buttonView.rightPin.constant = 0; + } + } +} + +@end diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 1be45402..3ec411ae 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -49,6 +49,8 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import +#import +#import #import #import #import diff --git a/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.h b/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.h index a73dd8cc..4957f306 100644 --- a/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.h +++ b/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.h @@ -7,12 +7,11 @@ // #import -#import +#import @class LabelView; @class LabelWithInternalButton; -NS_ASSUME_NONNULL_BEGIN -@interface MVMCoreUILargeHeaderSingleLabelTemplate : TopLabelsAndBottomButtonsViewController +@interface MVMCoreUILargeHeaderSingleLabelTemplate : MVMCoreUIThreeLayerViewController // A label that can go below the top labels. Can be a normal label or one with internal buttons. @property (nullable, weak, nonatomic) LabelView *labelViewUnderTopLabels; @@ -25,5 +24,3 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSDictionary *)actionMapForLabelUnderTopLabelsWithInternalButton; @end - -NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.m b/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.m index 122e770b..563fdbdd 100644 --- a/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.m +++ b/MVMCoreUI/Templates/MVMCoreUILargeHeaderSingleLabelTemplate.m @@ -10,6 +10,7 @@ #import "LabelView.h" #import "LabelWithInternalButton.h" #import "UIColor+MFConvenience.h" +#import "TopLabelsView.h" @interface MVMCoreUILargeHeaderSingleLabelTemplate () @@ -23,11 +24,6 @@ [self.topLabelsView.separatorView hide]; } -- (void)initialLoad { - [super initialLoad]; - self.rebuildUIOnSizeChange = NO; -} - - (nullable NSArray *)buildViewsBetweenLabelsAndButtons { NSDictionary *labelActionMap = [self actionMapForLabelUnderTopLabelsWithInternalButton]; NSString *labelString = [self stringForLabelUnderTopLabels]; @@ -76,10 +72,9 @@ // Dispose of any resources that can be recreated. } -- (UIEdgeInsets)paddingForTopLabels { - UIEdgeInsets edge = [super paddingForTopLabels]; - edge.bottom = PaddingTwo; - return edge; +- (void)updateTopLabelsPadding:(CGFloat)size { + [super updateTopLabelsPadding:size]; + self.topLabelsView.bottomLabelConstraint.constant = PaddingTwo; } @end diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 6f85f6d2..81545583 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -49,6 +49,9 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Sizing +// Grabs the width from the available container. ++ (CGFloat)getWidth; + // Gets the space needed at the top of the view for the status bar. + (CGFloat)getTopSpaceWithStatusBarForView:(UIView *_Nonnull)view; diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index dfcc970b..c0135d4f 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -8,6 +8,7 @@ #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" +#import "MVMCoreUISession.h" @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; @@ -97,6 +98,15 @@ #pragma mark - Sizing ++ (CGFloat)getWidth { + UIViewController *controller = [MVMCoreUISession sharedGlobal].splitViewController ?: [MVMCoreUISession sharedGlobal].navigationController ?: [UIApplication sharedApplication].keyWindow.rootViewController; + if (controller) { + return CGRectGetWidth(controller.view.bounds); + } else { + return CGRectGetWidth([UIScreen mainScreen].bounds); + } +} + + (CGFloat)getTopSpaceWithStatusBarForView:(UIView *)view { CGPoint viewStartPointInWindowSpace = [[UIApplication sharedApplication].keyWindow convertPoint:CGPointMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame)) fromView:[view superview]]; if (CGRectGetMaxY([UIApplication sharedApplication].statusBarFrame) > viewStartPointInWindowSpace.y) {