From b5a97de18351799d33e15e195dc50163dc37f7ff Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Oct 2019 14:03:47 -0400 Subject: [PATCH 01/21] swiftify --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++++----- MVMCoreUI/Atoms/Views/Label.swift | 1 - .../Containers/NavigationController.swift | 33 +++++++++++++++++++ MVMCoreUI/MVMCoreUI.h | 1 - MVMCoreUI/OtherHandlers/CoreUIObject.swift | 23 +++++++++++++ .../MVMCoreUIMoleculeMappingObject.m | 3 +- MVMCoreUI/OtherHandlers/MVMCoreUIObject.h | 20 ----------- MVMCoreUI/OtherHandlers/MVMCoreUIObject.m | 27 --------------- .../OtherHandlers/MoleculeDelegateProtocol.h | 1 + 9 files changed, 66 insertions(+), 59 deletions(-) create mode 100644 MVMCoreUI/Containers/NavigationController.swift create mode 100644 MVMCoreUI/OtherHandlers/CoreUIObject.swift delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIObject.h delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIObject.m diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0eca06db..cb81fe8e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -51,8 +51,6 @@ D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; }; D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; }; D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; - 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 */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -179,6 +177,8 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */; }; + D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */; }; + D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B93236214AD00A9AEDC /* NavigationController.swift */; }; D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; @@ -240,8 +240,6 @@ D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = ""; }; D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = ""; }; D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; 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 = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; @@ -372,6 +370,8 @@ D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeCollectionViewCell.swift; sourceTree = ""; }; + D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreUIObject.swift; sourceTree = ""; }; + D2B18B93236214AD00A9AEDC /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHeadlineBody.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; @@ -617,6 +617,7 @@ D29DF2B621E7BE66003B2FB9 /* SplitViewController */, D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */, D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */, + D2B18B93236214AD00A9AEDC /* NavigationController.swift */, ); path = Containers; sourceTree = ""; @@ -779,8 +780,7 @@ isa = PBXGroup; children = ( D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */, - D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, - D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, + D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */, D29DF27321E79E81003B2FB9 /* MVMCoreUILoggingHandler.h */, @@ -905,7 +905,6 @@ D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */, D29DF2C421E7BF57003B2FB9 /* MFTabBarSwipeAnimator.h in Headers */, D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */, - D28B4F8A21FF967C00712C7A /* MVMCoreUIObject.h in Headers */, D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */, D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */, D29DF2BD21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h in Headers */, @@ -1049,12 +1048,12 @@ DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, - D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */, D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, + D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, @@ -1108,6 +1107,7 @@ D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, + D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */, D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 52ee43d1..be52b36d 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -80,7 +80,6 @@ public typealias ActionBlock = () -> () //------------------------------------------------------ @objc public func setupView() { - backgroundColor = .clear numberOfLines = 0 lineBreakMode = .byWordWrapping diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift new file mode 100644 index 00000000..689ba1b5 --- /dev/null +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -0,0 +1,33 @@ +// +// NavigationController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class NavigationController: UINavigationController { + var separatorView: SeparatorView? + + static func navigationController() -> Self? { + return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self + } + + /*static func setupNavigationController() -> Self? { + let navigationController = NavigationController() + UIColor.mfSetBackgroundColor(forNavigationBar: .white, navigationBar: navigationController.navigationBar, transparent: false) + navigationController.navigationBar.shadowImage = UIImage() + navigationController.navigationBar.isOpaque = true + navigationController.navigationBar.tintColor = .black + navigationController.separatorView = SeparatorView.separatorAdd(to: navigationController.navigationBar, position: SeparatorPositionBot, withHorizontalPadding: 0) + navigationController.separatorView?.setAsLight() + navigationController.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14)] + + MVMCoreUISession.sharedGlobal()?.navigationController = navigationController + MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController + MVMCoreNavigationHandler.shared()?.navigationController = navigationController + return navigationController + }*/ +} diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 258fcd1c..db10107c 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -16,7 +16,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #pragma mark - OtherHandlers -#import #import #import #import diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift new file mode 100644 index 00000000..af0f5023 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -0,0 +1,23 @@ +// +// CoreUIObject.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class CoreUIObject: MVMCoreObject { + public var moleculeMap: MVMCoreUIMoleculeMappingObject? + + open override func defaultInitialSetup() { + cache = MVMCoreCache() + sessionHandler = MVMCoreSessionTimeHandler() + actionHandler = MVMCoreActionHandler() + session = MVMCoreUISession() + viewControllerMapping = MVMCoreUIViewControllerMappingObject() + loggingDelegate = MVMCoreUILoggingHandler() + moleculeMap = MVMCoreUIMoleculeMappingObject() + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 2f73e272..29471fc4 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -11,7 +11,6 @@ @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreLoadObject; @import MVMCore.MVMCoreErrorObject; -#import "MVMCoreUIObject.h" #import #import "MFTextField.h" #import "MVMCoreUIPageControl.h" @@ -70,7 +69,7 @@ + (nullable instancetype)sharedMappingObject { - return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self]; + return [MVMCoreActionUtility initializerClassCheck:[CoreUIObject sharedInstance].moleculeMap classToVerify:self]; } - (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIObject.h deleted file mode 100644 index 080bd457..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIObject.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// MVMCoreUIObject.h -// MVMCoreUI -// -// Created by Scott Pfeil on 1/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface MVMCoreUIObject : MVMCoreObject - -@property (nullable, nonatomic, strong) MVMCoreUIMoleculeMappingObject *moleculeMap; - -@end - -NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIObject.m deleted file mode 100644 index cea769d1..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIObject.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// MVMCoreUIObject.m -// MVMCoreUI -// -// Created by Scott Pfeil on 1/28/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreUIObject.h" -#import "MVMCoreUISession.h" -#import "MVMCoreUIViewControllerMappingObject.h" -#import "MVMCoreUILoggingHandler.h" - -@implementation MVMCoreUIObject - -- (void)defaultInitialSetup { - self.cache = [[MVMCoreCache alloc] init]; - self.sessionHandler = [[MVMCoreSessionTimeHandler alloc] init]; - self.actionHandler = [[MVMCoreActionHandler alloc] init]; - - self.session = [[MVMCoreUISession alloc] init]; - self.viewControllerMapping = [[MVMCoreUIViewControllerMappingObject alloc] init]; - self.loggingDelegate = [[MVMCoreUILoggingHandler alloc] init]; - self.moleculeMap = [[MVMCoreUIMoleculeMappingObject alloc] init]; -} - -@end diff --git a/MVMCoreUI/OtherHandlers/MoleculeDelegateProtocol.h b/MVMCoreUI/OtherHandlers/MoleculeDelegateProtocol.h index 57eb63f5..a69dad3c 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeDelegateProtocol.h +++ b/MVMCoreUI/OtherHandlers/MoleculeDelegateProtocol.h @@ -6,6 +6,7 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // #import +#import @protocol MoleculeDelegateProtocol From 52f31eff42509163871d77f0d5a70e3c0586af9e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 4 Nov 2019 15:34:32 -0500 Subject: [PATCH 02/21] header changes --- MVMCoreUI/BaseControllers/MFViewController.m | 1 - MVMCoreUI/Containers/NavigationController.swift | 15 ++++++++------- .../MVMCoreUISplitViewController.h | 5 ++--- .../MVMCoreUISplitViewController.m | 6 +++--- MVMCoreUI/MVMCoreUI.h | 2 -- MVMCoreUI/OtherHandlers/MVMCoreUISession.h | 4 ++-- MVMCoreUI/Utility/MVMCoreUIUtility.m | 1 - 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 2311781e..2c8e3997 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -35,7 +35,6 @@ #import "MVMCoreUISession.h" #import "MVMCoreUILoggingHandler.h" #import "MVMCoreUITabBarPageControlViewController.h" -#import "MVMCoreUINavigationController.h" #import @import MVMAnimationFramework; diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 689ba1b5..1b551ffb 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -9,25 +9,26 @@ import UIKit @objcMembers open class NavigationController: UINavigationController { - var separatorView: SeparatorView? + public var separatorView: SeparatorView? - static func navigationController() -> Self? { + public static func navigationController() -> Self? { return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self } - /*static func setupNavigationController() -> Self? { - let navigationController = NavigationController() + public static func setupNavigationController() -> Self? { + let navigationController = self.init() UIColor.mfSetBackgroundColor(forNavigationBar: .white, navigationBar: navigationController.navigationBar, transparent: false) navigationController.navigationBar.shadowImage = UIImage() navigationController.navigationBar.isOpaque = true navigationController.navigationBar.tintColor = .black navigationController.separatorView = SeparatorView.separatorAdd(to: navigationController.navigationBar, position: SeparatorPositionBot, withHorizontalPadding: 0) navigationController.separatorView?.setAsLight() - navigationController.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14)] - + if let font = MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14) { + navigationController.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font]; + } MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController return navigationController - }*/ + } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index cf27dc78..af02281d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -11,10 +11,9 @@ @import MVMCore.MVMCoreActionDelegateProtocol; #import #import - -@class MVMCoreUINavigationController; @class MVMCoreUITopAlertView; @class MFViewController; +@class NavigationController; typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { MFNoDrawer = 0, @@ -34,7 +33,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @property (nullable, strong, nonatomic) UIBarButtonItem *backButton; -@property (nullable, weak, nonatomic, readonly) MVMCoreUINavigationController *navigationController; +@property (nullable, weak, nonatomic, readonly) NavigationController *navigationController; // Reference to the top alert view @property (nullable, weak, nonatomic) MVMCoreUITopAlertView *topAlertView; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index af1e5c53..b529ac19 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -23,7 +23,7 @@ #import "MVMCoreUIConstants.h" #import "MVMCoreUICommonViewsUtility.h" #import "MVMCoreUITopAlertView.h" -#import "MVMCoreUINavigationController.h" +#import @interface MVMCoreUISplitViewController () @@ -50,7 +50,7 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) { @property (weak, nonatomic, readwrite) UIViewController *leftPanel; @property (weak, nonatomic, readwrite) UIViewController *rightPanel; -@property (weak, nonatomic, readwrite) MVMCoreUINavigationController *navigationController; +@property (weak, nonatomic, readwrite) NavigationController *navigationController; // A view that covers the detail view when the master is out. @property (weak, nonatomic) IBOutlet UIView *mainViewCoverView; @@ -802,7 +802,7 @@ CGFloat const PanelAnimationDuration = 0.2; } // The main view. - MVMCoreUINavigationController *navigationController = [MVMCoreUINavigationController setupNavigationController]; + NavigationController *navigationController = [NavigationController setupNavigationController]; self.navigationController = navigationController; self.automaticallyAdjustsScrollViewInsets = NO; diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index db10107c..795298b3 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -58,8 +58,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #pragma mark - Containers -#import - #import #import #import diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h index 8adb32cd..ca2db26e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h @@ -11,15 +11,15 @@ @class MVMCoreUITopAlertView; @class MVMCoreUISplitViewController; @class MFViewController; -@class MVMCoreUINavigationController; @class MFLoadingViewController; +@class NavigationController; NS_ASSUME_NONNULL_BEGIN @interface MVMCoreUISession : MVMCoreSessionObject @property (weak, nonatomic, nullable) MVMCoreUITopAlertView *topAlertView; @property (weak, nonatomic, nullable) MVMCoreUISplitViewController *splitViewController; -@property (weak, nonatomic, nullable) MVMCoreUINavigationController *navigationController; +@property (weak, nonatomic, nullable) NavigationController *navigationController; @property (weak, nonatomic, nullable) MFLoadingViewController *loadingViewController; /// Tracks the current page type the user is currently viewing. KVO compliant. diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index 48a7a6a1..b760eb36 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -9,7 +9,6 @@ #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" #import "MVMCoreUISession.h" -#import "MVMCoreUINavigationController.h" #import "MVMCoreUISplitViewController.h" @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreGetterUtility; From 4b374c4e7e32b05e853bf43f10122439e105e4fe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 5 Nov 2019 08:50:54 -0500 Subject: [PATCH 03/21] modernizing --- MVMCoreUI.xcodeproj/project.pbxproj | 20 +++++++--------- .../Containers/NavigationController.swift | 24 +++++++++++++------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 43766f37..3e5230ed 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -30,8 +30,6 @@ 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; - D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; }; D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */; }; @@ -182,10 +180,10 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */; }; - D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */; }; - D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B93236214AD00A9AEDC /* NavigationController.swift */; }; D2B18B7F2360913400A9AEDC /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B7E2360913400A9AEDC /* Control.swift */; }; D2B18B812360945C00A9AEDC /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B802360945C00A9AEDC /* View.swift */; }; + D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */; }; + D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B93236214AD00A9AEDC /* NavigationController.swift */; }; D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; @@ -194,6 +192,7 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; + D2F4DDE62371A4CB00CD28BB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F4DDE52371A4CB00CD28BB /* ViewController.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; @@ -225,8 +224,6 @@ 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; - D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; - D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = ""; }; D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodySwitch.swift; sourceTree = ""; }; @@ -381,10 +378,10 @@ D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeCollectionViewCell.swift; sourceTree = ""; }; - D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreUIObject.swift; sourceTree = ""; }; - D2B18B93236214AD00A9AEDC /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; D2B18B7E2360913400A9AEDC /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; D2B18B802360945C00A9AEDC /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; + D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreUIObject.swift; sourceTree = ""; }; + D2B18B93236214AD00A9AEDC /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHeadlineBody.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; @@ -393,6 +390,7 @@ D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = ""; }; + D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = ""; }; DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; @@ -610,6 +608,7 @@ D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, + D2F4DDE52371A4CB00CD28BB /* ViewController.swift */, ); path = BaseControllers; sourceTree = ""; @@ -631,8 +630,6 @@ children = ( D29DF2B721E7BE79003B2FB9 /* TabBarController */, D29DF2B621E7BE66003B2FB9 /* SplitViewController */, - D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */, - D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */, D2B18B93236214AD00A9AEDC /* NavigationController.swift */, ); path = Containers; @@ -888,7 +885,6 @@ D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */, D29DF18021E69E49003B2FB9 /* MFView.h in Headers */, D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */, - D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */, D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */, D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */, D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, @@ -1098,7 +1094,6 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, - D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, @@ -1114,6 +1109,7 @@ D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, + D2F4DDE62371A4CB00CD28BB /* ViewController.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 1b551ffb..f22ebb2f 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -15,20 +15,30 @@ import UIKit return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self } + public static func style(_ navigationBar: UINavigationBar) { + UIColor.mfSetBackgroundColor(forNavigationBar: .white, navigationBar: navigationBar, transparent: false) + navigationBar.shadowImage = UIImage() + navigationBar.isOpaque = true + navigationBar.tintColor = .black + if let font = MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14) { + navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font]; + } + } + public static func setupNavigationController() -> Self? { let navigationController = self.init() - UIColor.mfSetBackgroundColor(forNavigationBar: .white, navigationBar: navigationController.navigationBar, transparent: false) - navigationController.navigationBar.shadowImage = UIImage() - navigationController.navigationBar.isOpaque = true - navigationController.navigationBar.tintColor = .black + style(navigationController.navigationBar) navigationController.separatorView = SeparatorView.separatorAdd(to: navigationController.navigationBar, position: SeparatorPositionBot, withHorizontalPadding: 0) navigationController.separatorView?.setAsLight() - if let font = MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14) { - navigationController.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font]; - } MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController return navigationController } + + public static func setupNavigationControllerAsMainController() -> Self? { + guard let navigationController = setupNavigationController() else { return nil } + MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) + return navigationController + } } From f1b8a61e047e5e1713ada21004a9add1e0c7cb8a Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 14 Nov 2019 18:15:22 -0500 Subject: [PATCH 04/21] 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 05/21] 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 06/21] 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 07/21] 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 08/21] 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 a865664cff5d5d3288cf62ba348f50597c38bf6c Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Nov 2019 16:52:13 -0500 Subject: [PATCH 09/21] 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 8376e5c79e35981deb5f48f4430dc026e6058d8e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh Jain" Date: Fri, 15 Nov 2019 16:53:18 -0500 Subject: [PATCH 10/21] 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]]; } From d29e8ea3bd1392c95edd84a0bec2520b5662e902 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 19 Nov 2019 09:18:15 -0500 Subject: [PATCH 11/21] small changes --- MVMCoreUI.xcodeproj/project.pbxproj | 34 ++++++++++++++----- MVMCoreUI/Atoms/Views/GraphView.swift | 6 +++- .../Controllers}/StackableViewController.h | 0 .../Controllers}/StackableViewController.m | 0 ...abelsAndBottomButtonsTableViewController.h | 0 ...abelsAndBottomButtonsTableViewController.m | 0 .../TopLabelsAndBottomButtonsViewController.h | 0 .../TopLabelsAndBottomButtonsViewController.m | 0 8 files changed, 30 insertions(+), 10 deletions(-) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/StackableViewController.h (100%) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/StackableViewController.m (100%) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/TopLabelsAndBottomButtonsTableViewController.h (100%) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/TopLabelsAndBottomButtonsTableViewController.m (100%) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/TopLabelsAndBottomButtonsViewController.h (100%) rename MVMCoreUI/{LegacyControllers => Legacy/Controllers}/TopLabelsAndBottomButtonsViewController.m (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cac661ed..09f36473 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -427,6 +427,26 @@ path = FormUIHelpers; sourceTree = ""; }; + D213347423842FE3008E41B3 /* Controllers */ = { + isa = PBXGroup; + children = ( + D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, + D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, + D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, + D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, + D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, + D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */, + ); + path = Controllers; + sourceTree = ""; + }; + D213347523842FF5008E41B3 /* Views */ = { + isa = PBXGroup; + children = ( + ); + path = Views; + sourceTree = ""; + }; D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( @@ -486,17 +506,13 @@ path = Items; sourceTree = ""; }; - D22D1F582204D2590077CEC0 /* LegacyControllers */ = { + D22D1F582204D2590077CEC0 /* Legacy */ = { isa = PBXGroup; children = ( - D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, - D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, - D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, - D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, - D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, - D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */, + D213347523842FF5008E41B3 /* Views */, + D213347423842FE3008E41B3 /* Controllers */, ); - path = LegacyControllers; + path = Legacy; sourceTree = ""; }; D29DF0C221E404D4003B2FB9 = { @@ -527,7 +543,7 @@ D29DF13321E68604003B2FB9 /* Styles */, D29DF11021E6805F003B2FB9 /* Categories */, D29DF11921E68467003B2FB9 /* Containers */, - D22D1F582204D2590077CEC0 /* LegacyControllers */, + D22D1F582204D2590077CEC0 /* Legacy */, D29DF10F21E67A7D003B2FB9 /* BaseControllers */, D29DF11E21E6851E003B2FB9 /* TopAlert */, D29DF10D21E67A70003B2FB9 /* Atoms */, diff --git a/MVMCoreUI/Atoms/Views/GraphView.swift b/MVMCoreUI/Atoms/Views/GraphView.swift index ebd074a0..eb2b2099 100644 --- a/MVMCoreUI/Atoms/Views/GraphView.swift +++ b/MVMCoreUI/Atoms/Views/GraphView.swift @@ -109,7 +109,7 @@ public struct GraphObject { } -@objcMembers open class GraphView: View { +@objcMembers open class GraphView: View, MVMCoreUIViewConstrainingProtocol { var heightConstraint: NSLayoutConstraint? var gradientLayer: CALayer? @@ -240,6 +240,10 @@ public struct GraphObject { return containLayer } +//MARK: MVMCoreUIViewConstrainingProtocol + public func needsToBeConstrained() -> Bool { + return true + } //MARK: Animation func rotationAnimation(_ object: GraphObject) { diff --git a/MVMCoreUI/LegacyControllers/StackableViewController.h b/MVMCoreUI/Legacy/Controllers/StackableViewController.h similarity index 100% rename from MVMCoreUI/LegacyControllers/StackableViewController.h rename to MVMCoreUI/Legacy/Controllers/StackableViewController.h diff --git a/MVMCoreUI/LegacyControllers/StackableViewController.m b/MVMCoreUI/Legacy/Controllers/StackableViewController.m similarity index 100% rename from MVMCoreUI/LegacyControllers/StackableViewController.m rename to MVMCoreUI/Legacy/Controllers/StackableViewController.m diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsTableViewController.h similarity index 100% rename from MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.h rename to MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsTableViewController.h diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsTableViewController.m similarity index 100% rename from MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m rename to MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsTableViewController.m diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.h similarity index 100% rename from MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h rename to MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.h diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m similarity index 100% rename from MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m rename to MVMCoreUI/Legacy/Controllers/TopLabelsAndBottomButtonsViewController.m From 3cb075499e83135cbb790785041a340b308bb0ae Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 19 Nov 2019 10:39:30 -0500 Subject: [PATCH 12/21] 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 13/21] 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 14/21] 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 c96f5050a83360e378ec63a8839ebab81943b1ad Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Nov 2019 10:20:24 -0500 Subject: [PATCH 15/21] Line to swift --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++- MVMCoreUI/Atoms/Views/CaretView.swift | 14 ++- MVMCoreUI/Atoms/Views/DashLine.swift | 5 +- MVMCoreUI/Atoms/Views/Line.swift | 113 ++++++++++++++++++ MVMCoreUI/Atoms/Views/MultiProgress.swift | 4 +- .../NSLayoutConstraint+MFConvenience.h | 2 + .../NSLayoutConstraint+MFConvenience.m | 27 ++++- .../Containers/NavigationController.swift | 6 +- MVMCoreUI/{Atoms => Legacy}/Views/LabelView.h | 0 MVMCoreUI/{Atoms => Legacy}/Views/LabelView.m | 0 MVMCoreUI/{Atoms => Legacy}/Views/MFView.h | 0 MVMCoreUI/{Atoms => Legacy}/Views/MFView.m | 0 .../{Atoms => Legacy}/Views/SeparatorView.h | 0 .../{Atoms => Legacy}/Views/SeparatorView.m | 0 MVMCoreUI/Molecules/Items/TableViewCell.swift | 73 ++++++----- MVMCoreUI/Molecules/StandardHeaderView.swift | 30 ++--- .../MVMCoreUIMoleculeMappingObject.m | 3 +- .../Templates/MoleculeListTemplate.swift | 9 +- 18 files changed, 220 insertions(+), 82 deletions(-) create mode 100644 MVMCoreUI/Atoms/Views/Line.swift rename MVMCoreUI/{Atoms => Legacy}/Views/LabelView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/LabelView.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/MFView.m (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/SeparatorView.h (100%) rename MVMCoreUI/{Atoms => Legacy}/Views/SeparatorView.m (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 09f36473..1ed38510 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; + D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; }; D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */; }; D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */; }; @@ -229,6 +230,7 @@ 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; + D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = ""; }; D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodySwitch.swift; sourceTree = ""; }; D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = ""; }; @@ -443,6 +445,12 @@ D213347523842FF5008E41B3 /* Views */ = { isa = PBXGroup; children = ( + D29DF17E21E69E2E003B2FB9 /* MFView.h */, + D29DF17F21E69E2E003B2FB9 /* MFView.m */, + D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, + D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, + D29DF15921E697DA003B2FB9 /* SeparatorView.h */, + D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, ); path = Views; sourceTree = ""; @@ -737,19 +745,14 @@ DBC4391622442196001AB423 /* CaretView.swift */, DBC4391722442197001AB423 /* DashLine.swift */, DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */, - D29DF17E21E69E2E003B2FB9 /* MFView.h */, - D29DF17F21E69E2E003B2FB9 /* MFView.m */, - D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, - D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */, D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */, D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */, + D213347623843825008E41B3 /* Line.swift */, D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */, D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */, D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */, - D29DF15921E697DA003B2FB9 /* SeparatorView.h */, - D29DF15A21E697DA003B2FB9 /* SeparatorView.m */, D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */, D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */, D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */, @@ -1092,6 +1095,7 @@ D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, + D213347723843825008E41B3 /* Line.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index ec4457c2..b68d0535 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -8,7 +8,7 @@ // -open class CaretView: MFView { +open class CaretView: View { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -26,7 +26,7 @@ open class CaretView: MFView { // MARK: - Initialization //------------------------------------------------------ - @objc public init() { + @objc public override init() { super.init(frame: .zero) } @@ -99,7 +99,7 @@ open class CaretView: MFView { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { + @objc open func setAsMolecule() { defaultState() } @@ -124,12 +124,14 @@ open class CaretView: MFView { lineWidth = lineWidthValue } } - - open override func needsToBeConstrained() -> Bool { +} + +extension CaretView: MVMCoreUIViewConstrainingProtocol { + open func needsToBeConstrained() -> Bool { return true } - open override func alignment() -> UIStackView.Alignment { + open func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } } diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 512b48cd..25e39b1b 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -10,7 +10,7 @@ import MVMCore -open class DashLine: MFView { +open class DashLine: View { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -62,8 +62,7 @@ open class DashLine: MFView { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { - + @objc open func setAsMolecule() { backgroundColor = .clear isHidden = false } diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift new file mode 100644 index 00000000..a5934aac --- /dev/null +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -0,0 +1,113 @@ +// +// Line.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 11/19/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class Line: View { + + public var heightConstraint: NSLayoutConstraint? + + public enum Style: String, Codable { + case standard + case thin + case medium + case heavy + case none + } + + public var style = Style.standard { + didSet { + switch style { + case .standard: + heightConstraint?.constant = 1 + backgroundColor = .mfSilver() + setNeedsLayout() + layoutIfNeeded() + case .thin: + heightConstraint?.constant = 1 + backgroundColor = .black + setNeedsLayout() + layoutIfNeeded() + case .medium: + heightConstraint?.constant = 2 + backgroundColor = .black + setNeedsLayout() + layoutIfNeeded() + case .heavy: + heightConstraint?.constant = 4 + backgroundColor = .black + setNeedsLayout() + layoutIfNeeded() + case .none: + heightConstraint?.constant = 0 + setNeedsLayout() + layoutIfNeeded() + } + } + } + + // MARK: - Helpers + open func shouldBeVisible() -> Bool { + guard let type = json?.optionalStringForKey(KeyType) else { return false } + return type != "none" + } + + public convenience init(pinTo view: UIView, edge: UIRectEdge, useMargin: Bool) { + self.init(frame: .zero) + view.addSubview(self) + NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: self, useMargins: useMargin, pinTop: edge != .bottom, pinBottom: edge != .top, pinLeft: edge != .right, pinRight: edge != .left).values)) + } + + // MARK: - MVMCoreViewProtocol + open override func setupView() { + super.setupView() + backgroundColor = .black + heightConstraint = heightAnchor.constraint(equalToConstant: 1) + heightConstraint?.isActive = true + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + + if let typeString = json?.optionalStringForKey(KeyType), let type = Style.init(rawValue: typeString) { + style = type + } else { + style = .standard + } + + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + } + + open override func reset() { + style = .standard + } + + open func copyBackgroundColor() -> Bool { + return false + } + + public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + guard let type = json?.optionalStringForKey(KeyType) else { return 0 } + switch type { + case "thin", "standard": + return 1 + case "medium": + return 2 + case "heavy": + return 4 + default: + return 0 + } + } +} + +extension Line: MVMCoreUIViewConstrainingProtocol { + open func needsToBeConstrained() -> Bool { + return true + } +} diff --git a/MVMCoreUI/Atoms/Views/MultiProgress.swift b/MVMCoreUI/Atoms/Views/MultiProgress.swift index fe902d9f..fdfb5316 100644 --- a/MVMCoreUI/Atoms/Views/MultiProgress.swift +++ b/MVMCoreUI/Atoms/Views/MultiProgress.swift @@ -34,7 +34,7 @@ import UIKit } } -@objcMembers open class MultiProgress: MFView { +@objcMembers open class MultiProgress: View { ///passing value to progressList creates corresponding progress bars var progressList: Array? { didSet { @@ -49,7 +49,7 @@ import UIKit guard progressObject.progress > 0.0 else { continue } - let view = MFView(frame: .zero) + let view = UIView(frame: .zero) view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) view.backgroundColor = progressObject.color diff --git a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h index 3d615da7..824b8b81 100644 --- a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h +++ b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.h @@ -62,6 +62,8 @@ extern NSString * _Nonnull const ConstraintWidth; #pragma mark - With Margins + (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins; ++ (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop pinBottom:(BOOL)pinBottom pinLeft:(BOOL)pinLeft pinRight:(BOOL)pinRight; ++ (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop topConstant:(CGFloat)topConstant pinBottom:(BOOL)pinBottom bottomConstant:(CGFloat)bottomConstant pinLeft:(BOOL)pinLeft leftConstant:(CGFloat)leftConstant pinRight:(BOOL)pinRight rightConstant:(CGFloat)rightConstant; + (nonnull NSLayoutConstraint *)pinViewTopToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; + (nonnull NSLayoutConstraint *)pinViewLeftToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; + (nonnull NSLayoutConstraint *)pinViewRightToSuperview:(nonnull UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant; diff --git a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m index 72aad96f..43fa6beb 100644 --- a/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m +++ b/MVMCoreUI/Categories/NSLayoutConstraint+MFConvenience.m @@ -161,11 +161,28 @@ NSString *const ConstraintWidth = @"width"; #pragma mark - With Margins + (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins { - return @{ConstraintTop:[self pinViewTopToSuperview:subview useMargins:useMargins constant:0], - ConstraintLeading:[self pinViewLeftToSuperview:subview useMargins:useMargins constant:0], - ConstraintTrailing:[self pinViewRightToSuperview:subview useMargins:useMargins constant:0], - ConstraintBot:[self pinViewBottomToSuperview:subview useMargins:useMargins constant:0], - }; + return [NSLayoutConstraint pinViewToSuperview:subview useMargins:useMargins pinTop:YES topConstant:0 pinBottom:YES bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; +} + ++ (nonnull NSDictionary *)pinViewToSuperview:(nonnull UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop pinBottom:(BOOL)pinBottom pinLeft:(BOOL)pinLeft pinRight:(BOOL)pinRight { + return [NSLayoutConstraint pinViewToSuperview:subview useMargins:useMargins pinTop:pinTop topConstant:0 pinBottom:pinBottom bottomConstant:0 pinLeft:pinLeft leftConstant:0 pinRight:pinRight rightConstant:0]; +} + ++ (NSDictionary *)pinViewToSuperview:(UIView *)subview useMargins:(BOOL)useMargins pinTop:(BOOL)pinTop topConstant:(CGFloat)topConstant pinBottom:(BOOL)pinBottom bottomConstant:(CGFloat)bottomConstant pinLeft:(BOOL)pinLeft leftConstant:(CGFloat)leftConstant pinRight:(BOOL)pinRight rightConstant:(CGFloat)rightConstant { + NSMutableDictionary *constraints = [[NSMutableDictionary alloc] init]; + if (pinTop) { + [constraints setObject:[self pinViewTopToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintTop]; + } + if (pinLeft) { + [constraints setObject:[self pinViewLeftToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintLeading]; + } + if (pinRight) { + [constraints setObject:[self pinViewRightToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintTrailing]; + } + if (pinBottom) { + [constraints setObject:[self pinViewBottomToSuperview:subview useMargins:useMargins constant:topConstant] forKey:ConstraintBot]; + } + return constraints; } + (NSLayoutConstraint *)pinViewTopToSuperview:(UIView *)view useMargins:(BOOL)useMargins constant:(CGFloat)constant { diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index f22ebb2f..353ea861 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -9,7 +9,7 @@ import UIKit @objcMembers open class NavigationController: UINavigationController { - public var separatorView: SeparatorView? + public var separatorView: Line? public static func navigationController() -> Self? { return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self @@ -28,8 +28,8 @@ import UIKit public static func setupNavigationController() -> Self? { let navigationController = self.init() style(navigationController.navigationBar) - navigationController.separatorView = SeparatorView.separatorAdd(to: navigationController.navigationBar, position: SeparatorPositionBot, withHorizontalPadding: 0) - navigationController.separatorView?.setAsLight() + navigationController.separatorView = Line(pinTo: navigationController.navigationBar, edge: .bottom, useMargin: false) + navigationController.separatorView?.style = .standard MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController diff --git a/MVMCoreUI/Atoms/Views/LabelView.h b/MVMCoreUI/Legacy/Views/LabelView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelView.h rename to MVMCoreUI/Legacy/Views/LabelView.h diff --git a/MVMCoreUI/Atoms/Views/LabelView.m b/MVMCoreUI/Legacy/Views/LabelView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/LabelView.m rename to MVMCoreUI/Legacy/Views/LabelView.m diff --git a/MVMCoreUI/Atoms/Views/MFView.h b/MVMCoreUI/Legacy/Views/MFView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/MFView.h rename to MVMCoreUI/Legacy/Views/MFView.h diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Legacy/Views/MFView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/MFView.m rename to MVMCoreUI/Legacy/Views/MFView.m diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.h b/MVMCoreUI/Legacy/Views/SeparatorView.h similarity index 100% rename from MVMCoreUI/Atoms/Views/SeparatorView.h rename to MVMCoreUI/Legacy/Views/SeparatorView.h diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.m b/MVMCoreUI/Legacy/Views/SeparatorView.m similarity index 100% rename from MVMCoreUI/Atoms/Views/SeparatorView.m rename to MVMCoreUI/Legacy/Views/SeparatorView.m diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index cc531d75..13faeb42 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -21,8 +21,8 @@ import UIKit private var caretViewHeightSizeObject: MFSizeObject? // For separation between cells. - public var topSeparatorView: SeparatorView? - public var bottomSeparatorView: SeparatorView? + public var topSeparatorView: Line? + public var bottomSeparatorView: Line? public enum SeparatorFrequency: String { case all case allExceptTop @@ -57,21 +57,22 @@ import UIKit open func styleStandard() { topMarginPadding = 24 bottomMarginPadding = 24 - bottomSeparatorView?.show() - bottomSeparatorView?.setAsLight() + topSeparatorView?.style = .none + bottomSeparatorView?.style = .standard } open func styleHeader() { topMarginPadding = 48 bottomMarginPadding = 16 - bottomSeparatorView?.show() - bottomSeparatorView?.setAsRegular() + topSeparatorView?.style = .none + bottomSeparatorView?.style = .thin } open func styleNone() { topMarginPadding = 0 bottomMarginPadding = 0 - bottomSeparatorView?.hide() + topSeparatorView?.style = .none + bottomSeparatorView?.style = .none } /// Adds the molecule to the view. @@ -111,23 +112,25 @@ import UIKit // MARK: - MFViewProtocol public func updateView(_ size: CGFloat) { MFStyler.setMarginsFor(self, size: size, defaultHorizontal: updateViewHorizontalDefaults, top: topMarginPadding, bottom: bottomMarginPadding) + if accessoryView != nil { // Smaller left margin if accessory view. var margin = directionalLayoutMargins margin.trailing = 16 contentView.directionalLayoutMargins = margin + + // Update caret automatically. + if let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject { + caretView.frame = CGRect(x: 0, y: 0, width: widthObject.getValueBased(onSize: size), height: heightObject.getValueBased(onSize: size)) + } } else { contentView.directionalLayoutMargins = directionalLayoutMargins } - topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading) - bottomSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading) - - molecule?.updateView(size) - if let _ = accessoryView, let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject { - caretView.frame = CGRect(x: 0, y: 0, width: widthObject.getValueBased(onSize: size), height: heightObject.getValueBased(onSize: size)) - } + topSeparatorView?.updateView(size) bottomSeparatorView?.updateView(size) + + molecule?.updateView(size) } public func setupView() { @@ -256,8 +259,8 @@ import UIKit setSeparatorFrequency(separatorFrequency, indexPath: indexPath) } } else { - topSeparatorView?.hide() - bottomSeparatorView?.setAsLight() + topSeparatorView?.style = .standard + bottomSeparatorView?.style = .standard setSeparatorFrequency(TableViewCell.SeparatorFrequency.allExceptTop, indexPath: indexPath) } } @@ -275,12 +278,22 @@ import UIKit // MARK: - Separator open func addSeparatorsIfNeeded() { if topSeparatorView == nil { - topSeparatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionTop) - topSeparatorView?.hide() + let line = Line() + line.style = .none + addSubview(line) + NSLayoutConstraint.pinViewTop(toSuperview: line, useMargins: false, constant: 0).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true + topSeparatorView = line } if bottomSeparatorView == nil { - bottomSeparatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot) - bottomSeparatorView?.hide() + let line = Line() + line.style = .none + addSubview(line) + NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true + bottomSeparatorView = line } } @@ -289,26 +302,26 @@ import UIKit switch separatorFrequency { case .all: if indexPath.row == 0 { - topSeparatorView?.show() + topSeparatorView?.isHidden = false } else { - topSeparatorView?.hide() + topSeparatorView?.isHidden = true } - bottomSeparatorView?.show() + bottomSeparatorView?.isHidden = false case .allExceptBottom: - topSeparatorView?.show() - bottomSeparatorView?.hide() + topSeparatorView?.isHidden = false + bottomSeparatorView?.isHidden = true case .between: if indexPath.row == 0 { - topSeparatorView?.hide() + topSeparatorView?.isHidden = true } else { - topSeparatorView?.show() + topSeparatorView?.isHidden = false } - bottomSeparatorView?.hide() + bottomSeparatorView?.isHidden = true case .allExceptTop: fallthrough default: - topSeparatorView?.hide() - bottomSeparatorView?.show() + topSeparatorView?.isHidden = true + bottomSeparatorView?.isHidden = false } } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index d54bde87..f00443a8 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -9,12 +9,12 @@ import UIKit public class StandardHeaderView: ViewConstrainingView { - var separatorView: SeparatorView? + var line: Line? // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) - separatorView?.updateView(size) + line?.updateView(size) } public override func setupView() { @@ -24,21 +24,12 @@ public class StandardHeaderView: ViewConstrainingView { updateViewHorizontalDefaults = true topMarginPadding = PaddingDefaultVerticalSpacing bottomMarginPadding = PaddingDefaultVerticalSpacing - if separatorView == nil, let separatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot, withHorizontalPadding: 0) { - separatorView.setAsHeavy() - addSubview(separatorView) - self.separatorView = separatorView - } - } - - public override func setLeftPinConstant(_ constant: CGFloat) { - super.setLeftPinConstant(constant) - separatorView?.leftPin?.constant = constant - } - - public override func setRightPinConstant(_ constant: CGFloat) { - super.setRightPinConstant(constant) - separatorView?.rightPin?.constant = constant + + guard line == nil else { return } + let line = Line(pinTo: self, edge: .bottom, useMargin: true) + line.style = .heavy + addSubview(line) + self.line = line } // MARK: - MVMCoreUIMoleculeViewProtocol @@ -50,7 +41,7 @@ public class StandardHeaderView: ViewConstrainingView { (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false) if let separatorJSON = json?.optionalDictionaryForKey("separator") { - separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) + line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) } } @@ -58,8 +49,7 @@ public class StandardHeaderView: ViewConstrainingView { super.reset() topMarginPadding = PaddingDefaultVerticalSpacing bottomMarginPadding = PaddingDefaultVerticalSpacing - separatorView?.setAsHeavy() - separatorView?.show() + line?.style = .heavy } public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 365244b1..4303dc55 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -26,7 +26,7 @@ dispatch_once(&onceToken, ^{ mapping = [@{ @"label": Label.class, - @"line": SeparatorView.class, + @"line": Line.class, @"button": ButtonView.class, @"textButton": MFTextButton.class, @"header": StandardHeaderView.class, @@ -43,7 +43,6 @@ @"progressbar": ProgressBar.class, @"circleProgress": GraphView.class, @"multiProgressBar": MultiProgress.class, - @"checkbox": MVMCoreUICheckBox.class, @"radioButton": RadioButton.class, @"radioButtonLabel": RadioButtonLabel.class, @"listItem": MoleculeTableViewCell.class, diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 7fcbe1f6..2aed3c65 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -76,14 +76,13 @@ open class MoleculeListTemplate: ThreeLayerTableViewController { return UITableViewCell() } let delegate = delegateObject() as? MVMCoreUIDelegateObject + let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol + moleculeCell?.reset?() if let protocolCell = cell as? MoleculeListCellProtocol { protocolCell.setSeparatorWithJSON?(loadObject?.pageJSON?.optionalDictionaryForKey("separator"), delegateObject: delegate, additionalData: nil, indexPath: indexPath) } - if let protocolCell = cell as? MVMCoreUIMoleculeViewProtocol { - protocolCell.reset?() - protocolCell.setWithJSON(moleculeInfo.molecule, delegateObject: delegate, additionalData: nil) - protocolCell.updateView(tableView.bounds.width) - } + moleculeCell?.setWithJSON(moleculeInfo.molecule, delegateObject: delegate, additionalData: nil) + moleculeCell?.updateView(tableView.bounds.width) return cell } From 654be26b2c84eab7fb687ca526950c959812ab92 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Nov 2019 11:06:47 -0500 Subject: [PATCH 16/21] 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 17/21] 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) + } +} From e32b9cfdda4c269ed5bd5961913a338c7bb22153 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Nov 2019 13:29:16 -0500 Subject: [PATCH 18/21] PR comments --- MVMCoreUI/Atoms/Views/Line.swift | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Line.swift b/MVMCoreUI/Atoms/Views/Line.swift index a5934aac..f7a81ac5 100644 --- a/MVMCoreUI/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atoms/Views/Line.swift @@ -26,28 +26,20 @@ import UIKit case .standard: heightConstraint?.constant = 1 backgroundColor = .mfSilver() - setNeedsLayout() - layoutIfNeeded() case .thin: heightConstraint?.constant = 1 backgroundColor = .black - setNeedsLayout() - layoutIfNeeded() case .medium: heightConstraint?.constant = 2 backgroundColor = .black - setNeedsLayout() - layoutIfNeeded() case .heavy: heightConstraint?.constant = 4 backgroundColor = .black - setNeedsLayout() - layoutIfNeeded() case .none: heightConstraint?.constant = 0 - setNeedsLayout() - layoutIfNeeded() } + setNeedsLayout() + layoutIfNeeded() } } @@ -74,6 +66,7 @@ import UIKit // MARK: - MVMCoreUIMoleculeViewProtocol open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + // If no type, default to standard. if let typeString = json?.optionalStringForKey(KeyType), let type = Style.init(rawValue: typeString) { style = type } else { @@ -92,16 +85,16 @@ import UIKit } public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - guard let type = json?.optionalStringForKey(KeyType) else { return 0 } - switch type { - case "thin", "standard": - return 1 - case "medium": + guard let type = json?.optionalStringForKey(KeyType), let style = Style(rawValue: type) else { return 1 } + switch style { + case .none: + return 0 + case .medium: return 2 - case "heavy": + case .heavy: return 4 default: - return 0 + return 1 } } } From 3944e028638bd9574c061821bfb143cde75940a4 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Wed, 20 Nov 2019 17:30:52 -0500 Subject: [PATCH 19/21] Remote Scott's missing test controller. --- MVMCoreUI.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1ed38510..391e20f5 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -195,7 +195,6 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; }; - D2F4DDE62371A4CB00CD28BB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F4DDE52371A4CB00CD28BB /* ViewController.swift */; }; DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; }; DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; @@ -1136,7 +1135,6 @@ D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, - D2F4DDE62371A4CB00CD28BB /* ViewController.swift in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */, From d884602d87ce55a7374b706ee6ca0aa9c2b2d73b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Nov 2019 09:06:09 -0500 Subject: [PATCH 20/21] tweaks --- MVMCoreUI.xcodeproj/project.pbxproj | 3 ++- MVMCoreUI/Atoms/Views/Label.swift | 2 +- MVMCoreUI/Models/Extensions/ModelHelper.swift | 2 +- MVMCoreUI/Models/Molecules/ListItemModel.swift | 12 ++++++------ MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 21071088..688228ef 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; - 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; @@ -67,6 +66,7 @@ D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; }; D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; }; D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; }; D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; }; @@ -1179,6 +1179,7 @@ D213347723843825008E41B3 /* Line.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, 01EB369023609801006832FA /* ListItemModel.swift in Sources */, + D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index a653985d..2f68a8d4 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -212,7 +212,7 @@ public typealias ActionBlock = () -> () } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) { - //LabelModel() + guard let label = label else { return } label.attributedText = nil label.text = json?.optionalStringForKey(KeyText) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 661280a9..da5e0d56 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -8,7 +8,7 @@ import Foundation -extension KeyedDecodingContainer where Key : CodingKey{ +extension KeyedDecodingContainer where Key : CodingKey { private enum TypeCodingKey: String, CodingKey { case moleculeName } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a903299a..da14a602 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -12,31 +12,31 @@ import Foundation public static var identifier: String = "listItem" public var moleculeName: String? public var molecule: MoleculeProtocol? - public var actionMap: ActionMapModel? + public var action: ActionModel? - public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { + public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) { self.molecule = molecule - self.actionMap = actionMap + self.action = actionMap self.moleculeName = Self.identifier } enum CodingKeys: String, CodingKey { case moleculeName case molecule - case actionMap + case action } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) - self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(self.molecule, forKey: .molecule) - try container.encodeIfPresent(actionMap, forKey: .actionMap) + try container.encodeIfPresent(action, forKey: .action) } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 1b754e50..400e7450 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -58,7 +58,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol } if let seperatorModel = headerModel.seperator as? LineModel { - separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) + line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } From 664d3195bb7b8cf59967337fa596e801d84217fd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Nov 2019 09:20:05 -0500 Subject: [PATCH 21/21] line fix in header --- MVMCoreUI/Molecules/StandardHeaderView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index f00443a8..aa2b52af 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -26,9 +26,12 @@ public class StandardHeaderView: ViewConstrainingView { bottomMarginPadding = PaddingDefaultVerticalSpacing guard line == nil else { return } - let line = Line(pinTo: self, edge: .bottom, useMargin: true) + let line = Line() line.style = .heavy addSubview(line) + NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true self.line = line }