back button change
This commit is contained in:
parent
ecd4cf9227
commit
206017443e
@ -18,7 +18,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var tintColor: Color
|
public var tintColor: Color
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
public var alwaysShowBackButton = false
|
public var alwaysShowBackButton: Bool?
|
||||||
public var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? = NavigationImageButtonModel(with: "nav_back", action: ActionBackModel())
|
public var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? = NavigationImageButtonModel(with: "nav_back", action: ActionBackModel())
|
||||||
public var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
public var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||||
public var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
public var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||||
@ -52,7 +52,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white)
|
||||||
tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black)
|
tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .standard)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) ?? LineModel(type: .standard)
|
||||||
alwaysShowBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysShowBackButton) ?? false
|
alwaysShowBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysShowBackButton)
|
||||||
if let backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol) = try typeContainer.decodeModelIfPresent(codingKey: .backButton) {
|
if let backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol) = try typeContainer.decodeModelIfPresent(codingKey: .backButton) {
|
||||||
self.backButton = backButton
|
self.backButton = backButton
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
|||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(tintColor, forKey: .tintColor)
|
try container.encode(tintColor, forKey: .tintColor)
|
||||||
try container.encodeIfPresent(line, forKey: .line)
|
try container.encodeIfPresent(line, forKey: .line)
|
||||||
try container.encode(alwaysShowBackButton, forKey: .alwaysShowBackButton)
|
try container.encodeIfPresent(alwaysShowBackButton, forKey: .alwaysShowBackButton)
|
||||||
try container.encodeModelIfPresent(backButton, forKey: .backButton)
|
try container.encodeModelIfPresent(backButton, forKey: .backButton)
|
||||||
try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons)
|
try container.encodeModelsIfPresent(additionalLeftButtons, forKey: .additionalLeftButtons)
|
||||||
try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons)
|
try container.encodeModelsIfPresent(additionalRightButtons, forKey: .additionalRightButtons)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public protocol NavigationItemModelProtocol {
|
|||||||
var backgroundColor: Color? { get set }
|
var backgroundColor: Color? { get set }
|
||||||
var tintColor: Color { get set }
|
var tintColor: Color { get set }
|
||||||
var line: LineModel? { get set }
|
var line: LineModel? { get set }
|
||||||
var alwaysShowBackButton: Bool { get set }
|
var alwaysShowBackButton: Bool? { get set }
|
||||||
var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set }
|
var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set }
|
||||||
var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||||
var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||||
|
|||||||
@ -47,13 +47,15 @@ import UIKit
|
|||||||
public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) {
|
public static func setNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) {
|
||||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
var leftItems: [UIBarButtonItem] = []
|
var leftItems: [UIBarButtonItem] = []
|
||||||
if let backButtonModel = navigationItemModel.backButton,
|
if navigationItemModel.alwaysShowBackButton != false {
|
||||||
navigationController.viewControllers.count > 1 || navigationItemModel.alwaysShowBackButton {
|
if let backButtonModel = navigationItemModel.backButton,
|
||||||
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
navigationController.viewControllers.count > 1 || navigationItemModel.alwaysShowBackButton ?? false {
|
||||||
}
|
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||||
if let leftItemModels = navigationItemModel.additionalLeftButtons {
|
}
|
||||||
for item in leftItemModels {
|
if let leftItemModels = navigationItemModel.additionalLeftButtons {
|
||||||
leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
for item in leftItemModels {
|
||||||
|
leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil
|
viewController.navigationItem.leftBarButtonItems = leftItems.count > 0 ? leftItems : nil
|
||||||
|
|||||||
@ -48,13 +48,15 @@ public extension MVMCoreUISplitViewController {
|
|||||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
|
|
||||||
// Add back button first.
|
// Add back button first.
|
||||||
if let backButtonModel = navigationItemModel?.backButton {
|
if navigationItemModel?.alwaysShowBackButton != false {
|
||||||
if navigationController.viewControllers.count > 1 || navigationItemModel!.alwaysShowBackButton {
|
if let backButtonModel = navigationItemModel?.backButton {
|
||||||
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
if navigationController.viewControllers.count > 1 || navigationItemModel!.alwaysShowBackButton ?? false {
|
||||||
|
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||||
|
}
|
||||||
|
} else if let backButton = backButton,
|
||||||
|
navigationController.viewControllers.count > 1 {
|
||||||
|
leftItems.append(backButton)
|
||||||
}
|
}
|
||||||
} else if let backButton = backButton,
|
|
||||||
navigationController.viewControllers.count > 1 {
|
|
||||||
leftItems.append(backButton)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the panel button after the back button.
|
// Add the panel button after the back button.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user