diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift index 6b184bac..981715ad 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLinkModel.swift @@ -93,6 +93,17 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea try container.encode(enabled, forKey: .enabled) try container.encode(inverted, forKey: .inverted) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return iconPosition == model.iconPosition + && title == model.title + && action.isEqual(to: model.action) + && accessibilityText == model.accessibilityText + && accessibilityIdentifier == model.accessibilityIdentifier + && enabled == model.enabled + && inverted == model.inverted + } } extension CaretLinkModel { diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift index bdc724b6..fd7a8287 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift @@ -107,5 +107,26 @@ open class BadgeIndicatorModel: MoleculeModelProtocol { try container.encodeIfPresent(hideBorder, forKey: .hideBorder) try container.encodeIfPresent(width, forKey: .width) try container.encodeIfPresent(height, forKey: .height) - } + } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return inverted == model.inverted + && accessibilityText == model.accessibilityText + && number == model.number + && fillColor == model.fillColor + && borderColorLight == model.borderColorLight + && borderColorDark == model.borderColorDark + && kind == model.kind + && maximumDigits == model.maximumDigits + && size == model.size + && leadingCharacter == model.leadingCharacter + && trailingText == model.trailingText + && dotSize == model.dotSize + && verticalPadding == model.verticalPadding + && hideDot == model.hideDot + && hideBorder == model.hideBorder + && width == model.width + && height == model.height + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift index aefa9dfe..a3227894 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift @@ -147,4 +147,26 @@ open class ButtonIconModel: ButtonModelProtocol, MoleculeModelProtocol { try container.encodeIfPresent(selectable, forKey: .selectable) try container.encodeIfPresent(iconOffset, forKey: .iconOffset) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return inverted == model.inverted + && accessibilityText == model.accessibilityText + && badgeIndicator == model.badgeIndicator + && expandDirection == model.expandDirection + && kind == model.kind + && surfaceType == model.surfaceType + && iconName == model.iconName + && selectedIconName == model.selectedIconName + && size == model.size + && customContainerSize == model.customContainerSize + && customIconSize == model.customIconSize + && customBadgeIndicatorOffSet == model.customBadgeIndicatorOffSet + && floating == model.floating + && fitToIcon == model.fitToIcon + && hideBorder == model.hideBorder + && showBadgeIndicator == model.showBadgeIndicator + && selectable == model.selectable + && iconOffset == model.iconOffset + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift index ac8e6d9e..17bef757 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift @@ -35,4 +35,12 @@ open class IconModel: MoleculeModelProtocol { /// A custom size of the icon. public var customSize: Int? + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return color == model.color + && size == model.size + && surface == model.surface + && customSize == model.customSize + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift index 6959bc8f..587598c6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift @@ -68,6 +68,12 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { try container.encodeIfPresent(diameter, forKey: .diameter) try container.encodeIfPresent(inverted, forKey: .inverted) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return diameter == model.diameter + && inverted == model.inverted + } } extension LoadingSpinnerModel { diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift index 0e7c6032..9b887f06 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift @@ -49,6 +49,21 @@ open class TileContainerModel: TileContainerBaseModel Bool { + guard let model = model as? Self else { return false } + return backgroundImage == model.backgroundImage + && action.isEqual(to: model.action) + && imageFallbackColor == model.imageFallbackColor + && width == model.width + && height == model.height + && showBorder == model.showBorder + && showDropShadow == model.showDropShadow + && padding.value == model.padding.value + && color == model.color + && aspectRatio == model.aspectRatio + && backgroundEffect == model.backgroundEffect + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift index e53066d0..53a57169 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift @@ -161,4 +161,32 @@ open class TileletModel: TileContainerBaseModel, Molec try container.encodeIfPresent(textPercentage, forKey: .textPercentage) try super.encode(to: encoder) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return backgroundImage == model.backgroundImage + && action.isEqual(to: model.action) + && imageFallbackColor == model.imageFallbackColor + && width == model.width + && height == model.height + && showBorder == model.showBorder + && showDropShadow == model.showDropShadow + && padding.value == model.padding.value + && color == model.color + && aspectRatio == model.aspectRatio + && backgroundEffect == model.backgroundEffect + + && badge == model.badge + && eyebrow == model.eyebrow + && eyebrowColor == model.eyebrowColor + && title == model.title + && titleColor == model.titleColor + && subTitle == model.subTitle + && subTitleColor == model.subTitleColor + && descriptiveIcon == model.descriptiveIcon + && directionalIcon == model.directionalIcon + && textWidth == model.textWidth + && textPercentage == model.textPercentage + + } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift index 0c9886d7..7e088616 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift @@ -95,6 +95,16 @@ open class TooltipModel: MoleculeModelProtocol { try container.encodeModelIfPresent(molecule, forKey: .contentView) } + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return surface == model.surface + && size == model.size + && fillColor == model.fillColor + && closeButtonText == model.closeButtonText + && title == model.title + && content == model.content + && molecule == model.molecule + } } extension TooltipModel { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 072913f6..fb2b56cc 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -181,7 +181,11 @@ open class TabItemModel: Codable, Equatable, MoleculeModelComparisonProtocol { public static func == (lhs: TabItemModel, rhs: TabItemModel) -> Bool { return lhs.label.isEqual(to: rhs.label) - && lhs.action.isEqual(to: rhs.action) + } + + public func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return self == model } public func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index f57c5801..d390b0bb 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -8,6 +8,7 @@ import UIKit import VDS +import MVMCore @objcMembers open class TwoButtonView: VDS.View, VDSMoleculeViewProtocol { @@ -97,4 +98,5 @@ import VDS //-------------------------------------------------- public func updateView(_ size: CGFloat) {} + } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift index 893d2753..4056abaa 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift @@ -47,4 +47,11 @@ public class TwoLinkViewModel: ParentMoleculeModelProtocol { try container.encodeIfPresent(rightLink, forKey: .rightLink) try container.encodeIfPresent(leftLink, forKey: .leftLink) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return rightLink == model.rightLink + && leftLink == model.leftLink + } + } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift index 0fc5d5d5..f9dd351a 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift @@ -112,6 +112,17 @@ open class NotificationMoleculeModel: MoleculeModelProtocol { try container.encodeIfPresent(inverted, forKey: .inverted) try container.encode(style, forKey: .style) } + + open func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return accessibilityIdentifier == model.accessibilityIdentifier + && headline == model.headline + && body == model.body + && button == model.button + && secondaryButton == model.secondaryButton + && inverted == model.inverted + && style == model.style + } } extension NotificationMoleculeModel {