From bba4cbfb66e0ad3bf7c4b41b4d0a43e309af16bd Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 5 Jun 2021 00:05:54 +0530 Subject: [PATCH 01/14] Option to set 'numberOfLines' for label from label's json. --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 ++++ .../Atomic/Atoms/Views/Label/LabelModel.swift | 15 +++++++++++++++ ...stLeftVariableIconWithRightCaretBodyText.swift | 3 +++ 3 files changed, 22 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 026e9acf..09ed3386 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -315,6 +315,10 @@ public typealias ActionBlock = () -> () if let color = labelModel.textColor { textColor = color.uiColor } + + if let numberofLines = labelModel.numberOfLines { + numberOfLines = numberofLines + } if let attributes = labelModel.attributes, let labelText = text { let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index fbbc9e03..8aa4c0d6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -25,6 +25,7 @@ public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? + public var numberOfLines:Int? //-------------------------------------------------- // MARK: - Keys @@ -44,18 +45,30 @@ case html case hero case makeWholeViewClickable + case numberOfLines } enum AttributeTypeKey: String, CodingKey { case type } + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + internal func setDefaults() { + if numberOfLines == nil { + numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(text: String) { self.text = text + setDefaults() } //-------------------------------------------------- @@ -76,6 +89,7 @@ html = try typeContainer.decodeIfPresent(String.self, forKey: .html) hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable) + numberOfLines = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfLines) } public func encode(to encoder: Encoder) throws { @@ -93,5 +107,6 @@ try container.encodeIfPresent(html, forKey: .html) try container.encodeIfPresent(hero, forKey: .hero) try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable) + try container.encodeIfPresent(numberOfLines, forKey: .numberOfLines) } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index b9e4a3e1..feb8694d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -73,6 +73,9 @@ headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) updateAccessibilityLabel() + if let numberOfLines = model.rightLabel.numberOfLines{ + rightLabel.numberOfLines = numberOfLines + } } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { From 921df032b29ae0649c3c6ecb831d5824aef343ec Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 9 Jun 2021 23:12:45 +0530 Subject: [PATCH 02/14] Changes as per review comments --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 5 +++-- .../Atomic/Atoms/Views/Label/LabelModel.swift | 15 ++------------- ...stLeftVariableIconWithRightCaretBodyText.swift | 4 ---- ...tVariableIconWithRightCaretBodyTextModel.swift | 3 +++ 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 09ed3386..395ab923 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -316,8 +316,8 @@ public typealias ActionBlock = () -> () textColor = color.uiColor } - if let numberofLines = labelModel.numberOfLines { - numberOfLines = numberofLines + if let lines = labelModel.numberOfLines { + numberOfLines = lines } if let attributes = labelModel.attributes, let labelText = text { @@ -794,6 +794,7 @@ extension Label { accessibilityCustomActions = [] clauses = [] accessibilityTraits = .staticText + numberOfLines = 0 } public func needsToBeConstrained() -> Bool { true } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 8aa4c0d6..5cc07fed 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -25,7 +25,7 @@ public var html: String? public var hero: Int? public var makeWholeViewClickable: Bool? - public var numberOfLines:Int? + public var numberOfLines: Int? //-------------------------------------------------- // MARK: - Keys @@ -51,24 +51,13 @@ enum AttributeTypeKey: String, CodingKey { case type } - - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - internal func setDefaults() { - if numberOfLines == nil { - numberOfLines = 1 - } - } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- public init(text: String) { self.text = text - setDefaults() } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index feb8694d..6174fc4b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -55,7 +55,6 @@ leftImage.contentMode = .scaleAspectFit rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } @@ -73,9 +72,6 @@ headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) updateAccessibilityLabel() - if let numberOfLines = model.rightLabel.numberOfLines{ - rightLabel.numberOfLines = numberOfLines - } } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift index 891f37f5..5076eb9e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyTextModel.swift @@ -29,6 +29,9 @@ public class ListLeftVariableIconWithRightCaretBodyTextModel: ListItemModel, Mol } headlineBody.style = .item headlineBody.headline?.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //----------------------------------------------------- From 1d556b65630b543148a4f6ab69dc212931e6721d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 10:31:03 -0400 Subject: [PATCH 03/14] manager changes to allow manager to handle navigation bar logic --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - .../NavigationBarRefreshProtocol.swift | 34 --------- .../BaseControllers/ViewController.swift | 56 ++++---------- MVMCoreUI/Behaviors/GetContactBehavior.swift | 12 --- .../Containers/NavigationController.swift | 74 ++++++++++++++++++- .../MVMCoreUIDetailViewProtocol.h | 3 - ...MCoreUISplitViewController+Extension.swift | 32 +++++++- .../MVMCoreUISplitViewController.m | 17 ++--- MVMCoreUI/Utility/MVMCoreUIUtility.h | 3 + MVMCoreUI/Utility/MVMCoreUIUtility.m | 13 +++- 10 files changed, 136 insertions(+), 112 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d48fa228..c9833c3f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -323,7 +323,6 @@ D20C7009250BF99B0095B21C /* TopNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20C7008250BF99B0095B21C /* TopNotificationModel.swift */; }; D20C700B250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20C700A250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift */; }; D20F3B44252E00E4004B3F56 /* PageProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20F3B43252E00E4004B3F56 /* PageProtocol.swift */; }; - D20F3B5E252F9B5E004B3F56 /* NavigationBarRefreshProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D2169301251E51E7002A6324 /* SectionListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2169300251E51E7002A6324 /* SectionListTemplate.swift */; }; @@ -887,7 +886,6 @@ D20C7008250BF99B0095B21C /* TopNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopNotificationModel.swift; sourceTree = ""; }; D20C700A250BFDE40095B21C /* MVMCoreUITopAlertView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUITopAlertView+Extension.swift"; sourceTree = ""; }; D20F3B43252E00E4004B3F56 /* PageProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageProtocol.swift; sourceTree = ""; }; - D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarRefreshProtocol.swift; sourceTree = ""; }; D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModel.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D2169300251E51E7002A6324 /* SectionListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionListTemplate.swift; sourceTree = ""; }; @@ -2319,7 +2317,6 @@ D20F3B43252E00E4004B3F56 /* PageProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, D28BA7442481652D00B75CB8 /* TabBarProtocol.swift */, - D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, ); path = Protocols; @@ -2754,7 +2751,6 @@ D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */, 0A9D09222433796500D2E6C0 /* CarouselIndicator.swift in Sources */, - D20F3B5E252F9B5E004B3F56 /* NavigationBarRefreshProtocol.swift in Sources */, D29E28DA23D21AFA00ACEA85 /* StringAndMoleculeModel.swift in Sources */, D260105D23D0BCD400764D80 /* Stack.swift in Sources */, 0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift b/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift deleted file mode 100644 index 2d4002e3..00000000 --- a/MVMCoreUI/Atomic/Protocols/NavigationBarRefreshProtocol.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// NavigationBarRefreshProtocol.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 10/8/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - -/// A protocol to inform that we should refresh the navigation bar ui. -@objc public protocol NavigationBarRefreshProtocol { - @objc func refreshNavigationUI() -} - -extension UIViewController: NavigationBarRefreshProtocol { - - /// Convenience function to refresh the navigation bar ui. A separate function for others to use. - @objc public static func refreshNavigationUI(for viewController: UIViewController) { - guard let model = (viewController as? PageProtocol)?.pageModel?.navigationBar else { return } - if let navigationController = viewController.navigationController { - NavigationController.setNavigationItem(navigationController: navigationController, navigationItemModel: model, viewController: viewController) - MVMCoreUISplitViewController.setNavigationBarUI(for: viewController, navigationController: navigationController, navigationItemModel: model) - } - if let manager = ((viewController as? MVMCoreViewManagerViewControllerProtocol)?.manager as? NavigationBarRefreshProtocol) { - // Refresh the manager if possible. - manager.refreshNavigationUI() - } - } - - public func refreshNavigationUI() { - UIViewController.refreshNavigationUI(for: self) - } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index cd67632f..f86061e5 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -114,17 +114,6 @@ import UIKit try parsePageJSON() MVMCoreDispatchUtility.performBlock(onMainThread: { self.handleNewDataAndUpdateUI() - - if MVMCoreUIUtility.getCurrentVisibleController() == self { - // Update navigation bar if showing. - self.setNavigationBar() - self.manager?.refreshNavigationUI() - } - // Update splitview properties - if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(self.bottomProgress() ?? 0) - self.updateTabBar() - } }) } catch { if let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: "updateJSON for pageType: \(String(describing: pageType))") { @@ -237,6 +226,11 @@ import UIKit /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, open func handleNewData() { + if model?.navigationBar == nil { + let navigationItem = createDefaultLegacyNavigationModel() + model?.navigationBar = navigationItem + } + executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in behavior.onPageNew(rootMolecules: getRootMolecules(), delegateObjectIVar) } @@ -250,8 +244,14 @@ import UIKit view.backgroundColor = backgroundColor.uiColor } - // Sets up the navigation item based on the data. - setNavigationItem() + // Update splitview properties + if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { + MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) + updateTabBar() + } + + // Notify the manager of new data + manager?.newDataReceived?(in: self) } //-------------------------------------------------- @@ -267,28 +267,6 @@ import UIKit return model?.navigationBar } - /// Sets the navigation item for this view controller. - open func setNavigationItem() { - guard let navigationItemModel = getNavigationModel(), - let navigationController = navigationController - else { return } - - // Utilize helper function to set the navigation item state. - NavigationController.setNavigationItem(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: self) - } - - /// Sets the appearance of the navigation bar based on the model. - open func setNavigationBar() { - guard let navigationItemModel = getNavigationModel(), - let navigationController = navigationController else { - MVMCoreUISession.sharedGlobal()?.splitViewController?.parent?.setNeedsStatusBarAppearanceUpdate() - return - } - - // Utilize helper function to set the split view and navigation item state. - MVMCoreUISplitViewController.setNavigationBarUI(for: self, navigationController: navigationController, navigationItemModel: navigationItemModel) - } - //-------------------------------------------------- // MARK: - TabBar //-------------------------------------------------- @@ -378,9 +356,6 @@ import UIKit updateTabBar() } - // Update the navigation bar ui when view is appearing. - setNavigationBar() - // Track. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) @@ -536,11 +511,6 @@ import UIKit // MARK: - MVMCoreUIDetailViewProtocol //-------------------------------------------------- - // Reset the navigation state. - public func splitViewDidReset() { - setNavigationBar() - } - public func isLeftPanelAccessible() -> Bool { // TODO: Remove when hamburger menu is fully phased out. if loadObject?.pageJSON?.boolForKey(KeyHideMainMenu) ?? false { diff --git a/MVMCoreUI/Behaviors/GetContactBehavior.swift b/MVMCoreUI/Behaviors/GetContactBehavior.swift index 9b488e68..c69bdbce 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -43,18 +43,6 @@ public class PageGetContactBehavior: PageVisibilityBehavior { // TODO: move to protocol function instead guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return } controller.handleNewDataAndUpdateUI() - - if MVMCoreUIUtility.getCurrentVisibleController() == controller { - // Update navigation bar if showing. - controller.setNavigationBar() - controller.manager?.refreshNavigationUI() - } - - // Update splitview properties - if controller == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(controller.bottomProgress() ?? 0) - controller.updateTabBar() - } }) } } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 331656b7..bcbf927e 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -8,8 +8,9 @@ import UIKit -@objcMembers open class NavigationController: UINavigationController { +@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { public var separatorView: Line? + public var manager: (UIViewController & MVMCoreViewManagerProtocol)? /// Getter for the main navigation controller public static func navigationController() -> Self? { @@ -33,6 +34,7 @@ import UIKit MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController + MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) return navigationController } @@ -103,4 +105,74 @@ import UIKit viewController.navigationItem.titleView = molecule } } + + /// Convenience function to return the navigation model of the lowest controller traversing managers + public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { + let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) + guard let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + return model + } +} + +extension NavigationController: MVMCoreViewManagerProtocol { + // TODO: change this to optional + public func getCurrentViewController() -> UIViewController { + return topViewController! + } + + public func containsPage(withPageType pageType: String?) -> Bool { + for case let controller as MVMCoreViewControllerProtocol in viewControllers { + if controller.pageType == pageType { + return true + } + } + return false + } + + public func newDataReceived(in viewController: UIViewController) { + if viewController == topViewController, + let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.newDataReceived?(in: viewController) + } + + public func willDisplay(_ viewController: UIViewController) { + guard let topViewController = topViewController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) + } + manager?.willDisplay?(viewController) + } + + public func displayedViewController(_ viewController: UIViewController) { + guard let topViewController = topViewController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + } + manager?.displayedViewController?(viewController) + } +} + +extension NavigationController: MVMCorePresentationDelegateProtocol { + public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { + guard self == navigationController else { return } + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) + controller.viewControllerReady?(inManager: self) + } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.willDisplay?(viewController) + } + + public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { + guard self == navigationController else { return } + if let model = Self.getNavigationModel(from: viewController) { + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.displayedViewController?(viewController) + } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 60ce0873..bd81fec5 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -48,9 +48,6 @@ NS_ASSUME_NONNULL_BEGIN - (UIStatusBarStyle)defaultStatusBarStyle; - (nullable UIColor *)defaultStatusBarBackgroundColor; -/// Called when the split view did reset. If this function found, the splitview assumes it is handling the split view state and does not do anything. If you have navigation item buttons, override this function and handle the panels manually. -- (void)splitViewDidReset; - @end NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index eb22eccb..835a2df9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -24,7 +24,6 @@ public extension MVMCoreUISplitViewController { /// Sets the navigation item for the view controller based on the model and splitview controller private func set(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) @@ -104,4 +103,35 @@ public extension MVMCoreUISplitViewController { viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } + + @objc func navigationBarModelExists() -> Bool { + // Legacy Navigation + (navigationController?.topViewController as? PageProtocol)?.pageModel?.navigationBar != nil + } + + /// Convenience function to update the navigation + @objc func updateNavigationBarFor(viewController: UIViewController) { + guard viewController == getCurrentDetailViewController(), + let navigationController = navigationController, + let model = NavigationController.getNavigationModel(from: viewController) else { return } + set(for: viewController, navigationController: navigationController, navigationItemModel: model) + } +} + +extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { + public func getCurrentViewController() -> UIViewController { + navigationController!.getCurrentViewController() + } + + public func containsPage(withPageType pageType: String?) -> Bool { + navigationController!.containsPage(withPageType: pageType) + } + + public func displayedViewController(_ viewController: UIViewController) { + updateNavigationBarFor(viewController: viewController) + } + + public func newDataReceived(in viewController: UIViewController) { + updateNavigationBarFor(viewController: viewController) + } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 3b1de765..ab44e181 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -857,6 +857,7 @@ CGFloat const PanelAnimationDuration = 0.2; // The main view. NavigationController *navigationController = [NavigationController setupNavigationController]; + navigationController.manager = self; self.navigationController = navigationController; UIView *mainView = navigationController.view; @@ -988,9 +989,11 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)resetDrawers { - if ([self.navigationItemViewController respondsToSelector:@selector(splitViewDidReset)]) { - [((UIViewController *)self.navigationItemViewController) splitViewDidReset]; + if (!self.navigationItemViewController) { return; } + if ([self navigationBarModelExists]) { + [self updateNavigationBarForViewController:self.navigationItemViewController]; } else { + // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; [self setRightPanelIsAccessible:self.rightPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; @@ -1066,10 +1069,7 @@ CGFloat const PanelAnimationDuration = 0.2; } // if it is not presented viewcontroller, existing BAU logic will be working if (!viewController) { - viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationController.topViewController]; } return viewController; } @@ -1077,10 +1077,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (UIViewController *)getCurrentDetailViewController { __block UIViewController *viewController = nil; [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ - viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationController.topViewController]; }]; return viewController; } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 6852e936..171ebeea 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -34,6 +34,9 @@ NS_ASSUME_NONNULL_BEGIN /// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. + (UIViewController *)getCurrentVisibleController; +/// Gets the first non manager controller. ++ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; + /// Checks if the view or any descendents of the view is currently focused for voice over. + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view; diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.m b/MVMCoreUI/Utility/MVMCoreUIUtility.m index dd059fed..01f576c5 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.m +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.m @@ -63,14 +63,19 @@ } // if it is not presented viewcontroller, existing BAU logic will be working if (!viewController) { - viewController = [MVMCoreUISession sharedGlobal].navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { - viewController = [viewController performSelector:@selector(getCurrentViewController)]; - } + viewController = [self getViewControllerTraversingManagers:[MVMCoreUISession sharedGlobal].navigationController.topViewController]; } return viewController; } ++ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController { + UIViewController *controller = viewController; + while ([controller conformsToProtocol:@protocol(MVMCoreViewManagerProtocol)]) { + controller = [controller performSelector:@selector(getCurrentViewController)]; + } + return controller; +} + + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view { if (!UIAccessibilityIsVoiceOverRunning()) { return NO; From 48d427ec4edd2ce84db768a208086fd1f08d3e67 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 11:04:47 -0400 Subject: [PATCH 04/14] Managers handle navigation bar nullable --- MVMCoreUI/Containers/NavigationController.swift | 8 ++++---- .../MVMCoreUISplitViewController+Extension.swift | 4 ++-- MVMCoreUI/Utility/MVMCoreUIUtility.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index bcbf927e..6176427f 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -108,16 +108,16 @@ import UIKit /// Convenience function to return the navigation model of the lowest controller traversing managers public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) - guard let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), + let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } return model } } extension NavigationController: MVMCoreViewManagerProtocol { // TODO: change this to optional - public func getCurrentViewController() -> UIViewController { - return topViewController! + public func getCurrentViewController() -> UIViewController? { + return topViewController } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 835a2df9..a62a3788 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -119,8 +119,8 @@ public extension MVMCoreUISplitViewController { } extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { - public func getCurrentViewController() -> UIViewController { - navigationController!.getCurrentViewController() + public func getCurrentViewController() -> UIViewController? { + navigationController?.getCurrentViewController() } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 171ebeea..c6959723 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -32,10 +32,10 @@ NS_ASSUME_NONNULL_BEGIN + (UIEdgeInsets)getMarginsForView:(nullable UIView *)view; /// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. -+ (UIViewController *)getCurrentVisibleController; ++ (nullable UIViewController *)getCurrentVisibleController; /// Gets the first non manager controller. -+ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; ++ (nullable UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; /// Checks if the view or any descendents of the view is currently focused for voice over. + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view; From f32aff549a7cb22b263ab70d5143f6da1fdf2ba7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 11:47:59 -0400 Subject: [PATCH 05/14] comment --- .../MVMCoreUISplitViewController+Extension.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index a62a3788..fcd4e821 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -8,6 +8,7 @@ import Foundation +// Navigation bar update functions public extension MVMCoreUISplitViewController { /// Convenience function. Sets the navigation and split view properties for the view controller. Panel access is determined if view controller is a detail view protocol. From f09892b4c6b2e35c0f8303d75664aae6999e0bb5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 22 Jun 2021 17:27:41 +0530 Subject: [PATCH 06/14] Changes as per review comments - Default 'numberOfLines' for all Designed components --- .../Headers/H2/HeadersH2PricingTwoRows.swift | 3 --- .../H2/HeadersH2PricingTwoRowsModel.swift | 17 +++++++++++++++++ ...VariableIconWithRightCaretAllTextLinks.swift | 1 - ...bleIconWithRightCaretAllTextLinksModel.swift | 4 ++++ .../List/ListProgressBarThin.swift | 1 - .../List/ListProgressBarThinModel.swift | 4 ++++ .../List/Miscellaneous/ListStoreLocator.swift | 1 - .../Miscellaneous/ListStoreLocatorModel.swift | 11 +++++++++++ ...ightVariablePriceChangeAllTextAndLinks.swift | 1 - ...ariablePriceChangeAllTextAndLinksModel.swift | 11 +++++++++++ .../ListRightVariablePriceChangeBodyText.swift | 1 - ...tRightVariablePriceChangeBodyTextModel.swift | 3 +++ ...RightVariableRightCaretAlltextAndLinks.swift | 1 - ...VariableRightCaretAlltextAndLinksModel.swift | 11 +++++++++++ .../ListThreeColumnBillChanges.swift | 3 --- .../ListThreeColumnBillChangesModel.swift | 17 +++++++++++++++++ .../ListTwoColumnPriceDescription.swift | 3 --- .../ListTwoColumnPriceDescriptionModel.swift | 12 ++++++++++++ 18 files changed, 90 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift index a6d69e24..1baf057c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRows.swift @@ -48,11 +48,8 @@ import Foundation open override func setupView() { super.setupView() setDefaults() - body.numberOfLines = 1 body.lineBreakMode = .byTruncatingTail - body2.numberOfLines = 1 body2.lineBreakMode = .byTruncatingTail - body3.numberOfLines = 1 body3.lineBreakMode = .byTruncatingTail verticalLine1.widthConstraint?.isActive = true diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift index 01bd72e4..b608ba41 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -21,6 +21,23 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { public var body3: LabelModel public var subBody3: LabelModel? + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if body.numberOfLines == nil { + body.numberOfLines = 1 + } + if body2.numberOfLines == nil { + body2.numberOfLines = 1 + } + if body3.numberOfLines == nil { + body3.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift index fcd18f68..0c09e9e3 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinks.swift @@ -50,7 +50,6 @@ leftImage.contentMode = .scaleAspectFit rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift index 3129776b..a4fed00e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretAllTextLinksModel.swift @@ -31,6 +31,10 @@ public class ListLeftVariableIconWithRightCaretAllTextLinksModel: ListItemModel, image.width = 30 image.height = 30 } + + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //----------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift index 79530eb6..9b85dc4f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThin.swift @@ -71,7 +71,6 @@ rightBar.widthAnchor.constraint(equalToConstant: 20).isActive = true rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() horizontalStack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift index 5309ebe1..52c175df 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ListProgressBarThinModel.swift @@ -45,6 +45,10 @@ public class ListProgressBarThinModel: ListItemModel, MoleculeModelProtocol { rightBar.backgroundColor = Color(uiColor: .gray) } + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + leftHeadline.hero = 0 } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift index b10b3069..1e271e87 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocator.swift @@ -39,7 +39,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() horizontalStack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index 10a0cd29..d690d681 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -18,6 +18,17 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public var leftSubBody: LabelModel public var rightLabel: LabelModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift index ec58684c..d0b2ff70 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift @@ -61,7 +61,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift index 7b1e065a..8d6ba0cb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift @@ -17,6 +17,17 @@ public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, Mo public var rightLabel: LabelModel public var arrow: ArrowModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift index b503b57a..a03b676d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift @@ -46,7 +46,6 @@ rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift index e3b325b6..c7efdb07 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift @@ -37,6 +37,9 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM if let headline = headlineBody.headline { headline.hero = 0 } + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift index 3a342b6a..12f11b9e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift @@ -38,7 +38,6 @@ super.setupView() rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift index d3725ed1..f16daf2b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinksModel.swift @@ -16,6 +16,17 @@ public class ListRightVariableRightCaretAllTextAndLinksModel: ListItemModel, Mol public var rightLabel: LabelModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift index 3db13a01..ddb202b6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChanges.swift @@ -39,9 +39,6 @@ open override func setupView() { super.setupView() - leftLabel.numberOfLines = 1 - centerLabel.numberOfLines = 1 - rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift index 00bf689c..9b121926 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/ThreeColumn/ListThreeColumnBillChangesModel.swift @@ -17,6 +17,23 @@ public class ListThreeColumnBillChangesModel: ListItemModel, MoleculeModelProtoc public var centerLabel: LabelModel public var rightLabel: LabelModel + //----------------------------------------------------- + // MARK: - Methods + //----------------------------------------------------- + + override public func setDefaults() { + super.setDefaults() + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + if centerLabel.numberOfLines == nil { + centerLabel.numberOfLines = 1 + } + if leftLabel.numberOfLines == nil { + leftLabel.numberOfLines = 1 + } + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift index c083e457..b211c918 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift @@ -74,9 +74,6 @@ view.addSubview(rightVerticalStack) NSLayoutConstraint.pinViews(leftView: leftVerticalStack, rightView: rightVerticalStack, alignTop: true) - leftHeadline.numberOfLines = 1 - rightLabel.numberOfLines = 1 - rightSubLabel.numberOfLines = 1 } //---------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift index 822b5074..f88677a8 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift @@ -34,6 +34,18 @@ public class ListTwoColumnPriceDescriptionModel: ListItemModel, MoleculeModelPro if rightSubLabel.attributes == nil { rightSubLabel.attributes = [LabelAttributeStrikeThroughModel(0, rightSubLabel.text.count)] } + + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } + + if rightSubLabel.numberOfLines == nil { + rightSubLabel.numberOfLines = 1 + } + + if leftHeadline.numberOfLines == nil { + leftHeadline.numberOfLines = 1 + } } //-------------------------------------------------- From f3f65763fc1c76c14255dd5e4def849ac9802c30 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 11:55:26 -0400 Subject: [PATCH 07/14] bug fixes --- MVMCoreUI/Containers/NavigationController.swift | 14 ++++++++------ .../MVMCoreUISplitViewController+Extension.swift | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 6176427f..776bfe2a 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -130,11 +130,11 @@ extension NavigationController: MVMCoreViewManagerProtocol { } public func newDataReceived(in viewController: UIViewController) { - if viewController == topViewController, - let model = Self.getNavigationModel(from: viewController) { - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) - } + guard let topViewController = topViewController, + viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), + let model = Self.getNavigationModel(from: viewController) else { return } + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) manager?.newDataReceived?(in: viewController) } @@ -160,7 +160,6 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { guard self == navigationController else { return } if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) - controller.viewControllerReady?(inManager: self) } if let model = Self.getNavigationModel(from: viewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) @@ -174,5 +173,8 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) } manager?.displayedViewController?(viewController) + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + controller.viewControllerReady?(inManager: self) + } } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index fcd4e821..4c389bd3 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -75,7 +75,7 @@ public extension MVMCoreUISplitViewController { leftItems.append(contentsOf: additionalLeftButtons) } - viewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) + navigationController.topViewController?.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) } /// Sets the right navigation items for the view controller based on model and splitview. @@ -102,7 +102,7 @@ public extension MVMCoreUISplitViewController { rightItems.append(contentsOf: additionalRightButtons) } - viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) + navigationController.topViewController?.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } @objc func navigationBarModelExists() -> Bool { @@ -129,7 +129,8 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func displayedViewController(_ viewController: UIViewController) { - updateNavigationBarFor(viewController: viewController) + guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + updateNavigationBarFor(viewController: controller) } public func newDataReceived(in viewController: UIViewController) { From f6c672e22dba34ff4b89f4babc8396b11495a3b1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 14:36:52 -0400 Subject: [PATCH 08/14] fix explicit --- .../MVMCoreUISplitViewController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 4c389bd3..77f9126d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -125,7 +125,7 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func containsPage(withPageType pageType: String?) -> Bool { - navigationController!.containsPage(withPageType: pageType) + navigationController?.containsPage(withPageType: pageType) ?? false } public func displayedViewController(_ viewController: UIViewController) { From 5af484daad932b931efa90565148dbc5ce0fe548 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 14:39:21 -0400 Subject: [PATCH 09/14] remove check --- .../MVMCoreUISplitViewController+Extension.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 77f9126d..b7e6ce6d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -129,8 +129,7 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { } public func displayedViewController(_ viewController: UIViewController) { - guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } - updateNavigationBarFor(viewController: controller) + updateNavigationBarFor(viewController: viewController) } public func newDataReceived(in viewController: UIViewController) { From 4bdd6fa775c93d138b8825f48d4890285ceecd2a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 17:00:52 -0400 Subject: [PATCH 10/14] flow fixes for manager propagation. Navigation fixes. --- .../Containers/NavigationController.swift | 51 +++++++++++-------- ...MCoreUISplitViewController+Extension.swift | 23 +++++---- .../MVMCoreUISplitViewController.m | 8 +-- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 776bfe2a..eb378b08 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -106,23 +106,28 @@ import UIKit } } - /// Convenience function to return the navigation model of the lowest controller traversing managers - public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), - let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + /// Convenience function to return the navigation model of the lowest controller traversing managers if applicable. + public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { + guard let topViewController = topViewController, + viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), + let model = (viewController as? PageProtocol)?.pageModel?.navigationBar else { return nil } return model } } extension NavigationController: MVMCoreViewManagerProtocol { - // TODO: change this to optional public func getCurrentViewController() -> UIViewController? { - return topViewController + guard let topViewController = topViewController else { return nil } + return MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) } public func containsPage(withPageType pageType: String?) -> Bool { - for case let controller as MVMCoreViewControllerProtocol in viewControllers { - if controller.pageType == pageType { + for controller in viewControllers { + if let manager = controller as? MVMCoreViewManagerProtocol, + manager.containsPage(withPageType: pageType) { + return true + } else if let controller = controller as? MVMCoreViewControllerProtocol, + controller.pageType == pageType { return true } } @@ -130,25 +135,25 @@ extension NavigationController: MVMCoreViewManagerProtocol { } public func newDataReceived(in viewController: UIViewController) { - guard let topViewController = topViewController, - viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController), - let model = Self.getNavigationModel(from: viewController) else { return } - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + } manager?.newDataReceived?(in: viewController) } public func willDisplay(_ viewController: UIViewController) { - guard let topViewController = topViewController else { return } - if let model = Self.getNavigationModel(from: viewController) { + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) } manager?.willDisplay?(viewController) } public func displayedViewController(_ viewController: UIViewController) { - guard let topViewController = topViewController else { return } - if let model = Self.getNavigationModel(from: viewController) { + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) } manager?.displayedViewController?(viewController) @@ -161,18 +166,20 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) } - if let model = Self.getNavigationModel(from: viewController) { + guard let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let model = getNavigationModel(from: newViewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) } - manager?.willDisplay?(viewController) + manager?.willDisplay?(newViewController) } public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { - guard self == navigationController else { return } - if let model = Self.getNavigationModel(from: viewController) { + guard self == navigationController, + let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let model = getNavigationModel(from: newViewController) { Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) } - manager?.displayedViewController?(viewController) + manager?.displayedViewController?(newViewController) if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { controller.viewControllerReady?(inManager: self) } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index b7e6ce6d..b1d1deac 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -15,9 +15,8 @@ public extension MVMCoreUISplitViewController { static func setNavigationBarUI(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { guard let splitView = MVMCoreUISplitViewController.main(), navigationController == splitView.navigationController, - navigationController.topViewController == viewController else { + viewController == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() else { /// Not the split view navigation controller, skip split functions. - NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) return } splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel) @@ -25,7 +24,6 @@ public extension MVMCoreUISplitViewController { /// Sets the navigation item for the view controller based on the model and splitview controller private func set(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) @@ -37,6 +35,8 @@ public extension MVMCoreUISplitViewController { /// Sets the left navigation items for the view controller based on model and splitview. func setLeftNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { + guard let topViewController = navigationController.topViewController else { return } + var leftItems: [UIBarButtonItem] = [] let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject @@ -75,11 +75,13 @@ public extension MVMCoreUISplitViewController { leftItems.append(contentsOf: additionalLeftButtons) } - navigationController.topViewController?.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) + topViewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue) } /// Sets the right navigation items for the view controller based on model and splitview. func setRightNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { + guard let topViewController = navigationController.topViewController else { return } + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject var rightItems: [UIBarButtonItem] = [] @@ -102,19 +104,20 @@ public extension MVMCoreUISplitViewController { rightItems.append(contentsOf: additionalRightButtons) } - navigationController.topViewController?.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) + topViewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } @objc func navigationBarModelExists() -> Bool { // Legacy Navigation - (navigationController?.topViewController as? PageProtocol)?.pageModel?.navigationBar != nil + guard let currentViewController = getCurrentDetailViewController(), + let _ = navigationController?.getNavigationModel(from: currentViewController) else { return false } + return true } - /// Convenience function to update the navigation + /// Convenience function to update the navigation bar for the @objc func updateNavigationBarFor(viewController: UIViewController) { - guard viewController == getCurrentDetailViewController(), - let navigationController = navigationController, - let model = NavigationController.getNavigationModel(from: viewController) else { return } + guard let navigationController = navigationController, + let model = navigationController.getNavigationModel(from: viewController) else { return } set(for: viewController, navigationController: navigationController, navigationItemModel: model) } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index ab44e181..5cc7156d 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -240,7 +240,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { NSMutableArray *leftBarButtonItems = [NSMutableArray array]; - if (viewController.navigationController && [MVMCoreNavigationHandler.sharedNavigationHandler getViewControllersForNavigationController:viewController.navigationController].count > 1) { + if (self.navigationController && [MVMCoreNavigationHandler.sharedNavigationHandler getViewControllersForNavigationController:self.navigationController].count > 1) { [leftBarButtonItems addObject:self.backButton]; } if ((accessible && !extended) && self.leftPanelButton) { @@ -250,7 +250,7 @@ CGFloat const PanelAnimationDuration = 0.2; if (extraButtons) { [leftBarButtonItems addObjectsFromArray:extraButtons]; } - [viewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; + [self.navigationController.topViewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; } - (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons { @@ -422,7 +422,7 @@ CGFloat const PanelAnimationDuration = 0.2; if (extraButtons) { [navigationItems addObjectsFromArray:extraButtons]; } - [viewController.navigationItem setRightBarButtonItems:(navigationItems.count > 0 ? navigationItems : nil) animated:!DisableAnimations]; + [self.navigationController.topViewController.navigationItem setRightBarButtonItems:(navigationItems.count > 0 ? navigationItems : nil) animated:!DisableAnimations]; } - (BOOL)shouldExtendRightPanel { @@ -991,7 +991,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)resetDrawers { if (!self.navigationItemViewController) { return; } if ([self navigationBarModelExists]) { - [self updateNavigationBarForViewController:self.navigationItemViewController]; + [self updateNavigationBarForViewController:[MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationItemViewController]]; } else { // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; From eb94c7eaff5b1ef33c3610209c74e944b1b972f1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 22 Jun 2021 17:54:35 -0400 Subject: [PATCH 11/14] undo needless change --- .../SplitViewController/MVMCoreUISplitViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5cc7156d..20f0d227 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -991,7 +991,7 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)resetDrawers { if (!self.navigationItemViewController) { return; } if ([self navigationBarModelExists]) { - [self updateNavigationBarForViewController:[MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationItemViewController]]; + [self updateNavigationBarForViewController:self.navigationItemViewController]; } else { // Legacy [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES]; From 8b3b4964b887b9128f461b802fb1abbdf631646f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 10:02:40 -0400 Subject: [PATCH 12/14] add missing number of lines --- MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift | 1 - MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift | 6 ++++++ MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift | 1 + .../TopNotification/CollapsableNotificationModel.swift | 3 +++ .../TopNotification/CollapsableNotificationTopView.swift | 1 - 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift index bc905a79..c6f7144f 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tag.swift @@ -24,7 +24,6 @@ import Foundation super.setupView() layer.borderColor = UIColor.mvmCoolGray6.cgColor layer.borderWidth = 1 - label.numberOfLines = 1 addSubview(label) NSLayoutConstraint.constraintPinSubview(label, pinTop: true, topConstant: 13, pinBottom: true, bottomConstant: 13, pinLeft: true, leftConstant: 15, pinRight: true, rightConstant: 15) } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift index e0247e71..56a86742 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift @@ -21,6 +21,12 @@ import Foundation case backgroundColor } + public func setDefaults() { + if label.numberOfLines == nil { + label.numberOfLines = 1 + } + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) label = try typeContainer.decode(LabelModel.self, forKey: .label) diff --git a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift index 18de25f1..065c502a 100644 --- a/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift +++ b/MVMCoreUI/Atomic/Molecules/Doughnut/DoughnutChart.swift @@ -64,6 +64,7 @@ open class DoughnutChart: View { open override func reset() { super.reset() titleLabel.reset() + titleLabel.numberOfLines = 1 subTitleLabel.reset() clearLayers() } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift index bdcd3fe1..511f41a5 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift @@ -26,6 +26,9 @@ open class CollapsableNotificationModel: NotificationModel { open override func setDefaults() { super.setDefaults() + if topLabel.numberOfLines == nil { + topLabel.numberOfLines = 1 + } if topLabel.textColor == nil { topLabel.textColor = Color(uiColor: .white) } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift index c23edeae..b3223fc7 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift @@ -11,7 +11,6 @@ import Foundation @objcMembers open class CollapsableNotificationTopView: View { public let label: Label = { let label = Label(fontStyle: .BoldBodySmall) - label.numberOfLines = 1 label.textAlignment = .center label.setContentHuggingPriority(.defaultHigh, for: .vertical) return label From 91df3b197d9ea47ab306da45943016bd26b5d903 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 10:18:08 -0400 Subject: [PATCH 13/14] comment fix --- .../MVMCoreUISplitViewController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index b1d1deac..bb1b24d5 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -114,7 +114,7 @@ public extension MVMCoreUISplitViewController { return true } - /// Convenience function to update the navigation bar for the + /// Convenience function to update the navigation bar if the controller is the current lowest controller. @objc func updateNavigationBarFor(viewController: UIViewController) { guard let navigationController = navigationController, let model = navigationController.getNavigationModel(from: viewController) else { return } From cb2fabd282a8cf50af8dac83dc9b5180904ccccf Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 11:50:26 -0400 Subject: [PATCH 14/14] fixes --- .../H2/HeadersH2PricingTwoRowsModel.swift | 26 +++++++------------ .../Miscellaneous/ListStoreLocatorModel.swift | 14 +++------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift index b608ba41..5ca1eae1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -21,23 +21,6 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { public var body3: LabelModel public var subBody3: LabelModel? - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - override public func setDefaults() { - super.setDefaults() - if body.numberOfLines == nil { - body.numberOfLines = 1 - } - if body2.numberOfLines == nil { - body2.numberOfLines = 1 - } - if body3.numberOfLines == nil { - body3.numberOfLines = 1 - } - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -66,6 +49,15 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol { subBody?.attributes = [LabelAttributeStrikeThroughModel(0, subBody?.text.count ?? 0)] subBody2?.attributes = [LabelAttributeStrikeThroughModel(0, subBody2?.text.count ?? 0)] subBody3?.attributes = [LabelAttributeStrikeThroughModel(0, subBody3?.text.count ?? 0)] + if body.numberOfLines == nil { + body.numberOfLines = 1 + } + if body2.numberOfLines == nil { + body2.numberOfLines = 1 + } + if body3.numberOfLines == nil { + body3.numberOfLines = 1 + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift index d690d681..44c4ef90 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -18,17 +18,6 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { public var leftSubBody: LabelModel public var rightLabel: LabelModel - //----------------------------------------------------- - // MARK: - Methods - //----------------------------------------------------- - - override public func setDefaults() { - super.setDefaults() - if rightLabel.numberOfLines == nil { - rightLabel.numberOfLines = 1 - } - } - //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -49,6 +38,9 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() leftHeadline.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //--------------------------------------------------