Merge branch 'feature/atomic_vds_badgeIndicator_buttonIcon_tileContainer' into 'develop'

Property Updates that were missing

### Summary 
VDS Integration for new Atomic Components for BadgeIndicator, ButtonIcon, TileContainer

### JIRA Ticket

- BadgeIndicator - https://onejira.verizon.com/browse/ONEAPP-6305
- ButtonIcon - https://onejira.verizon.com/browse/ONEAPP-6315 
- TileContainer - https://onejira.verizon.com/browse/ONEAPP-6679

Co-authored-by: Matt Bruce <matt.bruce@verizon.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1105
This commit is contained in:
Pfeil, Scott Robert 2024-04-25 20:25:19 +00:00
commit 9518e34d5d
4 changed files with 87 additions and 28 deletions

View File

@ -27,6 +27,14 @@ open class ButtonIcon: VDS.ButtonIcon, VDSMoleculeViewProtocol {
public func viewModelDidUpdate() { public func viewModelDidUpdate() {
surface = viewModel.surface surface = viewModel.surface
onClick = { [weak self] control in
guard let self, let viewModel = self.viewModel else { return }
MVMCoreUIActionHandler.performActionUnstructured(with: viewModel.action,
sourceModel: viewModel,
additionalData: self.additionalData,
delegateObject: self.delegateObject)
}
badgeIndicatorModel = viewModel.badgeIndicatorModel badgeIndicatorModel = viewModel.badgeIndicatorModel
kind = viewModel.kind kind = viewModel.kind
surfaceType = viewModel.surfaceType surfaceType = viewModel.surfaceType

View File

@ -51,19 +51,12 @@ open class TileContainer: VDS.TileContainer, VDSMoleculeViewProtocol{
} }
} }
// set backgroundImage
if let imageName = viewModel.backgroundImage { if let imageName = viewModel.backgroundImage {
loadImage(imageName) loadImage(imageName)
} }
padding = viewModel.padding //set action
color = viewModel.color
backgroundEffect = viewModel.backgroundEffect
aspectRatio = viewModel.aspectRatio
width = viewModel.width
height = viewModel.height
showBorder = viewModel.showBorder
showDropShadows = viewModel.showDropShadwows
//setup action
if let action = viewModel.action { if let action = viewModel.action {
//add the subscriber //add the subscriber
onClick = { [weak self] control in onClick = { [weak self] control in
@ -74,6 +67,18 @@ open class TileContainer: VDS.TileContainer, VDSMoleculeViewProtocol{
delegateObject: self.delegateObject) delegateObject: self.delegateObject)
} }
} }
//set the rest of the properties
surface = viewModel.surface
imageFallbackColor = viewModel.imageFallbackColor
width = viewModel.width
height = viewModel.height
showBorder = viewModel.showBorder
showDropShadow = viewModel.showDropShadow
padding = viewModel.padding
color = viewModel.color
aspectRatio = viewModel.aspectRatio
backgroundEffect = viewModel.backgroundEffect
} }
private func loadImage(_ imageName: String? = nil) { private func loadImage(_ imageName: String? = nil) {

View File

@ -55,37 +55,44 @@ open class TileContainerBaseModel<PaddingType: DefaultValuing & Codable, TileCon
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public var inverted: Bool = false
public var backgroundImage: String? public var backgroundImage: String?
public var action: ActionModelProtocol? public var action: ActionModelProtocol?
public var imageFallbackColor: Surface = .light public var imageFallbackColor: Surface = .light
public var width: CGFloat? public var width: CGFloat?
public var height: CGFloat? public var height: CGFloat?
public var showBorder: Bool = false public var showBorder: Bool = false
public var showDropShadwows: Bool = false public var showDropShadow: Bool = false
public var padding = PaddingType.defaultValue public var padding = PaddingType.defaultValue
public var color: TileContainerType.BackgroundColor = .black public var color: TileContainerType.BackgroundColor = .black
public var aspectRatio: TileContainerType.AspectRatio = .ratio1x1 public var aspectRatio: TileContainerType.AspectRatio = .ratio1x1
public var backgroundEffect: TileContainerType.BackgroundEffect = .none public var backgroundEffect: TileContainerType.BackgroundEffect = .none
public var surface: Surface { inverted ? .dark : .light }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case inverted
case backgroundImage case backgroundImage
case action case action
case padding
case color
case aspectRatio
case imageFallbackColor case imageFallbackColor
case width case width
case height case height
case showBorder case showBorder
case showDropShadows case showDropShadow
case padding
case color
case aspectRatio
case backgroundEffect case backgroundEffect
} }
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false
backgroundImage = try container.decodeIfPresent(String.self, forKey: .backgroundImage) backgroundImage = try container.decodeIfPresent(String.self, forKey: .backgroundImage)
action = try container.decodeModelIfPresent(codingKey: .action)
imageFallbackColor = try container.decodeIfPresent(VDS.Surface.self, forKey: .imageFallbackColor) ?? .light
width = try container.decodeIfPresent(CGFloat.self, forKey: .width) width = try container.decodeIfPresent(CGFloat.self, forKey: .width)
height = try container.decodeIfPresent(CGFloat.self, forKey: .height) height = try container.decodeIfPresent(CGFloat.self, forKey: .height)
action = try container.decodeModelIfPresent(codingKey: .action) showBorder = try container.decodeIfPresent(Bool.self, forKey: .showBorder) ?? false
showDropShadow = try container.decodeIfPresent(Bool.self, forKey: .showDropShadow) ?? false
padding = try container.decodeIfPresent(PaddingType.self, forKey: .padding) ?? PaddingType.defaultValue padding = try container.decodeIfPresent(PaddingType.self, forKey: .padding) ?? PaddingType.defaultValue
color = try container.decodeIfPresent(TileContainerType.BackgroundColor.self, forKey: .color) ?? .black color = try container.decodeIfPresent(TileContainerType.BackgroundColor.self, forKey: .color) ?? .black
aspectRatio = try container.decodeIfPresent(TileContainerType.AspectRatio.self, forKey: .aspectRatio) ?? .ratio1x1 aspectRatio = try container.decodeIfPresent(TileContainerType.AspectRatio.self, forKey: .aspectRatio) ?? .ratio1x1
@ -96,12 +103,15 @@ open class TileContainerBaseModel<PaddingType: DefaultValuing & Codable, TileCon
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(backgroundImage, forKey: .backgroundImage) try container.encodeIfPresent(backgroundImage, forKey: .backgroundImage)
try container.encodeModelIfPresent(action, forKey: .action)
try container.encodeIfPresent(imageFallbackColor, forKey: .imageFallbackColor)
try container.encodeIfPresent(width, forKey: .width) try container.encodeIfPresent(width, forKey: .width)
try container.encodeIfPresent(height, forKey: .height) try container.encodeIfPresent(height, forKey: .height)
try container.encodeIfPresent(backgroundEffect, forKey: .backgroundEffect) try container.encodeIfPresent(showBorder, forKey: .showBorder)
try container.encodeIfPresent(showDropShadow, forKey: .showDropShadow)
try container.encodeIfPresent(padding, forKey: .padding) try container.encodeIfPresent(padding, forKey: .padding)
try container.encodeIfPresent(color, forKey: .color) try container.encodeIfPresent(color, forKey: .color)
try container.encodeIfPresent(aspectRatio, forKey: .aspectRatio) try container.encodeIfPresent(aspectRatio, forKey: .aspectRatio)
try container.encodeModelIfPresent(action, forKey: .action) try container.encodeIfPresent(backgroundEffect, forKey: .backgroundEffect)
} }
} }

View File

@ -39,16 +39,7 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{
// MARK: - Public // MARK: - Public
//-------------------------------------------------- //--------------------------------------------------
public func viewModelDidUpdate() { public func viewModelDidUpdate() {
//tilelet specific properties
padding = viewModel.padding
color = viewModel.color
backgroundEffect = viewModel.backgroundEffect
aspectRatio = viewModel.aspectRatio
width = viewModel.width
height = viewModel.height
showBorder = viewModel.showBorder
showDropShadows = viewModel.showDropShadwows
if let value = viewModel.textWidth { if let value = viewModel.textWidth {
textWidth = .value(value) textWidth = .value(value)
} else if let percentage = viewModel.textPercentage { } else if let percentage = viewModel.textPercentage {
@ -70,6 +61,51 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{
delegateObject: self.delegateObject) delegateObject: self.delegateObject)
} }
} }
// TileContainer properties
// set backgroundImage
if let imageName = viewModel.backgroundImage {
loadImage(imageName)
}
//set action
if let action = viewModel.action {
//add the subscriber
onClick = { [weak self] control in
guard let self, let viewModel = self.viewModel else { return }
MVMCoreUIActionHandler.performActionUnstructured(with: action,
sourceModel: viewModel,
additionalData: self.additionalData,
delegateObject: self.delegateObject)
}
}
//set the rest of the properties
surface = viewModel.surface
imageFallbackColor = viewModel.imageFallbackColor
width = viewModel.width
height = viewModel.height
showBorder = viewModel.showBorder
showDropShadow = viewModel.showDropShadow
padding = viewModel.padding
color = viewModel.color
aspectRatio = viewModel.aspectRatio
backgroundEffect = viewModel.backgroundEffect
}
private func loadImage(_ imageName: String? = nil) {
guard let imageName else {
if backgroundImage != nil {
backgroundImage = nil
}
return
}
let finishedLoadingBlock: MVMCoreGetImageBlock = {[weak self] (image, data, isFallbackImage) in MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in
guard let self = self else { return }
self.backgroundImage = image
})}
MVMCoreCache.shared()?.getImage(imageName, useWidth: false, widthForS7: 0, useHeight: false, heightForS7: 0, format: nil, localFallbackImageName: nil, allowServerQueryParameters: false, localBundle: nil, completionHandler: finishedLoadingBlock)
} }
//-------------------------------------------------- //--------------------------------------------------