diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5eedcf5b..b90b6f5e 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -325,7 +325,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 */; }; @@ -891,7 +890,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 = ""; }; @@ -2325,7 +2323,6 @@ D20F3B43252E00E4004B3F56 /* PageProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, D28BA7442481652D00B75CB8 /* TabBarProtocol.swift */, - D20F3B5D252F9B5D004B3F56 /* NavigationBarRefreshProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, ); path = Protocols; @@ -2761,7 +2758,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/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/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 026e9acf..395ab923 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 lines = labelModel.numberOfLines { + numberOfLines = lines + } 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]) @@ -790,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 fbbc9e03..5cc07fed 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,12 +45,13 @@ case html case hero case makeWholeViewClickable + case numberOfLines } enum AttributeTypeKey: String, CodingKey { case type } - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -76,6 +78,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 +96,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/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..5ca1eae1 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -49,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/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/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index b9e4a3e1..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() } 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 + } } //----------------------------------------------------- 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..44c4ef90 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/Miscellaneous/ListStoreLocatorModel.swift @@ -38,6 +38,9 @@ public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol { override public func setDefaults() { super.setDefaults() leftHeadline.hero = 0 + if rightLabel.numberOfLines == nil { + rightLabel.numberOfLines = 1 + } } //-------------------------------------------------- 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 + } } //-------------------------------------------------- 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 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 06efad05..5cd811de 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) @@ -540,11 +515,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 bfb80230..77c0d7f4 100644 --- a/MVMCoreUI/Behaviors/GetContactBehavior.swift +++ b/MVMCoreUI/Behaviors/GetContactBehavior.swift @@ -44,18 +44,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..eb378b08 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,83 @@ import UIKit viewController.navigationItem.titleView = molecule } } + + /// 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 { + public func getCurrentViewController() -> UIViewController? { + guard let topViewController = topViewController else { return nil } + return MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) + } + + public func containsPage(withPageType pageType: String?) -> Bool { + 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 + } + } + return false + } + + public func newDataReceived(in viewController: UIViewController) { + 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) { + 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) { + if let topViewController = topViewController, + let model = 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) + } + guard let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let model = getNavigationModel(from: newViewController) { + Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + } + manager?.willDisplay?(newViewController) + } + + public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { + 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?(newViewController) + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + controller.viewControllerReady?(inManager: self) + } + } } 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..bb1b24d5 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -8,15 +8,15 @@ 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. 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) @@ -24,8 +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) @@ -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) } - viewController.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,6 +104,38 @@ public extension MVMCoreUISplitViewController { rightItems.append(contentsOf: additionalRightButtons) } - viewController.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 + guard let currentViewController = getCurrentDetailViewController(), + let _ = navigationController?.getNavigationModel(from: currentViewController) else { return false } + return true + } + + /// 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 } + 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) ?? false + } + + 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..20f0d227 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 { @@ -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..c6959723 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -32,7 +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. ++ (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; 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;