Merge branch 'feature/modernize' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/modernize
This commit is contained in:
commit
095b1d7a86
@ -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];
|
||||
|
||||
@ -255,7 +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];
|
||||
[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;
|
||||
|
||||
@ -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<MVMCoreErrorObject>) -> 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.
|
||||
}
|
||||
}
|
||||
@ -71,4 +71,6 @@
|
||||
- (BOOL)bottomViewOutsideOfScroll;
|
||||
//override for setting attributed headline and message
|
||||
-(void)setHeadlineAndMessage;
|
||||
- (nullable UIView *)topAccessoryView;
|
||||
|
||||
@end
|
||||
|
||||
@ -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]];
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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]];
|
||||
}
|
||||
|
||||
43
MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift
Normal file
43
MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift
Normal file
@ -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<MVMCoreErrorObject?>?) -> [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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user