latest carousel
This commit is contained in:
parent
d19653557f
commit
2037cbba82
@ -58,6 +58,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
/// The maxmum count of pages before the indicatorView forces a Numeric Indicator in place of Bar.
|
||||
private var _numberOfPages = 0
|
||||
|
||||
/// Holds the total number of pages displayed by the carousel.
|
||||
|
||||
@ -15,13 +15,11 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
//--------------------------------------------------
|
||||
|
||||
public class var identifier: String {
|
||||
return ""
|
||||
return "barsCarouselIndicator"
|
||||
}
|
||||
|
||||
public var backgroundColor: Color?
|
||||
public var moleculeName: String?
|
||||
|
||||
/// The maxmum count of pages before the indicatorView forces a Numeric Indicator in place of Bar.
|
||||
public var numberOfPages: Int = 0
|
||||
|
||||
// Sets the current Index to focus on.
|
||||
@ -67,10 +65,6 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
||||
moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
|
||||
if let numberOfPages = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfPages) {
|
||||
self.numberOfPages = numberOfPages
|
||||
}
|
||||
|
||||
if let currentIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .currentIndex) {
|
||||
self.currentIndex = currentIndex
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
open class NumericCarouselIndicatorModel: CarouselIndicatorModel {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
|
||||
@ -105,25 +105,22 @@ open class Carousel: View {
|
||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
self.delegateObject = delegateObject
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
|
||||
guard let carouselModel = model as? CarouselModel else { return }
|
||||
|
||||
collectionView.backgroundColor = backgroundColor
|
||||
collectionView.layer.borderColor = backgroundColor?.cgColor
|
||||
collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0
|
||||
collectionView.layer.borderWidth = carouselModel.border ? 1 : 0
|
||||
backgroundColor = .white
|
||||
|
||||
registerCells(with: carouselModel, delegateObject: delegateObject)
|
||||
setupLayout(with: carouselModel)
|
||||
prepareMolecules(with: carouselModel)
|
||||
itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100
|
||||
if let alignment = carouselModel.itemAlignment {
|
||||
itemAlignment = alignment
|
||||
}
|
||||
|
||||
if let height = carouselModel.height {
|
||||
collectionViewHeight?.constant = CGFloat(height)
|
||||
collectionViewHeight?.isActive = true
|
||||
}
|
||||
itemWidthPercent = carouselModel.itemWidthPercent / 100
|
||||
itemAlignment = carouselModel.itemAlignment
|
||||
|
||||
collectionViewHeight?.constant = CGFloat(carouselModel.height)
|
||||
collectionViewHeight?.isActive = true
|
||||
|
||||
setupPagingMolecule((carouselModel.pagingMolecule as! (CarouselPagingModelProtocol & MoleculeModelProtocol)), delegateObject: delegateObject)
|
||||
collectionView.reloadData()
|
||||
|
||||
@ -21,12 +21,12 @@ import UIKit
|
||||
public var backgroundColor: Color?
|
||||
public var molecules: [CarouselItemModel]
|
||||
public var moleculeName: String?
|
||||
public var spacing: Float?
|
||||
public var border: Bool?
|
||||
public var loop: Bool?
|
||||
public var height: Float?
|
||||
public var itemWidthPercent: Float?
|
||||
public var itemAlignment: UICollectionView.ScrollPosition?
|
||||
public var spacing: Float = 1
|
||||
public var border: Bool = false
|
||||
public var loop: Bool = false
|
||||
public var height: Float = 300
|
||||
public var itemWidthPercent: Float = 100
|
||||
public var itemAlignment: UICollectionView.ScrollPosition = .left
|
||||
public var pagingMolecule: MoleculeModelProtocol?
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -62,12 +62,31 @@ import UIKit
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules)
|
||||
self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
self.spacing = try typeContainer.decode(Float.self, forKey: .spacing)
|
||||
self.border = try typeContainer.decode(Bool.self, forKey: .border)
|
||||
self.loop = try typeContainer.decode(Bool.self, forKey: .loop)
|
||||
self.height = try typeContainer.decode(Float.self, forKey: .height)
|
||||
self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent)
|
||||
self.itemAlignment = try typeContainer.decode(UICollectionView.ScrollPosition.self, forKey: .itemAlignment)
|
||||
|
||||
if let spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) {
|
||||
self.spacing = spacing
|
||||
}
|
||||
|
||||
if let border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) {
|
||||
self.border = border
|
||||
}
|
||||
|
||||
if let loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) {
|
||||
self.loop = loop
|
||||
}
|
||||
|
||||
if let height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) {
|
||||
self.height = height
|
||||
}
|
||||
|
||||
if let itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) {
|
||||
self.itemWidthPercent = itemWidthPercent
|
||||
}
|
||||
|
||||
if let itemAlignment = try typeContainer.decodeIfPresent(UICollectionView.ScrollPosition.self, forKey: .itemAlignment) {
|
||||
self.itemAlignment = itemAlignment
|
||||
}
|
||||
|
||||
self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user