Added bgColor implementation in image
This commit is contained in:
parent
5d89ae873d
commit
d388f5be84
@ -252,6 +252,10 @@ import UIKit
|
|||||||
imageView.clipsToBounds = true
|
imageView.clipsToBounds = true
|
||||||
imageView.layer.cornerRadius = cornerRadius
|
imageView.layer.cornerRadius = cornerRadius
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let backgroundColor = imageModel.backgroundColor?.uiColor {
|
||||||
|
imageView.backgroundColor = backgroundColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - load functions
|
// MARK: - load functions
|
||||||
|
|||||||
@ -19,15 +19,7 @@ open class BGImageMolecule: MoleculeContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
guard let castModel = model as? BGImageMoleculeModel else {
|
image.setOptional(with: (model as? BGImageMoleculeModel)?.image, delegateObject, additionalData)
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
return
|
|
||||||
}
|
|
||||||
image.setOptional(with: castModel.image, delegateObject, additionalData)
|
|
||||||
super.set(with: castModel, delegateObject, additionalData)
|
|
||||||
if let cornerRadius = castModel.cornerRadius {
|
|
||||||
layer.cornerRadius = cornerRadius
|
|
||||||
clipsToBounds = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel {
|
|||||||
return "bgImageContainer"
|
return "bgImageContainer"
|
||||||
}
|
}
|
||||||
public var image: ImageViewModel
|
public var image: ImageViewModel
|
||||||
public var cornerRadius: CGFloat?
|
|
||||||
|
|
||||||
open override func setDefaults() {
|
open override func setDefaults() {
|
||||||
if useHorizontalMargins == nil {
|
if useHorizontalMargins == nil {
|
||||||
@ -32,7 +31,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel {
|
|||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case image
|
case image
|
||||||
case cornerRadius
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(_ image: ImageViewModel, molecule: MoleculeModelProtocol) {
|
public init(_ image: ImageViewModel, molecule: MoleculeModelProtocol) {
|
||||||
@ -43,7 +41,6 @@ open class BGImageMoleculeModel: MoleculeContainerModel {
|
|||||||
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)
|
||||||
image = try typeContainer.decode(ImageViewModel.self, forKey:.image)
|
image = try typeContainer.decode(ImageViewModel.self, forKey:.image)
|
||||||
cornerRadius = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .cornerRadius)
|
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +48,5 @@ open class BGImageMoleculeModel: MoleculeContainerModel {
|
|||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(image, forKey: .image)
|
try container.encode(image, forKey: .image)
|
||||||
try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user