//
//  CollectionTemplateItemProtocol.swift
//  MVMCoreUI
//
//  Created by Scott Pfeil on 4/9/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


/// A protocol that items of the CollectionTemplate must conform to.
public protocol CollectionTemplateItemProtocol: UICollectionViewCell {
    
    /// Set the width of the item. Used for the columns functionality
    func set(width: CGFloat)
    
    /// Handle action when cell is pressed
    func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?)

    /// Called when the cell will display.
    func willDisplay()
    
    /// Handle the selection of cell
    func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool
}

// Default implementation does nothing
extension CollectionTemplateItemProtocol {
    
    public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }

    public func willDisplay() { }
    
    public func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { false }
}
