Digital PCT265 story PCT-135: ContainerModel ModelComparisonProtocol conformance.
This commit is contained in:
parent
9ff5b58eb5
commit
cb659b63e9
@ -8,7 +8,7 @@
|
|||||||
// A base class that has common list item boilerplate model stuffs.
|
// A base class that has common list item boilerplate model stuffs.
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol, ModelComparisonProtocol, MoleculeModelComparisonProtocol {
|
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol, MoleculeModelComparisonProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -131,8 +131,8 @@ import MVMCore
|
|||||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public override func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
guard super.isEqual(to: model), let model = model as? Self else { return false }
|
||||||
return backgroundColor == model.backgroundColor
|
return backgroundColor == model.backgroundColor
|
||||||
&& hideArrow == model.hideArrow
|
&& hideArrow == model.hideArrow
|
||||||
&& style == model.style
|
&& style == model.style
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
fatalError("init(from:) has not been implemented")
|
fatalError("init(from:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public override func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
guard let model = model as? Self else { return false }
|
||||||
return backgroundColor == model.backgroundColor
|
return backgroundColor == model.backgroundColor
|
||||||
&& spacing == model.spacing
|
&& spacing == model.spacing
|
||||||
|
|||||||
@ -62,13 +62,13 @@ open class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtoco
|
|||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public override func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
guard super.isEqual(to: model), let model = model as? Self else { return false }
|
||||||
return backgroundColor == model.backgroundColor
|
return backgroundColor == model.backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Declare for overrides.
|
||||||
public func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool {
|
public func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
return isEqual(to: model)
|
||||||
return backgroundColor == model.backgroundColor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@
|
|||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public override func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
guard let model = model as? Self else { return false }
|
||||||
return backgroundColor == model.backgroundColor
|
return backgroundColor == model.backgroundColor
|
||||||
&& axis == model.axis
|
&& axis == model.axis
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
open class ContainerModel: ContainerModelProtocol, Codable {
|
open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -113,4 +113,17 @@ open class ContainerModel: ContainerModelProtocol, Codable {
|
|||||||
try container.encodeIfPresent(bottomPadding, forKey: .bottomPadding)
|
try container.encodeIfPresent(bottomPadding, forKey: .bottomPadding)
|
||||||
try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
|
guard let model = model as? Self else { return false }
|
||||||
|
return horizontalAlignment == model.horizontalAlignment
|
||||||
|
&& useHorizontalMargins == model.useHorizontalMargins
|
||||||
|
&& leftPadding == model.leftPadding
|
||||||
|
&& rightPadding == model.rightPadding
|
||||||
|
&& verticalAlignment == model.verticalAlignment
|
||||||
|
&& useVerticalMargins == model.useVerticalMargins
|
||||||
|
&& topPadding == model.topPadding
|
||||||
|
&& bottomPadding == model.bottomPadding
|
||||||
|
&& cornerRadius == model.cornerRadius
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user