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