From a865664cff5d5d3288cf62ba348f50597c38bf6c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Nov 2019 16:52:13 -0500 Subject: [PATCH 1/4] add top accessory view --- ...abelsAndBottomButtonsTableViewController.h | 2 + ...abelsAndBottomButtonsTableViewController.m | 43 +++++++++++++------ .../TopLabelsAndBottomButtonsViewController.h | 2 + .../TopLabelsAndBottomButtonsViewController.m | 28 ++++++++++-- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h index 04defbb4..b9beb281 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 UIView *)topAccessoryView; + @end diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 8b0a23bf..db1b7e5a 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 @@ -70,6 +71,9 @@ } } +- (nullable UIView *)topAccessoryView { + return nil; +} - (void)newDataBuildScreen { [super newDataBuildScreen]; @@ -92,10 +96,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 +257,26 @@ 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 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]]; + } + self.headerView = header; } @@ -281,6 +295,7 @@ self.footerView = footer; } + - (void)showHeader { if (self.headerView) { @@ -459,6 +474,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.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h index 720f0097..ab9823b8 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -38,6 +38,8 @@ #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 0c9d1d5d..95c0e26e 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; @@ -101,7 +103,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; @@ -115,9 +117,19 @@ } [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]; + + 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.active = YES; - // Checks if we are using a different object than the bottom buttons. UIView *bottomView = [self useCustomViewInsteadOfButtons]; self.customBottemView = (bottomView != nil); @@ -266,7 +278,10 @@ if (self.topLabelsView) { [self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]]; } - +} + +- (nullable UIView *)topAccessoryView { + return nil; } - (void)updateViewConstraints { @@ -409,6 +424,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 3cb075499e83135cbb790785041a340b308bb0ae Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 19 Nov 2019 10:39:30 -0500 Subject: [PATCH 2/4] make checkbox expandable --- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index 50377b1a..3f74a3ee 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -228,7 +228,9 @@ static const CGFloat CheckBoxHeightWidth = 18.0; NSDictionary *constraints = [NSLayoutConstraint constraintPinView:checkedSquare heightConstraint:YES heightConstant:size widthConstraint:YES widthConstant:size]; self.checkboxWidth = constraints[ConstraintWidth]; self.checkboxHeight = constraints[ConstraintHeight]; - [NSLayoutConstraint constraintPinSubview:checkedSquare pinTop:YES pinBottom:YES pinLeft:YES pinRight:NO]; + [NSLayoutConstraint constraintPinSubview:checkedSquare pinTop:NO pinBottom:NO pinLeft:YES pinRight:NO]; + [checkedSquare.topAnchor constraintGreaterThanOrEqualToAnchor:containterView.topAnchor].active = YES; + [containterView.bottomAnchor constraintGreaterThanOrEqualToAnchor:checkedSquare.bottomAnchor].active = YES; self.checkboxRightPinConstraint = [checkedSquare.trailingAnchor constraintEqualToAnchor:containterView.trailingAnchor]; @@ -256,6 +258,8 @@ static const CGFloat CheckBoxHeightWidth = 18.0; [containterView addSubview:descriptionLabel]; [NSLayoutConstraint constraintPinSubview:descriptionLabel pinCenterX:NO pinCenterY:YES]; [NSLayoutConstraint constraintPinSubview:descriptionLabel pinTop:NO pinBottom:NO pinLeft:NO pinRight:YES]; + [descriptionLabel.topAnchor constraintGreaterThanOrEqualToAnchor:containterView.topAnchor].active = YES; + [containterView.bottomAnchor constraintGreaterThanOrEqualToAnchor:descriptionLabel.bottomAnchor].active = YES; self.descriptionLabelLeadingConstraint = [NSLayoutConstraint constraintWithItem:descriptionLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.checkedSquare attribute:NSLayoutAttributeTrailing multiplier:1 constant:11]; self.descriptionLabelLeadingConstraint.active = YES; From 3851ad036ae63791d5ad6b532f5317abef3e8436 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 19 Nov 2019 12:53:48 -0500 Subject: [PATCH 3/4] change to equal --- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index 3f74a3ee..6a9d7fff 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -258,8 +258,8 @@ static const CGFloat CheckBoxHeightWidth = 18.0; [containterView addSubview:descriptionLabel]; [NSLayoutConstraint constraintPinSubview:descriptionLabel pinCenterX:NO pinCenterY:YES]; [NSLayoutConstraint constraintPinSubview:descriptionLabel pinTop:NO pinBottom:NO pinLeft:NO pinRight:YES]; - [descriptionLabel.topAnchor constraintGreaterThanOrEqualToAnchor:containterView.topAnchor].active = YES; - [containterView.bottomAnchor constraintGreaterThanOrEqualToAnchor:descriptionLabel.bottomAnchor].active = YES; + [descriptionLabel.topAnchor constraintEqualToAnchor:containterView.topAnchor].active = YES; + [containterView.bottomAnchor constraintEqualToAnchor:descriptionLabel.bottomAnchor].active = YES; self.descriptionLabelLeadingConstraint = [NSLayoutConstraint constraintWithItem:descriptionLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.checkedSquare attribute:NSLayoutAttributeTrailing multiplier:1 constant:11]; self.descriptionLabelLeadingConstraint.active = YES; From a409b331c52a8b3269264bab02cceb666b5c8143 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 19 Nov 2019 12:56:07 -0500 Subject: [PATCH 4/4] revert --- MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m index 6a9d7fff..54358ebe 100644 --- a/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m +++ b/MVMCoreUI/Atoms/Views/MVMCoreUICheckBox.m @@ -257,9 +257,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0; Label *descriptionLabel = [Label commonLabelB2:YES]; [containterView addSubview:descriptionLabel]; [NSLayoutConstraint constraintPinSubview:descriptionLabel pinCenterX:NO pinCenterY:YES]; - [NSLayoutConstraint constraintPinSubview:descriptionLabel pinTop:NO pinBottom:NO pinLeft:NO pinRight:YES]; - [descriptionLabel.topAnchor constraintEqualToAnchor:containterView.topAnchor].active = YES; - [containterView.bottomAnchor constraintEqualToAnchor:descriptionLabel.bottomAnchor].active = YES; + [NSLayoutConstraint constraintPinSubview:descriptionLabel pinTop:YES pinBottom:YES pinLeft:NO pinRight:YES]; self.descriptionLabelLeadingConstraint = [NSLayoutConstraint constraintWithItem:descriptionLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.checkedSquare attribute:NSLayoutAttributeTrailing multiplier:1 constant:11]; self.descriptionLabelLeadingConstraint.active = YES;