This commit is contained in:
Kevin G Christiano 2020-03-11 15:22:20 -04:00
parent 90d98fdc2e
commit f7f15c906f
5 changed files with 11 additions and 23 deletions

View File

@ -33,15 +33,11 @@ open class BarsIndicatorView: CarouselIndicator {
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
public var parentCarouselIndicator: CarouselIndicator? {
return superview as? CarouselIndicator
}
open override var isEnabled: Bool {
didSet {
barReferences.forEach { view, heightConstraint in
view.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3
view.backgroundColor = isEnabled ? indicatorTintColor : disabledIndicatorColor
}
}
}
@ -80,16 +76,12 @@ open class BarsIndicatorView: CarouselIndicator {
func generateBars() {
guard let numberOfPages = parentCarouselIndicator?.numberOfPages,
let currentIndex = parentCarouselIndicator?.currentIndex
else { return }
var bars = [(View, NSLayoutConstraint)]()
for i in 0..<numberOfPages {
let bar = View()
bar.widthAnchor.constraint(equalToConstant: BarsIndicatorView.indicatorBarWidth).isActive = true
// bar.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3
bar.backgroundColor = isEnabled ? indicatorTintColor : disabledIndicatorColor
let barHeight = i == currentIndex ? BarsIndicatorView.indicatorBarHeight.selected : BarsIndicatorView.indicatorBarHeight.unselected
let heightConstraint = bar.heightAnchor.constraint(equalToConstant: barHeight)
heightConstraint.isActive = true
@ -116,8 +108,8 @@ open class BarsIndicatorView: CarouselIndicator {
guard !barReferences.isEmpty else { return }
let expression = {
self.barReferences[previousIndex].view.backgroundColor = self.parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack
self.barReferences[newIndex].view.backgroundColor = self.parentCarouselIndicator?.currentIndicatorColor ?? .mvmBlack
self.barReferences[previousIndex].view.backgroundColor = self.indicatorTintColor
self.barReferences[newIndex].view.backgroundColor = self.currentIndicatorColor
self.barReferences[previousIndex].constraint.constant = BarsIndicatorView.indicatorBarHeight.unselected
self.barReferences[newIndex].constraint.constant = BarsIndicatorView.indicatorBarHeight.selected
self.layoutIfNeeded()

View File

@ -201,13 +201,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
// MARK: - Methods
//--------------------------------------------------
open func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) {
// indicatorView?.updateUI(previousIndex: previousIndex,
// newIndex: currentIndex,
// totalCount: numberOfPages,
// isAnimated: carouselIndicatorModel?.isAnimated ?? true)
}
open func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { }
public func performAction() {

View File

@ -38,7 +38,7 @@ open class NumericIndicatorView: CarouselIndicator {
// MARK: - Computed Properties
//--------------------------------------------------
open override var isEnabled: Bool = true {
open override var isEnabled: Bool {
didSet {
pageCount.textColor = isEnabled ? indicatorTintColor : disabledIndicatorColor
leftArrow.tintColor = isEnabled ? indicatorTintColor : disabledIndicatorColor

View File

@ -69,7 +69,8 @@ import UIKit
height = try typeContainer.decodeIfPresent(Float.self, forKey: .height)
itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent)
itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment)
pagingMolecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .pagingMolecule) as? CarouselPagingModelProtocol
let model : MoleculeModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule)!
pagingMolecule = model as? CarouselPagingModelProtocol
}
public func encode(to encoder: Encoder) throws {

View File

@ -97,9 +97,10 @@ import Foundation
// Other Molecules
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self)
// Other Organisms
// Carousel
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CarouselIndicator.self, viewModelClass: CarouselIndicatorModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: BarsIndicatorView.self, viewModelClass: BarsCarouselIndicatorModel.self)
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumericIndicatorView.self, viewModelClass: NumericCarouselIndicatorModel.self)
// Designed List Items
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self)