Merge branch 'feature/navigation_updates' into 'develop'
Feature/navigation updates See merge request BPHV_MIPS/mvm_core_ui!486
This commit is contained in:
commit
c78c7e2c0b
@ -11,34 +11,34 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public static var identifier: String = "navigationImageButton"
|
public static var identifier: String = "navigationImageButton"
|
||||||
|
|
||||||
public var imageName: String
|
public var image: String
|
||||||
public var action: ActionModelProtocol
|
public var action: ActionModelProtocol
|
||||||
|
|
||||||
public init(with imageName: String, action: ActionModelProtocol) {
|
public init(with image: String, action: ActionModelProtocol) {
|
||||||
self.imageName = imageName
|
self.image = image
|
||||||
self.action = action
|
self.action = action
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case imageName
|
case image
|
||||||
case action
|
case action
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
imageName = try typeContainer.decode(String.self, forKey: .imageName)
|
image = try typeContainer.decode(String.self, forKey: .image)
|
||||||
action = try typeContainer.decodeModel(codingKey: .action)
|
action = try typeContainer.decodeModel(codingKey: .action)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(imageName, forKey: .imageName)
|
try container.encode(image, forKey: .image)
|
||||||
try container.encodeModel(action, forKey: .action)
|
try container.encodeModel(action, forKey: .action)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function that creates a BarButtonItem for the model.
|
/// Convenience function that creates a BarButtonItem for the model.
|
||||||
public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem {
|
public func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> UIBarButtonItem {
|
||||||
let image = UIImage(named: imageName, in: MVMCoreCache.shared()?.bundleToUseForImages(), compatibleWith: nil)
|
let imageName = UIImage(named: image, in: MVMCoreCache.shared()?.bundleToUseForImages(), compatibleWith: nil)
|
||||||
return ImageBarButtonItem.create(with: image, actionModel: action, delegateObject: delegateObject, additionalData: additionalData)
|
return ImageBarButtonItem.create(with: imageName, actionModel: action, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user