Presenter
is a simple protocol defined as:
public protocol Presenter {
associatedtype CellType
associatedtype ModelType
func render(cell: CellType, with: ModelType, at: IndexPath)
}
Pickme can be configured by using Configuration
object.
public struct Configuration {
// Minimum scale for the item
public var minScale: CGFloat = 1.0
// Maximum scale for the item
public var maxScale: CGFloat = 2.0
// Spacing between each items
public var itemSpacing: CGFloat = 10.0
// Size of each item
public var itemSize: CGSize = CGSize(width: 50, height: 50)
// Cell identifier of collection view cell
public var cellIdentifier: String = "Cell"
// Hide scrollbar for collection view
public var hideScrollbar: Bool = true
// Defines how many cells participate in scaling
public var flowDistance: CGFloat = 50.0
}
flowDistance
parameter is an important configuration parameter that defines how your items will be scaled. It is the distance from center of collection view on either side. The item will participate in scaling, only if its center lies with in flowDistance from center of collection view.
Pickme can be initialized in following ways:
// Initialize with default configuration
Pickme(with: collectionView, items: ["a", "b"], presenter: CustomPresenter())
// Initialize with configuration block
Pickme(with: collectionView, items: ["a", "b"], presenter: CustomPresenter()) { config in
config.itemSpacing = 15.0
config.itemSize = CGSize(width: 50.0, height: 50.0)
config.flowDistance = 50.0
}
// Initialize with existing configuration
Pickme(with: collectionView, items: ["a", "b"], presenter: CustomPresenter(), configuration: configuarion)
Reloads table view with new items
Selects the item at index with optional animation. Default value for animation is true
.
Get the index of selected item