From a865664cff5d5d3288cf62ba348f50597c38bf6c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Nov 2019 16:52:13 -0500 Subject: [PATCH 1/6] 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/6] 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/6] 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/6] 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; From 654be26b2c84eab7fb687ca526950c959812ab92 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Nov 2019 11:06:47 -0500 Subject: [PATCH 5/6] remove test file --- .../BaseControllers/ViewController.swift | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 MVMCoreUI/BaseControllers/ViewController.swift diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift deleted file mode 100644 index 1bdbf76e..00000000 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// ViewController.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 11/5/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers open class ViewController: UIViewController, MVMCoreViewControllerProtocol { - public var pageType: String? - public var loadObject: MVMCoreLoadObject? - - // MARK: - Response handling - public func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { - pageType = loadObject.pageType - self.loadObject = loadObject - - // Verifies all modules needed are loaded. - return MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) - } - - public class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { - guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType) else { return true } - - guard let loadedModules = loadObject?.modulesJSON else { return false } - - for case let key as String in Array(loadedModules.keys) { - guard modulesRequired.count > 0 else { break } - if let index = modulesRequired.firstIndex(where: {($0 as? String) == key}), index != NSNotFound { - modulesRequired.remove(at: index) - } - } - - guard modulesRequired.count == 0 else { - if error != nil { - error = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorCritical), messageToLog: modulesRequired.description, code: ErrorCode.requiredModuleNotPresent.rawValue, domain: ErrorDomainNative, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject!)) - } - return false - } - return true - } - - open func newDataBuildScreen() { - // TODO- tell navigation object to update with model - - } - - open func initialLoad() { - } - - open func updateViews() { - } - - override open func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } -} From 947af9b3c759399997ebecc2e65f8d710db887d4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Nov 2019 11:08:30 -0500 Subject: [PATCH 6/6] why? --- .../Items/MoleculeTableViewCell.swift | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift new file mode 100644 index 00000000..4769b7e5 --- /dev/null +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -0,0 +1,43 @@ +// +// MoleculeTableViewCell.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/18/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class MoleculeTableViewCell: TableViewCell { + + // MARK: - MVMCoreUIMoleculeViewProtocol + public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + + guard molecule == nil, let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule), let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) else { return } + addMolecule(moleculeView) + } + + public override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) else { + return 80 + } + return max(2 * PaddingDefaultVerticalSpacing3, height) + } + + public override class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? { + guard let molecule = molecule?.optionalDictionaryForKey(KeyMolecule) else { + return "\(self)<>" + } + let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) ?? "" + return "\(self)<\(moleculeName)>" + } + + public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), + let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else { + return nil + } + return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error) + } +}