Digital PCT265 story DE307-731: Support 'gone' configuration for carousel cells.
This commit is contained in:
parent
d0bf8a1573
commit
750e50d476
@ -24,6 +24,7 @@
|
|||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = FormValidator.defaultGroupName
|
||||||
public var baseValue: AnyHashable?
|
public var baseValue: AnyHashable?
|
||||||
|
public var gone: Bool = false
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Validation
|
// MARK: - Validation
|
||||||
@ -53,6 +54,7 @@
|
|||||||
case groupName
|
case groupName
|
||||||
case enabled
|
case enabled
|
||||||
case readOnly
|
case readOnly
|
||||||
|
case gone
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -76,6 +78,7 @@
|
|||||||
if let readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) {
|
if let readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) {
|
||||||
self.readOnly = readOnly
|
self.readOnly = readOnly
|
||||||
}
|
}
|
||||||
|
gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) ?? false
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +102,7 @@
|
|||||||
&& fieldValue == model.fieldValue
|
&& fieldValue == model.fieldValue
|
||||||
&& enabled == model.enabled
|
&& enabled == model.enabled
|
||||||
&& readOnly == model.readOnly
|
&& readOnly == model.readOnly
|
||||||
|
&& gone == model.gone
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool {
|
public override func isVisuallyEquivalent(to model: any MoleculeModelComparisonProtocol) -> Bool {
|
||||||
@ -107,5 +111,6 @@
|
|||||||
&& peakingArrowColor == model.peakingArrowColor
|
&& peakingArrowColor == model.peakingArrowColor
|
||||||
&& enabled == model.enabled
|
&& enabled == model.enabled
|
||||||
&& readOnly == model.readOnly
|
&& readOnly == model.readOnly
|
||||||
|
&& gone == model.gone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,7 @@ open class Carousel: View {
|
|||||||
showPeaking(false)
|
showPeaking(false)
|
||||||
|
|
||||||
// Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled.
|
// Go to current cell. layoutIfNeeded is needed otherwise cellForItem returns nil for peaking logic. The dispatch is a sad way to ensure the collection view is ready to be scrolled.
|
||||||
guard let model = model as? CarouselModel, !model.molecules.isEmpty else { return }
|
guard let model = model as? CarouselModel, !model.visibleMolecules.isEmpty else { return }
|
||||||
guard (model.paging == true || loop == true) else {
|
guard (model.paging == true || loop == true) else {
|
||||||
DispatchQueue.main.async { [self] in
|
DispatchQueue.main.async { [self] in
|
||||||
updatePagerVisibility()
|
updatePagerVisibility()
|
||||||
@ -228,7 +228,7 @@ open class Carousel: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func prepareMolecules(with carouselModel: CarouselModel?) {
|
func prepareMolecules(with carouselModel: CarouselModel?) {
|
||||||
guard let newMolecules = carouselModel?.molecules else {
|
guard let newMolecules = carouselModel?.visibleMolecules else {
|
||||||
numberOfPages = 0
|
numberOfPages = 0
|
||||||
molecules = nil
|
molecules = nil
|
||||||
return
|
return
|
||||||
|
|||||||
@ -44,6 +44,10 @@ import UIKit
|
|||||||
public var selectable = false
|
public var selectable = false
|
||||||
public var selectedIndex: Int?
|
public var selectedIndex: Int?
|
||||||
|
|
||||||
|
public var visibleMolecules: [MoleculeModelProtocol & CarouselItemModelProtocol] {
|
||||||
|
molecules.filter { !$0.gone }
|
||||||
|
}
|
||||||
|
|
||||||
public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) {
|
public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) {
|
||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
public protocol CarouselItemModelProtocol: FormFieldProtocol, ContainerModelProtocol {
|
public protocol CarouselItemModelProtocol: FormFieldProtocol, ContainerModelProtocol {
|
||||||
var analyticsData: JSONValueDictionary? { get set }
|
var analyticsData: JSONValueDictionary? { get set }
|
||||||
|
var gone: Bool { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension CarouselItemModelProtocol {
|
public extension CarouselItemModelProtocol {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user