Signed-off-by: Jarrod Courtney <jarrod.courtney@verizon.com>

This commit is contained in:
Jarrod Courtney 2024-10-15 14:52:39 -05:00
parent f3e97ecfd4
commit cb8fc9efa2
3 changed files with 22 additions and 6 deletions

View File

@ -7,6 +7,7 @@
//
import Foundation
import VDSCoreTokens
@objcMembers open class ImageButton: Button {
@ -24,6 +25,7 @@ import Foundation
super.set(with: model, delegateObject, additionalData)
return
}
image.setOptional(with: castModel.image, delegateObject, additionalData)
castModel.updateUI = { [weak self] in
MVMCoreDispatchUtility.performBlock(onMainThread: {
@ -42,10 +44,10 @@ import Foundation
}
if castModel.enabled {
if let enabledTintColor = castModel.enabledTintColor {
image.imageView.tintColor = enabledTintColor.uiColor
image.tintColor = enabledTintColor.uiColor
}
} else if let disabledTintColor = castModel.disabledTintColor {
image.imageView.tintColor = disabledTintColor.uiColor
image.tintColor = disabledTintColor.uiColor
}
if let traits = model?.accessibilityTraits {
accessibilityTraits = traits

View File

@ -30,6 +30,7 @@
public var clipsImage: Bool?
public var allowServerParameters: Bool?
public var shouldMaskRecordedView: Bool? = false
public var tintColor: Color?
//--------------------------------------------------
// MARK: - Initializer
@ -62,6 +63,7 @@
case clipsImage
case shouldMaskRecordedView
case allowServerParameters
case tintColor
}
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {

View File

@ -36,6 +36,7 @@
private var currentImageHeight: CGFloat?
private var currentImageName: String?
private var isFallbackImage: Bool = false
private var renderingMode: UIImage.RenderingMode = .automatic
private var containerHelper = ContainerHelper()
@ -44,6 +45,12 @@
set { imageView.accessibilityLabel = newValue }
}
open override var tintColor: UIColor! {
didSet {
renderingMode = tintColor != nil ? .alwaysTemplate : .automatic
}
}
//--------------------------------------------------
// MARK: - Constraint Properties
//--------------------------------------------------
@ -127,12 +134,13 @@
open func defaultCompletionBlock() -> MVMCoreGetImageBlock {
return { image, gifData,_ in MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in
guard let self else { return }
if let image = image {
self?.imageView.image = image
self?.layoutIfNeeded()
imageView.image = image.withRenderingMode(renderingMode)
layoutIfNeeded()
} else if let gifData = gifData {
self?.imageView.loadGifWithData(gifData)
self?.layoutIfNeeded()
imageView.loadGifWithData(gifData)
layoutIfNeeded()
}
})}
}
@ -274,6 +282,10 @@
imageView.isAccessibilityElement = true
}
if let color = imageModel.tintColor?.uiColor {
tintColor = color
}
let width = imageModel.width ?? imageWidth
let height = imageModel.height ?? imageHeight