added 2 new arrays to accept color changes on each carousel page
Signed-off-by: Jarrod Courtney <jarrod.courtney@verizon.com>
This commit is contained in:
parent
4f1f36186c
commit
ec584feae8
@ -104,6 +104,14 @@ open class BarsIndicatorView: CarouselIndicator {
|
||||
}
|
||||
}
|
||||
|
||||
public override var indicatorColors: [Color]? {
|
||||
get { super.indicatorColors }
|
||||
}
|
||||
|
||||
public override var currentIndicatorColors: [Color]? {
|
||||
get { super.currentIndicatorColors }
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Setup
|
||||
//--------------------------------------------------
|
||||
@ -250,6 +258,10 @@ open class BarsIndicatorView: CarouselIndicator {
|
||||
|
||||
guard newIndex < totalCount else { return }
|
||||
|
||||
if let indicatorColors = indicatorColors, let currentIndicatorColors = currentIndicatorColors {
|
||||
indicatorColor = indicatorColors[newIndex].uiColor
|
||||
currentIndicatorColor = currentIndicatorColors[newIndex].uiColor
|
||||
}
|
||||
// Ensure the number of pages matches the number of bar references.
|
||||
if (totalCount - barReferences.count) != 0 {
|
||||
barReferences.forEach {
|
||||
@ -263,9 +275,9 @@ open class BarsIndicatorView: CarouselIndicator {
|
||||
}
|
||||
|
||||
barReferences[previousIndex].backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor
|
||||
barReferences[newIndex].backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor
|
||||
barReferences[previousIndex].constraint?.constant = IndicatorBar.unselectedHeight
|
||||
barReferences[previousIndex].layer.cornerRadius = IndicatorBar.unselectedCornerRadius
|
||||
barReferences[newIndex].backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor
|
||||
barReferences[newIndex].constraint?.constant = IndicatorBar.selectedHeight
|
||||
barReferences[newIndex].layer.cornerRadius = IndicatorBar.selectedCornerRadius
|
||||
layoutIfNeeded()
|
||||
|
||||
@ -98,6 +98,20 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
public var indicatorColors: [Color]? {
|
||||
get {
|
||||
guard let model = carouselIndicatorModel else { return nil }
|
||||
return model.indicatorColors
|
||||
}
|
||||
}
|
||||
|
||||
public var currentIndicatorColors: [Color]? {
|
||||
get {
|
||||
guard let model = carouselIndicatorModel else { return nil }
|
||||
return model.currentIndicatorColors
|
||||
}
|
||||
}
|
||||
|
||||
var accessibilityValueFormat: String? {
|
||||
MVMCoreUIUtility.hardcodedString(withKey: (carouselIndicatorModel?.accessibilityHasSlidesInsteadOfPage ?? false) ? "MVMCoreUIPageControlslides_currentpage_index" : "MVMCoreUIPageControl_currentpage_index")
|
||||
}
|
||||
@ -210,10 +224,14 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
||||
guard let model = model as? CarouselIndicatorModel else { return }
|
||||
|
||||
previousIndex = 0
|
||||
indicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor
|
||||
disabledIndicatorColor = model.disabledIndicatorColor.uiColor
|
||||
currentIndex = model.currentIndex
|
||||
isEnabled = model.enabled
|
||||
|
||||
if let indicatorColors = model.indicatorColors {
|
||||
indicatorColor = indicatorColors[currentIndex].uiColor
|
||||
}
|
||||
indicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor
|
||||
disabledIndicatorColor = model.disabledIndicatorColor.uiColor
|
||||
|
||||
formatAccessibilityValue(index: currentIndex + 1, total: numberOfPages)
|
||||
isHidden = model.hidesForSinglePage && numberOfPages <= 1
|
||||
|
||||
@ -39,7 +39,9 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
public var indicatorColor: Color = Color(uiColor: VDSColor.elementsPrimaryOnlight)
|
||||
public var indicatorColor_inverted: Color = Color(uiColor: VDSColor.elementsPrimaryOndark)
|
||||
public var position: CGFloat?
|
||||
|
||||
public var indicatorColors: [Color]? = nil
|
||||
public var currentIndicatorColors: [Color]? = nil
|
||||
|
||||
/// Allows sendActions() to trigger even if index is already at min/max index.
|
||||
public var alwaysSendAction = false
|
||||
|
||||
@ -62,6 +64,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
case indicatorColor
|
||||
case position
|
||||
case inverted
|
||||
case indicatorColors
|
||||
case currentIndicatorColors
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -76,6 +80,14 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
|
||||
if let colors = try typeContainer.decodeIfPresent([Color].self, forKey: .indicatorColors) {
|
||||
self.indicatorColors = colors
|
||||
}
|
||||
|
||||
if let currentColors = try typeContainer.decodeIfPresent([Color].self, forKey: .currentIndicatorColors) {
|
||||
self.currentIndicatorColors = currentColors
|
||||
}
|
||||
|
||||
if let currentIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .currentIndex) {
|
||||
self.currentIndex = currentIndex
|
||||
}
|
||||
@ -133,6 +145,8 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
try container.encode(disabledIndicatorColor, forKey: .disabledIndicatorColor)
|
||||
try container.encode(indicatorColor, forKey: .indicatorColor)
|
||||
try container.encodeIfPresent(position, forKey: .position)
|
||||
try container.encode(indicatorColors, forKey: .indicatorColors)
|
||||
try container.encode(currentIndicatorColors, forKey: .currentIndicatorColors)
|
||||
}
|
||||
|
||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user