adding titleView support on navigationBar
This commit is contained in:
parent
33ca1a0517
commit
65d2129653
@ -22,6 +22,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
||||
public var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? = NavigationImageButtonModel(with: "nav_back", action: ActionBackModel())
|
||||
public var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||
public var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||
public var titleView: MoleculeModelProtocol?
|
||||
|
||||
public init() {
|
||||
hidden = false
|
||||
@ -43,6 +44,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
||||
case showRightPanelButton
|
||||
case additionalLeftButtons
|
||||
case additionalRightButtons
|
||||
case titleView
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
@ -58,6 +60,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
||||
}
|
||||
additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons)
|
||||
additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons)
|
||||
titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView)
|
||||
}
|
||||
|
||||
open func encode(to encoder: Encoder) throws {
|
||||
@ -72,5 +75,6 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
||||
try container.encodeModelIfPresent(backButton, forKey: .backButton)
|
||||
try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons)
|
||||
try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons)
|
||||
try container.encodeModelIfPresent(titleView, forKey: .titleView)
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,4 +18,5 @@ public protocol NavigationItemModelProtocol {
|
||||
var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set }
|
||||
var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||
var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||
var titleView: MoleculeModelProtocol? { get set }
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol TabPageModelProtocol {
|
||||
public protocol TabPageModelProtocol : ModelProtocol {
|
||||
var tabBarHidden: Bool { get set }
|
||||
var tabBarIndex: Int? { get set }
|
||||
}
|
||||
|
||||
@ -37,6 +37,8 @@ public extension MVMCoreUISplitViewController {
|
||||
|
||||
setNavigationIconColor(navigationItemModel.tintColor.uiColor)
|
||||
|
||||
setNavigationTitle(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
|
||||
if let progress = progress {
|
||||
setBottomProgressBarProgress(progress)
|
||||
}
|
||||
@ -108,6 +110,14 @@ public extension MVMCoreUISplitViewController {
|
||||
viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue)
|
||||
}
|
||||
|
||||
/// Sets the title of navigation item for the view controller based on model and splitview.
|
||||
func setNavigationTitle(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||
if let titleViewModel = navigationItemModel?.titleView, let molecule = MoleculeObjectMapping.shared()?.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) {
|
||||
viewController.navigationItem.titleView = molecule
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Legacy Functions
|
||||
/// Convenience setter for legacy files. Sets the navigation item for the view controller based on the json and splitview controller
|
||||
@objc static func setSplitViewController(for viewController: UIViewController, navigationController: UINavigationController, navigationJSON: [String: Any], leftPanelAccessible: Bool, rightPanelAccessible: Bool, progress: NSNumber?) throws {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user