From f1b8a61e047e5e1713ada21004a9add1e0c7cb8a Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 14 Nov 2019 18:15:22 -0500 Subject: [PATCH 1/6] top accessory view --- .../TopLabelsAndBottomButtonsViewController.h | 2 ++ .../TopLabelsAndBottomButtonsViewController.m | 36 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h index 720f0097..406fda1a 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -38,6 +38,8 @@ #pragma mark - Subclass +- (nullable NSArray *)topAccessoryViews; + // 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. diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index 0c9d1d5d..8bdb49de 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -101,7 +101,13 @@ // Removes the bottom view out of scroll if it is there. [self.viewOutOfScroll removeFromSuperview]; [StackableViewController removeUIViews:[self.contentView subviews]]; - + + UIView *topAccessoryView = [self setUpTopAccessoryView]; + [self.contentView addSubview:topAccessoryView]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]]; + self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topAccessoryView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + self.topConstraintForTopView.active = YES; + // Checks if we are using a different object than top labels. UIView *topView = [self useCustomViewInsteadOfLabels]; self.topView = topView; @@ -115,9 +121,8 @@ } [self.contentView addSubview:topView]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]]; - self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; - self.topConstraintForTopView.active = YES; - + [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; + // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; self.customBottemView = (bottomView != nil); @@ -266,7 +271,28 @@ if (self.topLabelsView) { [self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]]; } - +} + +- (nullable NSArray *)topAccessoryViews { + return nil; +} + +- (UIView *)setUpTopAccessoryView { + UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; + headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; + NSArray *accessoryViews = [self topAccessoryViews]; + if (accessoryViews.count > 0) { + __block typeof(self) weakSelf = self; + [StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; + edgeInsets.left = 0; + edgeInsets.right = 0; + return edgeInsets; + }]; + } else { + [NSLayoutConstraint constraintPinView:headerAccessoryView heightConstraint:YES heightConstant:0 widthConstraint:NO widthConstant:0]; + } + return headerAccessoryView; } - (void)updateViewConstraints { From 627114ded8d6649d323c53053098cfa0d0ac0a12 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 14 Nov 2019 19:27:56 -0500 Subject: [PATCH 2/6] top accessory in tableview controller --- ...abelsAndBottomButtonsTableViewController.h | 2 + ...abelsAndBottomButtonsTableViewController.m | 64 +++++++++++++++---- .../TopLabelsAndBottomButtonsViewController.m | 30 +++++---- 3 files changed, 71 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h index 04defbb4..dd5dd3be 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h @@ -71,4 +71,6 @@ - (BOOL)bottomViewOutsideOfScroll; //override for setting attributed headline and message -(void)setHeadlineAndMessage; +- (nullable NSArray *)topAccessoryViews; + @end diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 8b0a23bf..2dc60d52 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -70,6 +70,27 @@ } } +- (nullable NSArray *)topAccessoryViews { + return nil; +} + +- (nullable UIView *)setUpTopAccessoryView { + NSArray *accessoryViews = [self topAccessoryViews]; + if (accessoryViews.count > 0) { + UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; + headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; + + __block typeof(self) weakSelf = self; + [StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; + edgeInsets.left = 0; + edgeInsets.right = 0; + return edgeInsets; + }]; + return headerAccessoryView; + } + return nil; +} - (void)newDataBuildScreen { [super newDataBuildScreen]; @@ -92,10 +113,10 @@ [self setHeadlineAndMessage]; self.topView = topLabelsView; } - + // Setup accessory view. [self setUpHeaderAccessoryView]; - + // add top view to table header if (self.topView) { self.topView.translatesAutoresizingMaskIntoConstraints = NO; @@ -253,16 +274,34 @@ UIView *headerAccessoryView = self.headerAccessoryView; [header addSubview:topView]; [header addSubview:headerAccessoryView]; - - // Sets up the constraints - if (headerAccessoryView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; - [NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - else { - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } + + UIView *topAccessoryView = [self setUpTopAccessoryView]; + if (topAccessoryView) { + [header addSubview:topAccessoryView]; + [NSLayoutConstraint constraintPinSubview:topAccessoryView pinTop:YES pinBottom:NO pinLeft:YES pinRight:YES]; + [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; + + // Sets up the constraints + if (headerAccessoryView) { + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; + [NSLayoutConstraint constraintPinSubview:topView pinTop:NO topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + else { + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + } else { + // Sets up the constraints + if (headerAccessoryView) { + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; + [NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + else { + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + } + self.headerView = header; } @@ -281,6 +320,7 @@ self.footerView = footer; } + - (void)showHeader { if (self.headerView) { diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index 8bdb49de..06ad0028 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -102,12 +102,6 @@ [self.viewOutOfScroll removeFromSuperview]; [StackableViewController removeUIViews:[self.contentView subviews]]; - UIView *topAccessoryView = [self setUpTopAccessoryView]; - [self.contentView addSubview:topAccessoryView]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]]; - self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topAccessoryView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; - self.topConstraintForTopView.active = YES; - // Checks if we are using a different object than top labels. UIView *topView = [self useCustomViewInsteadOfLabels]; self.topView = topView; @@ -121,8 +115,18 @@ } [self.contentView addSubview:topView]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]]; - [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; + UIView *topAccessoryView = [self setUpTopAccessoryView]; + if (topAccessoryView) { + [self.contentView addSubview:topAccessoryView]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]]; + self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topAccessoryView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; + } else { + self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + } + + self.topConstraintForTopView.active = YES; // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; self.customBottemView = (bottomView != nil); @@ -277,11 +281,12 @@ return nil; } -- (UIView *)setUpTopAccessoryView { - UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; - headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; +- (nullable UIView *)setUpTopAccessoryView { NSArray *accessoryViews = [self topAccessoryViews]; if (accessoryViews.count > 0) { + UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; + headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; + __block typeof(self) weakSelf = self; [StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; @@ -289,10 +294,9 @@ edgeInsets.right = 0; return edgeInsets; }]; - } else { - [NSLayoutConstraint constraintPinView:headerAccessoryView heightConstraint:YES heightConstant:0 widthConstraint:NO widthConstant:0]; + return headerAccessoryView; } - return headerAccessoryView; + return nil; } - (void)updateViewConstraints { From 76cd37d12168a50b1b1db054049e19b29ec8e151 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Fri, 15 Nov 2019 21:10:37 +0530 Subject: [PATCH 3/6] code cleanup --- ...abelsAndBottomButtonsTableViewController.m | 22 +++++++++---------- .../TopLabelsAndBottomButtonsViewController.m | 17 +++++++++----- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 2dc60d52..1b2e936d 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -31,6 +31,7 @@ @property (strong, nonatomic) UIView *footerViewOutsideOfScroll; @property (strong, nonatomic) NSLayoutConstraint *bottomViewTopConstraint; @property (strong, nonatomic) UIView *headerAccessoryView; +@property (strong, nonatomic) UIView *topAccessoryView; @end @@ -76,18 +77,12 @@ - (nullable UIView *)setUpTopAccessoryView { NSArray *accessoryViews = [self topAccessoryViews]; - if (accessoryViews.count > 0) { - UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; - headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; - - __block typeof(self) weakSelf = self; - [StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { - UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; - edgeInsets.left = 0; - edgeInsets.right = 0; - return edgeInsets; + if (accessoryViews.count) { + UIView *topAccessoryView = [MVMCoreUICommonViewsUtility commonView]; + [StackableViewController populateView:topAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + return UIEdgeInsetsZero; }]; - return headerAccessoryView; + return topAccessoryView; } return nil; } @@ -276,6 +271,7 @@ [header addSubview:headerAccessoryView]; UIView *topAccessoryView = [self setUpTopAccessoryView]; + self.topAccessoryView = topAccessoryView; if (topAccessoryView) { [header addSubview:topAccessoryView]; [NSLayoutConstraint constraintPinSubview:topAccessoryView pinTop:YES pinBottom:NO pinLeft:YES pinRight:YES]; @@ -499,6 +495,10 @@ #pragma mark - Animation -(void)setupIntroAnimations { + + if (self.topAccessoryView.subviews.count) { + [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topAccessoryView]]; + } if (self.topView.subviews.count) { [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topView]]; } diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index 06ad0028..d7c1ca41 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -31,6 +31,8 @@ @property (nullable, weak, nonatomic) UIView *betweenView; +@property (strong, nonatomic) UIView *topAccessoryView; + // Adds the button view to the screen. Out of the scroll or in. - (void)addViewOutsideOfScrollView:(UIView *)bottomView; - (void)addViewToContentView:(UIView *)bottomView; @@ -117,6 +119,7 @@ [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]]; UIView *topAccessoryView = [self setUpTopAccessoryView]; + self.topAccessoryView = topAccessoryView; if (topAccessoryView) { [self.contentView addSubview:topAccessoryView]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]]; @@ -283,18 +286,17 @@ - (nullable UIView *)setUpTopAccessoryView { NSArray *accessoryViews = [self topAccessoryViews]; - if (accessoryViews.count > 0) { - UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero]; - headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO; + if (accessoryViews.count) { + UIView *topAccessoryView = [MVMCoreUICommonViewsUtility commonView]; __block typeof(self) weakSelf = self; - [StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { + [StackableViewController populateView:topAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; edgeInsets.left = 0; edgeInsets.right = 0; return edgeInsets; }]; - return headerAccessoryView; + return topAccessoryView; } return nil; } @@ -439,6 +441,11 @@ #pragma mark - Animations -(void)setupIntroAnimations { + + if (self.topAccessoryView.subviews.count) { + [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topAccessoryView]]; + } + if (self.topView.subviews) { [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topView]]; } From 84f50f3b80008cedcc9ca6962291ebd2d4a25709 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Nov 2019 11:42:29 -0500 Subject: [PATCH 4/6] optimize --- ...abelsAndBottomButtonsTableViewController.m | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 2dc60d52..3082e0ac 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -280,26 +280,17 @@ [header addSubview:topAccessoryView]; [NSLayoutConstraint constraintPinSubview:topAccessoryView pinTop:YES pinBottom:NO pinLeft:YES pinRight:YES]; [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; + } - // Sets up the constraints - if (headerAccessoryView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; - [NSLayoutConstraint constraintPinSubview:topView pinTop:NO topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - else { - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - } else { - // Sets up the constraints - if (headerAccessoryView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; - [NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - else { - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } + BOOL topPin = topAccessoryView ? NO : YES; + // Sets up the constraints + if (headerAccessoryView) { + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; + [NSLayoutConstraint constraintPinSubview:topView pinTop:topPin topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + else { + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:topPin topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; } self.headerView = header; From 89cbfe00bae345ccc4d36c4bd134d4257d2e9e3a Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Nov 2019 12:09:20 -0500 Subject: [PATCH 5/6] clean up --- ...abelsAndBottomButtonsTableViewController.h | 2 +- ...abelsAndBottomButtonsTableViewController.m | 16 ++------------ .../TopLabelsAndBottomButtonsViewController.h | 2 +- .../TopLabelsAndBottomButtonsViewController.m | 21 ++----------------- 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h index dd5dd3be..b9beb281 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h @@ -71,6 +71,6 @@ - (BOOL)bottomViewOutsideOfScroll; //override for setting attributed headline and message -(void)setHeadlineAndMessage; -- (nullable NSArray *)topAccessoryViews; +- (nullable UIView *)topAccessoryView; @end diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index fe83351b..db1b7e5a 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -71,19 +71,7 @@ } } -- (nullable NSArray *)topAccessoryViews { - return nil; -} - -- (nullable UIView *)setUpTopAccessoryView { - NSArray *accessoryViews = [self topAccessoryViews]; - if (accessoryViews.count) { - UIView *topAccessoryView = [MVMCoreUICommonViewsUtility commonView]; - [StackableViewController populateView:topAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { - return UIEdgeInsetsZero; - }]; - return topAccessoryView; - } +- (nullable UIView *)topAccessoryView { return nil; } @@ -270,7 +258,7 @@ [header addSubview:topView]; [header addSubview:headerAccessoryView]; - UIView *topAccessoryView = [self setUpTopAccessoryView]; + UIView *topAccessoryView = [self topAccessoryView]; self.topAccessoryView = topAccessoryView; if (topAccessoryView) { [header addSubview:topAccessoryView]; diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h index 406fda1a..ab9823b8 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -38,7 +38,7 @@ #pragma mark - Subclass -- (nullable NSArray *)topAccessoryViews; +- (nullable UIView *)topAccessoryView; // Allow you to add any additional ui before buildViewsBetweenLabelsAndButtons gets called. Can use this to set the topBetweenEdgeView or bottomBetweenEdgeView - (void)buildInAdditionalViewsBeforeCenteredContent; diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index d7c1ca41..95c0e26e 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -118,7 +118,7 @@ [self.contentView addSubview:topView]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]]; - UIView *topAccessoryView = [self setUpTopAccessoryView]; + UIView *topAccessoryView = [self topAccessoryView]; self.topAccessoryView = topAccessoryView; if (topAccessoryView) { [self.contentView addSubview:topAccessoryView]; @@ -280,24 +280,7 @@ } } -- (nullable NSArray *)topAccessoryViews { - return nil; -} - -- (nullable UIView *)setUpTopAccessoryView { - NSArray *accessoryViews = [self topAccessoryViews]; - if (accessoryViews.count) { - UIView *topAccessoryView = [MVMCoreUICommonViewsUtility commonView]; - - __block typeof(self) weakSelf = self; - [StackableViewController populateView:topAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) { - UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object]; - edgeInsets.left = 0; - edgeInsets.right = 0; - return edgeInsets; - }]; - return topAccessoryView; - } +- (nullable UIView *)topAccessoryView { return nil; } From 8376e5c79e35981deb5f48f4430dc026e6058d8e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh Jain" Date: Fri, 15 Nov 2019 16:53:18 -0500 Subject: [PATCH 6/6] Revert "Merge branch 'feature/top_accessory' into 'develop'" This reverts merge request !175 --- ...abelsAndBottomButtonsTableViewController.h | 2 - ...abelsAndBottomButtonsTableViewController.m | 43 ++++++------------- .../TopLabelsAndBottomButtonsViewController.h | 2 - .../TopLabelsAndBottomButtonsViewController.m | 28 ++---------- 4 files changed, 16 insertions(+), 59 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h index b9beb281..04defbb4 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h @@ -71,6 +71,4 @@ - (BOOL)bottomViewOutsideOfScroll; //override for setting attributed headline and message -(void)setHeadlineAndMessage; -- (nullable UIView *)topAccessoryView; - @end diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index db1b7e5a..8b0a23bf 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -31,7 +31,6 @@ @property (strong, nonatomic) UIView *footerViewOutsideOfScroll; @property (strong, nonatomic) NSLayoutConstraint *bottomViewTopConstraint; @property (strong, nonatomic) UIView *headerAccessoryView; -@property (strong, nonatomic) UIView *topAccessoryView; @end @@ -71,9 +70,6 @@ } } -- (nullable UIView *)topAccessoryView { - return nil; -} - (void)newDataBuildScreen { [super newDataBuildScreen]; @@ -96,10 +92,10 @@ [self setHeadlineAndMessage]; self.topView = topLabelsView; } - + // Setup accessory view. [self setUpHeaderAccessoryView]; - + // add top view to table header if (self.topView) { self.topView.translatesAutoresizingMaskIntoConstraints = NO; @@ -257,26 +253,16 @@ UIView *headerAccessoryView = self.headerAccessoryView; [header addSubview:topView]; [header addSubview:headerAccessoryView]; - - UIView *topAccessoryView = [self topAccessoryView]; - self.topAccessoryView = topAccessoryView; - if (topAccessoryView) { - [header addSubview:topAccessoryView]; - [NSLayoutConstraint constraintPinSubview:topAccessoryView pinTop:YES pinBottom:NO pinLeft:YES pinRight:YES]; - [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; - } - - BOOL topPin = topAccessoryView ? NO : YES; - // Sets up the constraints - if (headerAccessoryView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; - [NSLayoutConstraint constraintPinSubview:topView pinTop:topPin topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - else { - self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:topPin topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; - } - + + // Sets up the constraints + if (headerAccessoryView) { + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topView]-0-[headerAccessoryView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView,headerAccessoryView)]]; + [NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:headerAccessoryView pinTop:NO topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } + else { + self.topViewBottomConstraint = [[NSLayoutConstraint constraintPinSubview:topView pinTop:YES topConstant:0 pinBottom:YES bottomConstant:[[self spaceAboveBetweenView] floatValue] pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0] objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; + } self.headerView = header; } @@ -295,7 +281,6 @@ self.footerView = footer; } - - (void)showHeader { if (self.headerView) { @@ -474,10 +459,6 @@ #pragma mark - Animation -(void)setupIntroAnimations { - - if (self.topAccessoryView.subviews.count) { - [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topAccessoryView]]; - } if (self.topView.subviews.count) { [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topView]]; } diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h index ab9823b8..720f0097 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -38,8 +38,6 @@ #pragma mark - Subclass -- (nullable UIView *)topAccessoryView; - // 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. diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index 95c0e26e..0c9d1d5d 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -31,8 +31,6 @@ @property (nullable, weak, nonatomic) UIView *betweenView; -@property (strong, nonatomic) UIView *topAccessoryView; - // Adds the button view to the screen. Out of the scroll or in. - (void)addViewOutsideOfScrollView:(UIView *)bottomView; - (void)addViewToContentView:(UIView *)bottomView; @@ -103,7 +101,7 @@ // Removes the bottom view out of scroll if it is there. [self.viewOutOfScroll removeFromSuperview]; [StackableViewController removeUIViews:[self.contentView subviews]]; - + // Checks if we are using a different object than top labels. UIView *topView = [self useCustomViewInsteadOfLabels]; self.topView = topView; @@ -117,19 +115,9 @@ } [self.contentView addSubview:topView]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]]; - - UIView *topAccessoryView = [self topAccessoryView]; - self.topAccessoryView = topAccessoryView; - if (topAccessoryView) { - [self.contentView addSubview:topAccessoryView]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]]; - self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topAccessoryView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; - [topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES; - } else { - self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; - } - + self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; self.topConstraintForTopView.active = YES; + // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; self.customBottemView = (bottomView != nil); @@ -278,10 +266,7 @@ if (self.topLabelsView) { [self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]]; } -} - -- (nullable UIView *)topAccessoryView { - return nil; + } - (void)updateViewConstraints { @@ -424,11 +409,6 @@ #pragma mark - Animations -(void)setupIntroAnimations { - - if (self.topAccessoryView.subviews.count) { - [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topAccessoryView]]; - } - if (self.topView.subviews) { [self.introAnimationManager addAnimationWithAnimation:[MVMAnimations fadeUpAnimationWithView:self.topView]]; }