From b4af1abe81246d611a34957d7f082d214967dc77 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 7 Mar 2022 01:03:36 -0500 Subject: [PATCH 001/102] subnav and tab bar color changes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../TabBarModel.swift | 53 ++++++++++++-- .../HorizontalCombinationViews/Tabs.swift | 5 +- .../TabsModel.swift | 73 +++++++++++++++++-- .../NavigationBar/NavigationBar.swift | 39 ++++++++++ .../NavigationBar/NavigationItemModel.swift | 71 +++++++++++++----- .../NavigationItemModelProtocol.swift | 1 - .../Containers/NavigationController.swift | 68 ++++++++++------- .../SubNav/SubNavManagerController.swift | 3 +- 9 files changed, 255 insertions(+), 62 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2b9c6711..a26f56e5 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -272,6 +272,7 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; + AF97288627D2BF63009DC250 /* NavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF97288527D2BF63009DC250 /* NavigationBar.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -855,6 +856,7 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; + AF97288527D2BF63009DC250 /* NavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBar.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1826,6 +1828,7 @@ children = ( D23EA7FC247EBB7500D60C34 /* Buttons */, D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */, + AF97288527D2BF63009DC250 /* NavigationBar.swift */, ); path = NavigationBar; sourceTree = ""; @@ -2740,6 +2743,7 @@ D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, 0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, + AF97288627D2BF63009DC250 /* NavigationBar.swift in Sources */, D2E2A9A123E095AB000B42E6 /* ButtonModelProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index fc3e9449..dfd28a86 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -10,10 +10,46 @@ import Foundation public class TabBarModel: MoleculeModelProtocol { public static var identifier: String = "tabBar" - public var backgroundColor: Color? = Color(uiColor: .white) public var tabs: [TabBarItemModel] - public var selectedColor = Color(uiColor: .mvmBlack) - public var unSelectedColor = Color(uiColor: .mvmCoolGray6) + + open var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmBlack) } + return Color(uiColor: .mvmWhite) + } + set { + _backgroundColor = newValue + } + } + + open var _selectedColor: Color? + open var selectedColor: Color { + get { + if let selectedColor = _selectedColor { return selectedColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmWhite) } + return Color(uiColor: .mvmBlack) + } + set { + _selectedColor = newValue + } + } + + open var _unSelectedColor: Color? + open var unSelectedColor: Color { + get { + if let unselectedColor = _unSelectedColor { return unselectedColor } + return Color(uiColor: .mvmCoolGray6) + } + set { + _unSelectedColor = newValue + } + } + + public var style: NavigationItemStyle? = NavigationItemStyle.dark // Must be capped to 0...(tabs.count - 1) public var selectedTab: Int = 0 @@ -25,6 +61,7 @@ public class TabBarModel: MoleculeModelProtocol { case selectedColor case unSelectedColor case selectedTab + case style } public init(with tabs: [TabBarItemModel]) { @@ -46,16 +83,20 @@ public class TabBarModel: MoleculeModelProtocol { if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedTab) { selectedTab = index } + if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { + self.style = style + } } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encode(selectedColor, forKey: .selectedColor) - try container.encode(unSelectedColor, forKey: .unSelectedColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_unSelectedColor, forKey: .unSelectedColor) try container.encode(selectedTab, forKey: .selectedTab) + try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 5802ddf8..b433d831 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -152,8 +152,7 @@ import UIKit self.delegateObject = delegateObject self.additionalData = additionalData selectedIndex = tabsModel?.selectedIndex ?? 0 - // TODO: Commented out until we have model support for bar color. Should also do unselected color. - //selectionLine.backgroundColor = tabsModel?.selectedColor.uiColor + selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor reloadData() } } @@ -333,7 +332,7 @@ extension Tabs { if selected { label.textColor = tabsModel?.selectedColor.uiColor ?? .black } else { - label.textColor = .mvmCoolGray6 + label.textColor = tabsModel?.unselectedColor.uiColor ?? .mvmCoolGray6 } updateAccessibility(indexPath: indexPath, selected: selected, tabsModel: tabsModel) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 398d7c59..b05b6b76 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -10,19 +10,72 @@ import UIKit public class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" - public var backgroundColor: Color? public var tabs: [TabItemModel] - public var selectedColor = Color(uiColor: .black) + + open var style: NavigationItemStyle? = .dark + + open var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmBlack) } + return Color(uiColor: .mvmWhite) + } + set { + _backgroundColor = newValue + } + } + + open var _selectedColor: Color? + open var selectedColor: Color { + get { + if let selectedColor = _selectedColor { return selectedColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmWhite) } + return Color(uiColor: .mvmBlack) + } + set { + _selectedColor = newValue + } + } + + open var _unselectedColor: Color? + open var unselectedColor: Color { + get { + if let unselectedColor = _unselectedColor { return unselectedColor } + return Color(uiColor: .mvmCoolGray6) + } + set { + _unselectedColor = newValue + } + } + + open var _selectedBarColor: Color? + open var selectedBarColor: Color { + get { + if let selectedBarColor = _selectedBarColor { return selectedBarColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmWhite) } + return Color(uiColor: .mvmRed) + } + set { + _selectedBarColor = newValue + } + } // Must be capped to 0...(tabs.count - 1) public var selectedIndex: Int = 0 private enum CodingKeys: String, CodingKey { + case moleculeName case tabs case backgroundColor case selectedColor + case unselectedColor + case selectedBarColor case selectedIndex - case moleculeName + case style } public init(with tabs: [TabItemModel]) { @@ -33,8 +86,11 @@ public class TabsModel: MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) { - selectedColor = color + _selectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) + _unselectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unselectedColor) + _selectedBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedBarColor) + if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { + self.style = style } if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) { selectedIndex = index @@ -45,9 +101,12 @@ public class TabsModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encode(selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_unselectedColor, forKey: .unselectedColor) + try container.encodeIfPresent(_selectedBarColor, forKey: .selectedBarColor) try container.encode(selectedIndex, forKey: .selectedIndex) + try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift new file mode 100644 index 00000000..72fb697e --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift @@ -0,0 +1,39 @@ +// +// NavigationBar.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/4/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import UIKit + +open class NavigationBar: UINavigationBar, MoleculeViewProtocol { + + public var line: Line = Line(model: LineModel(type: .standard), nil, nil) + + public required init?(coder: NSCoder) { + super.init(coder: coder) + setupView() + } + + public override init(frame: CGRect) { + super.init(frame: frame) + setupView() + } + + open func setupView() { + line.addLine(to: self, edge: .bottom, useMargin: false) + reset() + } + + public func reset() { + set(with: NavigationItemModel(), nil, nil) + } + + open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let model = model as? NavigationItemModel else { return } + NavigationController.setNavigation(bar: self, model: model) + line.setOptional(with: model.line, delegateObject, additionalData) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index d8126508..90a34079 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -6,6 +6,10 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +public enum NavigationItemStyle: String, Codable { + case light + case dark +} open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- @@ -14,12 +18,39 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open class var identifier: String { "navigationBar" } + private let defaultHidesSystemBackButton = true + open var title: String? - open var hidden: Bool - open var backgroundColor: Color? - open var tintColor: Color - open var line: LineModel? + open var hidden = false + open var line = LineModel(type: .standard) open var hidesSystemBackButton = true + open var style: NavigationItemStyle? = .dark + + open var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmBlack) } + return Color(uiColor: .mvmWhite) + } + set { + _backgroundColor = newValue + } + } + + open var _tintColor: Color? + open var tintColor: Color { + get { + if let tintColor = _tintColor { return tintColor } + if let style = style, + style == .dark { return Color(uiColor: .mvmWhite) } + return Color(uiColor: .mvmBlack) + } + set { + _tintColor = newValue + } + } /// If true, we add the button in the backButton property. If false we do not add the button. If nil, we add the button if the controller is not the bottom of the stack open var alwaysShowBackButton: Bool? @@ -33,12 +64,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc // MARK: - Initializer //-------------------------------------------------- - public init() { - hidden = false - backgroundColor = Color(uiColor: .mvmWhite) - tintColor = Color(uiColor: .mvmBlack) - line = LineModel(type: .standard) - } + public init() {} //-------------------------------------------------- // MARK: - Keys @@ -57,6 +83,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc case additionalLeftButtons case additionalRightButtons case titleView + case style } //-------------------------------------------------- @@ -66,16 +93,25 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) - hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) ?? false - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .mvmWhite) - tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .mvmBlack) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .standard) - hidesSystemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesSystemBackButton) ?? true + if let hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) { + self.hidden = hidden + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + _tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) + if let line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { + self.line = line + } + if let hidesSystemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesSystemBackButton) { + self.hidesSystemBackButton = hidesSystemBackButton + } alwaysShowBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysShowBackButton) backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons) additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) + if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { + self.style = style + } } open func encode(to encoder: Encoder) throws { @@ -83,8 +119,8 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(title, forKey: .title) try container.encode(hidden, forKey: .hidden) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encode(tintColor, forKey: .tintColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_tintColor, forKey: .tintColor) try container.encodeIfPresent(line, forKey: .line) try container.encode(hidesSystemBackButton, forKey: .hidesSystemBackButton) try container.encodeIfPresent(alwaysShowBackButton, forKey: .alwaysShowBackButton) @@ -92,6 +128,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons) try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons) try container.encodeModelIfPresent(titleView, forKey: .titleView) + try container.encodeIfPresent(style, forKey: .style) } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index 8f82c946..570581e5 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -13,7 +13,6 @@ public protocol NavigationItemModelProtocol { var hidden: Bool { get set } var backgroundColor: Color? { get set } var tintColor: Color { get set } - var line: LineModel? { get set } var hidesSystemBackButton: Bool { get set } var alwaysShowBackButton: Bool? { get set } var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index c2b63a6e..c7d461d5 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -9,28 +9,22 @@ import UIKit @objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { - public var separatorView: Line? public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)? + /// TODO: Remove after removing legacy connections. + public var separatorView: Line? { + get { + return (navigationBar as? NavigationBar)?.line + } + } /// Getter for the main navigation controller public static func navigationController() -> Self? { return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self } - /// Provides MVM styling to the navigation bar. Returns a reference to the line. - public static func style(_ navigationBar: UINavigationBar) -> Line { - navigationBar.backgroundColor = .white - navigationBar.shadowImage = UIImage() - navigationBar.isOpaque = true - navigationBar.tintColor = .black - navigationBar.titleTextAttributes = [NSAttributedString.Key.font: MFStyler.fontBoldBodySmall(false)]; - return Line(pinTo: navigationBar, edge: .bottom, useMargin: false) - } - /// Sets up the application with a navigation controller - public static func setupNavigationController() -> Self? { - let navigationController = self.init() - navigationController.separatorView = style(navigationController.navigationBar) + public static func setupNavigationController() -> NavigationController { + let navigationController = NavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil) MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController @@ -39,8 +33,8 @@ import UIKit } /// Sets up the application with a navigation controller as the main container. - public static func setupNavigationControllerAsMainController() -> Self? { - guard let navigationController = setupNavigationController() else { return nil } + public static func setupNavigationControllerAsMainController() -> NavigationController { + let navigationController = setupNavigationController() MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) return navigationController } @@ -84,18 +78,38 @@ import UIKit /// Convenience function for setting the navigation bar ui, except for the buttons. public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { + let navigationBar = navigationController.navigationBar + if let model = navigationItemModel as? NavigationItemModelProtocol & MoleculeModelProtocol, + let navigationBar = navigationBar as? MoleculeViewProtocol { + navigationBar.set(with: model, nil, nil) + } else { + setNavigation(bar: navigationController.navigationBar, model: navigationItemModel) + } navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - navigationController.navigationBar.barTintColor = navigationItemModel.backgroundColor?.uiColor ?? .white - - let tint = navigationItemModel.tintColor.uiColor - navigationController.navigationBar.tintColor = tint - - // Have the navigation title match the tint color - navigationController.navigationBar.titleTextAttributes?.updateValue(tint, forKey: .foregroundColor) - - // Update line. - if let navigationController = navigationController as? NavigationController { - navigationController.separatorView?.isHidden = navigationItemModel.line?.type ?? .standard == .none + } + + /// Convenience function for settin the navigation bar by the model + public static func setNavigation(bar: UINavigationBar, model: NavigationItemModelProtocol) { + let font = MFStyler.fontBoldBodySmall(false) + let backgroundColor = model.backgroundColor?.uiColor + let tint = model.tintColor.uiColor + bar.tintColor = tint + if #available(iOS 13.0, *) { + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: tint]; + appearance.backgroundColor = backgroundColor + appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + bar.standardAppearance = appearance + bar.scrollEdgeAppearance = appearance + } else { + // Fallback on earlier versions + bar.shadowImage = UIImage() + bar.isOpaque = true + bar.titleTextAttributes = [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: tint]; + bar.barTintColor = backgroundColor } } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 19a8c4fd..bab0d7af 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -119,7 +119,8 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Hides the navigation bar for the page. open func hideNavigationBarLine(for viewController: UIViewController) { - (viewController as? PageProtocol)?.pageModel?.navigationBar?.line?.type = .none + guard let navigationBar = navigationController?.navigationBar as? NavigationBar else { return } + navigationBar.isHidden = true } open override func updateViews() { From a03965cafe5cc6c1b4682b7ba6523d6d358bba57 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 00:07:31 -0500 Subject: [PATCH 002/102] nav line hide for subnav --- .../Containers/NavigationController.swift | 2 +- .../SubNav/SubNavManagerController.swift | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index c7d461d5..c5d84d22 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -88,7 +88,7 @@ import UIKit navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) } - /// Convenience function for settin the navigation bar by the model + /// Convenience function for setting the navigation bar by the model public static func setNavigation(bar: UINavigationBar, model: NavigationItemModelProtocol) { let font = MFStyler.fontBoldBodySmall(false) let backgroundColor = model.backgroundColor?.uiColor diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 77ffa97a..2bcd2597 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -78,7 +78,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) } - hideNavigationBarLine(for: viewController) } required public init?(coder: NSCoder) { @@ -111,17 +110,22 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } } + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + hideNavigationBarLine(true) + } + open override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - + hideNavigationBarLine(false) // Notify showing view we will disappear. (viewController as? MVMCoreViewManagerViewControllerProtocol)?.managerWillDisappear?(self) } - /// Hides the navigation bar for the page. - open func hideNavigationBarLine(for viewController: UIViewController) { + /// Hides/Shows the navigation bar for the page. + open func hideNavigationBarLine(_ isHidden: Bool) { guard let navigationBar = navigationController?.navigationBar as? NavigationBar else { return } - navigationBar.isHidden = true + navigationBar.line.isHidden = isHidden } open override func updateViews() { @@ -214,7 +218,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, index != tabs.selectedIndex else { return } viewController = controller pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType - hideNavigationBarLine(for: controller) if let viewController = getCurrentViewController() { manager?.willDisplay?(viewController) } @@ -298,14 +301,10 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } open func newDataReceived(in viewController: UIViewController) { - if viewController == self.viewController { - hideNavigationBarLine(for: viewController) - } manager?.newDataReceived?(in: viewController) } public func willDisplay(_ viewController: UIViewController) { - hideNavigationBarLine(for: viewController) manager?.willDisplay?(viewController) } From 44a57ab96e764c5e1af5c231dcfed6c081b0541d Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 00:10:31 -0500 Subject: [PATCH 003/102] name update --- .../NavigationBar/NavigationBar.swift | 2 +- .../Containers/NavigationController.swift | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift index 72fb697e..af748539 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift @@ -33,7 +33,7 @@ open class NavigationBar: UINavigationBar, MoleculeViewProtocol { open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let model = model as? NavigationItemModel else { return } - NavigationController.setNavigation(bar: self, model: model) + NavigationController.set(navigationBar: self, model: model) line.setOptional(with: model.line, delegateObject, additionalData) } } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index c5d84d22..630edbca 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -83,17 +83,17 @@ import UIKit let navigationBar = navigationBar as? MoleculeViewProtocol { navigationBar.set(with: model, nil, nil) } else { - setNavigation(bar: navigationController.navigationBar, model: navigationItemModel) + set(navigationBar: navigationController.navigationBar, model: navigationItemModel) } navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) } /// Convenience function for setting the navigation bar by the model - public static func setNavigation(bar: UINavigationBar, model: NavigationItemModelProtocol) { + public static func set(navigationBar: UINavigationBar, model: NavigationItemModelProtocol) { let font = MFStyler.fontBoldBodySmall(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor - bar.tintColor = tint + navigationBar.tintColor = tint if #available(iOS 13.0, *) { let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() @@ -101,15 +101,15 @@ import UIKit NSAttributedString.Key.foregroundColor: tint]; appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) - bar.standardAppearance = appearance - bar.scrollEdgeAppearance = appearance + navigationBar.standardAppearance = appearance + navigationBar.scrollEdgeAppearance = appearance } else { // Fallback on earlier versions - bar.shadowImage = UIImage() - bar.isOpaque = true - bar.titleTextAttributes = [NSAttributedString.Key.font: font, + navigationBar.shadowImage = UIImage() + navigationBar.isOpaque = true + navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tint]; - bar.barTintColor = backgroundColor + navigationBar.barTintColor = backgroundColor } } From a1f9e4babea9a13e2d019a555cce127ebbb7f6ca Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 12:07:33 -0500 Subject: [PATCH 004/102] remove testing default --- .../Molecules/HorizontalCombinationViews/TabBarModel.swift | 2 +- .../Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift | 2 +- .../Atomic/Molecules/NavigationBar/NavigationItemModel.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index dfd28a86..31eb28bc 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -49,7 +49,7 @@ public class TabBarModel: MoleculeModelProtocol { } } - public var style: NavigationItemStyle? = NavigationItemStyle.dark + public var style: NavigationItemStyle? // Must be capped to 0...(tabs.count - 1) public var selectedTab: Int = 0 diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index b2d46ec6..f624c478 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -12,7 +12,7 @@ public class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" public var tabs: [TabItemModel] - open var style: NavigationItemStyle? = .dark + open var style: NavigationItemStyle? open var _backgroundColor: Color? open var backgroundColor: Color? { diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 90a34079..5bf73caa 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -24,7 +24,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var hidden = false open var line = LineModel(type: .standard) open var hidesSystemBackButton = true - open var style: NavigationItemStyle? = .dark + open var style: NavigationItemStyle? open var _backgroundColor: Color? open var backgroundColor: Color? { From 9f574e854b45979487115c9119a08f8a7aefb7d7 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 12:18:49 -0500 Subject: [PATCH 005/102] change access level --- .../TabBarModel.swift | 28 +++++++++---------- .../TabsModel.swift | 28 +++++++++---------- .../NavigationBar/NavigationItemModel.swift | 4 +-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index 31eb28bc..ef36e04b 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -8,11 +8,11 @@ import Foundation -public class TabBarModel: MoleculeModelProtocol { +open class TabBarModel: MoleculeModelProtocol { public static var identifier: String = "tabBar" - public var tabs: [TabBarItemModel] + open var tabs: [TabBarItemModel] - open var _backgroundColor: Color? + private var _backgroundColor: Color? open var backgroundColor: Color? { get { if let backgroundColor = _backgroundColor { return backgroundColor } @@ -25,7 +25,7 @@ public class TabBarModel: MoleculeModelProtocol { } } - open var _selectedColor: Color? + private var _selectedColor: Color? open var selectedColor: Color { get { if let selectedColor = _selectedColor { return selectedColor } @@ -38,7 +38,7 @@ public class TabBarModel: MoleculeModelProtocol { } } - open var _unSelectedColor: Color? + private var _unSelectedColor: Color? open var unSelectedColor: Color { get { if let unselectedColor = _unSelectedColor { return unselectedColor } @@ -49,10 +49,10 @@ public class TabBarModel: MoleculeModelProtocol { } } - public var style: NavigationItemStyle? + open var style: NavigationItemStyle? // Must be capped to 0...(tabs.count - 1) - public var selectedTab: Int = 0 + open var selectedTab: Int = 0 private enum CodingKeys: String, CodingKey { case moleculeName @@ -88,7 +88,7 @@ public class TabBarModel: MoleculeModelProtocol { } } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) @@ -100,11 +100,11 @@ public class TabBarModel: MoleculeModelProtocol { } } -public class TabBarItemModel: Codable { - var title: String? - var image: String - var action: ActionModelProtocol - var accessibilityText: String? +open class TabBarItemModel: Codable { + open var title: String? + open var image: String + open var action: ActionModelProtocol + open var accessibilityText: String? private enum CodingKeys: String, CodingKey { case title @@ -127,7 +127,7 @@ public class TabBarItemModel: Codable { accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(title, forKey: .title) try container.encode(image, forKey: .image) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index f624c478..122c0763 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -8,13 +8,13 @@ import UIKit -public class TabsModel: MoleculeModelProtocol { +open class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" - public var tabs: [TabItemModel] + open var tabs: [TabItemModel] open var style: NavigationItemStyle? - open var _backgroundColor: Color? + private var _backgroundColor: Color? open var backgroundColor: Color? { get { if let backgroundColor = _backgroundColor { return backgroundColor } @@ -27,7 +27,7 @@ public class TabsModel: MoleculeModelProtocol { } } - open var _selectedColor: Color? + private var _selectedColor: Color? open var selectedColor: Color { get { if let selectedColor = _selectedColor { return selectedColor } @@ -40,7 +40,7 @@ public class TabsModel: MoleculeModelProtocol { } } - open var _unselectedColor: Color? + private var _unselectedColor: Color? open var unselectedColor: Color { get { if let unselectedColor = _unselectedColor { return unselectedColor } @@ -51,7 +51,7 @@ public class TabsModel: MoleculeModelProtocol { } } - open var _selectedBarColor: Color? + private var _selectedBarColor: Color? open var selectedBarColor: Color { get { if let selectedBarColor = _selectedBarColor { return selectedBarColor } @@ -65,7 +65,7 @@ public class TabsModel: MoleculeModelProtocol { } // Must be capped to 0...(tabs.count - 1) - public var selectedIndex: Int = 0 + open var selectedIndex: Int = 0 private enum CodingKeys: String, CodingKey { case moleculeName @@ -97,7 +97,7 @@ public class TabsModel: MoleculeModelProtocol { } } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) @@ -112,11 +112,11 @@ public class TabsModel: MoleculeModelProtocol { -public class TabItemModel: Codable { - public var label: LabelModel - public var action: ActionModelProtocol? +open class TabItemModel: Codable { + open var label: LabelModel + open var action: ActionModelProtocol? - init(label: LabelModel) { + public init(label: LabelModel) { self.label = label } @@ -125,7 +125,7 @@ public class TabItemModel: Codable { case action } - func setDefaults() { + open func setDefaults() { if label.textAlignment == nil { label.textAlignment = .center } @@ -144,7 +144,7 @@ public class TabItemModel: Codable { setDefaults() } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModel(label, forKey: .label) try container.encodeModelIfPresent(action, forKey: .action) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 5bf73caa..ac73ff18 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -26,7 +26,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var hidesSystemBackButton = true open var style: NavigationItemStyle? - open var _backgroundColor: Color? + private var _backgroundColor: Color? open var backgroundColor: Color? { get { if let backgroundColor = _backgroundColor { return backgroundColor } @@ -39,7 +39,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc } } - open var _tintColor: Color? + private var _tintColor: Color? open var tintColor: Color { get { if let tintColor = _tintColor { return tintColor } From c4c513250c5adf229adfab6023a2f9df7cf4e9c9 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 12:21:25 -0500 Subject: [PATCH 006/102] style push decode --- .../Molecules/HorizontalCombinationViews/TabBarModel.swift | 4 +--- .../Molecules/HorizontalCombinationViews/TabsModel.swift | 4 +--- .../Atomic/Molecules/NavigationBar/NavigationItemModel.swift | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index ef36e04b..2a55b31e 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -83,9 +83,7 @@ open class TabBarModel: MoleculeModelProtocol { if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedTab) { selectedTab = index } - if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { - self.style = style - } + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 122c0763..16897c67 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -89,9 +89,7 @@ open class TabsModel: MoleculeModelProtocol { _selectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) _unselectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unselectedColor) _selectedBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedBarColor) - if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { - self.style = style - } + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) { selectedIndex = index } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index ac73ff18..dc2800b3 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -109,9 +109,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons) additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) - if let style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { - self.style = style - } + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) } open func encode(to encoder: Encoder) throws { From 07226731c08cc58783763791acab121ee988d730 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 9 Mar 2022 17:15:15 -0500 Subject: [PATCH 007/102] Line model contains style logic. Fix for subnav revert custom navigation bar for now --- MVMCoreUI.xcodeproj/project.pbxproj | 4 -- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 59 ++++++---------- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 39 ++++++++++- .../NavigationBar/NavigationBar.swift | 39 ----------- .../NavigationBar/NavigationItemModel.swift | 2 +- .../NavigationItemModelProtocol.swift | 1 + .../BaseControllers/ViewController.swift | 1 + .../Containers/NavigationController.swift | 70 ++++++++++++------- .../SubNav/SubNavManagerController.swift | 21 ++++-- 9 files changed, 125 insertions(+), 111 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a26f56e5..2b9c6711 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -272,7 +272,6 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; - AF97288627D2BF63009DC250 /* NavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF97288527D2BF63009DC250 /* NavigationBar.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -856,7 +855,6 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; - AF97288527D2BF63009DC250 /* NavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBar.swift; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1828,7 +1826,6 @@ children = ( D23EA7FC247EBB7500D60C34 /* Buttons */, D20FB164241A5D75004AFC3A /* NavigationItemModel.swift */, - AF97288527D2BF63009DC250 /* NavigationBar.swift */, ); path = NavigationBar; sourceTree = ""; @@ -2743,7 +2740,6 @@ D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */, 0AE98BAF23FEF956004C5109 /* ExternalLink.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, - AF97288627D2BF63009DC250 /* NavigationBar.swift in Sources */, D2E2A9A123E095AB000B42E6 /* ButtonModelProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 22d33b1f..7985ec56 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -18,10 +18,6 @@ import UIKit get { return model as? LineModel } } - var lineBackgroundColor: Color? { - return (lineModel?.inverted ?? false) ? lineModel?.backgroundColor_inverted : lineModel?.backgroundColor - } - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -50,28 +46,33 @@ import UIKit addLine(to: view, edge: edge, useMargin: useMargin) } + public init() { + super.init(frame: .zero) + model = LineModel(type: .standard) + } + + public override init(frame: CGRect) { + super.init(frame: frame) + model = LineModel(type: .standard) + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + model = LineModel(type: .standard) + } + + public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.init(model: model, delegateObject, additionalData) + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- open func setStyle(_ style: LineModel.Style) { - - switch style { - case .standard: - updateLineConstraints(constant: 1) - backgroundColor = lineModel?.backgroundColor?.uiColor ?? .mvmCoolGray3 - case .thin: - updateLineConstraints(constant: 1) - backgroundColor = lineModel?.backgroundColor?.uiColor ?? .mvmBlack - case .medium: - updateLineConstraints(constant: 2) - backgroundColor = lineModel?.backgroundColor?.uiColor ?? .mvmBlack - case .heavy: - updateLineConstraints(constant: 4) - backgroundColor = lineModel?.backgroundColor?.uiColor ?? .mvmBlack - case .none: - updateLineConstraints(constant: 0) - } + lineModel?.type = style + backgroundColor = lineModel?.backgroundColor?.uiColor + updateLineConstraints(constant: CGFloat(lineModel?.thickness ?? 1)) } open func shouldBeVisible() -> Bool { @@ -90,12 +91,10 @@ import UIKit open override func setupView() { super.setupView() - heightConstraint = heightAnchor.constraint(equalToConstant: 1) heightConstraint?.isActive = true widthConstraint = widthAnchor.constraint(equalToConstant: 1) widthConstraint?.isActive = false - setStyle(.standard) } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { @@ -111,19 +110,7 @@ import UIKit } public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - - guard let type = (model as? LineModel)?.type else { return 1 } - - switch type { - case .none: - return 0 - case .medium: - return 2 - case .heavy: - return 4 - default: - return 1 - } + return (model as? LineModel)?.thickness ?? 1 } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 0f67b3f0..a9a29264 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -54,7 +54,39 @@ import UIKit //TODO: use color insted of backgroundColor. Needs server changes // public var color: Color? - public var backgroundColor: Color? + private var _backgroundColor: Color? + public var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if inverted { return backgroundColor_inverted } + if type == .standard { return Color(uiColor: .mvmCoolGray3) } + return Color(uiColor: .mvmBlack) + } + set { + _backgroundColor = newValue + } + } + + private var _thickness: CGFloat? + public var thickness: CGFloat { + get { + if let thickness = _thickness { return thickness } + switch type { + case .heavy: + return 4 + case .medium: + return 2 + case .none: + return 0 + default: + return 1 + } + } + set { + _thickness = newValue + } + } + public var backgroundColor_inverted: Color = Color(uiColor: .mvmWhite) public var inverted: Bool = false @@ -90,6 +122,7 @@ import UIKit case frequency case inverted case useVerticalLine + case thickness } //-------------------------------------------------- @@ -117,6 +150,7 @@ import UIKit backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) + _thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) } public func encode(to encoder: Encoder) throws { @@ -125,8 +159,9 @@ import UIKit try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor_inverted, forKey: .backgroundColor_inverted) try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine) + try container.encodeIfPresent(_thickness, forKey: .thickness) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift deleted file mode 100644 index af748539..00000000 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationBar.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// NavigationBar.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 3/4/22. -// Copyright © 2022 Verizon Wireless. All rights reserved. -// - -import UIKit - -open class NavigationBar: UINavigationBar, MoleculeViewProtocol { - - public var line: Line = Line(model: LineModel(type: .standard), nil, nil) - - public required init?(coder: NSCoder) { - super.init(coder: coder) - setupView() - } - - public override init(frame: CGRect) { - super.init(frame: frame) - setupView() - } - - open func setupView() { - line.addLine(to: self, edge: .bottom, useMargin: false) - reset() - } - - public func reset() { - set(with: NavigationItemModel(), nil, nil) - } - - open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let model = model as? NavigationItemModel else { return } - NavigationController.set(navigationBar: self, model: model) - line.setOptional(with: model.line, delegateObject, additionalData) - } -} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index dc2800b3..b7eaf2d8 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -22,7 +22,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var title: String? open var hidden = false - open var line = LineModel(type: .standard) + open var line: LineModel? = LineModel(type: .standard) open var hidesSystemBackButton = true open var style: NavigationItemStyle? diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index 570581e5..8f82c946 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -13,6 +13,7 @@ public protocol NavigationItemModelProtocol { var hidden: Bool { get set } var backgroundColor: Color? { get set } var tintColor: Color { get set } + var line: LineModel? { get set } var hidesSystemBackButton: Bool { get set } var alwaysShowBackButton: Bool? { get set } var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d7e947db..4a154d3a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -349,6 +349,7 @@ import UIKit } open func pageShown() { + guard self as? MVMCoreViewManagerProtocol == nil else { return } // Update split view properties if this is the current detail controller. if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 630edbca..21bc030b 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -10,12 +10,6 @@ import UIKit @objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)? - /// TODO: Remove after removing legacy connections. - public var separatorView: Line? { - get { - return (navigationBar as? NavigationBar)?.line - } - } /// Getter for the main navigation controller public static func navigationController() -> Self? { @@ -23,8 +17,8 @@ import UIKit } /// Sets up the application with a navigation controller - public static func setupNavigationController() -> NavigationController { - let navigationController = NavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil) + public static func setupNavigationController() -> Self? { + let navigationController = self.init() MVMCoreUISession.sharedGlobal()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController @@ -33,8 +27,8 @@ import UIKit } /// Sets up the application with a navigation controller as the main container. - public static func setupNavigationControllerAsMainController() -> NavigationController { - let navigationController = setupNavigationController() + public static func setupNavigationControllerAsMainController() -> Self? { + guard let navigationController = setupNavigationController() else { return nil } MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) return navigationController } @@ -76,23 +70,39 @@ import UIKit viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil } + static func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { + guard let thickness = navigationItemModel.line?.thickness, + let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } + return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) + } +// let rect = CGRect(origin: .zero, size: size) +// UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) +// color.setFill() +// UIRectFill(rect) +// let image = UIGraphicsGetImageFromCurrentImageContext() +// UIGraphicsEndImageContext() +// +// guard let cgImage = image?.cgImage else { return nil } +// self.init(cgImage: cgImage) +// +//// let pixelScale = UIScreen.main.scale +//// let pixelSize = thickness / pixelScale +//// let fillSize = CGSize(width: pixelSize, height: pixelSize) +//// let fillRect = CGRect(origin: CGPoint.zero, size: fillSize) +//// UIGraphicsBeginImageContextWithOptions(fillRect.size, false, pixelScale) +//// graphicsContext.setFillColor(backgroundColor.cgColor) +//// graphicsContext.fill(fillRect) +//// let image = UIGraphicsGetImageFromCurrentImageContext() +//// UIGraphicsEndImageContext() +// return image +// } + /// Convenience function for setting the navigation bar ui, except for the buttons. public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { let navigationBar = navigationController.navigationBar - if let model = navigationItemModel as? NavigationItemModelProtocol & MoleculeModelProtocol, - let navigationBar = navigationBar as? MoleculeViewProtocol { - navigationBar.set(with: model, nil, nil) - } else { - set(navigationBar: navigationController.navigationBar, model: navigationItemModel) - } - navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - } - - /// Convenience function for setting the navigation bar by the model - public static func set(navigationBar: UINavigationBar, model: NavigationItemModelProtocol) { let font = MFStyler.fontBoldBodySmall(false) - let backgroundColor = model.backgroundColor?.uiColor - let tint = model.tintColor.uiColor + let backgroundColor = navigationItemModel.backgroundColor?.uiColor + let tint = navigationItemModel.tintColor.uiColor navigationBar.tintColor = tint if #available(iOS 13.0, *) { let appearance = UINavigationBarAppearance() @@ -101,16 +111,19 @@ import UIKit NSAttributedString.Key.foregroundColor: tint]; appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear + appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) navigationBar.standardAppearance = appearance navigationBar.scrollEdgeAppearance = appearance } else { // Fallback on earlier versions - navigationBar.shadowImage = UIImage() navigationBar.isOpaque = true + navigationBar.shadowImage = getNavigationBarShadowImage(for: navigationItemModel) navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tint]; navigationBar.barTintColor = backgroundColor } + navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) } /// Convenience function for setting the navigation titleView. @@ -213,3 +226,12 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { } } } + +extension UIColor { + func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { + return UIGraphicsImageRenderer(size: size).image { rendererContext in + self.setFill() + rendererContext.fill(CGRect(origin: .zero, size: size)) + } + } +} diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 2bcd2597..37a33ca9 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -110,22 +110,29 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } } - open override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) + open override func pageShown() { + super.pageShown() hideNavigationBarLine(true) } open override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - hideNavigationBarLine(false) // Notify showing view we will disappear. (viewController as? MVMCoreViewManagerViewControllerProtocol)?.managerWillDisappear?(self) } /// Hides/Shows the navigation bar for the page. open func hideNavigationBarLine(_ isHidden: Bool) { - guard let navigationBar = navigationController?.navigationBar as? NavigationBar else { return } - navigationBar.line.isHidden = isHidden + guard self == navigationController?.topViewController else { return } + if #available(iOS 13.0, *) { + var color = UIColor.clear + if !isHidden, + let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { + color = backgroundColor + } + navigationController?.navigationBar.standardAppearance.shadowColor = color + navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color + } } open override func updateViews() { @@ -257,6 +264,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, if let viewController = getCurrentViewController() { manager?.displayedViewController?(viewController) } + hideNavigationBarLine(true) } // MARK: - TabsDelegate @@ -283,6 +291,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, // MARK: - MVMCoreViewManagerViewControllerProtocol open override func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { + super.viewControllerReady(inManager: manager) // Pass on down (viewController as? MVMCoreViewManagerViewControllerProtocol)?.viewControllerReady?(inManager: self) } @@ -302,6 +311,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open func newDataReceived(in viewController: UIViewController) { manager?.newDataReceived?(in: viewController) + hideNavigationBarLine(true) } public func willDisplay(_ viewController: UIViewController) { @@ -310,6 +320,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, public func displayedViewController(_ viewController: UIViewController) { manager?.displayedViewController?(viewController) + hideNavigationBarLine(true) } // MARK: - MVMCoreUISwipeNavigationProtocol From f23e30645ea413303c3948d91ffb703da9ab3c62 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 10:05:33 -0500 Subject: [PATCH 008/102] Fix for base style for legacy controllers. (sign in different user font) --- MVMCoreUI/Containers/NavigationController.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 21bc030b..6b1e6100 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -23,6 +23,7 @@ import UIKit MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) + NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: NavigationItemModel()) return navigationController } @@ -98,7 +99,7 @@ import UIKit // } /// Convenience function for setting the navigation bar ui, except for the buttons. - public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { + public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { let navigationBar = navigationController.navigationBar let font = MFStyler.fontBoldBodySmall(false) let backgroundColor = navigationItemModel.backgroundColor?.uiColor @@ -174,7 +175,7 @@ extension NavigationController: MVMCoreViewManagerProtocol { let topViewController = topViewController, let model = getNavigationModel(from: viewController) { Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) } manager?.newDataReceived?(in: viewController) } @@ -189,9 +190,8 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func displayedViewController(_ viewController: UIViewController) { if isDisplayed(viewController: viewController), - let topViewController = topViewController, let model = getNavigationModel(from: viewController) { - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: topViewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) } manager?.displayedViewController?(viewController) } @@ -218,7 +218,7 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { guard self == navigationController, let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } if let model = getNavigationModel(from: newViewController) { - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model, viewController: viewController) + Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) } manager?.displayedViewController?(newViewController) if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { From 04ab9ef0569a934838fa0409fcd623077d6cfd1b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 10:59:00 -0500 Subject: [PATCH 009/102] version changes --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 2b9c6711..ae49c2b5 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3282,9 +3282,9 @@ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -3309,9 +3309,9 @@ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; From 8fc03e75e03fb496c21232487a2ccdee144927f6 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 11:27:54 -0500 Subject: [PATCH 010/102] iOS 13 --- .../Atomic/Atoms/Views/Label/Label.swift | 24 ++-- MVMCoreUI/Atomic/Atoms/Views/Wheel.swift | 135 +++--------------- .../HorizontalCombinationViews/TabBar.swift | 27 +--- 3 files changed, 36 insertions(+), 150 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 687683d7..fcbb31e4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -256,21 +256,19 @@ public typealias ActionBlock = () -> () * appropriately called. * Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml */ - if #available(iOS 13, *) { - if let attributedText = attributedText, let text = text, !text.isEmpty { - let attributedString = NSMutableAttributedString(string: text) - let range = NSRange(location: 0, length: text.count) - for attribute in attributedText.attributes(at: 0, effectiveRange: nil) { - if attribute.key == .underlineStyle { - attributedString.addAttribute(.underlineStyle, value: 0, range: range) - } - if attribute.key == .strikethroughStyle { - attributedString.addAttribute(.strikethroughStyle, value: 0, range: range) - } + if let attributedText = attributedText, let text = text, !text.isEmpty { + let attributedString = NSMutableAttributedString(string: text) + let range = NSRange(location: 0, length: text.count) + for attribute in attributedText.attributes(at: 0, effectiveRange: nil) { + if attribute.key == .underlineStyle { + attributedString.addAttribute(.underlineStyle, value: 0, range: range) + } + if attribute.key == .strikethroughStyle { + attributedString.addAttribute(.strikethroughStyle, value: 0, range: range) } - - self.attributedText = attributedString } + + self.attributedText = attributedString } hero = labelModel.hero diff --git a/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift b/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift index dc50f8f3..9ae1335c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Wheel.swift @@ -49,125 +49,28 @@ import UIKit } heightConstraint?.constant = graphObject.diameter - // iOS 12 uses the conic gradient and a mask for simplicity. - if #available(iOS 12, *) { - let gradient = CAGradientLayer() - gradient.type = .conic - gradient.startPoint = CGPoint(x: 0.5, y: 0.5) - gradient.endPoint = CGPoint(x: 0.5, y: 0.0) - gradient.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter) - gradient.colors = graphObject.colors.map({ (color) -> CGColor in - return color.cgColor - }) - gradientLayer = gradient - layer.addSublayer(gradient) - - let center = CGPoint(x: gradient.bounds.midX, y: gradient.bounds.midY) - let radius = (graphObject.diameter - graphObject.lineWidth) / 2.0 - let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: (3 / 2 * .pi), endAngle: -(1 / 2 * .pi), clockwise: false) - let mask = CAShapeLayer() - mask.fillColor = UIColor.clear.cgColor - mask.strokeColor = UIColor.white.cgColor - mask.lineWidth = graphObject.lineWidth - mask.path = path.cgPath - gradient.mask = mask - return - } + let gradient = CAGradientLayer() + gradient.type = .conic + gradient.startPoint = CGPoint(x: 0.5, y: 0.5) + gradient.endPoint = CGPoint(x: 0.5, y: 0.0) + gradient.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter) + gradient.colors = graphObject.colors.map({ (color) -> CGColor in + return color.cgColor + }) + gradientLayer = gradient + layer.addSublayer(gradient) - //create circle path - let radius = graphObject.diameter / 2.0 - - //begin point will be at the bottom, clockwise direction - let path = UIBezierPath(arcCenter: CGPoint(x: radius - , y: radius), radius: radius - graphObject.lineWidth/2.0, startAngle: CGFloat(Wheel.getPiValue(90.0)), endAngle: CGFloat(Wheel.getPiValue(90.0 + 360.0)), clockwise: true) - path.lineWidth = graphObject.lineWidth - - let circleLayer = CAShapeLayer() - circleLayer.path = path.cgPath - circleLayer.lineCap = .round - circleLayer.lineWidth = graphObject.lineWidth - circleLayer.fillColor = UIColor.clear.cgColor - circleLayer.strokeColor = UIColor.black.cgColor - - //create gradient layer - let gradientLayer = createGradientLayer(graphObject) - gradientLayer.mask = circleLayer - layer.addSublayer(gradientLayer) - self.gradientLayer = gradientLayer + let center = CGPoint(x: gradient.bounds.midX, y: gradient.bounds.midY) + let radius = (graphObject.diameter - graphObject.lineWidth) / 2.0 + let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: (3 / 2 * .pi), endAngle: -(1 / 2 * .pi), clockwise: false) + let mask = CAShapeLayer() + mask.fillColor = UIColor.clear.cgColor + mask.strokeColor = UIColor.white.cgColor + mask.lineWidth = graphObject.lineWidth + mask.path = path.cgPath + gradient.mask = mask } -/* - create three gradient layer for circle layout. - _____________ - | → | top layer for smooth gradient - ------------- - | | | - | ↑ | ↓ | - | | | - ------------- -*/ - func createGradientLayer(_ graphObject: WheelModel) -> CALayer { - let containLayer = CALayer() - containLayer.frame = CGRect(x: 0, y: 0, width: graphObject.diameter, height: graphObject.diameter) - let radius = graphObject.diameter / 2.0 - - //create graident layers - guard graphObject.colors.count > 1 else { - containLayer.backgroundColor = graphObject.colors.first?.cgColor - return containLayer - } - var topGradientHeight : CGFloat = 0.0 - var leftColors = graphObject.colors.prefix(through: graphObject.colors.count/2) - let rightColors = graphObject.colors.suffix(from: graphObject.colors.count/2) - - // make the top layer higher than line width for smooth look - topGradientHeight = min(max(graphObject.lineWidth, 1.0/(1.0+CGFloat(graphObject.colors.count))*graphObject.diameter), graphObject.diameter) - let topLayer = CAGradientLayer() - topLayer.frame = CGRect(x: 0.0, y: 0.0, width: graphObject.diameter, height: topGradientHeight) - //make the graident edge more smoothy - topLayer.startPoint = CGPoint(x: 0.25, y: 0.0) - topLayer.endPoint = CGPoint(x: 0.75, y: 0.0) - //if number of colors is even, need to display gradient layer, otherwise make top layer as solid color layer - if graphObject.colors.count % 2 == 0 { - leftColors.removeLast() - let firstColor = leftColors.last!.cgColor - let secondColor = rightColors.first!.cgColor - topLayer.colors = [firstColor, secondColor] - } else { - topLayer.backgroundColor = leftColors.last?.cgColor - } - containLayer.addSublayer(topLayer) - - let leftLayer = CAGradientLayer() - leftLayer.frame = CGRect(x: 0, y: topGradientHeight, width: radius, height: graphObject.diameter - topGradientHeight) - leftLayer.startPoint = CGPoint(x: 0, y: 1) - leftLayer.endPoint = CGPoint(x: 0, y: 0) - - //count of graidentLayer.colors must be bigger than 1, otherwise set backgroundColor - if leftColors.count > 1 { - leftLayer.colors = leftColors.map({ (color) -> CGColor in - return color.cgColor - }) - } else { - leftLayer.backgroundColor = leftColors.first?.cgColor - } - containLayer.addSublayer(leftLayer) - - let rightLayer = CAGradientLayer() - rightLayer.frame = CGRect(x: radius, y: topGradientHeight, width: radius, height: graphObject.diameter - topGradientHeight) - rightLayer.startPoint = CGPoint(x: 0, y: 0) - rightLayer.endPoint = CGPoint(x: 0, y: 1) - if rightColors.count > 1 { - rightLayer.colors = rightColors.map({ (color) -> CGColor in - return color.cgColor - }) - } else { - rightLayer.backgroundColor = rightColors.first?.cgColor - } - containLayer.addSublayer(rightLayer) - - return containLayer - } //MARK: MVMCoreUIViewConstrainingProtocol public func needsToBeConstrained() -> Bool { return true diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index 25bfa988..c4df44c0 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -34,32 +34,18 @@ self.model = model // Set appearance - if #available(iOS 13.0, *) { - let appearance = UITabBarAppearance() - appearance.backgroundColor = model.backgroundColor?.uiColor - set(tabItemAppearance: appearance.stackedLayoutAppearance, model: model) - set(tabItemAppearance: appearance.inlineLayoutAppearance, model: model) - set(tabItemAppearance: appearance.compactInlineLayoutAppearance, model: model) - standardAppearance = appearance - } else { - // Fallback on earlier versions - backgroundColor = model.backgroundColor?.uiColor - tintColor = model.selectedColor.uiColor - unselectedItemTintColor = model.unSelectedColor.uiColor - barTintColor = model.backgroundColor?.uiColor - isTranslucent = false - } + let appearance = UITabBarAppearance() + appearance.backgroundColor = model.backgroundColor?.uiColor + set(tabItemAppearance: appearance.stackedLayoutAppearance, model: model) + set(tabItemAppearance: appearance.inlineLayoutAppearance, model: model) + set(tabItemAppearance: appearance.compactInlineLayoutAppearance, model: model) + standardAppearance = appearance // Add buttons var tabs: [UITabBarItem] = [] for (index, tab) in model.tabs.enumerated() { let tabBarItem = UITabBarItem(title: tab.title, image: MVMCoreCache.shared()?.getImageFromRegisteredBundles(tab.image), tag: index) tabBarItem.accessibilityLabel = tab.accessibilityText - if #available(iOS 13.0, *) { - } else { - tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) - tabBarItem.setTitleTextAttributes([NSAttributedString.Key.font: MFFonts.mfFontTXRegular(8)], for: .normal) - } tabs.append(tabBarItem) } setItems(tabs, animated: false) @@ -67,7 +53,6 @@ } /// Sets the item colors. - @available(iOS 13.0, *) private func set(tabItemAppearance: UITabBarItemAppearance, model: TabBarModel) { tabItemAppearance.normal.iconColor = model.unSelectedColor.uiColor tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(8)] From ebf97cdbe783108183c8114fddf31807ae88d59a Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 12:37:38 -0500 Subject: [PATCH 011/102] remove iOS 13 check --- .../Containers/NavigationController.swift | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 6b1e6100..3682fd6b 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -105,25 +105,18 @@ import UIKit let backgroundColor = navigationItemModel.backgroundColor?.uiColor let tint = navigationItemModel.tintColor.uiColor navigationBar.tintColor = tint - if #available(iOS 13.0, *) { - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [NSAttributedString.Key.font: font, - NSAttributedString.Key.foregroundColor: tint]; - appearance.backgroundColor = backgroundColor - appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) - appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear - appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) - navigationBar.standardAppearance = appearance - navigationBar.scrollEdgeAppearance = appearance - } else { - // Fallback on earlier versions - navigationBar.isOpaque = true - navigationBar.shadowImage = getNavigationBarShadowImage(for: navigationItemModel) - navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font, - NSAttributedString.Key.foregroundColor: tint]; - navigationBar.barTintColor = backgroundColor - } + + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: tint]; + appearance.backgroundColor = backgroundColor + appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear + appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) + navigationBar.standardAppearance = appearance + navigationBar.scrollEdgeAppearance = appearance + navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) } From 5790fc6febd327f683e820b90a608c004fa858cd Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 12:57:14 -0500 Subject: [PATCH 012/102] line update --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 2 +- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 7985ec56..76016292 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -72,7 +72,7 @@ import UIKit open func setStyle(_ style: LineModel.Style) { lineModel?.type = style backgroundColor = lineModel?.backgroundColor?.uiColor - updateLineConstraints(constant: CGFloat(lineModel?.thickness ?? 1)) + updateLineConstraints(constant: lineModel?.thickness ?? 1) } open func shouldBeVisible() -> Bool { diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index a9a29264..a3073f52 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -57,8 +57,8 @@ import UIKit private var _backgroundColor: Color? public var backgroundColor: Color? { get { - if let backgroundColor = _backgroundColor { return backgroundColor } if inverted { return backgroundColor_inverted } + if let backgroundColor = _backgroundColor { return backgroundColor } if type == .standard { return Color(uiColor: .mvmCoolGray3) } return Color(uiColor: .mvmBlack) } From e875002cb17e877026b9cda41f214d54b8e15739 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 13:40:30 -0500 Subject: [PATCH 013/102] remove test code --- .../Containers/NavigationController.swift | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 3682fd6b..7da6e0f6 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -76,27 +76,6 @@ import UIKit let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) } -// let rect = CGRect(origin: .zero, size: size) -// UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) -// color.setFill() -// UIRectFill(rect) -// let image = UIGraphicsGetImageFromCurrentImageContext() -// UIGraphicsEndImageContext() -// -// guard let cgImage = image?.cgImage else { return nil } -// self.init(cgImage: cgImage) -// -//// let pixelScale = UIScreen.main.scale -//// let pixelSize = thickness / pixelScale -//// let fillSize = CGSize(width: pixelSize, height: pixelSize) -//// let fillRect = CGRect(origin: CGPoint.zero, size: fillSize) -//// UIGraphicsBeginImageContextWithOptions(fillRect.size, false, pixelScale) -//// graphicsContext.setFillColor(backgroundColor.cgColor) -//// graphicsContext.fill(fillRect) -//// let image = UIGraphicsGetImageFromCurrentImageContext() -//// UIGraphicsEndImageContext() -// return image -// } /// Convenience function for setting the navigation bar ui, except for the buttons. public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { From b4d7392675ffe66a20873c0a5d2b77b2b5d7f1f4 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 10 Mar 2022 13:44:07 -0500 Subject: [PATCH 014/102] remove iOS 13 check --- .../Managers/SubNav/SubNavManagerController.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 37a33ca9..8fbf8d49 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -124,15 +124,13 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Hides/Shows the navigation bar for the page. open func hideNavigationBarLine(_ isHidden: Bool) { guard self == navigationController?.topViewController else { return } - if #available(iOS 13.0, *) { - var color = UIColor.clear - if !isHidden, - let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { - color = backgroundColor - } - navigationController?.navigationBar.standardAppearance.shadowColor = color - navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color + var color = UIColor.clear + if !isHidden, + let backgroundColor = (getCurrentViewController() as? PageProtocol)?.pageModel?.navigationBar?.line?.backgroundColor?.uiColor { + color = backgroundColor } + navigationController?.navigationBar.standardAppearance.shadowColor = color + navigationController?.navigationBar.scrollEdgeAppearance?.shadowColor = color } open override func updateViews() { From 5bbacf4de123e28f9493deba226c897e383f132b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 11 Mar 2022 15:28:21 -0500 Subject: [PATCH 015/102] Move status bar to the split view for control. Each page can style status bar now, not just top alerts. --- ...MCoreUISplitViewController+Extension.swift | 24 +++ .../MVMCoreUISplitViewController.h | 18 +- .../MVMCoreUISplitViewController.m | 82 +++++---- .../TopAlert/MVMCoreTopAlertViewProtocol.h | 9 +- .../MVMCoreUITopAlertView+Extension.swift | 2 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 15 -- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 164 ++++++------------ 7 files changed, 149 insertions(+), 165 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index a4bbcb08..58bb1497 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit // Navigation bar update functions public extension MVMCoreUISplitViewController { @@ -122,6 +123,29 @@ public extension MVMCoreUISplitViewController { navigationController.isDisplayed(viewController: viewController), let model = navigationController.getNavigationModel(from: viewController) else { return } set(for: viewController, navigationController: navigationController, navigationItemModel: model) + guard !(topAlertView?.overridingStatusBar() ?? false) else { return } + setStatusBarForCurrentViewController() + } + + /// Returns the bar style for the background color. Light if on a dark background, otherwise default. + func getStatusBarStyle(for backgroundColor: UIColor?) -> UIStatusBarStyle { + var greyScale: CGFloat = 0 + if backgroundColor?.getWhite(&greyScale, alpha: nil) == true, + greyScale < 0.5 { return .lightContent } + return .default + } + + /// Updates the status bar background color and style. + @objc func setStatusBarForCurrentViewController() { + let viewController = getCurrentViewController() as? MVMCoreUIDetailViewProtocol + let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ?? + navigationController?.navigationBar.standardAppearance.backgroundColor ?? + statusBarView?.backgroundColor + + let style = viewController?.defaultStatusBarStyle?() ?? + getStatusBarStyle(for: backgroundColor) + + setStatusBarBackgroundColor(backgroundColor, style: style) } } diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 9c07374d..db5e9cd9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -44,6 +44,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // Reference to the top alert view @property (nullable, weak, nonatomic) MVMCoreUITopAlertView *topAlertView; +// Reference to the status bar view +@property (nullable, weak, nonatomic) UIView *statusBarView; + // References to the current navigation item settings. @property (nonatomic, readonly) BOOL leftPanelIsAccessible; @property (nonatomic, readonly) BOOL rightPanelIsAccessible; @@ -122,10 +125,6 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { + (CGFloat)getApplicationViewWidth; + (CGFloat)getApplicationViewMaxSize; -// return subviewcontrollers' prefer status bar style -- (UIStatusBarStyle)getDefaultStatusBarStyle; -- (nullable UIColor *)getDefaultStatusBarBackgroundColor; - /// Returns true if a panel is showing. - (BOOL)isAPanelShowing; @@ -166,4 +165,15 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Updates if the tab bar is showing or not. - (void)updateTabBarShowing:(BOOL)showing; +#pragma mark - Status Bar + +/// Updates the status bar with the given style and background color +- (void)setStatusBarBackgroundColor:(nullable UIColor *)backgroundColor style:(UIStatusBarStyle)style; + +/// Shows the view under the status bar. +- (void)expandStatusBarView; + +/// Hides the view under the status bar. +- (void)collapseStatusBarView; + @end diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index e16daa56..5c337072 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -63,6 +63,10 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) { @property (weak, nonatomic, readwrite) UIViewController *navigationItemViewController; @property (strong, nonatomic) NSNumber *transitionWidth; +@property (nonatomic) UIStatusBarStyle statusBarStyle; +@property (strong, nonatomic) NSLayoutConstraint *statusBarHeightConstraint; +@property (strong, nonatomic) NSLayoutConstraint *statusBarBottomConstraint; + // Dismisses any panel - (void)dismissPanels:(id)sender; @@ -841,6 +845,38 @@ CGFloat const PanelAnimationDuration = 0.2; }]; } +#pragma mark - Status Bar + +- (void)setStatusBarBackgroundColor:(UIColor *)backgroundColor style:(UIStatusBarStyle)style { + self.statusBarView.backgroundColor = backgroundColor; + self.statusBarStyle = style; + + // Triggers preferredStatusBarStyle + [self.parentViewController setNeedsStatusBarAppearanceUpdate]; +} + +- (UIStatusBarStyle)preferredStatusBarStyle { + return self.statusBarStyle; +} + +- (void)expandStatusBarView { + __weak typeof(self) weakSelf = self; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + weakSelf.statusBarBottomConstraint.active = YES; + weakSelf.statusBarHeightConstraint.active = NO; + [weakSelf.view layoutIfNeeded]; + }]; +} + +- (void)collapseStatusBarView { + __weak typeof(self) weakSelf = self; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + weakSelf.statusBarBottomConstraint.active = NO; + weakSelf.statusBarHeightConstraint.active = YES; + [weakSelf.view layoutIfNeeded]; + }]; +} + #pragma mark - View Cyle - (void)loadView { @@ -849,6 +885,17 @@ CGFloat const PanelAnimationDuration = 0.2; view.translatesAutoresizingMaskIntoConstraints = NO; self.view = view; + // Status bar + UIView *statusBarView = [MVMCoreUICommonViewsUtility commonView]; + statusBarView.backgroundColor = [UIColor whiteColor]; + [self.view addSubview:statusBarView]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[statusBarView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView)]]; + id topGuide = view.safeAreaLayoutGuide; + self.statusBarBottomConstraint = [NSLayoutConstraint constraintWithItem:statusBarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + self.statusBarBottomConstraint.active = YES; + self.statusBarHeightConstraint = [statusBarView.heightAnchor constraintEqualToConstant:0]; + self.statusBarView = statusBarView; + // Top Alert MVMCoreUITopAlertView *topAlertView = nil; if ([[CoreUIObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { @@ -894,9 +941,9 @@ CGFloat const PanelAnimationDuration = 0.2; self.bottomProgressBarHeightConstraint = bottomProgressHeight; if (topAlertView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[topAlertView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAlertView, mainView, progressView)]]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[statusBarView]-0-[topAlertView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView,topAlertView, mainView, progressView)]]; } else { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(mainView, progressView)]]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[statusBarView]-0-[mainView]-0-[progressView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView,mainView, progressView)]]; } // Add tabbar if we have it. @@ -924,7 +971,6 @@ CGFloat const PanelAnimationDuration = 0.2; - (void)viewDidLoad { [super viewDidLoad]; - [self.topAlertView pinATopViewController:self]; // Creates the back button self.backButton = [[UIBarButtonItem alloc] initWithImage:[self imageForBackButton] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; @@ -1008,36 +1054,6 @@ CGFloat const PanelAnimationDuration = 0.2; } } -- (UIStatusBarStyle)preferredStatusBarStyle { - if (self.topAlertView.topAlertObject) { - return self.topAlertView.statusBarStyle; - } else { - UIStatusBarStyle style = [self getDefaultStatusBarStyle]; - [self.topAlertView resetDefaultBackgroundColor:[self getDefaultStatusBarBackgroundColor] basedOnStatusBarStyle:style]; - return style; - } -} - -- (UIStatusBarStyle)getDefaultStatusBarStyle { - UIViewController *viewController = [self getCurrentDetailViewController]; - if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] - && [viewController respondsToSelector:@selector(defaultStatusBarStyle)] - && [((UIViewController *)viewController) defaultStatusBarStyle]) { - return [((UIViewController *)viewController) defaultStatusBarStyle]; - } - return UIStatusBarStyleDefault; -} - -- (UIColor *)getDefaultStatusBarBackgroundColor { - UIViewController *viewController = [self getCurrentDetailViewController]; - if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] - && [viewController respondsToSelector:@selector(defaultStatusBarBackgroundColor)] - && [((UIViewController *)viewController) defaultStatusBarBackgroundColor]) { - return [((UIViewController *)viewController) defaultStatusBarBackgroundColor]; - } - return nil; -} - - (BOOL)isAPanelShowing { return fabs(self.mainViewLeading.constant) > 1; } diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h b/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h index e10cec10..e799e858 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h @@ -13,16 +13,19 @@ @optional -// Show based on the object +/// Show based on the object - (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler; -// Hides +/// Removes the notification - (void)hideAlertView:(BOOL)forceful completionHandler:(void (^ __nullable)(BOOL finished))completionHandler; -// Collapses the notification if it has a short top message. Otherwise removes notification. +/// Collapses the notification if it has a short top message. Otherwise removes notification. - (void)collapseNotification; /// Updates the existing top alert with the new object - (void)updateTopAlertWith:(nullable MVMCoreTopAlertObject *)topAlertObject; +/// Returns if the top alert is currently utilizing the status bar. +- (BOOL)overridingStatusBar; + @end diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 0328f03c..46765385 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -109,7 +109,7 @@ public extension MVMCoreUITopAlertView { // Update status bar. guard let statusBarDelegate = molecule as? StatusBarUI else { return } let statusBarUI = statusBarDelegate.getStatusBarUI() - self.setStatusBarColor(statusBarUI.color, statusBarStyle: statusBarUI.style) + MVMCoreUISplitViewController.main()?.setStatusBarBackgroundColor(statusBarUI.color, style: statusBarUI.style) }) } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 5bb033d7..fad65957 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -19,8 +19,6 @@ @interface MVMCoreUITopAlertView : UIView -@property (nonatomic, readonly) UIStatusBarStyle statusBarStyle; - // Delegate for the top alert view @property (nonatomic, nullable, weak) id animationDelegate; @@ -36,16 +34,6 @@ // Returns a TopAlertView with the mvm styling. Also sets the property in the session. + (nullable instancetype)setupTopAlertView; -// Pins the status bar view at the top of the passed in view controller. -- (void)pinATopViewController:(nonnull UIViewController *)viewController; - -// For controlling the status bar view -- (void)expandStatusBarView; -- (void)collapseStatusBarView; - -/// reset status bar background color, when backgroundColor is nil corresponding background color will be set based on style -- (void)resetDefaultBackgroundColor:(nullable UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style; - // Can be subclassed for custom views. - (nonnull UIView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor statusBarStyle:(UIStatusBarStyle *_Nullable)statusBarStyle; @@ -55,7 +43,4 @@ /// Get the content color based on the type - (nonnull UIColor *)getContentColorForType:(nullable NSString *)type; -// Set the status bar color. Used for updating the status bar when the view changes. -- (void)setStatusBarColor:(nullable UIColor *)statusBarColor statusBarStyle:(UIStatusBarStyle)style; - @end diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index eba4cfcc..c0835541 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -33,12 +33,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; @interface MVMCoreUITopAlertView () -@property (nonatomic, readwrite) UIStatusBarStyle statusBarStyle; -@property (weak, nonatomic) UIView *statusBarView; -@property (strong, nonatomic) NSLayoutConstraint *statusBarHeightConstraint; -@property (strong, nonatomic) NSLayoutConstraint *statusBarBottomConstraint; - -@property (weak, nonatomic) UIView *alertView; @property (weak, nullable, nonatomic, readwrite) UIView *currentAlert; @property (strong, nonatomic) NSLayoutConstraint *height; @@ -48,6 +42,8 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; /// Used if we delayed the collapse due to accessibility. @property (copy, nonatomic) void (^ hideCompletionHandler)(BOOL finished); +@property (nonatomic) BOOL currentAlertOverridingStatusBar; + @end @implementation MVMCoreUITopAlertView @@ -88,34 +84,11 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } - (void)setupView { - if (!self.statusBarView) { - self.clipsToBounds = YES; - - UIView *statusBarView = [MVMCoreUICommonViewsUtility commonView]; - UIView *alertView = [MVMCoreUICommonViewsUtility commonView]; - [self addSubview:alertView]; - [self addSubview:statusBarView]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[statusBarView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView)]]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[alertView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(alertView)]]; - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[statusBarView]-0-[alertView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(statusBarView,alertView)]]; - self.statusBarHeightConstraint = [statusBarView.heightAnchor constraintEqualToConstant:0]; - self.statusBarHeightConstraint.active = YES; - self.height = [alertView.heightAnchor constraintEqualToConstant:0]; - self.height.active = YES; - self.alertView = alertView; - self.statusBarView = statusBarView; - - [self setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; - - [self registerWithNotificationCenter]; - } -} - -- (void)pinATopViewController:(UIViewController *)viewController { - self.statusBarHeightConstraint.active = NO; - id topGuide = viewController.view.safeAreaLayoutGuide; - self.statusBarBottomConstraint = [NSLayoutConstraint constraintWithItem:self.statusBarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; - self.statusBarBottomConstraint.active = YES; + if (self.height) { return; } + self.clipsToBounds = YES; + self.height = [self.heightAnchor constraintEqualToConstant:0]; + self.height.active = YES; + [self registerWithNotificationCenter]; } - (void)updateView:(CGFloat)size { @@ -159,38 +132,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } } -- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler { - - self.animationDelegate = animationDelegate; - dispatch_async(dispatch_get_main_queue(), ^{ - - self.topAlertObject = topAlertObject; - self.topAlertClearspotView = nil; - - UIColor *statusBarColor = nil; - UIStatusBarStyle statusBarStyle = UIStatusBarStyleDefault; - UIView *view = [self topAlertViewForTopAlertObject:topAlertObject animationDelegate:animationDelegate statusBarColor:&statusBarColor statusBarStyle:&statusBarStyle]; - if ([view conformsToProtocol:@protocol(MVMCoreViewProtocol)]) { - [((UIView *)view) updateView:CGRectGetWidth(self.bounds)]; - } - if (!statusBarColor) { - statusBarColor = [UIColor whiteColor]; - } - [self setStatusBarColor:statusBarColor statusBarStyle:statusBarStyle]; - [self showAlertView:view topAlertObject:topAlertObject completionHandler:completionHandler]; - }); -} - -- (void)updateTopAlertWith:(MVMCoreTopAlertObject *)topAlertObject { - [self updateMoleculeWith:topAlertObject]; -} - -- (void)setStatusBarColor:(nullable UIColor *)statusBarColor statusBarStyle:(UIStatusBarStyle)style { - self.statusBarView.backgroundColor = statusBarColor; - self.statusBarStyle = style; - [[MVMCoreUISession sharedGlobal].splitViewController.parentViewController setNeedsStatusBarAppearanceUpdate]; -} - - (void)updateAccessibilityForTopAlert:(nullable UIView *)view { // Update accessibility with top alert if ([view isKindOfClass:[MVMCoreUITopAlertBaseView class]]) { @@ -212,7 +153,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; if (weakSelf.currentAlert.superview) { [weakSelf.currentAlert removeFromSuperview]; } - [weakSelf.alertView addSubview:view]; + [weakSelf addSubview:view]; [NSLayoutConstraint constraintPinSubviewToSuperview:view]; weakSelf.currentAlert = view; @@ -241,6 +182,40 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [[MVMCoreNavigationHandler sharedNavigationHandler] addNavigationOperation:operation]; } + +/// If the voice over user leaves top alert focus, hide. +- (void)accessibilityFocusChanged:(NSNotification *)notification { + if (notification.userInfo[UIAccessibilityFocusedElementKey] && ![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) { + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityElementFocusedNotification object:nil]; + [self hideAlertView:YES completionHandler:self.hideCompletionHandler]; + self.hideCompletionHandler = nil; + } +} + +#pragma mark - MVMCoreTopAlertViewProtocol + +- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler { + + self.animationDelegate = animationDelegate; + dispatch_async(dispatch_get_main_queue(), ^{ + + self.topAlertObject = topAlertObject; + self.topAlertClearspotView = nil; + + UIColor *statusBarColor = nil; + UIStatusBarStyle statusBarStyle = UIStatusBarStyleDefault; + UIView *view = [self topAlertViewForTopAlertObject:topAlertObject animationDelegate:animationDelegate statusBarColor:&statusBarColor statusBarStyle:&statusBarStyle]; + if ([view conformsToProtocol:@protocol(MVMCoreViewProtocol)]) { + [((UIView *)view) updateView:CGRectGetWidth(self.bounds)]; + } + if (statusBarColor) { + self.currentAlertOverridingStatusBar = YES; + [[MVMCoreUISplitViewController mainSplitViewController] setStatusBarBackgroundColor:statusBarColor style:statusBarStyle]; + } + [self showAlertView:view topAlertObject:topAlertObject completionHandler:completionHandler]; + }); +} + - (void)hideAlertView:(BOOL)forceful completionHandler:(void (^ __nullable)(BOOL finished))completionHandler { // If accessible and focused, do not collapse until unfocused. if (!forceful && [MVMCoreUIUtility viewContainsAccessiblityFocus:self]) { @@ -278,9 +253,12 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; completionHandler(finished); } weakSelf.topAlertObject = nil; - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; - }]; + if (weakSelf.currentAlertOverridingStatusBar) { + weakSelf.currentAlertOverridingStatusBar = NO; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [[MVMCoreUISplitViewController mainSplitViewController] setStatusBarForCurrentViewController]; + }]; + } }]; }]; }]; @@ -288,6 +266,11 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [[MVMCoreNavigationHandler sharedNavigationHandler] addNavigationOperation:operation]; } + +- (void)updateTopAlertWith:(MVMCoreTopAlertObject *)topAlertObject { + [self updateMoleculeWith:topAlertObject]; +} + - (void)collapseNotification { if (self.currentAlert) { if ([self.currentAlert isKindOfClass:[MVMCoreUITopAlertExpandableView class]] && ((MVMCoreUITopAlertExpandableView *)self.currentAlert).shortView.label.text.length > 0) { @@ -301,45 +284,8 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } } -- (void)expandStatusBarView { - __weak typeof(self) weakSelf = self; - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - weakSelf.statusBarBottomConstraint.active = YES; - weakSelf.statusBarHeightConstraint.active = NO; - [weakSelf.superview layoutIfNeeded]; - }]; -} - -- (void)collapseStatusBarView { - __weak typeof(self) weakSelf = self; - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - weakSelf.statusBarBottomConstraint.active = NO; - weakSelf.statusBarHeightConstraint.active = YES; - [weakSelf.superview layoutIfNeeded]; - }]; -} - -- (void)resetDefaultBackgroundColor:(UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style { - if (!self.topAlertObject) { - UIColor *defaultStatusBarBackgroundColor = backgroundColor; - if (!defaultStatusBarBackgroundColor) { - defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; - } - - //color doesn't match the current default value - if (!CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { - self.statusBarView.backgroundColor = defaultStatusBarBackgroundColor; - } - } -} - -/// If the voice over user leaves top alert focus, hide. -- (void)accessibilityFocusChanged:(NSNotification *)notification { - if (notification.userInfo[UIAccessibilityFocusedElementKey] && ![MVMCoreUIUtility viewContainsAccessiblityFocus:self]) { - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityElementFocusedNotification object:nil]; - [self hideAlertView:YES completionHandler:self.hideCompletionHandler]; - self.hideCompletionHandler = nil; - } +- (BOOL)overridingStatusBar { + return self.currentAlertOverridingStatusBar; } @end From 200bd2dc3d615d4d5de3b2f091ad0e59e1c417ad Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 10:37:18 -0400 Subject: [PATCH 016/102] objc cool gray --- MVMCoreUI/Categories/UIColor+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index ca763ac5..78363630 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -186,7 +186,7 @@ extension UIColor { //-------------------------------------------------- /// HEX: #F6F6F6 - public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") + @objc public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") /// HEX: #D8DADA public static let mvmCoolGray3 = UIColor.assetColor(named: "coolGray3") From 558e1803e548d68d83b9b1d9f9fa6d554bacc564 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 11:31:53 -0400 Subject: [PATCH 017/102] title offset and default for 3 dot O --- .../Atomic/Molecules/NavigationBar/NavigationItemModel.swift | 4 ++++ .../ModelProtocols/NavigationItemModelProtocol.swift | 1 + MVMCoreUI/Containers/NavigationController.swift | 1 + 3 files changed, 6 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index b7eaf2d8..574107d6 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -59,6 +59,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var titleView: MoleculeModelProtocol? + open var titleOffset: UIOffset? //-------------------------------------------------- // MARK: - Initializer @@ -84,6 +85,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc case additionalRightButtons case titleView case style + case titleOffset } //-------------------------------------------------- @@ -110,6 +112,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) + titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) ?? UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) } open func encode(to encoder: Encoder) throws { @@ -127,6 +130,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons) try container.encodeModelIfPresent(titleView, forKey: .titleView) try container.encodeIfPresent(style, forKey: .style) + try container.encodeIfPresent(titleOffset, forKey: .titleOffset) } } diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index 8f82c946..b9fb111a 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -20,4 +20,5 @@ public protocol NavigationItemModelProtocol { var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } var titleView: MoleculeModelProtocol? { get set } + var titleOffset: UIOffset? { get } } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 7da6e0f6..f369d118 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -91,6 +91,7 @@ import UIKit NSAttributedString.Key.foregroundColor: tint]; appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.titlePositionAdjustment = navigationItemModel.titleOffset ?? .zero appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) navigationBar.standardAppearance = appearance From 41031856e5baad17bb99b05e05e093845e4f2f51 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 13:44:41 -0400 Subject: [PATCH 018/102] vds color tokens library --- MVMCoreUI.xcodeproj/project.pbxproj | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8d19a539..ebb38987 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 48; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -272,6 +272,7 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; + AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -857,6 +858,7 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; + AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1181,6 +1183,7 @@ buildActionMask = 2147483647; files = ( D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, + AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2002,6 +2005,7 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */, ); @@ -3268,7 +3272,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -3291,7 +3296,11 @@ INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -3318,7 +3327,11 @@ INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; From ea9171c1246ec26d4362052a1277b0fc7b431085 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 13:53:51 -0400 Subject: [PATCH 019/102] remove force manager check --- MVMCoreUI/BaseControllers/ViewController.swift | 1 - MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 4a154d3a..d7e947db 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -349,7 +349,6 @@ import UIKit } open func pageShown() { - guard self as? MVMCoreViewManagerProtocol == nil else { return } // Update split view properties if this is the current detail controller. if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 8fbf8d49..57c84e3f 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -111,7 +111,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } open override func pageShown() { - super.pageShown() hideNavigationBarLine(true) } From 09e59d5b31c4ef56ec122f4ca6caf1b5d1db0fa4 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 13:55:39 -0400 Subject: [PATCH 020/102] comment --- MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 57c84e3f..c3be1868 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -111,6 +111,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } open override func pageShown() { + // Currently not calling super until we can decouple page shown logics for managers. hideNavigationBarLine(true) } From b89cc4386734a921d7810140ca77be79e29bb20a Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 14:46:35 -0400 Subject: [PATCH 021/102] Review Comments from static to extension --- MVMCoreUI.xcodeproj/project.pbxproj | 14 ++- .../NavigationController.swift | 87 ++----------------- .../UINavigationController+Extension.swift | 87 +++++++++++++++++++ ...MCoreUISplitViewController+Extension.swift | 15 ++-- 4 files changed, 112 insertions(+), 91 deletions(-) rename MVMCoreUI/Containers/{ => NavigationController}/NavigationController.swift (50%) create mode 100644 MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ae49c2b5..dee2e567 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -272,6 +272,7 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; + AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -855,6 +856,7 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; + AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1529,6 +1531,15 @@ path = Miscellaneous; sourceTree = ""; }; + AFE4A1D427DFBB2700C458D0 /* NavigationController */ = { + isa = PBXGroup; + children = ( + D2B18B93236214AD00A9AEDC /* NavigationController.swift */, + AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */, + ); + path = NavigationController; + sourceTree = ""; + }; D202AFE2242A5F1400E5BEDF /* Extensions */ = { isa = PBXGroup; children = ( @@ -2066,9 +2077,9 @@ D29DF11921E68467003B2FB9 /* Containers */ = { isa = PBXGroup; children = ( + AFE4A1D427DFBB2700C458D0 /* NavigationController */, 0ABD1369237B18EE0081388D /* Views */, D29DF2B621E7BE66003B2FB9 /* SplitViewController */, - D2B18B93236214AD00A9AEDC /* NavigationController.swift */, ); path = Containers; sourceTree = ""; @@ -2631,6 +2642,7 @@ DBC4391922442197001AB423 /* DashLine.swift in Sources */, D2ED27FC254B0E0300A1C293 /* MVMCoreAlertObject+Swift.swift in Sources */, D264FAAA2440F97600D98315 /* CollectionView.swift in Sources */, + AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */, AAC23FAD24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift in Sources */, BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */, 01F2C20527C81F9700DC3D36 /* SubNavSwipeAnimator.swift in Sources */, diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift similarity index 50% rename from MVMCoreUI/Containers/NavigationController.swift rename to MVMCoreUI/Containers/NavigationController/NavigationController.swift index 7da6e0f6..03c10595 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -23,7 +23,7 @@ import UIKit MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController MVMCoreNavigationHandler.shared()?.navigationController = navigationController MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) - NavigationController.setNavigationBarUI(navigationController: navigationController, navigationItemModel: NavigationItemModel()) + navigationController.setNavigationBarUI(with: NavigationItemModel()) return navigationController } @@ -34,79 +34,6 @@ import UIKit return navigationController } - /// Convenience function for setting the navigation item. - public static func setNavigationItem(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - viewController.navigationItem.title = navigationItemModel.title - viewController.navigationItem.accessibilityLabel = navigationItemModel.title - viewController.navigationItem.hidesBackButton = navigationItemModel.hidesSystemBackButton - viewController.navigationItem.leftItemsSupplementBackButton = !navigationItemModel.hidesSystemBackButton - setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - setNavigationTitleView(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - } - - /// Convenience function for setting the navigation buttons. - public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject - var leftItems: [UIBarButtonItem] = [] - if navigationItemModel.hidesSystemBackButton, - navigationItemModel.alwaysShowBackButton != false { - if let backButtonModel = navigationItemModel.backButton, - MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1 || navigationItemModel.alwaysShowBackButton ?? false { - leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - if let leftItemModels = navigationItemModel.additionalLeftButtons { - for item in leftItemModels { - leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - } - viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil - - var rightItems: [UIBarButtonItem] = [] - if let rightItemModels = navigationItemModel.additionalRightButtons { - for item in rightItemModels { - rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil - } - - static func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let thickness = navigationItemModel.line?.thickness, - let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } - return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) - } - - /// Convenience function for setting the navigation bar ui, except for the buttons. - public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - let navigationBar = navigationController.navigationBar - let font = MFStyler.fontBoldBodySmall(false) - let backgroundColor = navigationItemModel.backgroundColor?.uiColor - let tint = navigationItemModel.tintColor.uiColor - navigationBar.tintColor = tint - - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [NSAttributedString.Key.font: font, - NSAttributedString.Key.foregroundColor: tint]; - appearance.backgroundColor = backgroundColor - appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) - appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear - appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) - navigationBar.standardAppearance = appearance - navigationBar.scrollEdgeAppearance = appearance - - navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - } - - /// Convenience function for setting the navigation titleView. - public static func setNavigationTitleView(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { - let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject - if let titleViewModel = navigationItemModel?.titleView, let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) { - 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? { return (viewController as? PageProtocol)?.pageModel?.navigationBar @@ -146,8 +73,8 @@ extension NavigationController: MVMCoreViewManagerProtocol { if isDisplayed(viewController: viewController), let topViewController = topViewController, let model = getNavigationModel(from: viewController) { - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) + setNavigationItem(with: model, for: topViewController) + setNavigationBarUI(with: model) } manager?.newDataReceived?(in: viewController) } @@ -155,7 +82,7 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func willDisplay(_ viewController: UIViewController) { if let topViewController = topViewController, let model = getNavigationModel(from: viewController) { - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: topViewController) + setNavigationItem(with: model, for: topViewController) } manager?.willDisplay?(viewController) } @@ -163,7 +90,7 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func displayedViewController(_ viewController: UIViewController) { if isDisplayed(viewController: viewController), let model = getNavigationModel(from: viewController) { - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) + setNavigationBarUI(with: model) } manager?.displayedViewController?(viewController) } @@ -174,7 +101,7 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { guard self == navigationController, let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), let model = getNavigationModel(from: newViewController) else { return } - Self.setNavigationItem(navigationController: self, navigationItemModel: model, viewController: viewController) + setNavigationItem(with: model, for: viewController) } public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { @@ -190,7 +117,7 @@ extension NavigationController: MVMCorePresentationDelegateProtocol { guard self == navigationController, let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } if let model = getNavigationModel(from: newViewController) { - Self.setNavigationBarUI(navigationController: self, navigationItemModel: model) + setNavigationBarUI(with: model) } manager?.displayedViewController?(newViewController) if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift new file mode 100644 index 00000000..32de0bdf --- /dev/null +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -0,0 +1,87 @@ +// +// UINavigationController+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/14/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation + +public extension UINavigationController { + + /// Convenience function for setting the navigation item. + func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + viewController.navigationItem.title = model.title + viewController.navigationItem.accessibilityLabel = model.title + viewController.navigationItem.hidesBackButton = model.hidesSystemBackButton + viewController.navigationItem.leftItemsSupplementBackButton = !model.hidesSystemBackButton + setNavigationButtons(with: model, for: viewController) + setNavigationTitleView(with: model, for: viewController) + } + + /// Convenience function for setting the navigation buttons. + func setNavigationButtons(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject + var leftItems: [UIBarButtonItem] = [] + if model.hidesSystemBackButton, + model.alwaysShowBackButton != false { + if let backButtonModel = model.backButton, + MVMCoreNavigationHandler.shared()?.getViewControllers(for: self)?.count ?? 0 > 1 || model.alwaysShowBackButton ?? false { + leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + if let leftItemModels = model.additionalLeftButtons { + for item in leftItemModels { + leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + } + viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil + + var rightItems: [UIBarButtonItem] = [] + if let rightItemModels = model.additionalRightButtons { + for item in rightItemModels { + rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil + } + + /// Convenience function for setting the navigation titleView. + func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject + if let titleViewModel = model.titleView, + let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) { + viewController.navigationItem.titleView = molecule + } + } + + /// Returns a ShadowImage based on the line property of NavigationItemModelProtocol + func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { + guard let thickness = navigationItemModel.line?.thickness, + let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } + return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) + } + + /// Convenience function for setting the navigation bar ui + func setNavigationBarUI(with model: NavigationItemModelProtocol) { + let navigationBar = navigationBar + let font = MFStyler.fontBoldBodySmall(false) + let backgroundColor = model.backgroundColor?.uiColor + let tint = model.tintColor.uiColor + navigationBar.tintColor = tint + + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: tint]; + appearance.backgroundColor = backgroundColor + appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.shadowColor = model.line?.backgroundColor?.uiColor ?? .clear + appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate) + navigationBar.standardAppearance = appearance + navigationBar.scrollEdgeAppearance = appearance + + setNavigationBarHidden(model.hidden, animated: true) + } +} diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index a4bbcb08..c46a6bb6 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -12,18 +12,13 @@ import Foundation 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, - viewController == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() else { + func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { + guard navigationController == self.navigationController, + viewController == getCurrentDetailViewController() else { /// Not the split view navigation controller, skip split functions. return } - splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel) - } - - /// 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) @@ -121,7 +116,7 @@ public extension MVMCoreUISplitViewController { guard let navigationController = navigationController, navigationController.isDisplayed(viewController: viewController), let model = navigationController.getNavigationModel(from: viewController) else { return } - set(for: viewController, navigationController: navigationController, navigationItemModel: model) + setNavigationBar(for: viewController, navigationController: navigationController, navigationItemModel: model) } } From f198add1f6099f7e69f29bec678c705eb8990688 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 17:06:09 -0400 Subject: [PATCH 022/102] move to extension --- .../NavigationController/UINavigationController+Extension.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 32de0bdf..e4d5898a 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -77,6 +77,7 @@ public extension UINavigationController { NSAttributedString.Key.foregroundColor: tint]; appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.titlePositionAdjustment = navigationItemModel.titleOffset ?? .zero appearance.shadowColor = model.line?.backgroundColor?.uiColor ?? .clear appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate) navigationBar.standardAppearance = appearance From 8df6baf6b4fd3c206ede6c2819d45350a93be0cc Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Mar 2022 17:06:33 -0400 Subject: [PATCH 023/102] move to extension --- .../NavigationController/UINavigationController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index e4d5898a..ea5003f4 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -77,7 +77,7 @@ public extension UINavigationController { NSAttributedString.Key.foregroundColor: tint]; appearance.backgroundColor = backgroundColor appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) - appearance.titlePositionAdjustment = navigationItemModel.titleOffset ?? .zero + appearance.titlePositionAdjustment = model.titleOffset ?? .zero appearance.shadowColor = model.line?.backgroundColor?.uiColor ?? .clear appearance.shadowImage = getNavigationBarShadowImage(for: model)?.withRenderingMode(.alwaysTemplate) navigationBar.standardAppearance = appearance From 9ce71945ae2c619c8d61a3e49216a5588bbd4131 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 15 Mar 2022 16:36:06 -0400 Subject: [PATCH 024/102] merge --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 50 +++- .../HorizontalCombinationViews/TabBar.swift | 7 +- .../TabBarModel.swift | 74 ++++-- .../HorizontalCombinationViews/Tabs.swift | 21 +- .../TabsModel.swift | 96 ++++++-- .../NavigationBar/NavigationItemModel.swift | 76 +++++-- .../NavigationController.swift.orig | 213 ++++++++++++++++++ ...UISplitViewController+Extension.swift.orig | 168 ++++++++++++++ MVMCoreUI/Styles/Styler.swift | 4 +- 9 files changed, 635 insertions(+), 74 deletions(-) create mode 100644 MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig create mode 100644 MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 0f67b3f0..f463c0f9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens @objcMembers public class LineModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -54,8 +54,42 @@ import UIKit //TODO: use color insted of backgroundColor. Needs server changes // public var color: Color? - public var backgroundColor: Color? - public var backgroundColor_inverted: Color = Color(uiColor: .mvmWhite) + private var _backgroundColor: Color? + public var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if inverted { + if type == .standard { return Color(uiColor: VDSColor.interactiveDisabledOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOndark) + } + if type == .standard { return Color(uiColor: VDSColor.interactiveDisabledOnlight) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _backgroundColor = newValue + } + } + + private var _thickness: CGFloat? + public var thickness: CGFloat { + get { + if let thickness = _thickness { return thickness } + switch type { + case .heavy: + return 4 + case .medium: + return 2 + case .none: + return 0 + default: + return 1 + } + } + set { + _thickness = newValue + } + } + public var inverted: Bool = false // Use this to show vertical line @@ -90,6 +124,7 @@ import UIKit case frequency case inverted case useVerticalLine + case thickness } //-------------------------------------------------- @@ -111,12 +146,9 @@ import UIKit self.inverted = inverted } - if let backgroundColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor_inverted) { - self.backgroundColor_inverted = backgroundColor_inverted - } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) useVerticalLine = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalLine) + _thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) } public func encode(to encoder: Encoder) throws { @@ -125,8 +157,8 @@ import UIKit try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(backgroundColor_inverted, forKey: .backgroundColor_inverted) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(useVerticalLine, forKey: .useVerticalLine) + try container.encodeIfPresent(_thickness, forKey: .thickness) } } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index c4df44c0..dbea90d7 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 5/28/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import VDSColorTokens @objcMembers open class TabBar: UITabBar, MoleculeViewProtocol, TabBarProtocol, UITabBarDelegate { @@ -21,7 +21,6 @@ delegate = self translatesAutoresizingMaskIntoConstraints = false line.addLine(to: self, edge: .top, useMargin: false) - line.backgroundColor = .mvmCoolGray3 set(with: model, delegateObject, additionalData) } @@ -50,6 +49,10 @@ } setItems(tabs, animated: false) selectedItem = tabs[model.selectedTab] + + guard let lineModel = line.lineModel else { return } + lineModel.inverted = model.style == .dark + line.set(with: lineModel, delegateObject, additionalData) } /// Sets the item colors. diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index fc3e9449..beeb6149 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -7,16 +7,55 @@ // import Foundation +import VDSColorTokens -public class TabBarModel: MoleculeModelProtocol { +open class TabBarModel: MoleculeModelProtocol { public static var identifier: String = "tabBar" - public var backgroundColor: Color? = Color(uiColor: .white) - public var tabs: [TabBarItemModel] - public var selectedColor = Color(uiColor: .mvmBlack) - public var unSelectedColor = Color(uiColor: .mvmCoolGray6) + open var tabs: [TabBarItemModel] + + private var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.backgroundPrimaryDark) } + return Color(uiColor: VDSColor.backgroundPrimaryLight) + } + set { + _backgroundColor = newValue + } + } + + private var _selectedColor: Color? + open var selectedColor: Color { + get { + if let selectedColor = _selectedColor { return selectedColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsPrimaryOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _selectedColor = newValue + } + } + + private var _unSelectedColor: Color? + open var unSelectedColor: Color { + get { + if let unSelectedColor = _unSelectedColor { return unSelectedColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsSecondaryOndark) } + return Color(uiColor: VDSColor.elementsSecondaryOnlight) + } + set { + _unSelectedColor = newValue + } + } + + open var style: NavigationItemStyle? // Must be capped to 0...(tabs.count - 1) - public var selectedTab: Int = 0 + open var selectedTab: Int = 0 private enum CodingKeys: String, CodingKey { case moleculeName @@ -25,6 +64,7 @@ public class TabBarModel: MoleculeModelProtocol { case selectedColor case unSelectedColor case selectedTab + case style } public init(with tabs: [TabBarItemModel]) { @@ -46,24 +86,26 @@ public class TabBarModel: MoleculeModelProtocol { if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedTab) { selectedTab = index } + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) ?? .dark } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encode(selectedColor, forKey: .selectedColor) - try container.encode(unSelectedColor, forKey: .unSelectedColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_unSelectedColor, forKey: .unSelectedColor) try container.encode(selectedTab, forKey: .selectedTab) + try container.encodeIfPresent(style, forKey: .style) } } -public class TabBarItemModel: Codable { - var title: String? - var image: String - var action: ActionModelProtocol - var accessibilityText: String? +open class TabBarItemModel: Codable { + open var title: String? + open var image: String + open var action: ActionModelProtocol + open var accessibilityText: String? private enum CodingKeys: String, CodingKey { case title @@ -86,7 +128,7 @@ public class TabBarItemModel: Codable { accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(title, forKey: .title) try container.encode(image, forKey: .image) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 290ced62..4e424549 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -7,6 +7,7 @@ // import UIKit +import VDSColorTokens @objc public protocol TabsDelegate { func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool @@ -66,7 +67,7 @@ import UIKit open override func setupView() { super.setupView() - backgroundColor = .white + backgroundColor = VDSColor.backgroundPrimaryLight addSubview(bottomLine) setupCollectionView() setupSelectionLine() @@ -94,7 +95,7 @@ import UIKit bottomScrollView.delegate = self addSubview(bottomScrollView) bottomScrollView.addSubview(bottomContentView) - selectionLine.backgroundColor = .mvmRed + selectionLine.backgroundColor = VDSColor.paletteRed bottomContentView.addSubview(selectionLine) bringSubviewToFront(bottomScrollView) } @@ -153,8 +154,7 @@ import UIKit self.delegateObject = delegateObject self.additionalData = additionalData selectedIndex = tabsModel?.selectedIndex ?? 0 - // TODO: Commented out until we have model support for bar color. Should also do unselected color. - //selectionLine.backgroundColor = tabsModel?.selectedColor.uiColor + selectionLine.backgroundColor = tabsModel?.selectedBarColor.uiColor reloadData() } } @@ -169,10 +169,10 @@ extension Tabs: UICollectionViewDataSource { } public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let labelModel = tabsModel?.tabs[indexPath.row].label, let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TabCellId, for: indexPath) as? TabItemCell else { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TabCellId, for: indexPath) as? TabItemCell else { return UICollectionViewCell() } - cell.updateCell(labelModel: labelModel, indexPath: indexPath, delegateObject: delegateObject, additionalData: additionalData, selected: indexPath.row == selectedIndex, tabsModel: tabsModel) + cell.updateCell(indexPath: indexPath, delegateObject: delegateObject, additionalData: additionalData, selected: indexPath.row == selectedIndex, tabsModel: tabsModel) updateView(collectionView.bounds.width) return cell } @@ -332,13 +332,14 @@ extension Tabs { label.updateView(size) } - public func updateCell(labelModel: LabelModel, indexPath: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, selected: Bool, tabsModel: TabsModel?) { + public func updateCell(indexPath: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, selected: Bool, tabsModel: TabsModel?) { + guard let tabsModel = tabsModel else { return } label.reset() - label.set(with: labelModel, delegateObject, additionalData) + label.set(with: tabsModel.tabs[indexPath.row].label, delegateObject, additionalData) if selected { - label.textColor = tabsModel?.selectedColor.uiColor ?? .black + label.textColor = tabsModel.selectedColor.uiColor } else { - label.textColor = .mvmCoolGray6 + label.textColor = tabsModel.unselectedColor.uiColor } updateAccessibility(indexPath: indexPath, selected: selected, tabsModel: tabsModel) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 64f8df4d..6e154895 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -7,22 +7,78 @@ // import UIKit +import VDSColorTokens -public class TabsModel: MoleculeModelProtocol { +open class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" - public var backgroundColor: Color? - public var tabs: [TabItemModel] - public var selectedColor = Color(uiColor: .black) + open var tabs: [TabItemModel] + + open var style: NavigationItemStyle? + + private var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.backgroundPrimaryDark) } + return Color(uiColor: VDSColor.backgroundPrimaryLight) + } + set { + _backgroundColor = newValue + } + } + + private var _selectedColor: Color? + open var selectedColor: Color { + get { + if let selectedColor = _selectedColor { return selectedColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsPrimaryOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _selectedColor = newValue + } + } + + private var _unselectedColor: Color? + open var unselectedColor: Color { + get { + if let unselectedColor = _unselectedColor { return unselectedColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsSecondaryOndark) } + return Color(uiColor: VDSColor.elementsSecondaryOnlight) + } + set { + _unselectedColor = newValue + } + } + + private var _selectedBarColor: Color? + open var selectedBarColor: Color { + get { + if let selectedBarColor = _selectedBarColor { return selectedBarColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsPrimaryOndark) } + return Color(uiColor: VDSColor.paletteRed) + } + set { + _selectedBarColor = newValue + } + } // Must be capped to 0...(tabs.count - 1) - public var selectedIndex: Int = 0 + open var selectedIndex: Int = 0 private enum CodingKeys: String, CodingKey { + case moleculeName case tabs case backgroundColor case selectedColor + case unselectedColor + case selectedBarColor case selectedIndex - case moleculeName + case style } public init(with tabs: [TabItemModel]) { @@ -33,31 +89,35 @@ public class TabsModel: MoleculeModelProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) { - selectedColor = color - } + _selectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor) + _unselectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .unselectedColor) + _selectedBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedBarColor) + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) { selectedIndex = index } } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) - try container.encode(backgroundColor, forKey: .backgroundColor) - try container.encode(selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_selectedColor, forKey: .selectedColor) + try container.encodeIfPresent(_unselectedColor, forKey: .unselectedColor) + try container.encodeIfPresent(_selectedBarColor, forKey: .selectedBarColor) try container.encode(selectedIndex, forKey: .selectedIndex) + try container.encodeIfPresent(style, forKey: .style) } } -public class TabItemModel: Codable { - public var label: LabelModel - public var action: ActionModelProtocol? +open class TabItemModel: Codable { + open var label: LabelModel + open var action: ActionModelProtocol? - init(label: LabelModel) { + public init(label: LabelModel) { self.label = label } @@ -66,7 +126,7 @@ public class TabItemModel: Codable { case action } - func setDefaults() { + open func setDefaults() { if label.textAlignment == nil { label.textAlignment = .center } @@ -85,7 +145,7 @@ public class TabItemModel: Codable { setDefaults() } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModel(label, forKey: .label) try container.encodeModelIfPresent(action, forKey: .action) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index d8126508..c2e1ccc6 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -6,6 +6,12 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +import VDSColorTokens + +public enum NavigationItemStyle: String, Codable { + case light + case dark +} open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- @@ -14,12 +20,39 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open class var identifier: String { "navigationBar" } + private let defaultHidesSystemBackButton = true + open var title: String? - open var hidden: Bool - open var backgroundColor: Color? - open var tintColor: Color - open var line: LineModel? + open var hidden = false + open var line: LineModel? = LineModel(type: .standard) open var hidesSystemBackButton = true + open var style: NavigationItemStyle? + + private var _backgroundColor: Color? + open var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.backgroundPrimaryDark) } + return Color(uiColor: VDSColor.backgroundPrimaryLight) + } + set { + _backgroundColor = newValue + } + } + + private var _tintColor: Color? + open var tintColor: Color { + get { + if let tintColor = _tintColor { return tintColor } + if let style = style, + style == .dark { return Color(uiColor: VDSColor.elementsPrimaryOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _tintColor = newValue + } + } /// If true, we add the button in the backButton property. If false we do not add the button. If nil, we add the button if the controller is not the bottom of the stack open var alwaysShowBackButton: Bool? @@ -28,17 +61,13 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var titleView: MoleculeModelProtocol? + open var titleOffset: UIOffset? //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init() { - hidden = false - backgroundColor = Color(uiColor: .mvmWhite) - tintColor = Color(uiColor: .mvmBlack) - line = LineModel(type: .standard) - } + public init() {} //-------------------------------------------------- // MARK: - Keys @@ -57,6 +86,8 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc case additionalLeftButtons case additionalRightButtons case titleView + case style + case titleOffset } //-------------------------------------------------- @@ -66,16 +97,25 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) - hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) ?? false - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .mvmWhite) - tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .mvmBlack) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .standard) - hidesSystemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesSystemBackButton) ?? true + if let hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) { + self.hidden = hidden + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + _tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) + if let line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) { + self.line = line + } + if let hidesSystemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesSystemBackButton) { + self.hidesSystemBackButton = hidesSystemBackButton + } alwaysShowBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysShowBackButton) backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons) additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) + style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) + titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) ?? UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) + line?.inverted = style == .dark } open func encode(to encoder: Encoder) throws { @@ -83,8 +123,8 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(title, forKey: .title) try container.encode(hidden, forKey: .hidden) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encode(tintColor, forKey: .tintColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_tintColor, forKey: .tintColor) try container.encodeIfPresent(line, forKey: .line) try container.encode(hidesSystemBackButton, forKey: .hidesSystemBackButton) try container.encodeIfPresent(alwaysShowBackButton, forKey: .alwaysShowBackButton) @@ -92,6 +132,8 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons) try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons) try container.encodeModelIfPresent(titleView, forKey: .titleView) + try container.encodeIfPresent(style, forKey: .style) + try container.encodeIfPresent(titleOffset, forKey: .titleOffset) } } diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig b/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig new file mode 100644 index 00000000..30357881 --- /dev/null +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig @@ -0,0 +1,213 @@ +// +// NavigationController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 10/24/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { + public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)? + + /// Getter for the main navigation controller + public static func navigationController() -> Self? { + return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self + } + + /// Sets up the application with a navigation controller + public static func setupNavigationController() -> Self? { + let navigationController = self.init() + MVMCoreUISession.sharedGlobal()?.navigationController = navigationController + MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController + MVMCoreNavigationHandler.shared()?.navigationController = navigationController + MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) + navigationController.setNavigationBarUI(with: NavigationItemModel()) + return navigationController + } + + /// Sets up the application with a navigation controller as the main container. + public static func setupNavigationControllerAsMainController() -> Self? { + guard let navigationController = setupNavigationController() else { return nil } + MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) + return navigationController + } + +<<<<<<< HEAD:MVMCoreUI/Containers/NavigationController.swift + /// Convenience function for setting the navigation item. + public static func setNavigationItem(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { + viewController.navigationItem.title = navigationItemModel.title + viewController.navigationItem.accessibilityLabel = navigationItemModel.title + viewController.navigationItem.hidesBackButton = navigationItemModel.hidesSystemBackButton + viewController.navigationItem.leftItemsSupplementBackButton = !navigationItemModel.hidesSystemBackButton + setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + setNavigationTitleView(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + } + + /// Convenience function for setting the navigation buttons. + public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject + var leftItems: [UIBarButtonItem] = [] + if navigationItemModel.hidesSystemBackButton, + navigationItemModel.alwaysShowBackButton != false { + if let backButtonModel = navigationItemModel.backButton, + MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1 || navigationItemModel.alwaysShowBackButton ?? false { + leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + if let leftItemModels = navigationItemModel.additionalLeftButtons { + for item in leftItemModels { + leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + } + viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil + + var rightItems: [UIBarButtonItem] = [] + if let rightItemModels = navigationItemModel.additionalRightButtons { + for item in rightItemModels { + rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil + } + + static func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { + guard let thickness = navigationItemModel.line?.thickness, + let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } + return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) + } + + /// Convenience function for setting the navigation bar ui, except for the buttons. + public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { + let navigationBar = navigationController.navigationBar + let font = MFStyler.fontBoldBodySmall(false) + let backgroundColor = navigationItemModel.backgroundColor?.uiColor + let tint = navigationItemModel.tintColor.uiColor + navigationBar.tintColor = tint + + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: tint]; + appearance.backgroundColor = backgroundColor + appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) + appearance.titlePositionAdjustment = navigationItemModel.titleOffset ?? .zero + appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear + appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) + navigationBar.standardAppearance = appearance + navigationBar.scrollEdgeAppearance = appearance + + navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) + } + + /// Convenience function for setting the navigation titleView. + public static func setNavigationTitleView(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject + if let titleViewModel = navigationItemModel?.titleView, let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) { + viewController.navigationItem.titleView = molecule + } + } + +======= +>>>>>>> feature/develop_mvp_3:MVMCoreUI/Containers/NavigationController/NavigationController.swift + /// Convenience function to return the navigation model of the lowest controller traversing managers if applicable. + public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { + return (viewController as? PageProtocol)?.pageModel?.navigationBar + } + + /// Verifies the controller is the currently displayed controller. + public func isDisplayed(viewController: UIViewController) -> Bool { + guard let topViewController = topViewController, + viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) else { + return false + } + return true + } +} + +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 isDisplayed(viewController: viewController), + let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { + setNavigationItem(with: model, for: topViewController) + setNavigationBarUI(with: model) + } + manager?.newDataReceived?(in: viewController) + } + + public func willDisplay(_ viewController: UIViewController) { + if let topViewController = topViewController, + let model = getNavigationModel(from: viewController) { + setNavigationItem(with: model, for: topViewController) + } + manager?.willDisplay?(viewController) + } + + public func displayedViewController(_ viewController: UIViewController) { + if isDisplayed(viewController: viewController), + let model = getNavigationModel(from: viewController) { + setNavigationBarUI(with: model) + } + manager?.displayedViewController?(viewController) + } +} + +extension NavigationController: MVMCorePresentationDelegateProtocol { + public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) { + guard self == navigationController, + let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), + let model = getNavigationModel(from: newViewController) else { return } + setNavigationItem(with: model, for: viewController) + } + + public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { + guard self == navigationController, + let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) + } + 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) { + setNavigationBarUI(with: model) + } + manager?.displayedViewController?(newViewController) + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + controller.viewControllerReady?(inManager: self) + } + } +} + +extension UIColor { + func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { + return UIGraphicsImageRenderer(size: size).image { rendererContext in + self.setFill() + rendererContext.fill(CGRect(origin: .zero, size: size)) + } + } +} diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig new file mode 100644 index 00000000..49279b8e --- /dev/null +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig @@ -0,0 +1,168 @@ +// +// MVMCoreUISplitViewController+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 6/18/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +import UIKit + +// 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. + func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { + guard navigationController == self.navigationController, + viewController == getCurrentDetailViewController() else { + /// Not the split view navigation controller, skip split functions. + return + } + + setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) + setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) + + setLeftNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + setRightNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) + + setNavigationIconColor(navigationItemModel.tintColor.uiColor) + } + + /// 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 + + // Add back button first. + if navigationItemModel?.hidesSystemBackButton == true { + var showBackButton: Bool + if let forceBackButton = navigationItemModel?.alwaysShowBackButton { + showBackButton = forceBackButton + } else { + showBackButton = MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1 + } + if showBackButton { + if let backButtonModel = navigationItemModel?.backButton { + leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } else if let backButton = backButton { + // Default to legacy if we have default back button. + leftItems.append(backButton) + } + } + } + + // Add the panel button after the back button. + if let panelButton = leftPanelButton, + leftPanelIsAccessible, + !leftPanelStaysExtended() { + leftItems.append(panelButton) + } + + // Add other model buttons + if let leftItemModels = navigationItemModel?.additionalLeftButtons { + for item in leftItemModels { + leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + + // Add any buttons added by the splitview. + if let additionalLeftButtons = additionalLeftButtons(for: viewController) { + leftItems.append(contentsOf: additionalLeftButtons) + } + + 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] = [] + + // Add the panel button first. + if let panelButton = rightPanelButton, + rightPanelIsAccessible, + !rightPanelStaysExtended() { + rightItems.append(panelButton) + } + + // Add other model buttons + if let rightItemModels = navigationItemModel?.additionalRightButtons { + for item in rightItemModels { + rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) + } + } + + // Add any buttons added by the splitview. + if let additionalRightButtons = additionalRightButtons(for: viewController) { + rightItems.append(contentsOf: additionalRightButtons) + } + + 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, + navigationController.isDisplayed(viewController: viewController), + let model = navigationController.getNavigationModel(from: viewController) else { return } +<<<<<<< HEAD + set(for: viewController, navigationController: navigationController, navigationItemModel: model) + guard !(topAlertView?.overridingStatusBar() ?? false) else { return } + setStatusBarForCurrentViewController() + } + + /// Returns the bar style for the background color. Light if on a dark background, otherwise default. + func getStatusBarStyle(for backgroundColor: UIColor?) -> UIStatusBarStyle { + var greyScale: CGFloat = 0 + if backgroundColor?.getWhite(&greyScale, alpha: nil) == true, + greyScale < 0.5 { return .lightContent } + return .default + } + + /// Updates the status bar background color and style. + @objc func setStatusBarForCurrentViewController() { + let viewController = getCurrentViewController() as? MVMCoreUIDetailViewProtocol + let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ?? + navigationController?.navigationBar.standardAppearance.backgroundColor ?? + statusBarView?.backgroundColor + + let style = viewController?.defaultStatusBarStyle?() ?? + getStatusBarStyle(for: backgroundColor) + + setStatusBarBackgroundColor(backgroundColor, style: style) +======= + setNavigationBar(for: viewController, navigationController: navigationController, navigationItemModel: model) +>>>>>>> feature/develop_mvp_3 + } +} + +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) { + setupPanels() + updateNavigationBarFor(viewController: viewController) + } + + public func newDataReceived(in viewController: UIViewController) { + updateNavigationBarFor(viewController: viewController) + } +} diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 77402295..4da119fc 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -156,10 +156,10 @@ open class Styler { } } else { if isBold() { - return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) + return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) } else { - return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) + return size >= 13 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) } } } From 21ee88c5f429121c0455a778f205012c68dc50b4 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 15 Mar 2022 16:57:21 -0400 Subject: [PATCH 025/102] remove --- .../NavigationController.swift.orig | 213 ------------------ ...UISplitViewController+Extension.swift.orig | 168 -------------- 2 files changed, 381 deletions(-) delete mode 100644 MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig delete mode 100644 MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig b/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig deleted file mode 100644 index 30357881..00000000 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift.orig +++ /dev/null @@ -1,213 +0,0 @@ -// -// NavigationController.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 10/24/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol { - public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)? - - /// Getter for the main navigation controller - public static func navigationController() -> Self? { - return MVMCoreActionUtility.initializerClassCheck(MVMCoreUISession.sharedGlobal()?.navigationController, classToVerify: self) as? Self - } - - /// Sets up the application with a navigation controller - public static func setupNavigationController() -> Self? { - let navigationController = self.init() - MVMCoreUISession.sharedGlobal()?.navigationController = navigationController - MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController - MVMCoreNavigationHandler.shared()?.navigationController = navigationController - MVMCoreNavigationHandler.shared()?.addDelegate(navigationController) - navigationController.setNavigationBarUI(with: NavigationItemModel()) - return navigationController - } - - /// Sets up the application with a navigation controller as the main container. - public static func setupNavigationControllerAsMainController() -> Self? { - guard let navigationController = setupNavigationController() else { return nil } - MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) - return navigationController - } - -<<<<<<< HEAD:MVMCoreUI/Containers/NavigationController.swift - /// Convenience function for setting the navigation item. - public static func setNavigationItem(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - viewController.navigationItem.title = navigationItemModel.title - viewController.navigationItem.accessibilityLabel = navigationItemModel.title - viewController.navigationItem.hidesBackButton = navigationItemModel.hidesSystemBackButton - viewController.navigationItem.leftItemsSupplementBackButton = !navigationItemModel.hidesSystemBackButton - setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - setNavigationTitleView(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - } - - /// Convenience function for setting the navigation buttons. - public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) { - let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject - var leftItems: [UIBarButtonItem] = [] - if navigationItemModel.hidesSystemBackButton, - navigationItemModel.alwaysShowBackButton != false { - if let backButtonModel = navigationItemModel.backButton, - MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1 || navigationItemModel.alwaysShowBackButton ?? false { - leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - if let leftItemModels = navigationItemModel.additionalLeftButtons { - for item in leftItemModels { - leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - } - viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil - - var rightItems: [UIBarButtonItem] = [] - if let rightItemModels = navigationItemModel.additionalRightButtons { - for item in rightItemModels { - rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil - } - - static func getNavigationBarShadowImage(for navigationItemModel: NavigationItemModelProtocol) -> UIImage? { - guard let thickness = navigationItemModel.line?.thickness, - let backgroundColor = navigationItemModel.line?.backgroundColor else { return nil } - return backgroundColor.uiColor.image(CGSize(width: thickness, height: thickness)) - } - - /// Convenience function for setting the navigation bar ui, except for the buttons. - public static func setNavigationBarUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - let navigationBar = navigationController.navigationBar - let font = MFStyler.fontBoldBodySmall(false) - let backgroundColor = navigationItemModel.backgroundColor?.uiColor - let tint = navigationItemModel.tintColor.uiColor - navigationBar.tintColor = tint - - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [NSAttributedString.Key.font: font, - NSAttributedString.Key.foregroundColor: tint]; - appearance.backgroundColor = backgroundColor - appearance.titleTextAttributes.updateValue(tint, forKey: .foregroundColor) - appearance.titlePositionAdjustment = navigationItemModel.titleOffset ?? .zero - appearance.shadowColor = navigationItemModel.line?.backgroundColor?.uiColor ?? .clear - appearance.shadowImage = getNavigationBarShadowImage(for: navigationItemModel)?.withRenderingMode(.alwaysTemplate) - navigationBar.standardAppearance = appearance - navigationBar.scrollEdgeAppearance = appearance - - navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) - } - - /// Convenience function for setting the navigation titleView. - public static func setNavigationTitleView(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) { - let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject - if let titleViewModel = navigationItemModel?.titleView, let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) { - viewController.navigationItem.titleView = molecule - } - } - -======= ->>>>>>> feature/develop_mvp_3:MVMCoreUI/Containers/NavigationController/NavigationController.swift - /// Convenience function to return the navigation model of the lowest controller traversing managers if applicable. - public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - return (viewController as? PageProtocol)?.pageModel?.navigationBar - } - - /// Verifies the controller is the currently displayed controller. - public func isDisplayed(viewController: UIViewController) -> Bool { - guard let topViewController = topViewController, - viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) else { - return false - } - return true - } -} - -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 isDisplayed(viewController: viewController), - let topViewController = topViewController, - let model = getNavigationModel(from: viewController) { - setNavigationItem(with: model, for: topViewController) - setNavigationBarUI(with: model) - } - manager?.newDataReceived?(in: viewController) - } - - public func willDisplay(_ viewController: UIViewController) { - if let topViewController = topViewController, - let model = getNavigationModel(from: viewController) { - setNavigationItem(with: model, for: topViewController) - } - manager?.willDisplay?(viewController) - } - - public func displayedViewController(_ viewController: UIViewController) { - if isDisplayed(viewController: viewController), - let model = getNavigationModel(from: viewController) { - setNavigationBarUI(with: model) - } - manager?.displayedViewController?(viewController) - } -} - -extension NavigationController: MVMCorePresentationDelegateProtocol { - public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) { - guard self == navigationController, - let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), - let model = getNavigationModel(from: newViewController) else { return } - setNavigationItem(with: model, for: viewController) - } - - public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { - guard self == navigationController, - let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } - if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { - MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) - } - 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) { - setNavigationBarUI(with: model) - } - manager?.displayedViewController?(newViewController) - if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { - controller.viewControllerReady?(inManager: self) - } - } -} - -extension UIColor { - func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { - return UIGraphicsImageRenderer(size: size).image { rendererContext in - self.setFill() - rendererContext.fill(CGRect(origin: .zero, size: size)) - } - } -} diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig deleted file mode 100644 index 49279b8e..00000000 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift.orig +++ /dev/null @@ -1,168 +0,0 @@ -// -// MVMCoreUISplitViewController+Extension.swift -// MVMCoreUI -// -// Created by Scott Pfeil on 6/18/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation -import UIKit - -// 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. - func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { - guard navigationController == self.navigationController, - viewController == getCurrentDetailViewController() else { - /// Not the split view navigation controller, skip split functions. - return - } - - setLeftPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isLeftPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) - setRightPanelIsAccessible((viewController as? MVMCoreUIDetailViewProtocol)?.isRightPanelAccessible?() ?? false, for: viewController, updateNavigationButtons: false) - - setLeftNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - setRightNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController) - - setNavigationIconColor(navigationItemModel.tintColor.uiColor) - } - - /// 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 - - // Add back button first. - if navigationItemModel?.hidesSystemBackButton == true { - var showBackButton: Bool - if let forceBackButton = navigationItemModel?.alwaysShowBackButton { - showBackButton = forceBackButton - } else { - showBackButton = MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1 - } - if showBackButton { - if let backButtonModel = navigationItemModel?.backButton { - leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } else if let backButton = backButton { - // Default to legacy if we have default back button. - leftItems.append(backButton) - } - } - } - - // Add the panel button after the back button. - if let panelButton = leftPanelButton, - leftPanelIsAccessible, - !leftPanelStaysExtended() { - leftItems.append(panelButton) - } - - // Add other model buttons - if let leftItemModels = navigationItemModel?.additionalLeftButtons { - for item in leftItemModels { - leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - - // Add any buttons added by the splitview. - if let additionalLeftButtons = additionalLeftButtons(for: viewController) { - leftItems.append(contentsOf: additionalLeftButtons) - } - - 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] = [] - - // Add the panel button first. - if let panelButton = rightPanelButton, - rightPanelIsAccessible, - !rightPanelStaysExtended() { - rightItems.append(panelButton) - } - - // Add other model buttons - if let rightItemModels = navigationItemModel?.additionalRightButtons { - for item in rightItemModels { - rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil)) - } - } - - // Add any buttons added by the splitview. - if let additionalRightButtons = additionalRightButtons(for: viewController) { - rightItems.append(contentsOf: additionalRightButtons) - } - - 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, - navigationController.isDisplayed(viewController: viewController), - let model = navigationController.getNavigationModel(from: viewController) else { return } -<<<<<<< HEAD - set(for: viewController, navigationController: navigationController, navigationItemModel: model) - guard !(topAlertView?.overridingStatusBar() ?? false) else { return } - setStatusBarForCurrentViewController() - } - - /// Returns the bar style for the background color. Light if on a dark background, otherwise default. - func getStatusBarStyle(for backgroundColor: UIColor?) -> UIStatusBarStyle { - var greyScale: CGFloat = 0 - if backgroundColor?.getWhite(&greyScale, alpha: nil) == true, - greyScale < 0.5 { return .lightContent } - return .default - } - - /// Updates the status bar background color and style. - @objc func setStatusBarForCurrentViewController() { - let viewController = getCurrentViewController() as? MVMCoreUIDetailViewProtocol - let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ?? - navigationController?.navigationBar.standardAppearance.backgroundColor ?? - statusBarView?.backgroundColor - - let style = viewController?.defaultStatusBarStyle?() ?? - getStatusBarStyle(for: backgroundColor) - - setStatusBarBackgroundColor(backgroundColor, style: style) -======= - setNavigationBar(for: viewController, navigationController: navigationController, navigationItemModel: model) ->>>>>>> feature/develop_mvp_3 - } -} - -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) { - setupPanels() - updateNavigationBarFor(viewController: viewController) - } - - public func newDataReceived(in viewController: UIViewController) { - updateNavigationBarFor(viewController: viewController) - } -} From 02476e766d18eb3699dfe3570b1ee78e9f887870 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 24 Mar 2022 00:22:38 +0530 Subject: [PATCH 026/102] Updating button VDS component for 3.0 rebranding --- .../Atomic/Atoms/Buttons/PillButton.swift | 49 ++++++++++++++++--- MVMCoreUI/Styles/Styler.swift | 8 +-- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 5b8f75cb..edea692f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -128,6 +128,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { self.borderColor = borderColor } } + titleEdgeInsets = getContentEdgeInsets() } private func getInnerPadding() -> CGFloat { @@ -138,6 +139,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } + private func getContentEdgeInsets() -> UIEdgeInsets { + var verticalPadding = 0.0 + var horizontalPadding = 0.0 + switch buttonSize { + case .standard: + verticalPadding = Padding.Three + horizontalPadding = Padding.Five + break + case .small: + verticalPadding = Padding.Two + horizontalPadding = Padding.Four + break + default: + break + } + return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) + } + public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat { switch buttonSize { @@ -146,7 +165,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { return MFSizeObject(standardSize: tinyHeight, standardiPadPortraitSize: 34, iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight - + case .small: + let smallHeight = Styler.Button.Size.small.getHeight() + return MFSizeObject(standardSize: smallHeight, + standardiPadPortraitSize: 34, + iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? smallHeight default: let standardHeight = Styler.Button.Size.standard.getHeight() return MFSizeObject(standardSize: standardHeight, @@ -162,8 +185,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { return MFSizeObject(standardSize: 49, standardiPadPortraitSize: 90, iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49 - - default: return 151 + case .small: + return MFSizeObject(standardSize: 1, + standardiPadPortraitSize: 2, + iPadProLandscapeSize: 3)?.getValueBased(onSize: size) ?? 1 + case .standard: + return MFSizeObject(standardSize: 76, + standardiPadPortraitSize: 90, + iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 76 } } @@ -172,9 +201,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { let size = super.intrinsicContentSize let width = size.width + (2 * getInnerPadding()) return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) + } else if buttonSize == .small { + let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) } else { - let width = Padding.Component.gutterForApplicationWidth + (2.0 * Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth())) - return CGSize(width: min(292, width), height: getHeight()) + let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) } } @@ -218,9 +250,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight())) - - default: - titleLabel?.font = MFFonts.mfFont75Bd(13 * (intrinsicContentSize.height / Styler.Button.Size.standard.getHeight())) + case .small: + titleLabel?.font = Styler.Font.BoldBodySmall.getFont() + case .standard: + titleLabel?.font = Styler.Font.BoldBodyLarge.getFont() } layer.cornerRadius = getInnerPadding() diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 77402295..c8fe444e 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -178,16 +178,18 @@ open class Styler { case primary case secondary } - + ///MVA 3.0 - Button sizes are standard(default size), small, Tiny. Tiny button has been depricated as of Rebranding 3.0. public enum Size: String, Codable { case standard + case small case tiny func getHeight() -> CGFloat { switch self { case .standard: - return 42 - + return 44 + case .small: + return 32 case .tiny: return 20 } From 121c290f3b4beddbcde1d5db7d2131929304c42f Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 24 Mar 2022 13:35:49 +0530 Subject: [PATCH 027/102] updating title edge insets for button as per VDS --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index edea692f..e7d0aacc 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -128,7 +128,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { self.borderColor = borderColor } } - titleEdgeInsets = getContentEdgeInsets() } private func getInnerPadding() -> CGFloat { @@ -257,6 +256,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() + titleEdgeInsets = getContentEdgeInsets() } open override func setupView() { From 5a331429342b0d6c416c77182813e27ca4b59596 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 25 Mar 2022 01:20:22 +0530 Subject: [PATCH 028/102] Changes to read imageRenderingMode parameter from model sent from server. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++- .../UIImageRenderingMode+Extension.swift | 59 +++++++++++++++++++ .../Buttons/ImageBarButtonItem.swift | 7 ++- .../Buttons/NavigationImageButtonModel.swift | 6 ++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 MVMCoreUI/Atomic/Extensions/UIImageRenderingMode+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a6588ea8..1c042443 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -145,6 +145,7 @@ 32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */; }; 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; + 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; @@ -272,8 +273,8 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; - AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; + AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; }; BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; }; @@ -732,6 +733,7 @@ 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = ""; }; 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = ""; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = ""; }; + 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageRenderingMode+Extension.swift"; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = ""; }; @@ -859,8 +861,8 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; - AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; + AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = ""; }; BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = ""; }; @@ -1563,6 +1565,7 @@ D2ED27E6254B0CE600A1C293 /* UIAlertActionStyle+Codable.swift */, D2ED27E7254B0CE600A1C293 /* UIAlertControllerStyle+Extension.swift */, D2E0FFF726AF68530085D696 /* UITableViewRowAnimation+Extension.swift */, + 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */, ); path = Extensions; sourceTree = ""; @@ -2919,6 +2922,7 @@ C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, + 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */, AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */, AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Extensions/UIImageRenderingMode+Extension.swift b/MVMCoreUI/Atomic/Extensions/UIImageRenderingMode+Extension.swift new file mode 100644 index 00000000..21a1cea2 --- /dev/null +++ b/MVMCoreUI/Atomic/Extensions/UIImageRenderingMode+Extension.swift @@ -0,0 +1,59 @@ +// +// UIImageRenderingMode+Extension.swift +// MVMCoreUI +// +// Created by Nadigadda, Sumanth on 24/03/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import UIKit + +enum RenderingModeError: Error { + case notAnRenderingMode +} + +extension UIImage.RenderingMode: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "alwaysOriginal": + self = .alwaysOriginal + case "alwaysTemplate": + self = .alwaysTemplate + case "automatic": + self = .automatic + default: + return nil + } + } + + var rawValueString: String { + switch self { + case .alwaysOriginal: + return "alwaysOriginal" + case .alwaysTemplate: + return "alwaysTemplate" + case .automatic: + return "automatic" + @unknown default: + return "" + } + } +} + +extension UIImage.RenderingMode: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let renderingMode = UIImage.RenderingMode(rawValue: string) else { + throw RenderingModeError.notAnRenderingMode + } + self = renderingMode + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift index 50676cbc..634a6f6b 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -12,16 +12,17 @@ // MARK: - Initializers //-------------------------------------------------- - public static func create(with image: UIImage?) -> Self { + public static func create(with image: UIImage?, renderingMode: UIImage.RenderingMode = .alwaysTemplate) -> Self { let actionObject = ActionDelegate() - let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock)) + let button = self.init(image: image?.withRenderingMode(renderingMode), style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock)) button.actionDelegate = actionObject return button } /// Creates the item with the passed in action. public static func create(with image: UIImage?, model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let button = create(with: image) + let imageModel = model as? NavigationImageButtonModel + let button = create(with: image, renderingMode: imageModel?.imageRenderingMode ?? .alwaysTemplate) button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index 8ba75d1a..64000dc9 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -5,6 +5,8 @@ // Created by Scott Pfeil on 5/18/20. // +import UIKit + public class NavigationImageButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- @@ -17,6 +19,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule public var image: String public var action: ActionModelProtocol public var accessibilityText: String? + public var imageRenderingMode: UIImage.RenderingMode? //-------------------------------------------------- // MARK: - Initializer @@ -37,6 +40,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule case accessibilityIdentifier case moleculeName case accessibilityText + case imageRenderingMode } //-------------------------------------------------- @@ -49,6 +53,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule image = try typeContainer.decode(String.self, forKey: .image) action = try typeContainer.decodeModel(codingKey: .action) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) + imageRenderingMode = try typeContainer.decodeIfPresent(UIImage.RenderingMode.self, forKey: .imageRenderingMode) } open func encode(to encoder: Encoder) throws { @@ -58,6 +63,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule try container.encode(moleculeName, forKey: .moleculeName) try container.encodeModel(action, forKey: .action) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) + try container.encodeIfPresent(imageRenderingMode, forKey: .imageRenderingMode) } //-------------------------------------------------- From ced4728ca0ecb133cd4b5d2a0daa3f47fe70b5a5 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 24 Mar 2022 18:59:40 -0400 Subject: [PATCH 029/102] move navigation bar setter to pre-animation for smoothness --- .../NavigationController.swift | 17 ++++++----------- ...MVMCoreUISplitViewController+Extension.swift | 2 +- .../SubNav/SubNavManagerController.swift | 9 +++++++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index 03c10595..644dee73 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -69,7 +69,6 @@ extension NavigationController: MVMCoreViewManagerProtocol { } public func newDataReceived(in viewController: UIViewController) { - if isDisplayed(viewController: viewController), let topViewController = topViewController, let model = getNavigationModel(from: viewController) { @@ -81,44 +80,40 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func willDisplay(_ viewController: UIViewController) { if let topViewController = topViewController, + isDisplayed(viewController: viewController), let model = getNavigationModel(from: viewController) { setNavigationItem(with: model, for: topViewController) + setNavigationBarUI(with: model) } manager?.willDisplay?(viewController) } public func displayedViewController(_ viewController: UIViewController) { - if isDisplayed(viewController: viewController), - let model = getNavigationModel(from: viewController) { - setNavigationBarUI(with: model) - } manager?.displayedViewController?(viewController) } } extension NavigationController: MVMCorePresentationDelegateProtocol { public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) { + if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { + MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) + } guard self == navigationController, let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), let model = getNavigationModel(from: newViewController) else { return } setNavigationItem(with: model, for: viewController) + setNavigationBarUI(with: model) } public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { guard self == navigationController, let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } - if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { - MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) - } 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) { - setNavigationBarUI(with: model) - } 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 76afeca8..d2ef03e6 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -153,7 +153,7 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { navigationController?.containsPage(withPageType: pageType) ?? false } - public func displayedViewController(_ viewController: UIViewController) { + public func willDisplay(_ viewController: UIViewController) { setupPanels() updateNavigationBarFor(viewController: viewController) } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index c3be1868..adf11109 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -121,6 +121,11 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, (viewController as? MVMCoreViewManagerViewControllerProtocol)?.managerWillDisappear?(self) } + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + hideNavigationBarLine(true) + } + /// Hides/Shows the navigation bar for the page. open func hideNavigationBarLine(_ isHidden: Bool) { guard self == navigationController?.topViewController else { return } @@ -228,6 +233,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } tabs.selectIndex(index, animated: true) self.index = nil + hideNavigationBarLine(true) } public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) { @@ -262,7 +268,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, if let viewController = getCurrentViewController() { manager?.displayedViewController?(viewController) } - hideNavigationBarLine(true) } // MARK: - TabsDelegate @@ -314,11 +319,11 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, public func willDisplay(_ viewController: UIViewController) { manager?.willDisplay?(viewController) + hideNavigationBarLine(true) } public func displayedViewController(_ viewController: UIViewController) { manager?.displayedViewController?(viewController) - hideNavigationBarLine(true) } // MARK: - MVMCoreUISwipeNavigationProtocol From 71a9b139d3e3486e5867a85d1f7aa5d65e71ec17 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 29 Mar 2022 18:58:15 +0530 Subject: [PATCH 030/102] Setting default status to Tab bar model. --- .../Molecules/HorizontalCombinationViews/TabBarModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index 95e07a34..3b62210c 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -52,7 +52,7 @@ open class TabBarModel: MoleculeModelProtocol { } } - open var style: NavigationItemStyle? + open var style: NavigationItemStyle? = .dark // Must be capped to 0...(tabs.count - 1) open var selectedTab: Int = 0 @@ -86,7 +86,9 @@ open class TabBarModel: MoleculeModelProtocol { if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedTab) { selectedTab = index } - style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) + if let navStyle = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) { + style = navStyle + } } open func encode(to encoder: Encoder) throws { From a223d26d5a8ca8d749ef0b9f32f9a0443620b98d Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Wed, 30 Mar 2022 19:15:04 +0530 Subject: [PATCH 031/102] changes to Carousel Bars Component --- .../CarouselIndicator/BarsIndicatorView.swift | 8 +++++++- .../CarouselIndicator/CarouselIndicator.swift | 15 ++++++++++++--- .../CarouselIndicatorModel.swift | 3 ++- MVMCoreUI/Categories/UIColor+Extension.swift | 9 +++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 381b8112..cecc1841 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -20,6 +20,8 @@ open class BarsIndicatorView: CarouselIndicator { static let width: CGFloat = 24 static let selectedHeight: CGFloat = 4 static let unselectedHeight: CGFloat = 1 + static let selectedCornerRadius: CGFloat = 2 + static let unselectedCornerRadius: CGFloat = 0.5 var constraint: NSLayoutConstraint? @@ -52,7 +54,7 @@ open class BarsIndicatorView: CarouselIndicator { stackView.axis = .horizontal stackView.alignment = .bottom stackView.distribution = .equalSpacing - stackView.spacing = 6 + stackView.spacing = 4 return stackView }() @@ -189,6 +191,7 @@ open class BarsIndicatorView: CarouselIndicator { let bar = IndicatorBar() setAccessibilityLabel(view: bar, index: index) bar.backgroundColor = isEnabled ? (index == currentIndex ? currentIndicatorColor : indicatorColor) : disabledIndicatorColor + bar.layer.cornerRadius = index == currentIndex ? BarsIndicatorView.IndicatorBar.selectedCornerRadius : BarsIndicatorView.IndicatorBar.unselectedCornerRadius let barHeight = index == currentIndex ? BarsIndicatorView.IndicatorBar.selectedHeight : BarsIndicatorView.IndicatorBar.unselectedHeight let heightConstraint = bar.heightAnchor.constraint(equalToConstant: barHeight) heightConstraint.isActive = true @@ -251,6 +254,7 @@ open class BarsIndicatorView: CarouselIndicator { barReferences.forEach { $0.backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor $0.constraint?.constant = IndicatorBar.unselectedHeight + $0.layer.cornerRadius = IndicatorBar.unselectedCornerRadius } balanceBarCount(numberOfPages - barReferences.count) @@ -260,8 +264,10 @@ open class BarsIndicatorView: CarouselIndicator { let expression = { [self] in barReferences[previousIndex].backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor barReferences[previousIndex].constraint?.constant = IndicatorBar.unselectedHeight + barReferences[previousIndex].layer.cornerRadius = IndicatorBar.unselectedCornerRadius barReferences[newIndex].backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor barReferences[newIndex].constraint?.constant = IndicatorBar.selectedHeight + barReferences[newIndex].layer.cornerRadius = IndicatorBar.selectedCornerRadius layoutIfNeeded() } diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 6a82ef80..01a14f7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -71,8 +71,17 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { } public var disabledIndicatorColor: UIColor { - get { carouselIndicatorModel?.disabledIndicatorColor.uiColor ?? .mvmCoolGray3 } - set { carouselIndicatorModel?.disabledIndicatorColor = Color(uiColor: newValue) } + get { + guard let model = carouselIndicatorModel else { return .mvmGray44 } + return model.inverted ? model.disabledIndicatorColor_inverted.uiColor : model.disabledIndicatorColor.uiColor + } + set { + if let model = carouselIndicatorModel, model.inverted { + model.disabledIndicatorColor_inverted = Color(uiColor: newValue) + } else { + carouselIndicatorModel?.disabledIndicatorColor = Color(uiColor: newValue) + } + } } public var indicatorColor: UIColor { @@ -202,7 +211,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { previousIndex = 0 indicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor - disabledIndicatorColor = model.disabledIndicatorColor.uiColor + disabledIndicatorColor = model.inverted ? model.disabledIndicatorColor_inverted.uiColor : model.disabledIndicatorColor.uiColor currentIndex = model.currentIndex isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index 9b211857..a3c7c14b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -30,7 +30,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro /// Set true to make the accessibility value as "Slide #currentPage of #totalPage", otherwise will be "Page #currentPage of #totalPage", default is false public var accessibilityHasSlidesInsteadOfPage: Bool = false public var enabled: Bool = true - public var disabledIndicatorColor: Color = Color(uiColor: .mvmCoolGray3) + public var disabledIndicatorColor: Color = Color(uiColor: .mvmGray44) + public var disabledIndicatorColor_inverted: Color = Color(uiColor: .mvmGray65) public var indicatorColor: Color = Color(uiColor: .mvmBlack) public var indicatorColor_inverted: Color = Color(uiColor: .mvmWhite) public var position: CGFloat? diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 78363630..3c4c11ba 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,6 +52,8 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), + "gray44": (.mvmGray44, "#6F7171"), + "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -197,6 +199,13 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") + /// HEX: #6F7171 + public static let mvmGray44 = UIColor.assetColor(named: "gray44") + + /// HEX: #A7A7A7 + public static let mvmGray65 = UIColor.assetColor(named: "gray65") + + //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- From 2a17e95a60287433394d02d47b67f10f372af289 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 31 Mar 2022 12:56:13 -0400 Subject: [PATCH 032/102] rounded --- .../Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 381b8112..3995a3f7 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -38,6 +38,7 @@ open class BarsIndicatorView: CarouselIndicator { override func setupView() { super.setupView() isAccessibilityElement = true + layer.cornerRadius = 2 accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint") widthAnchor.constraint(equalToConstant: BarsIndicatorView.IndicatorBar.width).isActive = true accessibilityTraits = .button From 1beb6584b7f3033fb6badfe10919a3d0c10fb9f8 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 2 Apr 2022 00:59:51 +0530 Subject: [PATCH 033/102] Method to check style of current navigation bar. --- MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index aa54760a..ffb74ef9 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -56,4 +56,13 @@ public extension MVMCoreUIUtility { return findViews(by: type, views: queue) + matching } + + static func visibleNavigationBarStlye() -> NavigationItemStyle? { + if let vc = MVMCoreUIUtility.getCurrentVisibleController(), + let navController = NavigationController.navigationController(), + let navigationBar = navController.getNavigationModel(from: vc) as? NavigationItemModel { + return navigationBar.style + } + return nil + } } From 18f9449e425176986b9d705b6dad9251855fcd14 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sun, 3 Apr 2022 00:47:52 +0530 Subject: [PATCH 034/102] Modifying line component as part of VDS for brand 3.0 --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 8 ++++---- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 14 +++++++------- .../HeadersAndFooters/MoleculeSectionHeader.swift | 4 ++-- .../MoleculeSectionHeaderModel.swift | 2 +- .../NavigationBar/NavigationItemModel.swift | 2 +- MVMCoreUI/BaseClasses/TableViewCell.swift | 10 +++++----- .../Managers/SubNav/SubNavManagerController.swift | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 76016292..d4c4d26d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -48,17 +48,17 @@ import UIKit public init() { super.init(frame: .zero) - model = LineModel(type: .standard) + model = LineModel(type: .secondary) } public override init(frame: CGRect) { super.init(frame: frame) - model = LineModel(type: .standard) + model = LineModel(type: .secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) - model = LineModel(type: .standard) + model = LineModel(type: .secondary) } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { @@ -106,7 +106,7 @@ import UIKit } open override func reset() { - setStyle(.standard) + setStyle(.secondary) } public override static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index f463c0f9..b5b562eb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -30,15 +30,15 @@ import VDSColorTokens /** The style of the line: - - standard (1 height, silver) - - thin (1 height, black) + - secondary (1 height, silver) + - primary (1 height, black) - medium (2 height, black) - heavy (4 height, black) - none (hidden) */ public enum Style: String, Codable { - case standard - case thin + case secondary + case primary case medium case heavy case none @@ -49,7 +49,7 @@ import VDSColorTokens //-------------------------------------------------- public static var identifier: String = "line" - public var type: Style = .standard + public var type: Style = .secondary public var frequency: Frequency? = .allExceptTop //TODO: use color insted of backgroundColor. Needs server changes @@ -59,10 +59,10 @@ import VDSColorTokens get { if let backgroundColor = _backgroundColor { return backgroundColor } if inverted { - if type == .standard { return Color(uiColor: VDSColor.interactiveDisabledOndark) } + if type == .secondary { return Color(uiColor: VDSColor.paletteGray20) } return Color(uiColor: VDSColor.elementsPrimaryOndark) } - if type == .standard { return Color(uiColor: VDSColor.interactiveDisabledOnlight) } + if type == .secondary { return Color(uiColor: VDSColor.paletteGray85) } return Color(uiColor: VDSColor.elementsPrimaryOnlight) } set { diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeader.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeader.swift index ee80ca46..27bee7b3 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeader.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeader.swift @@ -22,7 +22,7 @@ import Foundation public override func setupView() { super.setupView() - line.setStyle(.thin) + line.setStyle(.primary) contentView.addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true @@ -51,7 +51,7 @@ import Foundation open override func reset() { super.reset() - line.setStyle(.thin) + line.setStyle(.primary) molecule?.reset() } diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift index 18360b30..47db5cbf 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift @@ -42,7 +42,7 @@ bottomPadding = PaddingDefaultVerticalSpacing3 } if line == nil { - line = LineModel(type: .thin) + line = LineModel(type: .primary) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index c2e1ccc6..523f6ea1 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -24,7 +24,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var title: String? open var hidden = false - open var line: LineModel? = LineModel(type: .standard) + open var line: LineModel? = LineModel(type: .secondary) open var hidesSystemBackButton = true open var style: NavigationItemStyle? diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index d0bb9c7e..551f7572 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -42,13 +42,13 @@ import UIKit switch style { case .standard?: topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.standard) + bottomSeparatorView?.setStyle(.secondary) case .shortDivider?: topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.thin) + bottomSeparatorView?.setStyle(.primary) case .tallDivider?: topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.thin) + bottomSeparatorView?.setStyle(.primary) case .sectionFooter?: topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.none) @@ -244,8 +244,8 @@ import UIKit topSeparatorView?.set(with: model, delegateObject, additionalData) bottomSeparatorView?.set(with: model, delegateObject, additionalData) } else { - topSeparatorView?.setStyle(.standard) - bottomSeparatorView?.setStyle(.standard) + topSeparatorView?.setStyle(.secondary) + bottomSeparatorView?.setStyle(.secondary) } setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath) } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index d594dead..b3a142ba 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -34,7 +34,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, }() public lazy var line: Line = { - return Line(model: LineModel(type: .standard), delegateObjectIVar, nil) + return Line(model: LineModel(type: .secondary), delegateObjectIVar, nil) }() public lazy var subNavigationController: UINavigationController = { From 0c54273066624b53de1c55a13e85ff765b2c5800 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sun, 3 Apr 2022 01:10:16 +0530 Subject: [PATCH 035/102] Setting default image rendering mode to automatic in image bar button --- .../Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift index 634a6f6b..5fa7c195 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -12,7 +12,7 @@ // MARK: - Initializers //-------------------------------------------------- - public static func create(with image: UIImage?, renderingMode: UIImage.RenderingMode = .alwaysTemplate) -> Self { + public static func create(with image: UIImage?, renderingMode: UIImage.RenderingMode = .automatic) -> Self { let actionObject = ActionDelegate() let button = self.init(image: image?.withRenderingMode(renderingMode), style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock)) button.actionDelegate = actionObject From d10332b372be19e115739c2b0a619992483aee58 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 4 Apr 2022 22:24:50 +0530 Subject: [PATCH 036/102] modifying image rendering changes in navigation bar --- .../NavigationBar/Buttons/ImageBarButtonItem.swift | 7 +++---- .../Buttons/NavigationImageButtonModel.swift | 8 +++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift index 5fa7c195..50676cbc 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/ImageBarButtonItem.swift @@ -12,17 +12,16 @@ // MARK: - Initializers //-------------------------------------------------- - public static func create(with image: UIImage?, renderingMode: UIImage.RenderingMode = .automatic) -> Self { + public static func create(with image: UIImage?) -> Self { let actionObject = ActionDelegate() - let button = self.init(image: image?.withRenderingMode(renderingMode), style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock)) + let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock)) button.actionDelegate = actionObject return button } /// Creates the item with the passed in action. public static func create(with image: UIImage?, model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Self { - let imageModel = model as? NavigationImageButtonModel - let button = create(with: image, renderingMode: imageModel?.imageRenderingMode ?? .alwaysTemplate) + let button = create(with: image) button.set(with: model, delegateObject: delegateObject, additionalData: additionalData) return button } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift index 64000dc9..f0b0bbc0 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/Buttons/NavigationImageButtonModel.swift @@ -19,7 +19,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule public var image: String public var action: ActionModelProtocol public var accessibilityText: String? - public var imageRenderingMode: UIImage.RenderingMode? + public var imageRenderingMode: UIImage.RenderingMode = .automatic //-------------------------------------------------- // MARK: - Initializer @@ -53,7 +53,9 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule image = try typeContainer.decode(String.self, forKey: .image) action = try typeContainer.decodeModel(codingKey: .action) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - imageRenderingMode = try typeContainer.decodeIfPresent(UIImage.RenderingMode.self, forKey: .imageRenderingMode) + if let mode = try typeContainer.decodeIfPresent(UIImage.RenderingMode.self, forKey: .imageRenderingMode) { + imageRenderingMode = mode + } } open func encode(to encoder: Encoder) throws { @@ -72,7 +74,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule /// Convenience function that creates a BarButtonItem for the model. public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem { - let uiImage = MVMCoreCache.shared()?.getImageFromRegisteredBundles(image) + let uiImage = MVMCoreCache.shared()?.getImageFromRegisteredBundles(image)?.withRenderingMode(imageRenderingMode) let buttonItem = ImageBarButtonItem.create(with: uiImage, model: self, delegateObject: delegateObject, additionalData: additionalData) buttonItem.accessibilityIdentifier = accessibilityIdentifier ?? image if let accessibilityString = accessibilityText { From 7840cb674f2faf0c044f79428f4afe150a92462f Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 5 Apr 2022 01:59:55 +0530 Subject: [PATCH 037/102] Adding new back button image for navigation bar --- .../Media.xcassets/nav_back.imageset/Back-1.png | Bin 636 -> 0 bytes .../Media.xcassets/nav_back.imageset/Back-2.png | Bin 906 -> 0 bytes .../Media.xcassets/nav_back.imageset/Back.png | Bin 366 -> 0 bytes .../nav_back.imageset/Contents.json | 12 ++++++------ .../Media.xcassets/nav_back.imageset/nav_back.png | Bin 0 -> 220 bytes .../nav_back.imageset/nav_back@2x.png | Bin 0 -> 302 bytes .../nav_back.imageset/nav_back@3x.png | Bin 0 -> 394 bytes 7 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-1.png delete mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-2.png delete mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back.png create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back.png create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@2x.png create mode 100644 MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@3x.png diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-1.png b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-1.png deleted file mode 100644 index 3fae0595ffb9eb65dc865fdc3f8c1d716ca794e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 636 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC#^NA%Cx&(BWL^R}E~ycoX}-P; zT0k}j17mw80}DtA5K93u0|WB{Mh0de%?J`(zyy~ySip>6gB0F2&*1?od*kA+Bp9tg-bQN(tvG2e{9<}EckK%V6$bK?0N>~0&=h|sr-j%f# zSB;NZ8=nhJU7U6BhStKGH0G5>T{8K)3-Z6T?waT$StBP|bE%JO@4? z1L7ZhH9n`#jd$7i`S}mEDL;*Vus(UH|550}wYxhR>Ra=-NpqPpFM0pR6sX$j!2L(j z6I^^9Us~6<=TB8&FEToCU;Cgx%MbS&=}9XLHU4g?Jha_=0<)#igZWb*v@`wT-pA~D zg<(qFtvwH|RZld&;r{Ucho0z6iD-Efd$*3H|t)AMBC#Z}~g^Hi7kB zifzsuE9)0$s<;7Z{Y@fCHZ2?6IcGj!AfjY<##W9TXJYiDgBcS5T2#-2avi#n!rZ64^pUJuggLar+3HYR-XJ;EIr%L_GPQrdVA~ZN0)ty(QgCAyr-+5%Q~lo FCID&k1FHZ4 diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-2.png b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Back-2.png deleted file mode 100644 index 48ad21763e95d2cb5187c0ef17aa1bb90918901e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 906 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(<^v49!D1}U6i==Pq0f$58#6uo^_3F;jbqOAehybx4_*0AX-@wuxn;X{tzM;-{o2LKxWgxPY3RJ1Z;y}varonA z<8npm(l_@7%umZ*4s4v^wwFzD|5oP*`Ewe+2ygU`RcCLoZ0VKKW^6cCMv7x`LB9xVrfzP%EFrA1FK-a#Om*>ALpK-qL#hI@i@fG#NI zJ2%7XTol6|*Bhm3ditv$n=m}!J-BmG-)1R>^_=HIOXpNE>`}6~ex)$X(&GBn!Z4-> zs!IC=qW>
  • *JZN5NwI)xv4a4=fMvT-~>shv7WOxgA#Lf*5R6ExunZe8upg<$+DW z@kpkI<1Fbxvgw8la*A&rTk9>q5ZC)7f4ghyud|X)2fUC#&L3-&y=!QdSusmJjA%mNf^<-*oxOX)MiouV%}iDXSIN zI;#5Kn$4zpIai)Z*nGKk`$o2v)!XOkPqZsKoA{9_`lg}Maz`P)>}H8ete4!^RVo{$ zaj!UcGIK)9UeyZcCH*nQ5l2pj?U*<5vI1v*=>$KJzI#re7%h1x6;y~c+Aa@NsC_c) z@MJrlmGOSfDtCImDJku{p7u2kXxPo_1@Btsuz6OP-@2(h^SGz{&SzpNHr*S7&z$-a zkZ&RqCA*}iWKKyb|EBc(SPLaxVb%Gn9uJqQwJ&a}8r#l9xGCxUy>>@?DE?toj@_o|`zD>^VRH18GV=+3A6h!~ZcnlL zro1O1tNYSBsY{GbKYXU=dWrs)yJxW7HM5*GlU+XI)h1ufWPin$^*MpJVx4Xs62CT~ zTBOKYSt3?`;u`(mlf;#d&5N}Uj$HG)U(GjWJ6GnTT{k_2ufL6&wL{M0l1g<7pG%Kz iIcJIWm(-2*>viq_uGRltP}O4s@~fw-pUXO@geCwLQ+o9P diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Contents.json b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Contents.json index 753f15c2..56ae55a3 100644 --- a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Contents.json +++ b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/Contents.json @@ -1,23 +1,23 @@ { "images" : [ { + "filename" : "nav_back.png", "idiom" : "universal", - "filename" : "Back.png", "scale" : "1x" }, { + "filename" : "nav_back@2x.png", "idiom" : "universal", - "filename" : "Back-1.png", "scale" : "2x" }, { + "filename" : "nav_back@3x.png", "idiom" : "universal", - "filename" : "Back-2.png", "scale" : "3x" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back.png b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back.png new file mode 100644 index 0000000000000000000000000000000000000000..895fade7109e9e7ea5b937adaa25e3a8111788aa GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GG!XV7ZFl!D-1!HlL zyA#8@b22Z19F}xPUq=Rpjs4tz5?O)#LQfaRkP61PQ}1#%81S^5pKp7W_s)SmJHzfC z@im!b!`T$NPUJ27^&pP&Eha2Kq$hW$?OVyhGHJ$lg@7~m32}4JxNcp=bkA7EyH?Q6 zIl=!*W5<*UInHi23w8zyC&X8L`^+T7wA=HFOSW>>(eEm}Gx@D;FDkRIS9!t+w4A}y L)z4*}Q$iB}lgCHV literal 0 HcmV?d00001 diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@2x.png b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e699cb47470c1e6084ce5374ae7d6d3f49ed5612 GIT binary patch literal 302 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?2=RS;(M3{v?36l5$8 za(7}_cTVOdki(Mh=%-{4AGgf7Ut8`G{k`18yk^Hgs|7Zn<zopr0GEVw6#xJL literal 0 HcmV?d00001 diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@3x.png b/MVMCoreUI/SupportingFiles/Media.xcassets/nav_back.imageset/nav_back@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..96e839ed04085187d59f599dc2a822c227b6b3b7 GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!oCO|{#S9FJ79h;%I?XTvD9BhG zE))=%ok5&U^q~kv+SntXN@y&9@qGMHa$DL zqvV;ZeWKs6>I+R;F_-=cgn6=`%!pz zM7Mp!6{R5jC`2g;1xdL-lK9Yh$wr9%WWA=KrWP7HtNgabI7a6KdyFq5!-1 Date: Tue, 5 Apr 2022 14:20:22 +0530 Subject: [PATCH 038/102] made changes to textlink as per core specs. --- .../Atomic/Atoms/Buttons/Link/Link.swift | 7 ++++--- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 17 +++++++++++++++- MVMCoreUI/Categories/UIColor+Extension.swift | 8 ++++++++ .../Categories/colors.xcassets/Contents.json | 6 +++--- .../gray44.colorset/Contents.json | 20 +++++++++++++++++++ .../gray65.colorset/Contents.json | 20 +++++++++++++++++++ 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 8e528deb..553b36d2 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -28,8 +28,8 @@ import UIKit // x should be according to the text, not the button let x = textRect.origin.x - // Line is 1 point below the text - let y = textRect.origin.y + textRect.size.height + 1 + // Line is 0 point below the text + let y = textRect.origin.y + textRect.size.height + 0 context.move(to: CGPoint(x: x, y: y)) context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) @@ -56,6 +56,7 @@ import UIKit } setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal) setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) + setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -82,7 +83,7 @@ extension Link { backgroundColor = .clear contentMode = .redraw setTitleColor(.mvmBlack, for: .normal) - setTitleColor(.mvmCoolGray6, for: .disabled) + setTitleColor(.mvmCoolGray3, for: .disabled) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 955601ac..adfce57c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -24,8 +24,11 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabled = true public var enabledColor = Color(uiColor: .mvmBlack) public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: .mvmCoolGray6) + public var disabledColor = Color(uiColor: .mvmCoolGray3) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) + public var activeColor = Color(uiColor: .mvmGray44) + public var activeColor_inverted = Color(uiColor: .mvmGray65) + public var inverted = false //-------------------------------------------------- @@ -53,6 +56,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case enabledColor_inverted case disabledColor case disabledColor_inverted + case activeColor + case activeColor_inverted case inverted } @@ -92,6 +97,14 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) { self.disabledColor_inverted = disabledColor_inverted } + + if let activeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor) { + self.activeColor = activeColor + } + + if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { + self.activeColor_inverted = activeColor_inverted + } } public func encode(to encoder: Encoder) throws { @@ -107,5 +120,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted) try container.encode(disabledColor, forKey: .disabledColor) try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) + try container.encode(activeColor, forKey: .activeColor) + try container.encode(activeColor_inverted, forKey: .activeColor_inverted) } } diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 78363630..4bc84c87 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,6 +52,8 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), + "gray44": (.mvmGray44, "#6F7171"), + "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -197,6 +199,12 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") + /// HEX: #6F7171 + public static let mvmGray44 = UIColor.assetColor(named: "gray44") + + /// HEX: #A7A7A7 + public static let mvmGray65 = UIColor.assetColor(named: "gray65") + //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Categories/colors.xcassets/Contents.json b/MVMCoreUI/Categories/colors.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/MVMCoreUI/Categories/colors.xcassets/Contents.json +++ b/MVMCoreUI/Categories/colors.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json new file mode 100644 index 00000000..296ef27c --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x71", + "green" : "0x71", + "red" : "0x6F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json new file mode 100644 index 00000000..aefc9ce0 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xA7", + "green" : "0xA7", + "red" : "0xA7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} From b88a006c00641626b46d7febf06d69bddba1ee53 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 5 Apr 2022 20:40:10 +0530 Subject: [PATCH 039/102] removed unnecessary value of y --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 553b36d2..54751274 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -29,7 +29,7 @@ import UIKit let x = textRect.origin.x // Line is 0 point below the text - let y = textRect.origin.y + textRect.size.height + 0 + let y = textRect.origin.y + textRect.size.height context.move(to: CGPoint(x: x, y: y)) context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) From 3a31acfe63c71391ac7df8d8fa4c63f68b174ae1 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 5 Apr 2022 20:54:56 +0530 Subject: [PATCH 040/102] adding color sets --- .../Categories/colors.xcassets/Contents.json | 6 +++--- .../gray44.colorset/Contents.json | 20 +++++++++++++++++++ .../gray65.colorset/Contents.json | 20 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Categories/colors.xcassets/Contents.json b/MVMCoreUI/Categories/colors.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/MVMCoreUI/Categories/colors.xcassets/Contents.json +++ b/MVMCoreUI/Categories/colors.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json new file mode 100644 index 00000000..296ef27c --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x71", + "green" : "0x71", + "red" : "0x6F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json new file mode 100644 index 00000000..aefc9ce0 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xA7", + "green" : "0xA7", + "red" : "0xA7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} From e8b01bee544e37b15ed26daa715af933832ffce0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 5 Apr 2022 21:55:45 +0530 Subject: [PATCH 041/102] Changing bottom tab bar font size. --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index dbea90d7..e7096069 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -58,11 +58,11 @@ import VDSColorTokens /// Sets the item colors. private func set(tabItemAppearance: UITabBarItemAppearance, model: TabBarModel) { tabItemAppearance.normal.iconColor = model.unSelectedColor.uiColor - tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(8)] + tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] tabItemAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) tabItemAppearance.selected.iconColor = model.selectedColor.uiColor - tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(8)] + tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] tabItemAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) } From 7d027341cb21f9cc1ec7165f47a4d3c636f313a8 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 7 Apr 2022 01:24:38 +0530 Subject: [PATCH 042/102] updating the accessory view from cart view to pealing arrow. --- MVMCoreUI/BaseClasses/TableViewCell.swift | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 551f7572..a80969ba 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -19,7 +19,7 @@ import UIKit public let containerHelper = ContainerHelper() // For the accessory view convenience. - private var caretView: CaretView? + private var caretView: UIImageView? private var caretViewWidthSizeObject: MFSizeObject? private var caretViewHeightSizeObject: MFSizeObject? @@ -185,20 +185,22 @@ import UIKit @objc public func addCaretViewAccessory() { guard accessoryView == nil else { return } + + let peakingImageView = UIImageView(image: MVMCoreUIUtility.imageNamed("peakingRightArrow")?.withRenderingMode(.alwaysTemplate)) - let caret = CaretView(lineWidth: 1) - caret.translatesAutoresizingMaskIntoConstraints = true - caret.isAccessibilityElement = true - caret.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint") - caret.accessibilityTraits = .button - caret.size = .small(.vertical) - if let size = caret.size?.dimensions() { - caret.frame = CGRect(origin: .zero, size: size) - caretViewWidthSizeObject = MFSizeObject(standardSize: size.width, standardiPadPortraitSize: 9) - caretViewHeightSizeObject = MFSizeObject(standardSize: size.height, standardiPadPortraitSize: 16) - } - caretView = caret - accessoryView = caret + peakingImageView.translatesAutoresizingMaskIntoConstraints = true + peakingImageView.alpha = 0 + peakingImageView.tintColor = .black + peakingImageView.isAccessibilityElement = true + peakingImageView.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint") + peakingImageView.accessibilityTraits = .button + let accessorySize = CGRect(origin: .zero, size: CGSize(width: 13.3, height: 13.3)) + peakingImageView.frame = accessorySize + caretViewWidthSizeObject = MFSizeObject(standardSize: accessorySize.width, standardiPadPortraitSize: 16.6) + caretViewHeightSizeObject = MFSizeObject(standardSize: accessorySize.height, standardiPadPortraitSize: 16.6) + caretView = peakingImageView + + accessoryView = peakingImageView } /// NOTE: Should only be called when displayed or about to be displayed. From c691b6add612d3e3ebb095293e67f4a6feebea7d Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 7 Apr 2022 23:33:55 +0530 Subject: [PATCH 043/102] Changes to swap store buttons with shop cart button in navigation bar --- .../MVMCoreUISplitViewController+Extension.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index d2ef03e6..12935302 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -90,6 +90,11 @@ public extension MVMCoreUISplitViewController { rightItems.append(panelButton) } + // Add any buttons added by the splitview. + if let additionalRightButtons = additionalRightButtons(for: viewController) { + rightItems.append(contentsOf: additionalRightButtons) + } + // Add other model buttons if let rightItemModels = navigationItemModel?.additionalRightButtons { for item in rightItemModels { @@ -97,11 +102,6 @@ public extension MVMCoreUISplitViewController { } } - // Add any buttons added by the splitview. - if let additionalRightButtons = additionalRightButtons(for: viewController) { - rightItems.append(contentsOf: additionalRightButtons) - } - topViewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue) } From def2e8ae7c2d3c822cfa9eab1440bacae4eff941 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 9 Apr 2022 02:37:31 +0530 Subject: [PATCH 044/102] Adding new component - title lockup --- MVMCoreUI.xcodeproj/project.pbxproj | 8 + .../EyebrowHeadlineBody.swift | 159 +++++++++++++++++ .../EyebrowHeadlineBodyModel.swift | 167 ++++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 4 files changed, 335 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift create mode 100644 MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1c042443..407051bd 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -146,6 +146,8 @@ 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */; }; + 4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */; }; + 4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; @@ -734,6 +736,8 @@ 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = ""; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = ""; }; 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageRenderingMode+Extension.swift"; sourceTree = ""; }; + 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyModel.swift; sourceTree = ""; }; + 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBody.swift; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = ""; }; @@ -1637,6 +1641,8 @@ EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */, 0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */, 0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */, + 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */, + 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -2731,6 +2737,7 @@ D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */, + 4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */, BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, D2ED2800254B0E0300A1C293 /* MVMCoreAlertHandler+Extension.swift in Sources */, D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */, @@ -2923,6 +2930,7 @@ 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, + 4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */, AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */, AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift new file mode 100644 index 00000000..7e9c5dc0 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift @@ -0,0 +1,159 @@ +// +// EyebrowHeadlineBody.swift +// MVMCoreUI +// +// Created by Nadigadda, Sumanth on 08/04/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +@objcMembers open class EyebrowHeadlineBody: View { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + + public let stack = Stack(frame: .zero) + public let eyebrow = Label(fontStyle: .RegularBodySmall) + public let headline = Label(fontStyle: .RegularBodySmall) + public let body = Label(fontStyle: .RegularBodySmall) + + var castModel: EyebrowHeadlineBodyModel? { + get { return model as? EyebrowHeadlineBodyModel } + } + + //-------------------------------------------------- + // MARK: - Initialization + //-------------------------------------------------- + + public convenience init(spacing: CGFloat) { + self.init(frame: .zero) + stack.stackModel?.spacing = spacing + stack.restack() + } + + //-------------------------------------------------- + // MARK: - MFViewProtocol + //-------------------------------------------------- + + open override func setupView() { + super.setupView() + stack.setAndCreateModel(with: [eyebrow, headline, body]) + stack.stackModel?.spacing = 0 + addSubview(stack) + NSLayoutConstraint.constraintPinSubview(toSuperview: stack) + stack.restack() + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? EyebrowHeadlineBodyModel.Style.large.defaultSpacing() + stack.updateView(size) + } + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + + open override func reset() { + super.reset() + stack.reset() + eyebrow.setFontStyle(.RegularBodySmall) + headline.setFontStyle(.RegularBodySmall) + body.setFontStyle(.RegularBodySmall) + } + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + setStyle(style: castModel?.style) + + ///Updating the text color + castModel?.eyebrow?.textColor = castModel?.headlineColor + castModel?.headline.textColor = castModel?.headlineColor + castModel?.body?.textColor = castModel?.bodyColor + + if let alignment = castModel?.alignment, let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) { + castModel?.eyebrow?.textAlignment = textAlignment + castModel?.headline.textAlignment = textAlignment + castModel?.body?.textAlignment = textAlignment + } + + stack.updateContainedMolecules(with: [castModel?.eyebrow, + castModel?.headline, + castModel?.body], + delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 65 + } + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func setStyle(style: EyebrowHeadlineBodyModel.Style? = .large) { + + ///If eyebrow style is not available, will set font style based on the component + ///Eyebrow and body share the same font size + if castModel?.eyebrow?.fontStyle == nil { + castModel?.eyebrow?.fontStyle = style?.defaultBodyFontStyle() + } + + ///If headline style is not available, will set font style based on the component + if castModel?.headline.fontStyle == nil { + castModel?.headline.fontStyle = style?.defaultHeadlineFontStyle() + } + + ///If body style is not available, will set font style based on the component + if castModel?.body?.fontStyle == nil { + castModel?.body?.fontStyle = style?.defaultBodyFontStyle() + } + } + + //-------------------------------------------------- + // MARK: - Accessibility Helpers + //-------------------------------------------------- + + /// Returns the labels text in one message. + func getAccessibilityMessage() -> String? { + + var message = "" + + if let eyebrowLabel = eyebrow.text { + message += eyebrowLabel + ", " + } + + if let headlineLabel = headline.text { + message += headlineLabel + ", " + } + + if let bodyLabel = body.text { + message += bodyLabel + } + + return message.count > 0 ? message : nil + } + + /// Returns an array of the appropriate accessibility elements. + func getAccessibilityElements() -> [Any]? { + + var elements: [UIView] = [] + + if eyebrow.hasText { + elements.append(eyebrow) + } + + if headline.hasText { + elements.append(headline) + } + + if body.hasText { + elements.append(body) + } + + return elements.count > 0 ? elements : nil + } +} diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift new file mode 100644 index 00000000..97b37637 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift @@ -0,0 +1,167 @@ +// +// EyebrowHeadlineBodyModel.swift +// MVMCoreUI +// +// Created by Nadigadda, Sumanth on 08/04/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import VDSColorTokens + +public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "eyebrowHeadlineBody" + public var moleculeName: String = EyebrowHeadlineBodyModel.identifier + + public var eyebrow: LabelModel? + public var headline: LabelModel + public var body: LabelModel? + + public var style: Style = .large + public var alignment: Alignment = .left + public var inverted: Bool = false + + private var _backgroundColor: Color? + public var backgroundColor: Color? { + get { + return inverted ? Color(uiColor: VDSColor.backgroundPrimaryDark) : Color(uiColor: VDSColor.backgroundPrimaryLight) + } + set { + _backgroundColor = newValue + } + } + + public var headlineColor: Color? { + return inverted ? Color(uiColor: VDSColor.elementsPrimaryOndark) : Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + + public var bodyColor: Color? { + return inverted ? Color(uiColor: VDSColor.elementsSecondaryOndark) : Color(uiColor: VDSColor.elementsSecondaryOnlight) + } + + public var children: [MoleculeModelProtocol] { + [eyebrow, headline, body].compactMap { (molecule: MoleculeModelProtocol?) in molecule } + } + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(eyebrow: LabelModel? = nil, headline: LabelModel, body: LabelModel? = nil) throws { + + self.eyebrow = eyebrow + self.headline = headline + self.body = body + } + + //-------------------------------------------------- + // MARK: - Enum + //-------------------------------------------------- + + /// Convenience styles for common situations. + public enum Style: String, Codable { + case small + case medium + case large + case xlarge + case xxlarge + + func defaultHeadlineFontStyle() -> Styler.Font { + + switch self { + case .small: + return .BoldBodyLarge + case .medium: + return .BoldTitleMedium + case .large: + return .BoldTitleLarge + case .xlarge: + return .TitleXLarge + case .xxlarge: + return .Title2XLarge + } + } + + func defaultBodyFontStyle() -> Styler.Font { + + switch self { + case .small,.medium,.large: + return .RegularBodySmall + case .xlarge,.xxlarge: + return .RegularBodyLarge + } + } + + func defaultSpacing() -> CGFloat { + + switch self { + case .small,.medium,.large: + return Padding.One + case .xlarge: + return Padding.Three + case .xxlarge: + return Padding.Four + } + } + } + + public enum Alignment: String, Codable { + case left + case center + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case eyebrow + case headline + case body + case inverted + case alignment + case style + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) + headline = try typeContainer.decodeMolecule(codingKey: .headline) + body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body) + + if let style = try typeContainer.decodeIfPresent(Style.self, forKey: .style) { + self.style = style + } + + if let alignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) { + self.alignment = alignment + } + + if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + self.inverted = inverted + } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(eyebrow, forKey: .eyebrow) + try container.encodeModelIfPresent(headline, forKey: .headline) + try container.encodeIfPresent(body, forKey: .body) + try container.encodeIfPresent(style, forKey: .style) + try container.encode(alignment, forKey: .alignment) + try container.encode(inverted, forKey: .inverted) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) + } +} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 2a7c9d90..5527813b 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -87,6 +87,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self) + ModelRegistry.register(handler: EyebrowHeadlineBody.self, for: EyebrowHeadlineBodyModel.self) // MARK:- Left Right Molecules ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) From e0a93cc71f228e317bde1dca8fb9ec47116568a3 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 11 Apr 2022 00:18:55 +0530 Subject: [PATCH 045/102] Adding width attribute to button, to set custom button size. --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 7 +++++ .../Atomic/Atoms/Buttons/PillButton.swift | 27 +++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 3b72d37c..8b3da748 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -23,6 +23,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var title: String public var action: ActionModelProtocol public var enabled: Bool = true + public var width: CGFloat? public var style: Styler.Button.Style? { didSet { guard let style = style else { return } @@ -183,6 +184,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat case disabledFillColor case disabledTextColor case disabledBorderColor + case width } //-------------------------------------------------- @@ -242,6 +244,10 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if let disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor) { self.disabledBorderColor = disabledBorderColor } + + if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { + self.width = width + } } open func encode(to encoder: Encoder) throws { @@ -263,5 +269,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(size, forKey: .size) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(width, forKey: .width) } } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e7d0aacc..4722e3fc 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -138,7 +138,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } - private func getContentEdgeInsets() -> UIEdgeInsets { + private func getTitleEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 switch buttonSize { @@ -196,16 +196,21 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } open override var intrinsicContentSize: CGSize { - if buttonSize == .tiny { - let size = super.intrinsicContentSize - let width = size.width + (2 * getInnerPadding()) - return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) - } else if buttonSize == .small { - let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + + if let buttonWidth = buttonModel?.width { + return CGSize(width: buttonWidth, height: getHeight()) } else { - let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + if buttonSize == .tiny { + let size = super.intrinsicContentSize + let width = size.width + (2 * getInnerPadding()) + return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) + } else if buttonSize == .small { + let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + } else { + let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + } } } @@ -256,7 +261,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() - titleEdgeInsets = getContentEdgeInsets() + titleEdgeInsets = getTitleEdgeInsets() } open override func setupView() { From b2a25f840a46f46a90f26a2ca537f01f7b7b5e02 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 11 Apr 2022 01:49:50 +0530 Subject: [PATCH 046/102] Adding pill button's inverted state logic --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 56 ++++++++++++------- .../Atomic/Atoms/Buttons/PillButton.swift | 2 +- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 8b3da748..30b5b496 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -7,6 +7,7 @@ // import UIKit +import VDSColorTokens public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) @@ -17,7 +18,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat //-------------------------------------------------- //Making static property as class property so that subclasses can override getter function of the property open class var identifier: String { "button" } - public var backgroundColor: Color? public var accessibilityIdentifier: String? public var accessibilityText: String? public var title: String @@ -58,6 +58,22 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var disabledTextColor_inverted: Color? public var disabledBorderColor_inverted: Color? + private var _backgroundColor: Color? + public var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if inverted { + if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOndark) + } + if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOnlight) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _backgroundColor = newValue + } + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -117,38 +133,39 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat func setPrimaryFacade() { if enabledFillColor == nil && enabledTextColor == nil { - enabledFillColor = Color(uiColor: .mvmBlack) - enabledTextColor = Color(uiColor: .mvmWhite) + enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) } if disabledFillColor == nil && disabledTextColor == nil { - disabledFillColor = Color(uiColor: .mvmCoolGray6) - disabledTextColor = Color(uiColor: .mvmWhite) + disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) } - enabledFillColor_inverted = Color(uiColor: .mvmWhite) - enabledTextColor_inverted = Color(uiColor: .mvmBlack) - disabledFillColor_inverted = Color(uiColor: .mvmCoolGray6) - disabledTextColor_inverted = Color(uiColor: .mvmBlack) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledFillColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + disabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) } /// Defines the default appearance for the Secondary style. func setSecondaryFacade() { if enabledTextColor == nil && enabledBorderColor == nil { - enabledTextColor = Color(uiColor: .mvmBlack) - enabledBorderColor = Color(uiColor: .mvmBlack) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) } if disabledTextColor == nil && disabledBorderColor == nil { - disabledTextColor = Color(uiColor: .mvmCoolGray6) - disabledBorderColor = Color(uiColor: .mvmCoolGray6) + disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) } - enabledTextColor_inverted = Color(uiColor: .mvmWhite) - enabledBorderColor_inverted = Color(uiColor: .mvmWhite) - disabledTextColor_inverted = Color(uiColor: .mvmCoolGray6) - disabledBorderColor_inverted = Color(uiColor: .mvmCoolGray6) + enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) } public func setFacade(by style: Styler.Button.Style) { @@ -194,7 +211,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) title = try typeContainer.decode(String.self, forKey: .title) @@ -245,6 +261,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat self.disabledBorderColor = disabledBorderColor } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { self.width = width } @@ -257,7 +275,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encode(enabled, forKey: .enabled) try container.encode(inverted, forKey: .inverted) try container.encodeModel(action, forKey: .action) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(enabledFillColor, forKey: .fillColor) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 4722e3fc..cd62c8d0 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -81,7 +81,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6 backgroundColor = .clear - layer.borderWidth = 1 + layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 borderColor = isEnabled ? buttonModel?.enabledColors.border ?? .mvmBlack : buttonModel?.disabledColors.border ?? .mvmCoolGray6 } From dd8c808fa623cc979eff89aedb30ed612acf5f2c Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 05:06:36 +0530 Subject: [PATCH 047/102] using colors from the VDS colors library. --- .../CarouselIndicator/CarouselIndicator.swift | 4 ++-- .../CarouselIndicatorModel.swift | 6 +++--- MVMCoreUI/Categories/UIColor+Extension.swift | 11 +--------- .../gray44.colorset/Contents.json | 20 ------------------- .../gray65.colorset/Contents.json | 20 ------------------- 5 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 01a14f7f..bbfedf19 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -5,7 +5,7 @@ // Created by Kevin Christiano on 1/30/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import VDSColorTokens open class CarouselIndicator: Control, CarouselPageControlProtocol { //-------------------------------------------------- @@ -72,7 +72,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { public var disabledIndicatorColor: UIColor { get { - guard let model = carouselIndicatorModel else { return .mvmGray44 } + guard let model = carouselIndicatorModel else { return VDSColor.paletteGray44 } return model.inverted ? model.disabledIndicatorColor_inverted.uiColor : model.disabledIndicatorColor.uiColor } set { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index a3c7c14b..3a3d3cc3 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -7,7 +7,7 @@ // import Foundation - +import VDSColorTokens open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -30,8 +30,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro /// Set true to make the accessibility value as "Slide #currentPage of #totalPage", otherwise will be "Page #currentPage of #totalPage", default is false public var accessibilityHasSlidesInsteadOfPage: Bool = false public var enabled: Bool = true - public var disabledIndicatorColor: Color = Color(uiColor: .mvmGray44) - public var disabledIndicatorColor_inverted: Color = Color(uiColor: .mvmGray65) + public var disabledIndicatorColor: Color = Color(uiColor: VDSColor.paletteGray44) + public var disabledIndicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteGray65) public var indicatorColor: Color = Color(uiColor: .mvmBlack) public var indicatorColor_inverted: Color = Color(uiColor: .mvmWhite) public var position: CGFloat? diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 3c4c11ba..ca763ac5 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,8 +52,6 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), - "gray44": (.mvmGray44, "#6F7171"), - "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -188,7 +186,7 @@ extension UIColor { //-------------------------------------------------- /// HEX: #F6F6F6 - @objc public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") + public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") /// HEX: #D8DADA public static let mvmCoolGray3 = UIColor.assetColor(named: "coolGray3") @@ -199,13 +197,6 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") - /// HEX: #6F7171 - public static let mvmGray44 = UIColor.assetColor(named: "gray44") - - /// HEX: #A7A7A7 - public static let mvmGray65 = UIColor.assetColor(named: "gray65") - - //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json deleted file mode 100644 index 296ef27c..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x71", - "green" : "0x71", - "red" : "0x6F" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json deleted file mode 100644 index aefc9ce0..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xA7", - "green" : "0xA7", - "red" : "0xA7" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} From 7d38ed346611df4fda1706245a4b82f23f00a0a7 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 05:11:30 +0530 Subject: [PATCH 048/102] added missing as is --- MVMCoreUI/Categories/UIColor+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index ca763ac5..78363630 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -186,7 +186,7 @@ extension UIColor { //-------------------------------------------------- /// HEX: #F6F6F6 - public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") + @objc public static let mvmCoolGray1 = UIColor.assetColor(named: "coolGray1") /// HEX: #D8DADA public static let mvmCoolGray3 = UIColor.assetColor(named: "coolGray3") From a8d0c12db8b9cc08d6f05f3efc708b1fbef1683f Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 17:24:06 +0530 Subject: [PATCH 049/102] using colors from the VDS colors library. --- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 6 +++--- MVMCoreUI/Categories/UIColor+Extension.swift | 8 -------- .../gray44.colorset/Contents.json | 20 ------------------- .../gray65.colorset/Contents.json | 20 ------------------- 4 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index adfce57c..3647ad10 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -26,8 +26,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabledColor_inverted = Color(uiColor: .mvmWhite) public var disabledColor = Color(uiColor: .mvmCoolGray3) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) - public var activeColor = Color(uiColor: .mvmGray44) - public var activeColor_inverted = Color(uiColor: .mvmGray65) + public var activeColor = Color(uiColor: VDSColor.paletteGray44) + public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) public var inverted = false diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 4bc84c87..78363630 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,8 +52,6 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), - "gray44": (.mvmGray44, "#6F7171"), - "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -199,12 +197,6 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") - /// HEX: #6F7171 - public static let mvmGray44 = UIColor.assetColor(named: "gray44") - - /// HEX: #A7A7A7 - public static let mvmGray65 = UIColor.assetColor(named: "gray65") - //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json deleted file mode 100644 index 296ef27c..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x71", - "green" : "0x71", - "red" : "0x6F" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json deleted file mode 100644 index aefc9ce0..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xA7", - "green" : "0xA7", - "red" : "0xA7" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} From 790a3c69bc5bd314f6d7c2024d9db1ca5cb94003 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 20:47:52 +0530 Subject: [PATCH 050/102] using VDSColor for disabled link --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 54751274..718fdd93 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens @objcMembers open class Link: Button { //-------------------------------------------------- @@ -83,7 +83,7 @@ extension Link { backgroundColor = .clear contentMode = .redraw setTitleColor(.mvmBlack, for: .normal) - setTitleColor(.mvmCoolGray3, for: .disabled) + setTitleColor(VDSColor.paletteGray85, for: .disabled) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 3647ad10..999b9e75 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -24,7 +24,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabled = true public var enabledColor = Color(uiColor: .mvmBlack) public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: .mvmCoolGray3) + public var disabledColor = Color(uiColor: VDSColor.paletteGray85) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) public var activeColor = Color(uiColor: VDSColor.paletteGray44) public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) From b972bdba5b2c4e7ff08617d3309507c37cc1476e Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 13 Apr 2022 00:26:35 +0530 Subject: [PATCH 051/102] Setting button width with constraint --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 5 +-- .../Atomic/Atoms/Buttons/PillButton.swift | 37 ++++++++----------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 30b5b496..abb2038c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -262,10 +262,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - - if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { - self.width = width - } + self.width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index cd62c8d0..e86d8a7b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -30,6 +30,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { didSet { buttonModel?.size = buttonSize } } + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + public var widthConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -138,7 +144,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } - private func getTitleEdgeInsets() -> UIEdgeInsets { + private func getContentEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 switch buttonSize { @@ -195,25 +201,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } } - open override var intrinsicContentSize: CGSize { - - if let buttonWidth = buttonModel?.width { - return CGSize(width: buttonWidth, height: getHeight()) - } else { - if buttonSize == .tiny { - let size = super.intrinsicContentSize - let width = size.width + (2 * getInnerPadding()) - return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) - } else if buttonSize == .small { - let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) - } else { - let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) - } - } - } - //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- @@ -261,7 +248,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() - titleEdgeInsets = getTitleEdgeInsets() + contentEdgeInsets = getContentEdgeInsets() + + if let contraint = buttonModel?.width { + widthConstraint = widthAnchor.constraint(equalToConstant: contraint) + widthConstraint?.isActive = true + } } open override func setupView() { @@ -272,6 +264,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { titleLabel?.textAlignment = .center contentHorizontalAlignment = .center stylePrimary() + + widthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + widthConstraint?.isActive = true } //-------------------------------------------------- From 27289f1ac8d29b23118cb283c4ba2a6d56acccda Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 13 Apr 2022 01:48:30 +0530 Subject: [PATCH 052/102] Font and padding changes to tiny button --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 2 +- MVMCoreUI/Styles/Styler.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e86d8a7b..14c57bfd 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -240,7 +240,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: - titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight())) + titleLabel?.font = Styler.Font.BoldMicro.getFont() case .small: titleLabel?.font = Styler.Font.BoldBodySmall.getFont() case .standard: diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 00c946b6..addde766 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -191,7 +191,7 @@ open class Styler { case .small: return 32 case .tiny: - return 20 + return 26 } } } From f21c59d6c363da7c2b7f9d059a33f2efb6a3db9f Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Wed, 13 Apr 2022 15:02:45 +0530 Subject: [PATCH 053/102] disabledIndicatorColor get called to set value --- .../Atoms/Views/CarouselIndicator/CarouselIndicator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index bbfedf19..fa647ad1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -211,7 +211,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { previousIndex = 0 indicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor - disabledIndicatorColor = model.inverted ? model.disabledIndicatorColor_inverted.uiColor : model.disabledIndicatorColor.uiColor + disabledIndicatorColor = model.disabledIndicatorColor.uiColor currentIndex = model.currentIndex isEnabled = model.enabled From 781f3d6d7c966924b7970e6c3d52c10c40d791c6 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 18 Apr 2022 16:40:56 +0530 Subject: [PATCH 054/102] Fix for navigation bar style update from webpage js bridge call --- .../Protocols/ModelProtocols/NavigationItemModelProtocol.swift | 1 + .../NavigationController/UINavigationController+Extension.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index b9fb111a..5148130d 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -21,4 +21,5 @@ public protocol NavigationItemModelProtocol { var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } var titleView: MoleculeModelProtocol? { get set } var titleOffset: UIOffset? { get } + var style: NavigationItemStyle? { get set } } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ea5003f4..405fbbab 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -71,7 +71,7 @@ public extension UINavigationController { let tint = model.tintColor.uiColor navigationBar.tintColor = tint - let appearance = UINavigationBarAppearance() + let appearance = navigationBar.standardAppearance appearance.configureWithOpaqueBackground() appearance.titleTextAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tint]; From afacedda9b6d4658493fbbf62ee9be231b375c05 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 20 Apr 2022 18:40:21 +0530 Subject: [PATCH 055/102] Refresh navigation bar, after updating navigation model received from JS call --- .../Containers/NavigationController/NavigationController.swift | 3 +++ .../UINavigationController+Extension.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index 644dee73..b1f54e57 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -74,6 +74,9 @@ extension NavigationController: MVMCoreViewManagerProtocol { let model = getNavigationModel(from: viewController) { setNavigationItem(with: model, for: topViewController) setNavigationBarUI(with: model) + + navigationBar.setNeedsLayout() + navigationBar.layoutIfNeeded() } manager?.newDataReceived?(in: viewController) } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 405fbbab..ea5003f4 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -71,7 +71,7 @@ public extension UINavigationController { let tint = model.tintColor.uiColor navigationBar.tintColor = tint - let appearance = navigationBar.standardAppearance + let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.titleTextAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tint]; From 9cdf267a21d41a88163f0b447cb5ff9e8bdc9db4 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 20 Apr 2022 18:44:01 +0530 Subject: [PATCH 056/102] Removing style parameter from navigation model protocol --- .../Protocols/ModelProtocols/NavigationItemModelProtocol.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift index 5148130d..b9fb111a 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/NavigationItemModelProtocol.swift @@ -21,5 +21,4 @@ public protocol NavigationItemModelProtocol { var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set } var titleView: MoleculeModelProtocol? { get set } var titleOffset: UIOffset? { get } - var style: NavigationItemStyle? { get set } } From e8b97c6f4da576700ccdb379a4ed13f0c0a1b3f2 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 20 Apr 2022 19:52:15 +0530 Subject: [PATCH 057/102] Updating navigation layout on display --- .../Containers/NavigationController/NavigationController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index b1f54e57..9b4b332a 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -87,6 +87,9 @@ extension NavigationController: MVMCoreViewManagerProtocol { let model = getNavigationModel(from: viewController) { setNavigationItem(with: model, for: topViewController) setNavigationBarUI(with: model) + + navigationBar.setNeedsLayout() + navigationBar.layoutIfNeeded() } manager?.willDisplay?(viewController) } From 05fb8cf5edda0ad840a7720d7c494ef16a296287 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Wed, 20 Apr 2022 21:01:07 +0530 Subject: [PATCH 058/102] moving to VDSColors for all colors --- .../Atoms/Views/CarouselIndicator/CarouselIndicator.swift | 2 +- .../Views/CarouselIndicator/CarouselIndicatorModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index fa647ad1..2b20cda1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -86,7 +86,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { public var indicatorColor: UIColor { get { - guard let model = carouselIndicatorModel else { return .mvmBlack } + guard let model = carouselIndicatorModel else { return VDSColor.paletteBlack} return model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor } set { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index 3a3d3cc3..3d6eac76 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -32,8 +32,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro public var enabled: Bool = true public var disabledIndicatorColor: Color = Color(uiColor: VDSColor.paletteGray44) public var disabledIndicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteGray65) - public var indicatorColor: Color = Color(uiColor: .mvmBlack) - public var indicatorColor_inverted: Color = Color(uiColor: .mvmWhite) + public var indicatorColor: Color = Color(uiColor: VDSColor.paletteBlack) + public var indicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteWhite) public var position: CGFloat? /// Allows sendActions() to trigger even if index is already at min/max index. From 4d407d43774e31e5d7a0d749c3634605cac98ea6 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Thu, 21 Apr 2022 01:29:34 +0530 Subject: [PATCH 059/102] colors to use token name itself instead of token alias. --- .../Atoms/Views/CarouselIndicator/CarouselIndicator.swift | 2 +- .../Views/CarouselIndicator/CarouselIndicatorModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 2b20cda1..f37a608d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -86,7 +86,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { public var indicatorColor: UIColor { get { - guard let model = carouselIndicatorModel else { return VDSColor.paletteBlack} + guard let model = carouselIndicatorModel else { return VDSColor.elementsPrimaryOnlight} return model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor } set { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index 3d6eac76..7a98e382 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -32,8 +32,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro public var enabled: Bool = true public var disabledIndicatorColor: Color = Color(uiColor: VDSColor.paletteGray44) public var disabledIndicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteGray65) - public var indicatorColor: Color = Color(uiColor: VDSColor.paletteBlack) - public var indicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteWhite) + public var indicatorColor: Color = Color(uiColor: VDSColor.elementsPrimaryOnlight) + public var indicatorColor_inverted: Color = Color(uiColor: VDSColor.elementsPrimaryOndark) public var position: CGFloat? /// Allows sendActions() to trigger even if index is already at min/max index. From 1e60db2fc47bd34d911e23b6e89c3a0d0ca51ed7 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Thu, 21 Apr 2022 01:34:40 +0530 Subject: [PATCH 060/102] uses token name instead of alias. --- .../Atoms/Views/CarouselIndicator/CarouselIndicator.swift | 2 +- .../Views/CarouselIndicator/CarouselIndicatorModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index f37a608d..1d7808bd 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -72,7 +72,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { public var disabledIndicatorColor: UIColor { get { - guard let model = carouselIndicatorModel else { return VDSColor.paletteGray44 } + guard let model = carouselIndicatorModel else { return VDSColor.elementsSecondaryOnlight } return model.inverted ? model.disabledIndicatorColor_inverted.uiColor : model.disabledIndicatorColor.uiColor } set { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index 7a98e382..164bb306 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -30,8 +30,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro /// Set true to make the accessibility value as "Slide #currentPage of #totalPage", otherwise will be "Page #currentPage of #totalPage", default is false public var accessibilityHasSlidesInsteadOfPage: Bool = false public var enabled: Bool = true - public var disabledIndicatorColor: Color = Color(uiColor: VDSColor.paletteGray44) - public var disabledIndicatorColor_inverted: Color = Color(uiColor: VDSColor.paletteGray65) + public var disabledIndicatorColor: Color = Color(uiColor: VDSColor.elementsSecondaryOnlight) + public var disabledIndicatorColor_inverted: Color = Color(uiColor: VDSColor.elementsSecondaryOndark) public var indicatorColor: Color = Color(uiColor: VDSColor.elementsPrimaryOnlight) public var indicatorColor_inverted: Color = Color(uiColor: VDSColor.elementsPrimaryOndark) public var position: CGFloat? From 31827b08162545192eec4382db35575260ff61e9 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Thu, 21 Apr 2022 02:14:37 +0530 Subject: [PATCH 061/102] moving to VDSColors for all colors. --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 5 +++-- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 718fdd93..b180d50f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -82,8 +82,9 @@ extension Link { super.setupView() backgroundColor = .clear contentMode = .redraw - setTitleColor(.mvmBlack, for: .normal) - setTitleColor(VDSColor.paletteGray85, for: .disabled) + setTitleColor(VDSColor.elementsPrimaryOnlight, for: .normal) + setTitleColor(VDSColor.interactiveDisabledOnlight, for: .disabled) + setTitleColor(VDSColor.interactiveActiveOnlight, for: .highlighted) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 999b9e75..83b1fc7c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -22,12 +22,12 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var accessibilityText: String? public var action: ActionModelProtocol public var enabled = true - public var enabledColor = Color(uiColor: .mvmBlack) - public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: VDSColor.paletteGray85) - public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) - public var activeColor = Color(uiColor: VDSColor.paletteGray44) - public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) + public var enabledColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + public var enabledColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + public var disabledColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + public var disabledColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + public var activeColor = Color(uiColor: VDSColor.interactiveActiveOnlight) + public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false From 064533950e3646a2e2ddd64324a8624be3bb57f0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 21 Apr 2022 19:36:39 +0530 Subject: [PATCH 062/102] VDS button component changes --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 14 ++++++-------- MVMCoreUI/Styles/Styler.swift | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index abb2038c..71cd8eb7 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -262,7 +262,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) + width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 14c57bfd..ab94d26f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- @@ -78,17 +78,17 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? .mvmBlack : buttonModel?.disabledColors.fill ?? .mvmCoolGray6 + backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack - disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6 + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor backgroundColor = .clear layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? .mvmBlack : buttonModel?.disabledColors.border ?? .mvmCoolGray6 + borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } /// Styles the button based on the model style @@ -236,8 +236,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { super.updateView(size) self.size = size - invalidateIntrinsicContentSize() - switch buttonSize { case .tiny: titleLabel?.font = Styler.Font.BoldMicro.getFont() @@ -250,7 +248,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width { + if let contraint = buttonModel?.width, contraint != widthConstraint?.constant { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index addde766..00c946b6 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -191,7 +191,7 @@ open class Styler { case .small: return 32 case .tiny: - return 26 + return 20 } } } From 05f96d1a015a032424fcb2fbedd79275edd709c3 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 25 Apr 2022 20:28:22 +0530 Subject: [PATCH 063/102] Supporting Standard/thin style in Line atom --- MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index b5b562eb..cc9e7333 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -32,6 +32,8 @@ import VDSColorTokens The style of the line: - secondary (1 height, silver) - primary (1 height, black) + - standard (1 height, silver) - deprecated + - thin (1 height, black) - deprecated - medium (2 height, black) - heavy (4 height, black) - none (hidden) @@ -39,6 +41,8 @@ import VDSColorTokens public enum Style: String, Codable { case secondary case primary + case standard + case thin case medium case heavy case none @@ -59,10 +63,10 @@ import VDSColorTokens get { if let backgroundColor = _backgroundColor { return backgroundColor } if inverted { - if type == .secondary { return Color(uiColor: VDSColor.paletteGray20) } + if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray20) } return Color(uiColor: VDSColor.elementsPrimaryOndark) } - if type == .secondary { return Color(uiColor: VDSColor.paletteGray85) } + if type == .secondary || type == .standard { return Color(uiColor: VDSColor.paletteGray85) } return Color(uiColor: VDSColor.elementsPrimaryOnlight) } set { From 8f234259b0119921d22ba94884a01d6430af0534 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 25 Apr 2022 23:16:43 +0530 Subject: [PATCH 064/102] Changes to add button width constraints --- .../Atomic/Atoms/Buttons/PillButton.swift | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index ab94d26f..b738205e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -35,6 +35,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- public var widthConstraint: NSLayoutConstraint? + public var minimumWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers @@ -75,8 +76,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite - disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor layer.borderWidth = 0 backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } @@ -137,13 +138,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } private func getInnerPadding() -> CGFloat { - getHeight() / 2.0 + buttonSize.getHeight() / 2.0 } - - private func getHeight() -> CGFloat { - PillButton.getHeight(for: buttonSize, size: size) - } - + private func getContentEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 @@ -161,28 +158,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) } - - public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat { - switch buttonSize { - case .tiny: - let tinyHeight = Styler.Button.Size.tiny.getHeight() - return MFSizeObject(standardSize: tinyHeight, - standardiPadPortraitSize: 34, - iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight - case .small: - let smallHeight = Styler.Button.Size.small.getHeight() - return MFSizeObject(standardSize: smallHeight, - standardiPadPortraitSize: 34, - iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? smallHeight - default: - let standardHeight = Styler.Button.Size.standard.getHeight() - return MFSizeObject(standardSize: standardHeight, - standardiPadPortraitSize: 46, - iPadProLandscapeSize: 50)?.getValueBased(onSize: size) ?? standardHeight - } - } - private func getMinimumWidth() -> CGFloat { switch buttonSize { @@ -229,7 +205,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - PillButton.getHeight(for: (model as? ButtonModel)?.size, size: MVMCoreUIUtility.getWidth()) + return (model as? ButtonModel)?.size?.getHeight() } open override func updateView(_ size: CGFloat) { @@ -248,9 +224,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, contraint != widthConstraint?.constant { + if let contraint = buttonModel?.width, widthConstraint == nil { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true + minimumWidthConstraint?.isActive = false } } @@ -263,8 +240,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { contentHorizontalAlignment = .center stylePrimary() - widthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) - widthConstraint?.isActive = true + widthConstraint?.isActive = false + + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + minimumWidthConstraint?.isActive = true } //-------------------------------------------------- From a53548522dcf4e923c092e8bbf7145a4d157b8af Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 25 Apr 2022 23:32:09 +0530 Subject: [PATCH 065/102] secondary button background color --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 71cd8eb7..f16afc7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -66,7 +66,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } return Color(uiColor: VDSColor.elementsPrimaryOndark) } - if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOnlight) } + if style == .secondary { return Color(uiColor: UIColor.clear) } return Color(uiColor: VDSColor.elementsPrimaryOnlight) } set { @@ -162,7 +162,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor_inverted = Color(uiColor: UIColor.clear) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) From 8ca99f5802327f607baa28be6afe8aa2eda3070e Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 26 Apr 2022 02:24:41 +0530 Subject: [PATCH 066/102] Setting label alignment changes per title lock up alignment --- .../EyebrowHeadlineBody.swift | 39 ++++++++++--------- .../EyebrowHeadlineBodyModel.swift | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift index 7e9c5dc0..cf58a95f 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift @@ -11,10 +11,15 @@ // MARK: - Outlets //-------------------------------------------------- - public let stack = Stack(frame: .zero) public let eyebrow = Label(fontStyle: .RegularBodySmall) public let headline = Label(fontStyle: .RegularBodySmall) public let body = Label(fontStyle: .RegularBodySmall) + public lazy var stack: Stack = { + return Stack.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .fill)), + (view: headline, model: StackItemModel(horizontalAlignment: .fill)), + (view: body, model: StackItemModel(horizontalAlignment: .fill))], + axis: .vertical) + }() var castModel: EyebrowHeadlineBodyModel? { get { return model as? EyebrowHeadlineBodyModel } @@ -24,9 +29,8 @@ // MARK: - Initialization //-------------------------------------------------- - public convenience init(spacing: CGFloat) { + public convenience init() { self.init(frame: .zero) - stack.stackModel?.spacing = spacing stack.restack() } @@ -36,8 +40,6 @@ open override func setupView() { super.setupView() - stack.setAndCreateModel(with: [eyebrow, headline, body]) - stack.stackModel?.spacing = 0 addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) stack.restack() @@ -56,9 +58,6 @@ open override func reset() { super.reset() stack.reset() - eyebrow.setFontStyle(.RegularBodySmall) - headline.setFontStyle(.RegularBodySmall) - body.setFontStyle(.RegularBodySmall) } //-------------------------------------------------- @@ -67,22 +66,24 @@ open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - setStyle(style: castModel?.style) + guard let model = model as? EyebrowHeadlineBodyModel else { return } + + setStyle(style: model.style) ///Updating the text color - castModel?.eyebrow?.textColor = castModel?.headlineColor - castModel?.headline.textColor = castModel?.headlineColor - castModel?.body?.textColor = castModel?.bodyColor + model.eyebrow?.textColor = model.headlineColor + model.headline.textColor = model.headlineColor + model.body?.textColor = model.bodyColor - if let alignment = castModel?.alignment, let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) { - castModel?.eyebrow?.textAlignment = textAlignment - castModel?.headline.textAlignment = textAlignment - castModel?.body?.textAlignment = textAlignment + if let textAlignment = NSTextAlignment(rawValue: model.alignment.rawValue) { + model.eyebrow?.textAlignment = textAlignment + model.headline.textAlignment = textAlignment + model.body?.textAlignment = textAlignment } - stack.updateContainedMolecules(with: [castModel?.eyebrow, - castModel?.headline, - castModel?.body], + stack.updateContainedMolecules(with: [model.eyebrow, + model.headline, + model.body], delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift index 97b37637..dbf8377c 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift @@ -100,7 +100,7 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode switch self { case .small,.medium,.large: - return Padding.One + return Padding.Two case .xlarge: return Padding.Three case .xxlarge: From db7bc5be2ba0e7fa58ca4a0366a2db33c64ee4b5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 29 Apr 2022 23:01:44 +0530 Subject: [PATCH 067/102] minor changes to button component --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 8 ++--- .../Atomic/Atoms/Buttons/PillButton.swift | 36 +++++-------------- MVMCoreUI/Styles/Styler.swift | 11 ++++++ 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index f16afc7f..92cde87c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -63,11 +63,9 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat get { if let backgroundColor = _backgroundColor { return backgroundColor } if inverted { - if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } - return Color(uiColor: VDSColor.elementsPrimaryOndark) + return enabled ? enabledFillColor_inverted : disabledFillColor_inverted } - if style == .secondary { return Color(uiColor: UIColor.clear) } - return Color(uiColor: VDSColor.elementsPrimaryOnlight) + return enabled ? enabledFillColor : disabledFillColor } set { _backgroundColor = newValue @@ -163,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: UIColor.clear) - enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index b738205e..de955378 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -76,20 +76,20 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor backgroundColor = .clear layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor } /// Styles the button based on the model style @@ -153,29 +153,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { verticalPadding = Padding.Two horizontalPadding = Padding.Four break - default: + case .tiny: + verticalPadding = getInnerPadding() + horizontalPadding = getInnerPadding() break } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) } - - private func getMinimumWidth() -> CGFloat { - - switch buttonSize { - case .tiny: - return MFSizeObject(standardSize: 49, - standardiPadPortraitSize: 90, - iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49 - case .small: - return MFSizeObject(standardSize: 1, - standardiPadPortraitSize: 2, - iPadProLandscapeSize: 3)?.getValueBased(onSize: size) ?? 1 - case .standard: - return MFSizeObject(standardSize: 76, - standardiPadPortraitSize: 90, - iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 76 - } - } //-------------------------------------------------- // MARK: - MVMCoreViewProtocol @@ -240,9 +224,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { contentHorizontalAlignment = .center stylePrimary() - widthConstraint?.isActive = false - - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) minimumWidthConstraint?.isActive = true } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 00c946b6..9cc487e8 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -194,6 +194,17 @@ open class Styler { return 20 } } + + func minimumWidth() -> CGFloat { + switch self { + case .standard: + return 76 + case .small: + return 0 + case .tiny: + return 49 + } + } } } From c2ac51c18cdd2fe3829cc79b0c5f15eccf0dbe6c Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 30 Apr 2022 00:00:57 +0530 Subject: [PATCH 068/102] Padding changes for button --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 3 ++- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 92cde87c..0eea3036 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -151,6 +151,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if enabledTextColor == nil && enabledBorderColor == nil { enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor = Color(uiColor: UIColor.clear) enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) } @@ -160,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: UIColor.clear) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index de955378..b70f4ccb 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -154,8 +154,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { horizontalPadding = Padding.Four break case .tiny: - verticalPadding = getInnerPadding() - horizontalPadding = getInnerPadding() + verticalPadding = Padding.One + horizontalPadding = Padding.Two break } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) @@ -211,7 +211,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { if let contraint = buttonModel?.width, widthConstraint == nil { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true - minimumWidthConstraint?.isActive = false + } else { + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + minimumWidthConstraint?.isActive = true } } @@ -223,9 +225,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { titleLabel?.textAlignment = .center contentHorizontalAlignment = .center stylePrimary() - - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - minimumWidthConstraint?.isActive = true } //-------------------------------------------------- From 7fb91d9b1ec99d83181ae0952e2bcaab82a55b10 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 3 May 2022 01:02:25 +0530 Subject: [PATCH 069/102] Updating button default style --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 4 +-- .../Atomic/Atoms/Buttons/PillButton.swift | 25 ++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 0eea3036..a6453dd5 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Styler.Button.Style? { + public var style: Styler.Button.Style? = .primary { didSet { guard let style = style else { return } setFacade(by: style) @@ -161,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor_inverted = Color(uiColor: UIColor.clear) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index b70f4ccb..7960fd99 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -76,31 +76,20 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor - layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor + buttonModel?.setPrimaryFacade() } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor - backgroundColor = .clear - layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor + buttonModel?.setSecondaryFacade() } /// Styles the button based on the model style private func style() { - switch buttonModel?.style { - case .secondary: - styleSecondary() - - default: - stylePrimary() + if buttonModel?.style == .primary { + layer.borderWidth = 0 } if let titleColor = buttonModel?.enabledColors.text { @@ -170,6 +159,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { super.set(with: model, delegateObject, additionalData) guard let model = model as? ButtonModel else { return } + + style() setTitle(model.title, for: .normal) if let accessibilityText = model.accessibilityText { accessibilityLabel = accessibilityText @@ -208,10 +199,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, widthConstraint == nil { + if let contraint = buttonModel?.width, (widthConstraint == nil || widthConstraint?.constant != contraint) { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true - } else { + } else if minimumWidthConstraint == nil { minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) minimumWidthConstraint?.isActive = true } From 5f6e987da81168f7a41c01f3bfba89c79e5bcb49 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 3 May 2022 23:26:38 +0530 Subject: [PATCH 070/102] modifying button border changes --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 7960fd99..84600397 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -43,6 +43,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { self.init() + model = ButtonModel.init(with: "", action: ActionOpenPageModel(pageType: "noop")) buttonSize = istiny ? .tiny : .standard isPrimary ? stylePrimary() : styleSecondary() } @@ -90,6 +91,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { if buttonModel?.style == .primary { layer.borderWidth = 0 + } else if buttonModel?.style == .secondary { + layer.borderWidth = 1 } if let titleColor = buttonModel?.enabledColors.text { @@ -111,7 +114,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } if let borderColor = buttonModel?.enabledColors.border { - layer.borderWidth = 1 self.borderColor = borderColor } } else { @@ -120,7 +122,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } if let borderColor = buttonModel?.disabledColors.border { - layer.borderWidth = 1 self.borderColor = borderColor } } @@ -160,7 +161,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { guard let model = model as? ButtonModel else { return } - style() setTitle(model.title, for: .normal) if let accessibilityText = model.accessibilityText { accessibilityLabel = accessibilityText From 083e52bc1919320b69b3a2f6e4a8356965cc1ee2 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 4 May 2022 01:35:21 +0530 Subject: [PATCH 071/102] TitleLockup model changes --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++-- .../LockUps/TitleLockup.swift} | 78 +++++----------- .../LockUps/TitleLockupModel.swift} | 91 +++++++++++++------ .../OtherHandlers/CoreUIModelMapping.swift | 2 +- 4 files changed, 95 insertions(+), 92 deletions(-) rename MVMCoreUI/Atomic/Molecules/{VerticalCombinationViews/EyebrowHeadlineBody.swift => DesignedComponents/LockUps/TitleLockup.swift} (54%) rename MVMCoreUI/Atomic/Molecules/{VerticalCombinationViews/EyebrowHeadlineBodyModel.swift => DesignedComponents/LockUps/TitleLockupModel.swift} (59%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 407051bd..730d98aa 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -145,9 +145,9 @@ 32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */; }; 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; + 444FB7C12821B73200DFE692 /* TitleLockup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444FB7C02821B73200DFE692 /* TitleLockup.swift */; }; + 444FB7C32821B76B00DFE692 /* TitleLockupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */; }; 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */; }; - 4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */; }; - 4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; @@ -735,9 +735,9 @@ 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = ""; }; 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = ""; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = ""; }; + 444FB7C02821B73200DFE692 /* TitleLockup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLockup.swift; sourceTree = ""; }; + 444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLockupModel.swift; sourceTree = ""; }; 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageRenderingMode+Extension.swift"; sourceTree = ""; }; - 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyModel.swift; sourceTree = ""; }; - 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBody.swift; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = ""; }; 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = ""; }; @@ -1435,6 +1435,8 @@ 525019DC2406430800EED91C /* ListProgressBarData.swift */, AA45AA0A24BF0263007A6EA7 /* LockUpsPlanNamesModel.swift */, AA45AA0C24BF0276007A6EA7 /* LockUpsPlanNames.swift */, + 444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */, + 444FB7C02821B73200DFE692 /* TitleLockup.swift */, ); path = LockUps; sourceTree = ""; @@ -1641,8 +1643,6 @@ EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */, 0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */, 0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */, - 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */, - 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */, ); path = VerticalCombinationViews; sourceTree = ""; @@ -2669,6 +2669,7 @@ 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, 3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */, AAA7CD69250641F90045B959 /* HeartModel.swift in Sources */, + 444FB7C12821B73200DFE692 /* TitleLockup.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, D28BA7452481652D00B75CB8 /* TabBarProtocol.swift in Sources */, AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, @@ -2737,7 +2738,6 @@ D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */, - 4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */, BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, D2ED2800254B0E0300A1C293 /* MVMCoreAlertHandler+Extension.swift in Sources */, D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */, @@ -2863,6 +2863,7 @@ 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */, 32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */, 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, + 444FB7C32821B76B00DFE692 /* TitleLockupModel.swift in Sources */, D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, @@ -2930,7 +2931,6 @@ 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, - 4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */, AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */, AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift similarity index 54% rename from MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift index cf58a95f..bc069b27 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift @@ -1,28 +1,28 @@ // -// EyebrowHeadlineBody.swift +// TitleLockup.swift // MVMCoreUI // -// Created by Nadigadda, Sumanth on 08/04/22. +// Created by Nadigadda, Sumanth on 04/05/22. // Copyright © 2022 Verizon Wireless. All rights reserved. // -@objcMembers open class EyebrowHeadlineBody: View { +@objcMembers open class TitleLockup: View { //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- public let eyebrow = Label(fontStyle: .RegularBodySmall) - public let headline = Label(fontStyle: .RegularBodySmall) - public let body = Label(fontStyle: .RegularBodySmall) + public let title = Label(fontStyle: .RegularBodySmall) + public let subTitle = Label(fontStyle: .RegularBodySmall) public lazy var stack: Stack = { return Stack.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .fill)), - (view: headline, model: StackItemModel(horizontalAlignment: .fill)), - (view: body, model: StackItemModel(horizontalAlignment: .fill))], + (view: title, model: StackItemModel(horizontalAlignment: .fill)), + (view: subTitle, model: StackItemModel(horizontalAlignment: .fill))], axis: .vertical) }() - var castModel: EyebrowHeadlineBodyModel? { - get { return model as? EyebrowHeadlineBodyModel } + var castModel: TitleLockupModel? { + get { return model as? TitleLockupModel } } //-------------------------------------------------- @@ -31,7 +31,6 @@ public convenience init() { self.init(frame: .zero) - stack.restack() } //-------------------------------------------------- @@ -47,7 +46,7 @@ open override func updateView(_ size: CGFloat) { super.updateView(size) - stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? EyebrowHeadlineBodyModel.Style.large.defaultSpacing() + stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? TitleLockupModel.Style.large.defaultSpacing() stack.updateView(size) } @@ -66,24 +65,11 @@ open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? EyebrowHeadlineBodyModel else { return } - - setStyle(style: model.style) - - ///Updating the text color - model.eyebrow?.textColor = model.headlineColor - model.headline.textColor = model.headlineColor - model.body?.textColor = model.bodyColor - - if let textAlignment = NSTextAlignment(rawValue: model.alignment.rawValue) { - model.eyebrow?.textAlignment = textAlignment - model.headline.textAlignment = textAlignment - model.body?.textAlignment = textAlignment - } - + guard let model = model as? TitleLockupModel else { return } + stack.updateContainedMolecules(with: [model.eyebrow, - model.headline, - model.body], + model.title, + model.subTitle], delegateObject, additionalData) } @@ -91,29 +77,6 @@ return 65 } - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - public func setStyle(style: EyebrowHeadlineBodyModel.Style? = .large) { - - ///If eyebrow style is not available, will set font style based on the component - ///Eyebrow and body share the same font size - if castModel?.eyebrow?.fontStyle == nil { - castModel?.eyebrow?.fontStyle = style?.defaultBodyFontStyle() - } - - ///If headline style is not available, will set font style based on the component - if castModel?.headline.fontStyle == nil { - castModel?.headline.fontStyle = style?.defaultHeadlineFontStyle() - } - - ///If body style is not available, will set font style based on the component - if castModel?.body?.fontStyle == nil { - castModel?.body?.fontStyle = style?.defaultBodyFontStyle() - } - } - //-------------------------------------------------- // MARK: - Accessibility Helpers //-------------------------------------------------- @@ -127,11 +90,11 @@ message += eyebrowLabel + ", " } - if let headlineLabel = headline.text { + if let headlineLabel = title.text { message += headlineLabel + ", " } - if let bodyLabel = body.text { + if let bodyLabel = subTitle.text { message += bodyLabel } @@ -147,14 +110,15 @@ elements.append(eyebrow) } - if headline.hasText { - elements.append(headline) + if title.hasText { + elements.append(title) } - if body.hasText { - elements.append(body) + if subTitle.hasText { + elements.append(subTitle) } return elements.count > 0 ? elements : nil } } + diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift similarity index 59% rename from MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift rename to MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift index dbf8377c..a4351cf4 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift @@ -1,25 +1,25 @@ // -// EyebrowHeadlineBodyModel.swift +// TitleLockupModel.swift // MVMCoreUI // -// Created by Nadigadda, Sumanth on 08/04/22. +// Created by Nadigadda, Sumanth on 04/05/22. // Copyright © 2022 Verizon Wireless. All rights reserved. // import VDSColorTokens -public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { +public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public static var identifier: String = "eyebrowHeadlineBody" - public var moleculeName: String = EyebrowHeadlineBodyModel.identifier + public static var identifier: String = "titleLockup" + public var moleculeName: String = TitleLockupModel.identifier public var eyebrow: LabelModel? - public var headline: LabelModel - public var body: LabelModel? + public var title: LabelModel + public var subTitle: LabelModel? public var style: Style = .large public var alignment: Alignment = .left @@ -35,27 +35,27 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode } } - public var headlineColor: Color? { + public var titleColor: Color? { return inverted ? Color(uiColor: VDSColor.elementsPrimaryOndark) : Color(uiColor: VDSColor.elementsPrimaryOnlight) } - public var bodyColor: Color? { + public var subTitleColor: Color? { return inverted ? Color(uiColor: VDSColor.elementsSecondaryOndark) : Color(uiColor: VDSColor.elementsSecondaryOnlight) } public var children: [MoleculeModelProtocol] { - [eyebrow, headline, body].compactMap { (molecule: MoleculeModelProtocol?) in molecule } + [eyebrow, title, subTitle].compactMap { (molecule: MoleculeModelProtocol?) in molecule } } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(eyebrow: LabelModel? = nil, headline: LabelModel, body: LabelModel? = nil) throws { + public init(eyebrow: LabelModel? = nil, title: LabelModel, subTitle: LabelModel? = nil) throws { self.eyebrow = eyebrow - self.headline = headline - self.body = body + self.title = title + self.subTitle = subTitle } //-------------------------------------------------- @@ -122,8 +122,8 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode case moleculeName case backgroundColor case eyebrow - case headline - case body + case title + case subTitle case inverted case alignment case style @@ -136,32 +136,71 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) - headline = try typeContainer.decodeMolecule(codingKey: .headline) - body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body) - - if let style = try typeContainer.decodeIfPresent(Style.self, forKey: .style) { - self.style = style + title = try typeContainer.decodeMolecule(codingKey: .title) + subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle) + + if let newStyle = try typeContainer.decodeIfPresent(Style.self, forKey: .style) { + style = newStyle + setStyle(style: newStyle) } - if let alignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) { - self.alignment = alignment + if let newAlignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) { + alignment = newAlignment } - if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { - self.inverted = inverted + if let invertedStatus = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + inverted = invertedStatus } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + updateLabelAttributes() } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(eyebrow, forKey: .eyebrow) - try container.encodeModelIfPresent(headline, forKey: .headline) - try container.encodeIfPresent(body, forKey: .body) + try container.encodeModel(title, forKey: .title) + try container.encodeIfPresent(subTitle, forKey: .subTitle) try container.encodeIfPresent(style, forKey: .style) try container.encode(alignment, forKey: .alignment) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) } + + //-------------------------------------------------- + // MARK: - Model updates + //-------------------------------------------------- + + private func setStyle(style: Style) { + + ///If eyebrow style is not available, will set font style based on the component + ///Eyebrow and body share the same font size + if eyebrow?.fontStyle == nil { + eyebrow?.fontStyle = style.defaultBodyFontStyle() + } + + ///If title style is not available, will set font style based on the component + if title.fontStyle == nil { + title.fontStyle = style.defaultHeadlineFontStyle() + } + + ///If subtitle style is not available, will set font style based on the component + if subTitle?.fontStyle == nil { + subTitle?.fontStyle = style.defaultBodyFontStyle() + } + } + + private func updateLabelAttributes() { + ///Updating the text color + eyebrow?.textColor = titleColor + title.textColor = titleColor + subTitle?.textColor = subTitleColor + + ///Updating the text alignment for all labels + if let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) { + eyebrow?.textAlignment = textAlignment + title.textAlignment = textAlignment + subTitle?.textAlignment = textAlignment + } + } } diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 5527813b..ef051b88 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -87,7 +87,6 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self) - ModelRegistry.register(handler: EyebrowHeadlineBody.self, for: EyebrowHeadlineBodyModel.self) // MARK:- Left Right Molecules ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) @@ -205,6 +204,7 @@ open class CoreUIModelMapping: ModelMapping { // MARK:- LockUps ModelRegistry.register(handler: LockUpsPlanNames.self, for: LockUpsPlanNamesModel.self) ModelRegistry.register(handler: LockupsPlanSMLXL.self, for: LockupsPlanSMLXLModel.self) + ModelRegistry.register(handler: TitleLockup.self, for: TitleLockupModel.self) // MARK: - Top Notifications ModelRegistry.register(handler: NotificationView.self, for: NotificationModel.self) From b6226616d8ebe465b19d324721c021e57b113a95 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 5 May 2022 12:33:13 -0400 Subject: [PATCH 072/102] Remove tab bar logic from base controllers and move to the manager. --- .../BaseControllers/ViewController.swift | 43 ------------------- .../MVMCoreUISplitViewController.h | 3 ++ .../MVMCoreUISplitViewController.m | 9 +++- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 26ab983f..772742b4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -43,9 +43,6 @@ import UIKit public var selectedField: UIView? - // Stores the previous tab bar index. - public var tabBarIndex: Int? - /// Checks if the screen width has changed open func screenSizeChanged() -> Bool { !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) @@ -244,12 +241,6 @@ import UIKit view.backgroundColor = backgroundColor.uiColor } - // 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,34 +258,6 @@ import UIKit return model?.navigationBar } - //-------------------------------------------------- - // MARK: - TabBar - //-------------------------------------------------- - - open func updateTabBar() { - guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self else { return } - MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar - - if let index = (model as? TabPageModelProtocol)?.tabBarIndex { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = loadObject?.requestParameters?.actionMap?["tabBarIndex"] as? Int { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = self.tabBarIndex { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = MVMCoreUISplitViewController.main()?.tabBar?.currentTabIndex() { - // Store current tab index for cases like back button. - self.tabBarIndex = index - } - - if let hidden = (model as? TabPageModelProtocol)?.tabBarHidden { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden) - } else if let hidden = loadObject?.requestParameters?.actionMap?["tabBarHidden"] as? Bool { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden) - } else { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(true) - } - } - //-------------------------------------------------- // MARK: - View Lifecycle //-------------------------------------------------- @@ -349,12 +312,6 @@ import UIKit } open func pageShown() { - // Update split view properties if this is the current detail controller. - if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) - updateTabBar() - } - // Track. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index db5e9cd9..d0530cc9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -55,6 +55,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Reference to the tabbar. @property (nullable, weak, nonatomic) UIView *tabBar; +/// Tab bar index history. +@property (nonnull, strong, nonatomic) NSMutableArray *tabBarIndices; + // Convenience getter + (nullable instancetype)mainSplitViewController; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5c337072..e005763b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -93,13 +93,20 @@ CGFloat const PanelAnimationDuration = 0.2; } - (nullable instancetype)initWithLeftPanel:(nullable UIViewController *)leftPanel rightPanel:(nullable UIViewController *)rightPanel { - if (self = [super init]) { + if (self = [self init]) { self.globalLeftPanel = leftPanel; self.globalRightPanel = rightPanel; } return self; } +- (nullable instancetype)init { + if (self = [super init]) { + self.tabBarIndices = [NSMutableArray array]; + } + return self; +} + #pragma mark - Main Subclassables - (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth { From f2fd2c8d493dfe03766a0157d7e27aa44a77900e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 5 May 2022 12:38:32 -0400 Subject: [PATCH 073/102] comments and new functions for setting --- ...MCoreUISplitViewController+Extension.swift | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 12935302..3c6c878b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -12,6 +12,64 @@ import UIKit // Navigation bar update functions public extension MVMCoreUISplitViewController { + /// Updates the state for various controls (navigation, tab, progress) for the controller. + func updateState(with viewController: UIViewController) { + guard let navigationController = navigationController, + navigationController.isDisplayed(viewController: viewController) else { return } + updateNavigationBarFor(viewController: viewController) + updateProgressBar(for: viewController) + updateTabBar(for: viewController) + } + + // MARK: - Progress Bar + /// Updates the progress bar based on the page json for the view controller. + func updateProgressBar(for viewController: UIViewController) { + guard let viewController = viewController as? MVMCoreViewControllerProtocol else { return } + var progress: Float = 0.0 + if let progressString = viewController.loadObject??.pageJSON?.optionalStringForKey(KeyProgressPercent), + let floatValue = Float(progressString) { + progress = floatValue/100 + } + setBottomProgressBarProgress(progress) + } + + // MARK: - Tab Bar + /// Updates the tab bar based on the page json for the view controller. + func updateTabBar(for viewController: UIViewController) { + let mvmViewController = viewController as? MVMCoreViewControllerProtocol + tabBar?.delegateObject = mvmViewController?.delegateObject?() as? MVMCoreUIDelegateObject + + let navigationIndex = (MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 1) - 1 + + // Set the highlighted index. In terms of priority, Page > Action > Previous. + if let index = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarIndex { + tabBar?.highlightTab(at: index) + } else if let index = mvmViewController?.loadObject??.requestParameters?.actionMap?["tabBarIndex"] as? Int { + tabBar?.highlightTab(at: index) + } else if navigationIndex < tabBarIndices.count { + let index = (tabBarIndices[navigationIndex] as! NSNumber).intValue + tabBar?.highlightTab(at: index) + } + + // Store current tab index, so we can switch back when going back in hierarchy. + if tabBarIndices.count > 0 { + tabBarIndices.removeObjects(in: NSRange(location: navigationIndex, length: tabBarIndices.count - navigationIndex)) + } + if let currentIndex = tabBar?.currentTabIndex() { + tabBarIndices.add(NSNumber(integerLiteral: currentIndex)) + } + + // Show/Hide. In terms of priority, Page > Action > Always Show. + if let hidden = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarHidden { + updateTabBarShowing(!hidden) + } else if let hidden = mvmViewController?.loadObject??.requestParameters?.actionMap?["tabBarHidden"] as? Bool { + updateTabBarShowing(!hidden) + } else { + updateTabBarShowing(true) + } + } + + // MARK: - Navigation Bar /// 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. func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { guard navigationController == self.navigationController, @@ -122,6 +180,7 @@ public extension MVMCoreUISplitViewController { setStatusBarForCurrentViewController() } + // MARK: - Status Bar /// Returns the bar style for the background color. Light if on a dark background, otherwise default. func getStatusBarStyle(for backgroundColor: UIColor?) -> UIStatusBarStyle { var greyScale: CGFloat = 0 @@ -155,10 +214,10 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { public func willDisplay(_ viewController: UIViewController) { setupPanels() - updateNavigationBarFor(viewController: viewController) + updateState(with: viewController) } public func newDataReceived(in viewController: UIViewController) { - updateNavigationBarFor(viewController: viewController) + updateState(with: viewController) } } From 2a1db08ab77c77441d93434f8ad889fc29b7e074 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 6 May 2022 15:51:53 +0530 Subject: [PATCH 074/102] setting button style and constraints. --- .../Atomic/Atoms/Buttons/PillButton.swift | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 84600397..10fb4b72 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -34,8 +34,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Constraints //-------------------------------------------------- - public var widthConstraint: NSLayoutConstraint? - public var minimumWidthConstraint: NSLayoutConstraint? + public var widthConstraint: NSLayoutConstraint { + return widthAnchor.constraint(equalToConstant: 0) + } + + public var minimumWidthConstraint: NSLayoutConstraint { + return widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + } //-------------------------------------------------- // MARK: - Initializers @@ -78,12 +83,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { public func stylePrimary() { buttonModel?.setPrimaryFacade() + style() } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { buttonModel?.setSecondaryFacade() + style() } /// Styles the button based on the model style @@ -199,12 +206,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, (widthConstraint == nil || widthConstraint?.constant != contraint) { - widthConstraint = widthAnchor.constraint(equalToConstant: contraint) - widthConstraint?.isActive = true - } else if minimumWidthConstraint == nil { - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - minimumWidthConstraint?.isActive = true + if let contraint = buttonModel?.width, widthConstraint.constant != contraint { + widthConstraint.constant = contraint + widthConstraint.isActive = true + minimumWidthConstraint.isActive = false + } else if !minimumWidthConstraint.isActive { + minimumWidthConstraint.isActive = true + widthConstraint.isActive = false } } From 45a1532f68fa384695dfac0e12cfd1e9c7bc48c5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 6 May 2022 22:13:56 +0530 Subject: [PATCH 075/102] updates to button width constraint --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 10fb4b72..ab46e476 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -211,6 +211,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { widthConstraint.isActive = true minimumWidthConstraint.isActive = false } else if !minimumWidthConstraint.isActive { + minimumWidthConstraint.constant = buttonSize.minimumWidth() minimumWidthConstraint.isActive = true widthConstraint.isActive = false } From 89bc6c72ab3453f9566a47aa7945ebf25967396b Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 7 May 2022 01:46:41 +0530 Subject: [PATCH 076/102] Updating default button style --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index a6453dd5..d180c884 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -85,6 +85,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action + setFacade(by: style ?? .primary) } public init(secondaryButtonWith title: String, action: ActionModelProtocol) { @@ -218,6 +219,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { self.style = style setFacade(by: style) + } else { + setFacade(by: .primary) } if let size = try typeContainer.decodeIfPresent(Styler.Button.Size.self, forKey: .size) { From adb337f8650a3af954112851d9bdb4b011573854 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 7 May 2022 23:46:56 +0530 Subject: [PATCH 077/102] Updating button constraints --- .../Atomic/Atoms/Buttons/PillButton.swift | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index ab46e476..39bb8b24 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -34,13 +34,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Constraints //-------------------------------------------------- - public var widthConstraint: NSLayoutConstraint { - return widthAnchor.constraint(equalToConstant: 0) - } - - public var minimumWidthConstraint: NSLayoutConstraint { - return widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - } + public var widthConstraint: NSLayoutConstraint? + public var minimumWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers @@ -206,14 +201,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, widthConstraint.constant != contraint { - widthConstraint.constant = contraint - widthConstraint.isActive = true - minimumWidthConstraint.isActive = false - } else if !minimumWidthConstraint.isActive { - minimumWidthConstraint.constant = buttonSize.minimumWidth() - minimumWidthConstraint.isActive = true - widthConstraint.isActive = false + if let contraint = buttonModel?.width { + + if widthConstraint == nil { + widthConstraint = widthAnchor.constraint(equalToConstant: contraint) + } else if widthConstraint?.constant != contraint { + widthConstraint?.constant = contraint + } + widthConstraint?.isActive = true + minimumWidthConstraint?.isActive = false + } else { + + if minimumWidthConstraint == nil { + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + } else { + minimumWidthConstraint?.constant = buttonSize.minimumWidth() + } + minimumWidthConstraint?.isActive = true + widthConstraint?.isActive = false } } From d3cac3f36db4171e69bce96e954379f81ff2a628 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 9 May 2022 14:29:59 +0530 Subject: [PATCH 078/102] set font size as per spec --- .../Atomic/Atoms/Buttons/Link/Link.swift | 10 ++------ .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index b180d50f..4f4a8b34 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -38,7 +38,7 @@ import VDSColorTokens open override var intrinsicContentSize: CGSize { guard let size = titleLabel?.intrinsicContentSize else { return super.intrinsicContentSize } - return CGSize(width: size.width, height: size.height + 2) + return CGSize(width: size.width, height: size.height + 1) } //-------------------------------------------------- @@ -58,6 +58,7 @@ import VDSColorTokens setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) isEnabled = model.enabled + titleLabel?.font = model.getFont(model.size) set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -69,13 +70,6 @@ extension Link { open override func updateView(_ size: CGFloat) { super.updateView(size) - - var width = size - if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { - width = MVMCoreUIUtility.getWidth() - } - - titleLabel?.font = MFStyler.fontB2(forWidth: width) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 83b1fc7c..af507860 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -30,6 +30,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false + public var size:linkFontSize = linkFontSize.small //-------------------------------------------------- // MARK: - Initializer @@ -59,8 +60,27 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case activeColor case activeColor_inverted case inverted + case size } + public enum linkFontSize: String, Codable { + case small + case large + } + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + + func getFont(_ type: linkFontSize) -> UIFont { + switch type { + case .small: + return MFStyler.fontRegularBodySmall() + case .large: + return MFStyler.fontRegularBodyLarge() + } + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- @@ -105,6 +125,9 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { self.activeColor_inverted = activeColor_inverted } + if let size = try typeContainer.decodeIfPresent(linkFontSize.self, forKey: .size) { + self.size = size + } } public func encode(to encoder: Encoder) throws { @@ -122,5 +145,6 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) try container.encode(activeColor, forKey: .activeColor) try container.encode(activeColor_inverted, forKey: .activeColor_inverted) + try container.encodeIfPresent(size, forKey: .size) } } From f589a5249eaadbdd5cbcd7e07eca7917cd90a8ed Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 9 May 2022 12:57:14 -0400 Subject: [PATCH 079/102] Button fixes for other containers --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 36 ++++++----------- .../Atomic/Atoms/Buttons/PillButton.swift | 40 ++++++++----------- .../TopAlert/MVMCoreUITopAlertMainView.m | 1 - 3 files changed, 30 insertions(+), 47 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index d180c884..fae40f0c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Styler.Button.Style? = .primary { + public var style: Styler.Button.Style? { didSet { guard let style = style else { return } setFacade(by: style) @@ -85,19 +85,21 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action - setFacade(by: style ?? .primary) + setFacade(by: .primary) } public init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary + setFacade(by: .secondary) } public init(primaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .primary + setFacade(by: .primary) } //-------------------------------------------------- @@ -130,16 +132,10 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat /// Defines the default appearance for the primary style. func setPrimaryFacade() { - - if enabledFillColor == nil && enabledTextColor == nil { - enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - } - - if disabledFillColor == nil && disabledTextColor == nil { - disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - } + enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) + disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) @@ -149,17 +145,11 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat /// Defines the default appearance for the Secondary style. func setSecondaryFacade() { - - if enabledTextColor == nil && enabledBorderColor == nil { - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledFillColor = Color(uiColor: UIColor.clear) - enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - } - - if disabledTextColor == nil && disabledBorderColor == nil { - disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - } + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor = Color(uiColor: UIColor.clear) + enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: UIColor.clear) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 39bb8b24..6b47f112 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -23,7 +23,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// Need to re-style on set. open override var isEnabled: Bool { - didSet { style() } + didSet { style(with: buttonModel) } } open var buttonSize: Styler.Button.Size = .standard { @@ -42,10 +42,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { - self.init() - model = ButtonModel.init(with: "", action: ActionOpenPageModel(pageType: "noop")) - buttonSize = istiny ? .tiny : .standard - isPrimary ? stylePrimary() : styleSecondary() + let model = ButtonModel(with: "", action: ActionNoopModel()) + model.style = isPrimary ? .primary : .secondary + model.size = istiny ? .tiny : .standard + self.init(model: model, nil, nil) } //-------------------------------------------------- @@ -76,32 +76,26 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - - buttonModel?.setPrimaryFacade() - style() + let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + style(with: buttonModel) } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - - buttonModel?.setSecondaryFacade() - style() + let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + style(with: buttonModel) } /// Styles the button based on the model style - private func style() { + private func style(with model: ButtonModel?) { - if buttonModel?.style == .primary { - layer.borderWidth = 0 - } else if buttonModel?.style == .secondary { - layer.borderWidth = 1 - } + layer.borderWidth = model?.style == .secondary ? 1 : 0 - if let titleColor = buttonModel?.enabledColors.text { + if let titleColor = model?.enabledColors.text { enabledTitleColor = titleColor } - if let disabledTitleColor = buttonModel?.disabledColors.text { + if let disabledTitleColor = model?.disabledColors.text { self.disabledTitleColor = disabledTitleColor } @@ -111,19 +105,19 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { #endif if isEnabled { - if let fillColor = buttonModel?.enabledColors.fill { + if let fillColor = model?.enabledColors.fill { backgroundColor = fillColor } - if let borderColor = buttonModel?.enabledColors.border { + if let borderColor = model?.enabledColors.border { self.borderColor = borderColor } } else { - if let fillColor = buttonModel?.disabledColors.fill { + if let fillColor = model?.disabledColors.fill { backgroundColor = fillColor } - if let borderColor = buttonModel?.disabledColors.border { + if let borderColor = model?.disabledColors.border { self.borderColor = borderColor } } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index fa96630f..d2a009c9 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -204,7 +204,6 @@ // Sets up to use a button action. Always uses the top view controller PillButton *button = [[PillButton alloc] initAsPrimaryButton:false makeTiny:true]; - [button styleSecondary]; [button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; [button setContentHuggingPriority:800 forAxis:UILayoutConstraintAxisHorizontal]; From a0fd19ea7aace29cfb74e5441efe028b994f2854 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 11 May 2022 21:11:34 +0530 Subject: [PATCH 080/102] Removing font scaling for Pillbutton --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 6b47f112..e578fa51 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -185,11 +185,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: - titleLabel?.font = Styler.Font.BoldMicro.getFont() + titleLabel?.font = Styler.Font.BoldMicro.getFont(false) case .small: - titleLabel?.font = Styler.Font.BoldBodySmall.getFont() + titleLabel?.font = Styler.Font.BoldBodySmall.getFont(false) case .standard: - titleLabel?.font = Styler.Font.BoldBodyLarge.getFont() + titleLabel?.font = Styler.Font.BoldBodyLarge.getFont(false) } layer.cornerRadius = getInnerPadding() From eaf4bbe116653b6b8c6e8c4c6b1097e92abb0b9b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 13:21:27 -0400 Subject: [PATCH 081/102] background color, bridge mf view controller new data, optional delegate --- MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift | 2 +- MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index ee4d9587..a3be96f5 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -75,7 +75,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo self.delegate = delegateObject } - public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { + public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) { guard let list = delegate?.moleculeListDelegate else { return } for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules { if let moleculesToAdd = model.getRecursiveMoleculesToAdd(), diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 76bc7f84..eadd5e4e 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -19,7 +19,7 @@ public protocol PageBehaviorProtocol: ModelHandlerProtocol { public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { - func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) + func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) } public protocol PageVisibilityBehavior: PageBehaviorProtocol { From 6ad5ebbf92d7c2d4c6d6d8e955af1ab3bf6509ac Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 17:41:35 -0400 Subject: [PATCH 082/102] 3.0 font updates --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 4 ++-- .../UINavigationController+Extension.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index e7096069..527ed054 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -58,11 +58,11 @@ import VDSColorTokens /// Sets the item colors. private func set(tabItemAppearance: UITabBarItemAppearance, model: TabBarModel) { tabItemAppearance.normal.iconColor = model.unSelectedColor.uiColor - tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) tabItemAppearance.selected.iconColor = model.selectedColor.uiColor - tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ea5003f4..b88e11ba 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -66,7 +66,7 @@ public extension UINavigationController { /// Convenience function for setting the navigation bar ui func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar - let font = MFStyler.fontBoldBodySmall(false) + let font = MFStyler.fontRegularBodyLarge(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor navigationBar.tintColor = tint From 4dc5ee5e6aa631a21b82c1979e89d1f411c70c6b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 17:59:42 -0400 Subject: [PATCH 083/102] bold --- .../NavigationController/UINavigationController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index b88e11ba..e1c7f6a3 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -66,7 +66,7 @@ public extension UINavigationController { /// Convenience function for setting the navigation bar ui func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar - let font = MFStyler.fontRegularBodyLarge(false) + let font = MFStyler.fontBoldBodyLarge(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor navigationBar.tintColor = tint From 19ef7a3a26aa337ea9e17f3b695703079cefb6a8 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 00:18:18 +0530 Subject: [PATCH 084/102] Fix for CXTDT-288387, removing line molecule from Tab --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 6 ------ MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 1 - 2 files changed, 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 4e424549..e78ccf19 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -28,7 +28,6 @@ import VDSColorTokens let bottomScrollView = UIScrollView(frame: .zero) let bottomContentView = View() - let bottomLine = Line() let selectionLine = View() var selectionLineLeftConstraint: NSLayoutConstraint? var selectionLineWidthConstraint: NSLayoutConstraint? @@ -68,7 +67,6 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight - addSubview(bottomLine) setupCollectionView() setupSelectionLine() setupConstraints() @@ -116,10 +114,6 @@ import VDSColorTokens selectionLineWidthConstraint = selectionLine.widthAnchor.constraint(equalToConstant: minimumItemWidth) selectionLineWidthConstraint?.isActive = true NSLayoutConstraint.constraintPinSubview(toSuperview: bottomContentView) - - //bottom line - bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; - NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) } //------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index d3b91b11..5fe9c530 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,7 +22,6 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self - tabs.bottomLine.setStyle(.none) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) From eeb6573e727eae09b6a6df3eefef6d5901c021ad Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 12:13:06 +0530 Subject: [PATCH 085/102] Reverting - line changes in Tab component & Removing line item in Subnavigation controller --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 7 +++++++ MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 1 + MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 6 +----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index e78ccf19..f6f834ca 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -28,6 +28,7 @@ import VDSColorTokens let bottomScrollView = UIScrollView(frame: .zero) let bottomContentView = View() + let bottomLine = Line() let selectionLine = View() var selectionLineLeftConstraint: NSLayoutConstraint? var selectionLineWidthConstraint: NSLayoutConstraint? @@ -67,6 +68,8 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight + bottomLine.setStyle(.secondary) + addSubview(bottomLine) setupCollectionView() setupSelectionLine() setupConstraints() @@ -114,6 +117,10 @@ import VDSColorTokens selectionLineWidthConstraint = selectionLine.widthAnchor.constraint(equalToConstant: minimumItemWidth) selectionLineWidthConstraint?.isActive = true NSLayoutConstraint.constraintPinSubview(toSuperview: bottomContentView) + + //bottom line + bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; + NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) } //------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 5fe9c530..0ecb230f 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,6 +22,7 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self + tabs.bottomLine.setStyle(.secondary) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index b3a142ba..f5c4023a 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -19,7 +19,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Used to layout the ui. public lazy var stackView: UIStackView = { - let stackView = UIStackView(arrangedSubviews: [tabs, line, subNavigationController.view]) + let stackView = UIStackView(arrangedSubviews: [tabs, subNavigationController.view]) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.isAccessibilityElement = false stackView.axis = .vertical @@ -33,10 +33,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, return tabs }() - public lazy var line: Line = { - return Line(model: LineModel(type: .secondary), delegateObjectIVar, nil) - }() - public lazy var subNavigationController: UINavigationController = { let subNavigationController = SubNavManagerNavigationController(rootViewController: viewController) subNavigationController.view.translatesAutoresizingMaskIntoConstraints = false From 4cf9f6128203313d5566633eb0f4a32eeb39b6cd Mon Sep 17 00:00:00 2001 From: Naresh Reddy Maram Reddy Date: Fri, 27 May 2022 12:17:46 +0530 Subject: [PATCH 086/102] Removed preferredControlTintColor & preferredBarTintColor for SFSafariViewControllers to use default. --- MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index fb7fe919..9425547c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -125,8 +125,6 @@ - (void)openURLInSafariWebView:(nonnull NSURL *)url { SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - safariViewController.preferredBarTintColor = [UIColor whiteColor]; - safariViewController.preferredControlTintColor = [UIColor blackColor]; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; } From 7fbac6b8dcef2edc7427044534503c4dc8118f41 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 20:25:47 +0530 Subject: [PATCH 087/102] Changes to set the line style after initialization --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 3 +++ .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index d4c4d26d..e36c8d23 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -49,16 +49,19 @@ import UIKit public init() { super.init(frame: .zero) model = LineModel(type: .secondary) + setStyle(.secondary) } public override init(frame: CGRect) { super.init(frame: frame) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index f6f834ca..4e424549 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -68,7 +68,6 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight - bottomLine.setStyle(.secondary) addSubview(bottomLine) setupCollectionView() setupSelectionLine() From 3e8f464aac5322b805712e7a779809654c43f25b Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 21:10:41 +0530 Subject: [PATCH 088/102] Reverting line changes in TabTableCell --- MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 0ecb230f..d3b91b11 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,7 +22,7 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self - tabs.bottomLine.setStyle(.secondary) + tabs.bottomLine.setStyle(.none) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) From cb75955bb4501c727537dd23fa41438606236cd8 Mon Sep 17 00:00:00 2001 From: vasavk Date: Mon, 30 May 2022 16:21:09 +0530 Subject: [PATCH 089/102] VDS FormControls --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6bfc7ba0..e51e8336 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; 0AF60F0926B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */; }; + 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */; }; 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; @@ -714,6 +715,7 @@ 0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = ""; }; 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.swift; sourceTree = ""; }; 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIUtility+Extension.swift"; sourceTree = ""; }; + 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; @@ -1189,6 +1191,7 @@ D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */, + 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2019,6 +2022,7 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */, From 4645e0de976a86eb9d610331d4419fb76a306572 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 9 Jun 2022 18:17:29 -0400 Subject: [PATCH 090/102] default the title offset for all inits --- .../Molecules/NavigationBar/NavigationItemModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 523f6ea1..64b61480 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -61,7 +61,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var titleView: MoleculeModelProtocol? - open var titleOffset: UIOffset? + open var titleOffset: UIOffset? = UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) //-------------------------------------------------- // MARK: - Initializer @@ -114,7 +114,9 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) - titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) ?? UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) + if let titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) { + self.titleOffset = titleOffset + } line?.inverted = style == .dark } From acc91902e56b8ad05926d7924278a18dc3ab39ff Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 10 Jun 2022 16:20:37 -0400 Subject: [PATCH 091/102] Global font changes --- .../Atomic/Atoms/Views/Label/Label.swift | 11 +- .../Molecules/HeadersAndFooters/Header.swift | 4 +- .../MoleculeHeaderView.swift | 4 +- .../HeadlineBody.swift | 24 +- MVMCoreUI/BaseClasses/TableViewCell.swift | 4 +- MVMCoreUI/Styles/MFStyler.h | 13 - MVMCoreUI/Styles/MFStyler.m | 318 +++--------------- MVMCoreUI/Styles/Styler.swift | 218 ++++++------ 8 files changed, 179 insertions(+), 417 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index fcbb31e4..c524b7b3 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -295,8 +295,8 @@ public typealias ActionBlock = () -> () accessibilityLabel = accessibilityText } - if let fontStyle = labelModel.fontStyle?.rawValue { - MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false) + if let fontStyle = labelModel.fontStyle { + fontStyle.styleLabel(self, genericScaling: false) standardFontSize = font.pointSize } else { let fontSize = labelModel.fontSize @@ -428,7 +428,7 @@ public typealias ActionBlock = () -> () label.accessibilityLabel = json?.optionalStringForKey("accessibilityText") if let fontStyle = json?.optionalStringForKey("fontStyle") { - MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil) + MFStyler.style(label: label, styleString: fontStyle, genericScaling: mvmLabel == nil) mvmLabel?.standardFontSize = label.font.pointSize } else { let fontSize = json?["fontSize"] as? CGFloat @@ -490,7 +490,7 @@ public typealias ActionBlock = () -> () case "font": if let fontStyle = attribute.optionalStringForKey("style") { - let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle, genericScaling: mvmLabel == nil) + let styles = MFStyler.getAttributedString(for: "0", styleString: fontStyle, genericScaling: mvmLabel == nil) attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range) @@ -531,8 +531,7 @@ public typealias ActionBlock = () -> () //------------------------------------------------------ public func setFontStyle(_ fontStyle: Styler.Font, _ scale: Bool = true) { - font = fontStyle.getFont(false) - textColor = .mvmBlack + fontStyle.styleLabel(self, genericScaling: false) setScale(scale) } diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift index 73b42dea..9d061f76 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/Header.swift @@ -33,7 +33,7 @@ open class HeaderView: Container { public override func setupView() { super.setupView() - line.setStyle(.heavy) + line.setStyle(.none) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true @@ -43,7 +43,7 @@ open class HeaderView: Container { // MARK: - MoleculeViewProtocol open override func reset() { super.reset() - line.setStyle(.heavy) + line.setStyle(.none) molecule?.reset() } diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeHeaderView.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeHeaderView.swift index 9e4afed6..4e999997 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeHeaderView.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeHeaderView.swift @@ -31,7 +31,7 @@ public class MoleculeHeaderView: MoleculeContainer { public override func setupView() { super.setupView() - line.setStyle(.heavy) + line.setStyle(.none) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true @@ -40,7 +40,7 @@ public class MoleculeHeaderView: MoleculeContainer { open override func reset() { super.reset() - line.setStyle(.heavy) + line.setStyle(.none) } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift index 43c22dcc..ae0d22c4 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -54,27 +54,27 @@ open class HeadlineBody: View { } public func styleLandingPageHeader() { - headlineLabel.setFontStyle(.Title2XLarge) - messageLabel.setFontStyle(.RegularBodySmall) - spaceBetweenLabelsConstant = Padding.Two + headlineLabel.setFontStyle(.RegularTitle2XLarge) + messageLabel.setFontStyle(.RegularTitleMedium) + spaceBetweenLabelsConstant = Padding.Four } public func stylePageHeader() { - headlineLabel.setFontStyle(.BoldTitleLarge) + headlineLabel.setFontStyle(.RegularTitleLarge) + messageLabel.setFontStyle(.RegularBodyLarge) + spaceBetweenLabelsConstant = Padding.Two + } + + public func styleListItem() { + headlineLabel.setFontStyle(.RegularTitleSmall) messageLabel.setFontStyle(.RegularBodySmall) spaceBetweenLabelsConstant = Padding.One } - public func styleListItem() { - headlineLabel.setFontStyle(.BoldBodySmall) - messageLabel.setFontStyle(.RegularBodySmall) - spaceBetweenLabelsConstant = 0 - } - public func styleListItemDivider() { - headlineLabel.setFontStyle(.BoldTitleMedium) + headlineLabel.setFontStyle(.BoldTitleSmall) messageLabel.setFontStyle(.RegularBodySmall) - spaceBetweenLabelsConstant = 0 + spaceBetweenLabelsConstant = Padding.Two } //-------------------------------------------------- diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index a80969ba..053bedd0 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -45,10 +45,10 @@ import UIKit bottomSeparatorView?.setStyle(.secondary) case .shortDivider?: topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.primary) + bottomSeparatorView?.setStyle(.none) case .tallDivider?: topSeparatorView?.setStyle(.none) - bottomSeparatorView?.setStyle(.primary) + bottomSeparatorView?.setStyle(.none) case .sectionFooter?: topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.none) diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index d8676016..541ede8c 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -217,7 +217,6 @@ B3 -> Legal + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling; + (nullable UIFont *)fontForHeadlineSmall2; + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling; -+ (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size; + (nullable UIFont *)fontB1ForWidth:(CGFloat)size; + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling; + (nullable UIFont *)fontB2ForWidth:(CGFloat)size; @@ -287,15 +286,8 @@ B3 -> Legal + (void)styleLabelRegularMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelRegularMicro:(nonnull UILabel *)label; -/// Will style the label with mva 3.0 fonts based on the string. -+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; - #pragma mark - 2.0 styles -/// Will style the label based on the string. Accepted values, including mva3.0 fonts and 2.0 fonts H1, H2, H3, H32, B1, B2, B3, B20 -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style; -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; - + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; + (void)styleLabelH1:(nonnull UILabel *)label; @@ -377,11 +369,6 @@ B3 -> Legal + (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; - -/// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20 -+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style; -+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling; - + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color; + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string; + (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 48ca21a8..9f5a02c0 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -113,27 +113,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 3.0 fonts + (nonnull UIFont *)getMVA3FontSize:(CGFloat)size bold:(BOOL)isBold { - if (isBold) { - if (size >= 15) { - return [MFFonts mfFontDSBold:size]; - } else { - return [MFFonts mfFontTXBold:size]; - } - } else { - if (size >= 15) { - return [MFFonts mfFontDSRegular:size]; - } else { - return [MFFonts mfFontTXRegular:size]; - } - } + return [self getFontForSize:size isBold:isBold]; } + (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling { - CGFloat size = 36; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"Title2XLarge" genericScaling:genericScaling]; } + (nonnull UIFont *)fontTitle2XLarge { @@ -141,22 +125,15 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling { - CGFloat size = 32; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"TitleXLarge" genericScaling:genericScaling]; } -+ (nonnull UIFont *)fontTitleXLarge{ + ++ (nonnull UIFont *)fontTitleXLarge { return [self fontTitleXLarge:YES]; } + (nonnull UIFont *)fontBoldTitleLarge:(BOOL)genericScaling { - CGFloat size = 24; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"BoldTitleLarge" genericScaling:genericScaling]; } + (nonnull UIFont *)fontBoldTitleLarge { @@ -164,11 +141,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling { - CGFloat size = 24; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:NO]; + return [self getFontForStyleString:@"RegularTitleLarge" genericScaling:genericScaling]; } + (nonnull UIFont *)fontRegularTitleLarge { @@ -176,11 +149,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"BoldTitleMedium" genericScaling:genericScaling]; } + (nonnull UIFont *)fontBoldTitleMedium { @@ -188,11 +157,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:NO]; + return [self getFontForStyleString:@"RegularTitleMedium" genericScaling:genericScaling]; } + (nonnull UIFont *)fontRegularTitleMedium { @@ -200,11 +165,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"BoldBodyLarge" genericScaling:genericScaling]; } + (nonnull UIFont *)fontBoldBodyLarge { @@ -212,11 +173,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:NO]; + return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; } + (nonnull UIFont *)fontRegularBodyLarge { @@ -224,11 +181,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"BoldBodySmall" genericScaling:genericScaling]; } + (nonnull UIFont *)fontBoldBodySmall { @@ -236,11 +189,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:NO]; + return [self getFontForStyleString:@"RegularBodySmall" genericScaling:genericScaling]; } + (nonnull UIFont *)fontRegularBodySmall { @@ -248,11 +197,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:YES]; + return [self getFontForStyleString:@"BoldMicro" genericScaling:genericScaling]; } + (nonnull UIFont *)fontBoldMicro { @@ -260,11 +205,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [self getMVA3FontSize:size bold:NO]; + return [self getFontForStyleString:@"RegularMicro" genericScaling:genericScaling]; } + (nonnull UIFont *)fontRegularMicro { @@ -275,11 +216,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 2.0 fonts + (nullable UIFont *)fontH1:(BOOL)genericScaling { - CGFloat size = 40; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"H1" genericScaling:genericScaling]; } + (nullable UIFont *)fontH1 { @@ -287,11 +224,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontH2:(BOOL)genericScaling { - CGFloat size = 25; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"H2" genericScaling:genericScaling]; } + (nullable UIFont *)fontH2 { @@ -299,11 +232,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontH3:(BOOL)genericScaling { - CGFloat size = 18; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"H3" genericScaling:genericScaling]; } + (nullable UIFont *)fontH3 { @@ -311,11 +240,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontH32:(BOOL)genericScaling { - CGFloat size = 32; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"H32" genericScaling:genericScaling]; } + (nullable UIFont *)fontH32 { @@ -323,11 +248,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontB1:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"B1" genericScaling:genericScaling]; } + (nullable UIFont *)fontB1 { @@ -335,11 +256,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontB2:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"B2" genericScaling:genericScaling]; } + (nullable UIFont *)fontB2 { @@ -347,11 +264,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontB3:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"B3" genericScaling:genericScaling]; } + (nullable UIFont *)fontB3 { @@ -359,11 +272,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontB20:(BOOL)genericScaling { - CGFloat size = 20; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"B20" genericScaling:genericScaling]; } + (nullable UIFont *)fontB20 { @@ -385,11 +294,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForBiggerHeadLine:(BOOL)genericScaling { - CGFloat size = 48; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"BoldFeatureSmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontForBiggerHeadline { @@ -397,31 +302,15 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling { - CGFloat size = 15; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; -} - -+ (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size { - CGFloat pointSize = 16; - pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; - return [MFFonts mfFont75Bd:pointSize]; + return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontB1ForWidth:(CGFloat)size { - CGFloat pointSize = 13; - pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; - return [MFFonts mfFont75Bd:pointSize]; + return [self getFontForStyleString:@"B1" scaleValue:size]; } + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling { @@ -432,9 +321,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontB2ForWidth:(CGFloat)size { - CGFloat pointSize = 13; - pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; - return [MFFonts mfFont55Rg:pointSize]; + return [self getFontForStyleString:@"B2" scaleValue:size]; } + (nullable UIFont *)fontForBodyWithSize:(CGFloat)size forWidth:(CGFloat)width { @@ -443,19 +330,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontforChatText:(BOOL)genericScaling { - CGFloat size = 14; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"RegularBodyMedium" genericScaling:genericScaling]; } + (nullable UIFont *)fontForAccountLandingGreeting:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; } + (nullable UIFont *)fontForProgressBarBottomLabel:(BOOL)genericScaling { @@ -467,47 +346,27 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForPrimaryButton:(BOOL)genericScaling { - CGFloat size = 13; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFontTXBold:size]; + return [self getFontForStyleString:@"BoldBodyLarge" genericScaling:genericScaling]; } + (nullable UIFont *)fontForPrimaryButtonForWidth:(CGFloat)size { - CGFloat pointSize = 13; - pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; - return [MFFonts mfFontTXBold:pointSize]; + return [self getFontForStyleString:@"BoldBodyLarge" scaleValue:size]; } + (nullable UIFont *)fontForSmallButton:(BOOL)genericScaling { - CGFloat size = 11; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFontTXBold:size]; + return [self getFontForStyleString:@"BoldBodySmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontForSmallButtonForWidth:(CGFloat)size { - CGFloat pointSize = 11; - pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size]; - return [MFFonts mfFontTXBold:pointSize]; + return [self getFontForStyleString:@"BoldBodySmall" scaleValue:size]; } + (nullable UIFont *)fontForTextField:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; } + (nullable UIFont *)fontForTextFieldUnderLabel:(BOOL)genericScaling { - CGFloat size = 12; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"RegularBodySmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontForUnreadMessageOnSupport:(BOOL)genericScaling { @@ -519,11 +378,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)font5GMessage:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont55Rg:size]; + return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; } + (nullable UIFont *)font5GMessage { @@ -554,11 +409,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForFeedCardTitle:(BOOL)genericScaling { - CGFloat size = 16; - if (genericScaling) { - size = [self sizeFontGenericForCurrentDevice:size]; - } - return [MFFonts mfFont75Bd:size]; + return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; } + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling { @@ -785,77 +636,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; [self styleLabelRegularMicro:label genericScaling:YES]; } -+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { - if ([style isEqualToString:@"Title2XLarge"]) { - [self styleLabelTitle2XLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"TitleXLarge"]) { - [self styleLabelTitleXLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"BoldTitleLarge"]) { - [self styleLabelBoldTitleLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"RegularTitleLarge"]) { - [self styleLabelRegularTitleLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"BoldTitleMedium"]) { - [self styleLabelBoldTitleMedium:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"RegularTitleMedium"]) { - [self styleLabelRegularTitleMedium:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"BoldBodyLarge"]) { - [self styleLabelBoldBodyLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"RegularBodyLarge"]) { - [self styleLabelRegularBodyLarge:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"BoldBodySmall"]) { - [self styleLabelBoldBodySmall:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"RegularBodySmall"]) { - [self styleLabelRegularBodySmall:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"BoldMicro"]) { - [self styleLabelBoldMicro:label genericScaling:genericScaling]; - return YES; - } else if ([style isEqualToString:@"RegularMicro"]) { - [self styleLabelRegularMicro:label genericScaling:genericScaling]; - return YES; - } else { - return NO; - } -} - - #pragma mark - 2.0 Styles -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { - if ([self styleMVA3Label:label withStyle:style genericScaling:genericScaling]) { - //try mva 3.0 font first - } else if ([style isEqualToString:@"H1"]) { - [self styleLabelH1:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H2"]) { - [self styleLabelH2:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H3"]) { - [self styleLabelH3:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H32"]) { - [self styleLabelH32:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B1"]) { - [self styleLabelB1:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B3"]) { - [self styleLabelB3:label genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B20"]) { - [self styleLabelB20:label genericScaling:genericScaling]; - } else { - [self styleLabelB2:label genericScaling:genericScaling]; - } -} - -+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style { - [self styleLabel:label withStyle:style genericScaling:YES]; -} - + (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { label.font = [MFStyler fontH1:genericScaling]; label.textColor = [UIColor blackColor]; @@ -975,30 +757,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - Attributed Strings -+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style { - return [self styleGetAttributedString:string withStyle:style genericScaling:YES]; -} - -+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling { - if ([style isEqualToString:@"H1"]) { - return [self styleGetH1AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H2"]) { - return [self styleGetH2AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H3"]) { - return [self styleGetH3AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"H32"]) { - return [self styleGetH32AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B1"]) { - return [self styleGetB1AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B3"]) { - return [self styleGetB3AttributedString:string genericScaling:genericScaling]; - } else if ([style isEqualToString:@"B20"]) { - return [self styleGetB20AttributedString:string genericScaling:genericScaling]; - } else { - return [self styleGetB2AttributedString:string genericScaling:genericScaling]; - } -} - + (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color { NSAttributedString *attributedString = nil; if (![string isEqual:[NSNull null]] && string.length > 0) { diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 9cc487e8..e9893a94 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -7,69 +7,103 @@ // import Foundation +import UIKit open class Styler { // MARK:- Font Enum public enum Font: String, Codable { - case Title2XLarge - case TitleXLarge - case BoldTitleLarge + case RegularFeatureXLarge + case BoldFeatureXLarge + case RegularFeatureLarge + case BoldFeatureLarge + case RegularFeatureMedium + case BoldFeatureMedium + case RegularFeatureSmall + case BoldFeatureSmall + case RegularFeatureXSmall + case BoldFeatureXSmall + + case RegularTitle2XLarge + case BoldTitle2XLarge + case RegularTitleXLarge + case BoldTitleXLarge case RegularTitleLarge - case BoldTitleMedium + case BoldTitleLarge case RegularTitleMedium - case BoldBodyLarge + case BoldTitleMedium + case RegularTitleSmall + case BoldTitleSmall + case RegularBodyLarge - case BoldBodySmall + case BoldBodyLarge + case RegularBodyMedium + case BoldBodyMedium case RegularBodySmall - case BoldMicro + case BoldBodySmall case RegularMicro + case BoldMicro // Legacy Fonts - case H1 - case H32 - case H2 - case B20 - case H3 - case B1 - case B2 - case B3 + case Title2XLarge // Maps to RegularTitle2XLarge + case TitleXLarge // Maps to RegularTitleXLarge + case H1 // Maps to RegularTitle2XLarge + case H32 // Maps to RegularTitleXLarge + case H2 // Maps to RegularTitleLarge + case B20 // Maps to RegularBodyLarge + case H3 // Maps to BoldTitleMedium + case B1 // Maps to BoldBodySmall + case B2 // Maps to RegularBodySmall + case B3 // Maps to RegularMicro /// Returns the font size of the current enum case. public func pointSize() -> CGFloat { switch self { - case .H1: + case .RegularFeatureXLarge, + .BoldFeatureXLarge: + return 96 + case .RegularFeatureLarge, + .BoldFeatureLarge: + return 80 + case .RegularFeatureMedium, + .BoldFeatureMedium: + return 64 + case .RegularFeatureSmall, + .BoldFeatureSmall: + return 48 + case .RegularFeatureXSmall, + .BoldFeatureXSmall, + .RegularTitle2XLarge, + .BoldTitle2XLarge, + .Title2XLarge, + .H1: return 40 - - case .Title2XLarge: - return 36 - - case .TitleXLarge, .H32: + case .RegularTitleXLarge, + .BoldTitleXLarge, + .TitleXLarge, + .H32: return 32 - - case .H2: - return 25 - case .BoldTitleLarge, - .RegularTitleLarge: + .RegularTitleLarge, + .H2: return 24 - case .BoldTitleMedium, - .RegularTitleMedium, .B20: + .RegularTitleMedium, + .H3: return 20 - - case .H3: - return 18 - - case .BoldBodyLarge, - .RegularBodyLarge: + case .RegularTitleSmall, + .BoldTitleSmall, + .BoldBodyLarge, + .RegularBodyLarge, + .B20: return 16 - + case .RegularBodyMedium, + .BoldBodyMedium: + return 14 case .BoldBodySmall, .B1, .RegularBodySmall, .B2: - return 13 - + return 12 case .BoldMicro, .RegularMicro, .B3: return 11 @@ -90,85 +124,38 @@ open class Styler { public func isBold() -> Bool { switch self { - case .RegularTitleLarge, - .RegularTitleMedium, .B20, - .RegularBodyLarge, - .RegularBodySmall, .B2, - .RegularMicro, .B3: - return false - - case .H1, - .Title2XLarge, - .TitleXLarge, .H32, - .H2, - .BoldTitleLarge, - .BoldTitleMedium, - .H3, - .BoldBodyLarge, - .BoldBodySmall, .B1, - .BoldMicro: - return true - } - } - - /// Determines if the current enum is a legacy or modern font. - public func isLegacyFont() -> Bool { - - switch self { - case .Title2XLarge, - .TitleXLarge, - .RegularTitleLarge, - .RegularTitleMedium, - .RegularBodyLarge, - .RegularBodySmall, - .RegularMicro, + case .BoldFeatureXLarge, + .BoldFeatureLarge, + .BoldFeatureMedium, + .BoldFeatureSmall, + .BoldFeatureXSmall, + .BoldTitle2XLarge, + .BoldTitleXLarge, .BoldTitleLarge, .BoldTitleMedium, + .BoldTitleSmall, .BoldBodyLarge, + .BoldBodyMedium, .BoldBodySmall, - .BoldMicro: - return false - - case .H1, - .H32, - .H2, .H3, .B1, - .B2, - .B3, - .B20: + .BoldMicro: return true + default: + return false } } - + /// Returns the font based on the declared enum case. public func getFont(_ genericScaling: Bool = true) -> UIFont { - let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize() - - if isLegacyFont() { - switch self { - case .B2, .B3, .B20: - return MFFonts.mfFont55Rg(size) - - default: - return MFFonts.mfFont75Bd(size) - } - } else { - if isBold() { - return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) - - } else { - return size >= 13 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) - } - } + return MFStyler.getFontFor(size: size, isBold: isBold()) } /// Styles the provided label to the declared enum Font case. - public func styleLabel(_ label: UILabel, textColor: UIColor = .mvmBlack, genericScaling: Bool = true) { - + public func styleLabel(_ label: UILabel, genericScaling: Bool = true) { label.font = getFont(genericScaling) - label.textColor = textColor + label.textColor = color() } } @@ -267,3 +254,34 @@ open class Styler { } } } + +@objc public extension MFStyler { + @objc static func getFontFor(size: CGFloat, isBold: Bool) -> UIFont { + if isBold { + return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) + } else { + return size >= 13 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size) + } + } + + @objc static func getFontFor(styleString: String, genericScaling: Bool = true) -> UIFont? { + return Styler.Font(rawValue: styleString)?.getFont(genericScaling) + } + + @objc static func getFontFor(styleString: String, scaleValue: CGFloat) -> UIFont? { + guard let font = Styler.Font(rawValue: styleString), + let size = Styler.Font(rawValue: styleString)?.pointSize(), + let newSize = Styler.sizeObjectGeneric(forCurrentDevice: size)?.getValueBased(onSize: scaleValue) else { return nil } + return getFontFor(size: newSize, isBold: font.isBold()) + } + + /// Styles the label accordingly to Styler.Font + @objc static func style(label: UILabel, styleString: String, genericScaling: Bool = true) { + Styler.Font(rawValue: styleString)?.styleLabel(label, genericScaling: genericScaling) + } + + @objc static func getAttributedString(for string: String, styleString: String, genericScaling: Bool = true) -> NSAttributedString { + let font = Styler.Font(rawValue: styleString)! + return styleGetAttributedString(string, font: font.getFont(genericScaling), color: font.color()) + } +} From 123ac6b2a192fd0acf65dddda37c34a4d1a52375 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 20 Jun 2022 11:43:50 -0400 Subject: [PATCH 092/102] Feed card revert. --- MVMCoreUI/Styles/MFStyler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 9f5a02c0..da7077ad 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -409,7 +409,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForFeedCardTitle:(BOOL)genericScaling { - return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; + return [self getFontForStyleString:@"BoldTitleXLarge" genericScaling:genericScaling]; } + (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling { From c2c6fdd524c8939315035bc38005c8df7d87302f Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 20 Jun 2022 12:55:42 -0400 Subject: [PATCH 093/102] Revert --- MVMCoreUI/Styles/MFStyler.m | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index da7077ad..e65fddc5 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -294,7 +294,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForBiggerHeadLine:(BOOL)genericScaling { - return [self getFontForStyleString:@"BoldFeatureSmall" genericScaling:genericScaling]; + CGFloat size = 48; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont75Bd:size]; } + (nullable UIFont *)fontForBiggerHeadline { @@ -302,11 +306,19 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling { - return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; + CGFloat size = 15; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont75Bd:size]; } + (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling { - return [self getFontForStyleString:@"BoldTitleSmall" genericScaling:genericScaling]; + CGFloat size = 16; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont75Bd:size]; } + (nullable UIFont *)fontB1ForWidth:(CGFloat)size { @@ -330,11 +342,19 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)fontforChatText:(BOOL)genericScaling { - return [self getFontForStyleString:@"RegularBodyMedium" genericScaling:genericScaling]; + CGFloat size = 14; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; } + (nullable UIFont *)fontForAccountLandingGreeting:(BOOL)genericScaling { - return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; + CGFloat size = 16; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; } + (nullable UIFont *)fontForProgressBarBottomLabel:(BOOL)genericScaling { @@ -378,7 +398,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; } + (nullable UIFont *)font5GMessage:(BOOL)genericScaling { - return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling]; + CGFloat size = 16; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [MFFonts mfFont55Rg:size]; } + (nullable UIFont *)font5GMessage { From c284614c29dcd2bc87cdf9fe08df06384c184502 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 20 Jun 2022 12:55:55 -0400 Subject: [PATCH 094/102] Comments --- MVMCoreUI/Styles/Styler.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index e9893a94..2cbc9a00 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -256,6 +256,7 @@ open class Styler { } @objc public extension MFStyler { + /// Creates the appropriate VZW font for a given size and weight. @objc static func getFontFor(size: CGFloat, isBold: Bool) -> UIFont { if isBold { return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size) @@ -264,10 +265,12 @@ open class Styler { } } + /// Creates the appropriate VZW font for a VDS style. @objc static func getFontFor(styleString: String, genericScaling: Bool = true) -> UIFont? { return Styler.Font(rawValue: styleString)?.getFont(genericScaling) } + /// Creates the appropriate VZW font for a VDS style, scaling based on the scaleValue threshold passed in. @objc static func getFontFor(styleString: String, scaleValue: CGFloat) -> UIFont? { guard let font = Styler.Font(rawValue: styleString), let size = Styler.Font(rawValue: styleString)?.pointSize(), @@ -280,6 +283,7 @@ open class Styler { Styler.Font(rawValue: styleString)?.styleLabel(label, genericScaling: genericScaling) } + /// Returns an attributed string with the passed in VDS Style. @objc static func getAttributedString(for string: String, styleString: String, genericScaling: Bool = true) -> NSAttributedString { let font = Styler.Font(rawValue: styleString)! return styleGetAttributedString(string, font: font.getFont(genericScaling), color: font.color()) From 305372fe0457bf049d4f4426ab7e84eaece2cbac Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 21 Jun 2022 15:10:59 -0500 Subject: [PATCH 095/102] added a public initializer Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Actions/ActionAlertModel.swift | 10 +++++++++- .../Atomic/Atoms/FormFields/Tags/TagModel.swift | 9 +++++++++ .../Atoms/FormFields/Tags/TagsModel.swift | 9 +++++++++ .../Atomic/Atoms/Selectors/HeartModel.swift | 7 ++++++- .../Atomic/Atoms/Selectors/RadioBoxModel.swift | 9 +++++++++ .../Atoms/Selectors/RadioBoxesModel.swift | 9 +++++++++ .../Atoms/Selectors/RadioSwatchModel.swift | 8 +++++++- .../Atoms/Selectors/RadioSwatchesModel.swift | 10 +++++++++- .../Atomic/Atoms/Views/CaretViewModel.swift | 8 +++++++- .../Atomic/Atoms/Views/CheckboxLabelModel.swift | 12 +++++++++++- .../Atomic/Atoms/Views/DashLineModel.swift | 8 +++++++- .../Atoms/Views/LoadingSpinnerModel.swift | 8 +++++++- MVMCoreUI/Atomic/Atoms/Views/StarModel.swift | 7 +++++++ MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift | 9 +++++++++ MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift | 8 +++++++- ...reeColumnInternationalDataDividerModel.swift | 2 +- .../RadioButtonLabelModel.swift | 13 +++++++++++-- .../Items/AccordionListItemModel.swift | 9 +++++++++ .../ActionDetailWithImageModel.swift | 10 ++++++++++ .../HeadlineBodyButtonModel.swift | 12 +++++++++++- .../Lists/NumberedListModel.swift | 9 +++++++++ .../Lists/UnOrderedListModel.swift | 12 +++++++++++- .../ModalSectionListTemplateModel.swift | 10 +++++++++- .../Templates/ModalStackPageTemplateModel.swift | 10 +++++++++- .../Templates/SectionListTemplateModel.swift | 17 +++++++++++++++++ .../Rules/Rules/RuleAllValueChangedModel.swift | 8 ++++++++ .../Rules/Rules/RuleAnyRequiredModel.swift | 8 ++++++++ .../Rules/Rules/RuleAnyValueChangedModel.swift | 8 ++++++++ .../Rules/Rules/RuleEqualsIgnoreCaseModel.swift | 8 ++++++++ .../Rules/Rules/RuleEqualsModel.swift | 8 ++++++++ .../Rules/Rules/RuleRegexModel.swift | 9 +++++++++ .../Rules/Rules/RuleRequiredModel.swift | 8 ++++++++ 32 files changed, 276 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift index cc6b3f60..67748a4d 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift @@ -5,7 +5,7 @@ // Created by Suresh, Kamlesh on 7/9/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore @objcMembers public class ActionAlertModel: ActionModelProtocol { //-------------------------------------------------- @@ -17,4 +17,12 @@ public var alert: AlertModel public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(alert: AlertModel) { + self.alert = alert + } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift index 56a86742..823d2478 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore @objcMembers public class TagModel: MoleculeModelProtocol { public static var identifier: String = "tag" @@ -27,6 +28,14 @@ import Foundation } } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(label: LabelModel) { + self.label = label + } + 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/FormFields/Tags/TagsModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift index 009f8fa1..6330bb94 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore @objcMembers public class TagsModel: MoleculeModelProtocol { public static var identifier: String = "tags" @@ -19,6 +20,14 @@ import Foundation case tags } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with tags: [TagModel]) { + self.tags = tags + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) tags = try typeContainer.decode([TagModel].self, forKey: .tags) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift index c03a7302..4be1343a 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/HeartModel.swift @@ -5,7 +5,7 @@ // Created by Lekshmi S on 07/09/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol { @@ -38,6 +38,11 @@ open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol { case readOnly } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init() { } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift index fc299b50..27defd48 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift @@ -5,6 +5,7 @@ // Created by Dhamodaram Nandi on 31/03/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +import MVMCore @objcMembers public class RadioBoxModel: MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -43,6 +44,14 @@ case readOnly } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(text: String) { + self.text = text + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift index 7e919553..852cd5c1 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxesModel.swift @@ -5,6 +5,7 @@ // Created by Dhamodaram Nandi on 31/03/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +import MVMCore @objcMembers public class RadioBoxesModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- @@ -52,6 +53,14 @@ case groupName } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with boxes: [RadioBoxModel]){ + self.boxes = boxes + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchModel.swift index 059dd2c8..f0a194e9 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchModel.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 4/17/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore @objcMembers public class RadioSwatchModel: MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -42,6 +42,12 @@ case readOnly } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift index 7e475081..21541d35 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatchesModel.swift @@ -5,7 +5,7 @@ // Created by Lekshmi S on 31/03/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore @objcMembers public class RadioSwatchesModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- @@ -50,6 +50,14 @@ case readOnly } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with swatches: [RadioSwatchModel]){ + self.swatches = swatches + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift index 9dc43286..1e2595ec 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift @@ -7,7 +7,7 @@ // import Foundation - +import MVMCore @objcMembers public class CaretViewModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -38,6 +38,12 @@ import Foundation case inverted } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index f3665eb0..239b5b1f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore public enum CheckboxPosition: String, Codable { case center @@ -16,9 +17,18 @@ public enum CheckboxPosition: String, Codable { @objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" - public var moleculeName: String public var backgroundColor: Color? public var checkboxAlignment: CheckboxPosition? public var checkbox: CheckboxModel public var label: LabelModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(checkbox: CheckboxModel, label: LabelModel) { + self.checkbox = checkbox + self.label = label + } + } diff --git a/MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift index c4375d53..95cc40fd 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/DashLineModel.swift @@ -7,7 +7,7 @@ // import Foundation - +import MVMCore @objcMembers public class DashLineModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -43,6 +43,12 @@ import Foundation case isHidden } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + //-------------------------------------------------- // MARK: - codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift index bdef3c86..ddfba326 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift @@ -7,7 +7,7 @@ // import Foundation - +import MVMCore open class LoadingSpinnerModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -32,6 +32,12 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { case diameter } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift index dc404a71..56f4f7ad 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift @@ -5,6 +5,7 @@ // Created by Lekshmi S on 15/09/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +import MVMCore open class StarModel: MoleculeModelProtocol { @@ -30,6 +31,12 @@ open class StarModel: MoleculeModelProtocol { case size } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift b/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift index 91470100..f79f638e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift @@ -5,6 +5,7 @@ // Created by Lekshmi S on 21/09/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +import MVMCore @objcMembers public class StarsModel: MoleculeModelProtocol { @@ -34,6 +35,14 @@ case size } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with stars: [StarModel]) { + self.stars = stars + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift index 3e8d4340..d2d01d45 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift @@ -7,10 +7,10 @@ // import Foundation +import MVMCore @objcMembers public class WebViewModel: MoleculeModelProtocol { public static var identifier: String = "webview" - public var moleculeName: String = WebViewModel.identifier public var backgroundColor: Color? public var url: URL? public var htmlString: String? @@ -30,6 +30,12 @@ import Foundation case borderColor } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift index f7df0c3a..7e402ca9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnInternationalDataDividerModel.swift @@ -23,7 +23,7 @@ public class ListThreeColumnInternationalDataDividerModel: ListItemModel, Molecu // MARK: - Initializers //------------------------------------------------------ - public init (leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { self.leftLabel = leftLabel self.centerLabel = centerLabel self.rightLabel = rightLabel diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift index 014030ce..2a9dbd49 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift @@ -7,7 +7,7 @@ // import Foundation - +import MVMCore @objcMembers public class RadioButtonLabelModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -16,7 +16,16 @@ import Foundation public static var identifier: String = "radioButtonLabel" public var backgroundColor: Color? - public var moleculeName: String public var radioButton: RadioButtonModel public var label: LabelModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(radioButton: RadioButtonModel, label: LabelModel) { + self.radioButton = radioButton + self.label = label + } + } diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift index b4f39881..a864d1c2 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionListItemModel.swift @@ -42,6 +42,15 @@ class AccordionListItemModel: MoleculeListItemModel { hideArrow = true } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with moleculeModel: MoleculeModelProtocol, molecules:[ListItemModelProtocol & MoleculeModelProtocol]) { + self.molecules = molecules + super.init(with: moleculeModel) + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift index 4cd2db26..7c8bd202 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -14,4 +14,14 @@ public class ActionDetailWithImageModel: MoleculeModelProtocol { public var backgroundColor: Color? public var headlineBodyButton: HeadlineBodyButtonModel public var image: ImageViewModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(headlineBodyButton: HeadlineBodyButtonModel, image: ImageViewModel) { + self.headlineBodyButton = headlineBodyButton + self.image = image + } + } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index cff8be23..70a08d3b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 1/22/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore public class HeadlineBodyButtonModel: MoleculeModelProtocol { //-------------------------------------------------- @@ -20,6 +20,16 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { public var button: ButtonModel public var buttonHeadlinePadding: CGFloat + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(headlineBody: HeadlineBodyModel, button: ButtonModel, buttonHeadlinePadding: CGFloat) { + self.headlineBody = headlineBody + self.button = button + self.buttonHeadlinePadding = buttonHeadlinePadding + } + //-------------------------------------------------- // MARK: - Method //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index 874868e5..00098d91 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -20,6 +20,15 @@ import Foundation case list case numberColor } + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(numberColor: Color, molecules: [StackItemModelProtocol & MoleculeModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { + self.numberColor = numberColor + super.init(molecules: molecules, axis: axis, spacing: spacing) + } // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 9ba49c1a..3bff1575 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -22,7 +22,17 @@ import Foundation case bulletChar case bulletColor } - + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(bulletChar: String, bulletColor: Color, molecules: [StackItemModelProtocol & MoleculeModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) { + self.bulletChar = bulletChar + self.bulletColor = bulletColor + super.init(molecules: molecules, axis: axis, spacing: spacing) + } + // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift index d0f4d456..09f71914 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 10/8/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore @objcMembers public class ModalSectionListTemplateModel: SectionListTemplateModel { //-------------------------------------------------- @@ -15,6 +15,14 @@ public override class var identifier: String { "modalSectionList" } public var closeAction: ActionModelProtocol? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public override init(with sections: [SectionModel], pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { + super.init(with: sections, pageType: pageType, screenHeading: screenHeading, molecules: molecules) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ModalStackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ModalStackPageTemplateModel.swift index 3e8d2363..5cbb864a 100644 --- a/MVMCoreUI/Atomic/Templates/ModalStackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ModalStackPageTemplateModel.swift @@ -15,6 +15,14 @@ public override class var identifier: String { "modalStack" } public var closeAction: ActionModelProtocol? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public override init(pageType: String, moleculeStack: StackModel) { + super.init(pageType: pageType, moleculeStack: moleculeStack) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -24,7 +32,7 @@ } //-------------------------------------------------- - // MARK: - Init + // MARK: - Initializer //-------------------------------------------------- required public init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift b/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift index 609e4cc0..7a6ec169 100644 --- a/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift @@ -19,6 +19,14 @@ public protocol SectionListHeaderFooterModel { } public var footer: (SectionListHeaderFooterModel & MoleculeModelProtocol)? public var rows: [ListItemModelProtocol & MoleculeModelProtocol] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with rows: [ListItemModelProtocol & MoleculeModelProtocol]) { + self.rows = rows + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -65,6 +73,15 @@ public protocol SectionListHeaderFooterModel { } } } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with sections: [SectionModel], pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { + self.sections = sections + super.init(pageType: pageType, screenHeading: screenHeading, molecules: molecules) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift index 69b8599b..5b4f320f 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift @@ -19,6 +19,14 @@ public class RuleAllValueChangedModel: RulesProtocol { public var errorMessage: [String: String]? public var fields: [String] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(with fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Validation //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift index 38dd6669..c8b7b055 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift @@ -19,6 +19,14 @@ public class RuleAnyRequiredModel: RuleAnyModelProtocol { public var fields: [String] public var errorMessage: [String: String]? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift index 1d2c8faf..d52f59e2 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift @@ -19,6 +19,14 @@ public class RuleAnyValueChangedModel: RuleAnyModelProtocol { public var errorMessage: [String: String]? public var fields: [String] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Validation //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsIgnoreCaseModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsIgnoreCaseModel.swift index 4149737e..ab7f21b6 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsIgnoreCaseModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsIgnoreCaseModel.swift @@ -20,6 +20,14 @@ public class RuleEqualsIgnoreCaseModel: RuleCompareModelProtocol { public var fields: [String] public var errorMessage: [String: String]? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Validation //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift index c8a8aa56..be7391ec 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift @@ -19,6 +19,14 @@ public class RuleEqualsModel: RuleCompareModelProtocol { public var fields: [String] public var errorMessage: [String: String]? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Validation //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift index 48e4582b..e654210a 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift @@ -18,6 +18,15 @@ public class RuleRegexModel: RulesProtocol { public var regex: String public var errorMessage: [String: String]? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String], regex: String) { + self.fields = fields + self.regex = regex + } + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift index f401721b..a0b51600 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift @@ -20,6 +20,14 @@ public class RuleRequiredModel: RulesProtocol { public var errorMessage: [String: String]? public var fields: [String] + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + //-------------------------------------------------- // MARK: - Validation //-------------------------------------------------- From 33ad5a3630c832d69c29aea7e7d4e5e3c9935025 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 21 Jun 2022 15:11:42 -0500 Subject: [PATCH 096/102] added override intializer for subclasses Signed-off-by: Matt Bruce --- .../Atoms/FormFields/TextFields/TextEntryFieldModel.swift | 8 ++++++++ .../Atoms/Views/Label/LabelAttributeFontModel.swift | 8 ++++++++ .../Atoms/Views/Label/LabelAttributeImageModel.swift | 8 ++++++++ .../HeadersAndFooters/MoleculeSectionHeaderModel.swift | 7 +++++++ .../Atomic/Templates/ModalListPageTemplateModel.swift | 8 ++++++++ 5 files changed, 39 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift index 7c2dfa9b..7d2eb987 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift @@ -38,6 +38,14 @@ public var displayFormat: String? public var displayMask: String? + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public override init(with text: String){ + super.init(with: text) + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift index 72d57e40..6a2a1af5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift @@ -18,6 +18,14 @@ var name: String? var size: CGFloat? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public override init(_ location: Int, _ length: Int) { + super.init(location, length) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift index 12e8d68d..7396e749 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift @@ -18,6 +18,14 @@ class LabelAttributeImageModel: LabelAttributeModel { var name: String? var URL: String? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public override init(_ location: Int, _ length: Int) { + super.init(location, length) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift index 47db5cbf..12201722 100644 --- a/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HeadersAndFooters/MoleculeSectionHeaderModel.swift @@ -14,6 +14,13 @@ public class override var identifier: String { "sectionHeader" } public var line: LineModel? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public override init(with moleculeModel: MoleculeModelProtocol) { + super.init(with: moleculeModel) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ModalListPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ModalListPageTemplateModel.swift index 9459aab6..f1208274 100644 --- a/MVMCoreUI/Atomic/Templates/ModalListPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ModalListPageTemplateModel.swift @@ -16,6 +16,14 @@ public var closeAction: ActionModelProtocol? + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public override init(pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { + super.init(pageType: pageType, screenHeading: screenHeading, molecules: molecules) + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- From d90503e9886cc9f1334cb3612c10bc428d4ce41f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 21 Jun 2022 15:12:53 -0500 Subject: [PATCH 097/102] added 'public' to current initializers Signed-off-by: Matt Bruce --- .../Atoms/Views/Video/VisibleBehaviorForVideoModel.swift | 2 +- .../Molecules/LeftRightViews/CornerLabelsModel.swift | 3 ++- .../LeftRightViews/ToggleMolecules/LabelToggleModel.swift | 3 ++- .../BGImageHeadlineBodyButtonModel.swift | 2 +- .../HeadlineBodyCaretLinkImageModel.swift | 2 +- MVMCoreUI/Containers/Views/Container.swift | 2 +- .../FormFieldEffect/ClearFormFieldEffectModel.swift | 6 +++++- .../FormFieldEffect/DisableFormFieldEffectModel.swift | 8 ++++++-- .../FormFieldEffect/DynamicRuleFormFieldEffectModel.swift | 6 +++++- .../FormFieldEffect/EnableFormFieldEffectModel.swift | 6 +++++- .../FormFieldEffect/HideFormFieldEffectModel.swift | 8 ++++++-- 11 files changed, 35 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Video/VisibleBehaviorForVideoModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Video/VisibleBehaviorForVideoModel.swift index 45734dac..44137b96 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Video/VisibleBehaviorForVideoModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Video/VisibleBehaviorForVideoModel.swift @@ -14,7 +14,7 @@ open class VisibleBehaviorForVideoModel: PageBehaviorModelProtocol { public var shouldAllowMultipleInstances: Bool = true public weak var videoModel: VideoModel? - init(with videoModel: VideoModel) { + public init(with videoModel: VideoModel) { self.videoModel = videoModel } } diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift index 5c910298..aabd29e7 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -7,6 +7,7 @@ // import UIKit +import MVMCore public class CornerLabelsModel: ParentMoleculeModelProtocol { public static var identifier: String = "cornerLabels" @@ -20,7 +21,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol { [molecule, topLeftLabel, topRightLabel, bottomLeftLabel, bottomRightLabel].compactMap { $0 } } - init(with molecule: MoleculeModelProtocol?) { + public init(with molecule: MoleculeModelProtocol?) { self.molecule = molecule } diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 29e7a609..ee0c5f78 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" @@ -15,7 +16,7 @@ public class LabelToggleModel: MoleculeModelProtocol { public var label: LabelModel public var toggle: ToggleModel - init(_ label: LabelModel, _ toggle: ToggleModel) { + public init(_ label: LabelModel, _ toggle: ToggleModel) { self.label = label self.toggle = toggle } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift index 7c4215c2..99ee1567 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/BGImageHeadlineBodyButtonModel.swift @@ -22,7 +22,7 @@ public class BGImageHeadlineBodyButtonModel: ContainerModel, MoleculeModelProtoc // MARK: - Initializer //-------------------------------------------------- - init(headlineBody: HeadlineBodyModel, image: ImageViewModel) { + public init(headlineBody: HeadlineBodyModel, image: ImageViewModel) { self.headlineBody = headlineBody self.image = image super.init() diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift index 2a3d844a..5d7752fe 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyCaretLinkImageModel.swift @@ -22,7 +22,7 @@ public class HeadlineBodyCaretLinkImageModel: ContainerModel, MoleculeModelProto // MARK: - Initializer //-------------------------------------------------- - init(headlineBody: HeadlineBodyModel, image: ImageViewModel) { + public init(headlineBody: HeadlineBodyModel, image: ImageViewModel) { self.headlineBody = headlineBody self.image = image super.init() diff --git a/MVMCoreUI/Containers/Views/Container.swift b/MVMCoreUI/Containers/Views/Container.swift index 5b2e83eb..32c22b54 100644 --- a/MVMCoreUI/Containers/Views/Container.swift +++ b/MVMCoreUI/Containers/Views/Container.swift @@ -75,7 +75,7 @@ open class Container: View, ContainerProtocol { self.view = view } - convenience init(andContain view: UIView) { + public convenience init(andContain view: UIView) { self.init() addAndContain(view) } diff --git a/MVMCoreUI/FormUIHelpers/FormFieldEffect/ClearFormFieldEffectModel.swift b/MVMCoreUI/FormUIHelpers/FormFieldEffect/ClearFormFieldEffectModel.swift index 173c0e33..32a18c6b 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldEffect/ClearFormFieldEffectModel.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldEffect/ClearFormFieldEffectModel.swift @@ -20,7 +20,11 @@ public class ClearFormFieldEffectModel: FormFieldEffectProtocol { public var activatedRuleIds: [String]? public var rules: [RulesProtocol] - init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { self.fieldKey = fieldKey self.activatedRuleIds = activatedRuleIds self.rules = rules diff --git a/MVMCoreUI/FormUIHelpers/FormFieldEffect/DisableFormFieldEffectModel.swift b/MVMCoreUI/FormUIHelpers/FormFieldEffect/DisableFormFieldEffectModel.swift index 09fbb6e3..ea0a718e 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldEffect/DisableFormFieldEffectModel.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldEffect/DisableFormFieldEffectModel.swift @@ -18,8 +18,12 @@ public class DisableFormFieldEffectModel: FormFieldEffectProtocol { public var fieldKey: String = "" public var activatedRuleIds: [String]? public var rules: [RulesProtocol] - - init(_ fieldKey: String, _ activatedRuleIds: [String], _ rules: [RulesProtocol]) { + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ fieldKey: String, _ activatedRuleIds: [String], _ rules: [RulesProtocol]) { self.fieldKey = fieldKey self.activatedRuleIds = activatedRuleIds self.rules = rules diff --git a/MVMCoreUI/FormUIHelpers/FormFieldEffect/DynamicRuleFormFieldEffectModel.swift b/MVMCoreUI/FormUIHelpers/FormFieldEffect/DynamicRuleFormFieldEffectModel.swift index 3a94f94b..38bfc79c 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldEffect/DynamicRuleFormFieldEffectModel.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldEffect/DynamicRuleFormFieldEffectModel.swift @@ -19,7 +19,11 @@ public class DynamicRuleFormFieldEffectModel: FormFieldEffectProtocol { public var activatedRuleIds: [String]? public var rules: [RulesProtocol] - init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { self.fieldKey = fieldKey self.activatedRuleIds = activatedRuleIds self.rules = rules diff --git a/MVMCoreUI/FormUIHelpers/FormFieldEffect/EnableFormFieldEffectModel.swift b/MVMCoreUI/FormUIHelpers/FormFieldEffect/EnableFormFieldEffectModel.swift index f4537bb6..271e57ea 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldEffect/EnableFormFieldEffectModel.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldEffect/EnableFormFieldEffectModel.swift @@ -21,7 +21,11 @@ public class EnableFormFieldEffectModel: FormFieldEffectProtocol { public var activatedRuleIds: [String]? public var rules: [RulesProtocol] - init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ fieldKey: String, activatedRuleIds: [String], rules: [RulesProtocol]) { self.fieldKey = fieldKey self.activatedRuleIds = activatedRuleIds self.rules = rules diff --git a/MVMCoreUI/FormUIHelpers/FormFieldEffect/HideFormFieldEffectModel.swift b/MVMCoreUI/FormUIHelpers/FormFieldEffect/HideFormFieldEffectModel.swift index 451dbe83..37929e12 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldEffect/HideFormFieldEffectModel.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldEffect/HideFormFieldEffectModel.swift @@ -18,8 +18,12 @@ public class HideFormFieldEffectModel: FormFieldEffectProtocol { public var fieldKey: String = "" public var activatedRuleIds: [String]? public var rules: [RulesProtocol] - - init(_ fieldKey: String, _ activatedRuleIds: [String], _ rules: [RulesProtocol]) { + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(_ fieldKey: String, _ activatedRuleIds: [String], _ rules: [RulesProtocol]) { self.fieldKey = fieldKey self.activatedRuleIds = activatedRuleIds self.rules = rules From 0a5c9b78eda7633298b255e9cbf02394edd60503 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 21 Jun 2022 16:26:57 -0400 Subject: [PATCH 098/102] Switch to UIStackView for simplicity. update inits. update didSets Removed style, allow dependency on title style like in the figma. --- .../LockUps/TitleLockup.swift | 15 +- .../LockUps/TitleLockupModel.swift | 183 +++++++++--------- 2 files changed, 103 insertions(+), 95 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift index bc069b27..b48e4ddb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift @@ -14,11 +14,11 @@ public let eyebrow = Label(fontStyle: .RegularBodySmall) public let title = Label(fontStyle: .RegularBodySmall) public let subTitle = Label(fontStyle: .RegularBodySmall) - public lazy var stack: Stack = { - return Stack.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .fill)), - (view: title, model: StackItemModel(horizontalAlignment: .fill)), - (view: subTitle, model: StackItemModel(horizontalAlignment: .fill))], - axis: .vertical) + public lazy var stack: UIStackView = { + let stack = UIStackView(arrangedSubviews: [eyebrow, title, subTitle]) + stack.translatesAutoresizingMaskIntoConstraints = false + stack.axis = .vertical + return stack }() var castModel: TitleLockupModel? { @@ -41,12 +41,10 @@ super.setupView() addSubview(stack) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) - stack.restack() } open override func updateView(_ size: CGFloat) { super.updateView(size) - stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? TitleLockupModel.Style.large.defaultSpacing() stack.updateView(size) } @@ -66,7 +64,8 @@ open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? TitleLockupModel else { return } - + stack.setCustomSpacing(model.defaultEyebrowTitleSpacing(), after: eyebrow) + stack.setCustomSpacing(model.defaultTitleSubTitleSpacing(), after: title) stack.updateContainedMolecules(with: [model.eyebrow, model.title, model.subTitle], diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift index a4351cf4..4548207d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift @@ -21,9 +21,25 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco public var title: LabelModel public var subTitle: LabelModel? - public var style: Style = .large - public var alignment: Alignment = .left - public var inverted: Bool = false + public var alignment: Alignment = .left { + didSet { + ///Updating the text alignment for all labels + if let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) { + eyebrow?.textAlignment = textAlignment + title.textAlignment = textAlignment + subTitle?.textAlignment = textAlignment + } + } + } + + public var inverted: Bool = false { + didSet { + ///Updating the text color + eyebrow?.textColor = titleColor + title.textColor = titleColor + subTitle?.textColor = subTitleColor + } + } private var _backgroundColor: Color? public var backgroundColor: Color? { @@ -52,68 +68,63 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco //-------------------------------------------------- public init(eyebrow: LabelModel? = nil, title: LabelModel, subTitle: LabelModel? = nil) throws { - self.eyebrow = eyebrow self.title = title self.subTitle = subTitle + updateLabelAttributes() } //-------------------------------------------------- // MARK: - Enum //-------------------------------------------------- - /// Convenience styles for common situations. - public enum Style: String, Codable { - case small - case medium - case large - case xlarge - case xxlarge - - func defaultHeadlineFontStyle() -> Styler.Font { - - switch self { - case .small: - return .BoldBodyLarge - case .medium: - return .BoldTitleMedium - case .large: - return .BoldTitleLarge - case .xlarge: - return .TitleXLarge - case .xxlarge: - return .Title2XLarge - } - } - - func defaultBodyFontStyle() -> Styler.Font { - - switch self { - case .small,.medium,.large: - return .RegularBodySmall - case .xlarge,.xxlarge: - return .RegularBodyLarge - } - } - - func defaultSpacing() -> CGFloat { - - switch self { - case .small,.medium,.large: - return Padding.Two - case .xlarge: - return Padding.Three - case .xxlarge: - return Padding.Four - } - } - } - public enum Alignment: String, Codable { case left case center } + //-------------------------------------------------- + // MARK: - Styling + //-------------------------------------------------- + + /// Returns the default fontStyle for the subtitle, based on the title fontStyle. + func defaultSubtitleFontStyle() -> Styler.Font { + switch title.fontStyle { + case .RegularTitleXLarge, .RegularTitle2XLarge, .RegularFeatureXSmall: + return .RegularBodyLarge + case .RegularFeatureSmall, .RegularFeatureMedium: + return .RegularTitleLarge + default: + return .RegularBodySmall + } + } + + /// Returns the default spacing between the eyebrow and title, based on the title fontStyle. + func defaultEyebrowTitleSpacing() -> CGFloat { + switch title.fontStyle { + case .RegularTitleXLarge, .RegularTitle2XLarge, .RegularFeatureXSmall, .RegularFeatureSmall: + return Padding.Three + case .RegularFeatureMedium: + return subTitle?.fontStyle == .RegularBodyLarge ? Padding.Three : Padding.Four + default: + return Padding.Two + } + } + + /// Returns the default spacing between the title and subTitle, based on the title fontStyle. + func defaultTitleSubTitleSpacing() -> CGFloat { + switch title.fontStyle { + case .RegularTitleXLarge: + return Padding.Three + case .RegularTitle2XLarge, .RegularFeatureXSmall, .RegularFeatureSmall: + return Padding.Four + case .RegularFeatureMedium: + return Padding.Five + default: + return Padding.Two + } + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -126,7 +137,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco case subTitle case inverted case alignment - case style } //-------------------------------------------------- @@ -135,14 +145,9 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) title = try typeContainer.decodeMolecule(codingKey: .title) + eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle) - - if let newStyle = try typeContainer.decodeIfPresent(Style.self, forKey: .style) { - style = newStyle - setStyle(style: newStyle) - } if let newAlignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) { alignment = newAlignment @@ -151,7 +156,9 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco if let invertedStatus = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { inverted = invertedStatus } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + updateLabelAttributes() } @@ -161,7 +168,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco try container.encodeIfPresent(eyebrow, forKey: .eyebrow) try container.encodeModel(title, forKey: .title) try container.encodeIfPresent(subTitle, forKey: .subTitle) - try container.encodeIfPresent(style, forKey: .style) try container.encode(alignment, forKey: .alignment) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) @@ -170,37 +176,40 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco //-------------------------------------------------- // MARK: - Model updates //-------------------------------------------------- - - private func setStyle(style: Style) { - - ///If eyebrow style is not available, will set font style based on the component - ///Eyebrow and body share the same font size - if eyebrow?.fontStyle == nil { - eyebrow?.fontStyle = style.defaultBodyFontStyle() - } - - ///If title style is not available, will set font style based on the component - if title.fontStyle == nil { - title.fontStyle = style.defaultHeadlineFontStyle() - } - - ///If subtitle style is not available, will set font style based on the component - if subTitle?.fontStyle == nil { - subTitle?.fontStyle = style.defaultBodyFontStyle() - } - } - + private func updateLabelAttributes() { - ///Updating the text color - eyebrow?.textColor = titleColor - title.textColor = titleColor - subTitle?.textColor = subTitleColor + // If subtitle style is not available, will set font style based on the component + if subTitle?.fontStyle == nil { + subTitle?.fontStyle = defaultSubtitleFontStyle() + } - ///Updating the text alignment for all labels + // If eyebrow style is not available, will set font style based on the component. Eyebrow and subtitle share the same font size + if eyebrow?.fontStyle == nil { + eyebrow?.fontStyle = subTitle?.fontStyle + } + + // Updating the text color + if eyebrow?.textColor == nil { + eyebrow?.textColor = subTitleColor + } + if title.textColor == nil { + title.textColor = titleColor + } + if subTitle?.textColor == nil { + subTitle?.textColor = subTitleColor + } + + // Updating the text alignment for all labels if let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) { - eyebrow?.textAlignment = textAlignment - title.textAlignment = textAlignment - subTitle?.textAlignment = textAlignment + if eyebrow?.textAlignment == nil { + eyebrow?.textAlignment = textAlignment + } + if title.textAlignment == nil { + title.textAlignment = textAlignment + } + if subTitle?.textAlignment == nil { + subTitle?.textAlignment = textAlignment + } } } } From 93d23d620d3388015d0c857dfc65c9cbad634894 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 21 Jun 2022 15:47:14 -0500 Subject: [PATCH 099/102] added default value Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift b/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift index 7a6ec169..023acae5 100644 --- a/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/SectionListTemplateModel.swift @@ -77,7 +77,7 @@ public protocol SectionListHeaderFooterModel { } // MARK: - Initializer //-------------------------------------------------- - public init(with sections: [SectionModel], pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { + public init(with sections: [SectionModel], pageType: String, molecules: [ListItemModelProtocol & MoleculeModelProtocol], screenHeading: String? = nil) { self.sections = sections super.init(pageType: pageType, screenHeading: screenHeading, molecules: molecules) } From 5efd98b5b71557e53569ab774518972518a70bd4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 Jun 2022 09:31:56 -0500 Subject: [PATCH 100/102] fixed variable order bug Signed-off-by: Matt Bruce --- .../Atomic/Templates/ModalSectionListTemplateModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift index 09f71914..582ce0ed 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplateModel.swift @@ -19,8 +19,8 @@ import MVMCore // MARK: - Initializer //-------------------------------------------------- - public override init(with sections: [SectionModel], pageType: String, screenHeading: String?, molecules: [ListItemModelProtocol & MoleculeModelProtocol]) { - super.init(with: sections, pageType: pageType, screenHeading: screenHeading, molecules: molecules) + public override init(with sections: [SectionModel], pageType: String, molecules: [ListItemModelProtocol & MoleculeModelProtocol], screenHeading: String?) { + super.init(with: sections, pageType: pageType, molecules: molecules, screenHeading: screenHeading) } //-------------------------------------------------- From 63184f3c609d33c0a0c5ebcb844ff5a9074ae3c0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 24 Jun 2022 10:19:09 -0500 Subject: [PATCH 101/102] added property back for the Swift Default Encoding issue with Extensions Signed-off-by: Matt Bruce --- .../HorizontalCombinationViews/RadioButtonLabelModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift index 2a9dbd49..69bca3fc 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/RadioButtonLabelModel.swift @@ -16,6 +16,7 @@ import MVMCore public static var identifier: String = "radioButtonLabel" public var backgroundColor: Color? + public var moleculeName: String = RadioButtonLabelModel.identifier public var radioButton: RadioButtonModel public var label: LabelModel From 60d3e2f47c24071cb5b053c1a832a12693e06624 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 24 Jun 2022 10:33:49 -0500 Subject: [PATCH 102/102] added back moleculeName for issue with Swift Default encoder Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift | 1 + MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index 239b5b1f..858984b0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -17,6 +17,7 @@ public enum CheckboxPosition: String, Codable { @objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" + public var moleculeName: String = CheckboxLabelModel.identifier public var backgroundColor: Color? public var checkboxAlignment: CheckboxPosition? public var checkbox: CheckboxModel diff --git a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift index d2d01d45..4cb2bd55 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift @@ -11,6 +11,7 @@ import MVMCore @objcMembers public class WebViewModel: MoleculeModelProtocol { public static var identifier: String = "webview" + public var moleculeName: String = WebViewModel.identifier public var backgroundColor: Color? public var url: URL? public var htmlString: String?