DTCollectionViewManager

open class DTCollectionViewManager

DTCollectionViewManager manages most of UICollectionView datasource and delegate methods and provides API for managing your data models in the collection view. Any method, that is not implemented by DTCollectionViewManager, will be forwarded to delegate.

See also

startManagingWithDelegate:
  • Bool property, that will be true, after startManagingWithDelegate method is called on DTCollectionViewManager.

    Declaration

    Swift

    open var isManagingCollectionView: Bool { get }
  • Implicitly unwrap storage property to MemoryStorage.

    Warning

    if storage is not MemoryStorage, will throw an exception.

    Declaration

    Swift

    open var memoryStorage: MemoryStorage! { get }
  • Anomaly handler, that handles reported by DTCollectionViewManager anomalies.

    Declaration

    Swift

    open var anomalyHandler: DTCollectionViewManagerAnomalyHandler
  • Storage, that holds your UICollectionView models. By default, it’s MemoryStorage instance.

    Note

    When setting custom storage for this property, it will be automatically configured for using with UICollectionViewFlowLayout and it’s delegate will be set to DTCollectionViewManager instance.

    Note

    Previous storage delegate property will be nilled out to avoid collisions.

    See also

    MemoryStorage, CoreDataStorage.

    Declaration

    Swift

    open var storage: Storage { get set }
  • Current storage, conditionally casted to SupplementaryStorage protocol.

    Declaration

    Swift

    public var supplementaryStorage: SupplementaryStorage? { get }
  • Object, that is responsible for updating UICollectionView, when received update from Storage

    Declaration

    Swift

    open var collectionViewUpdater: CollectionViewUpdater? { get set }
  • Object, that is responsible for implementing UICollectionViewDataSource protocol

    Declaration

    Swift

    open var collectionDataSource: DTCollectionViewDataSource? { get set }
  • Object, that is responsible for implementing UICollectionViewDelegate and UICollectionViewDelegateFlowLayout protocols

    Declaration

    Swift

    open var collectionDelegate: DTCollectionViewDelegate? { get set }
  • Object, that is responsible for implementing UICollectionViewDragDelegate protocol

    Declaration

    Swift

    open var collectionDragDelegate: DTCollectionViewDragDelegate? { get set }
  • Object, that is responsible for implementing UICOllectionViewDropDelegate protocol

    Declaration

    Swift

    open var collectionDropDelegate: DTCollectionViewDropDelegate? { get set }
  • Storage construction block, used by DTCollectionViewManager when it’s created. Returns MemoryStorage by default.

    Declaration

    Swift

    public static var defaultStorage: () -> Storage
  • Creates DTCollectionViewManager. Usually you don’t need to call this method directly, as manager property on DTCollectionViewManageable instance is filled automatically. DTCollectionViewManager.defaultStorage closure is used to determine which Storage would be used by default.

    Declaration

    Swift

    public init(storage: Storage = DTCollectionViewManager.defaultStorage())

    Parameters

    storage

    storage class to be used

  • If you access manager property when managed UICollectionView is already created(for example: viewDidLoad method), calling this method is not necessary. If for any reason, UICollectionView is created later, please call this method before modifying storage or registering cells/supplementary views.

    Precondition

    UICollectionView instance on delegate should not be nil.

    Declaration

    Swift

    open func startManaging(withDelegate delegate: DTCollectionViewManageable)

    Parameters

    delegate

    Object, that has UICollectionView, that will be managed by DTCollectionViewManager.

  • Undocumented

    Declaration

    Swift

    open func configureDiffableDataSource<SectionIdentifier, ItemIdentifier>(modelProvider: @escaping (IndexPath, ItemIdentifier) -> Any)
        -> UICollectionViewDiffableDataSource<SectionIdentifier, ItemIdentifier>
  • Undocumented

    Declaration

    Swift

    open func configureDiffableDataSource(modelProvider: @escaping (IndexPath, Any) -> Any) -> UICollectionViewDiffableDataSourceReference
  • Returns closure, that updates cell at provided indexPath.

    This is used by coreDataUpdater method and can be used to silently update a cell without animation.

    Declaration

    Swift

    open func updateCellClosure() -> (IndexPath, Any) -> Void
  • Updates visible cells, using collectionView.indexPathsForVisibleItems, and update block. This may be more efficient than running reloadData, if number of your data models does not change, and the change you want to reflect is completely within models state.

    Declaration

    Swift

    open func updateVisibleCells(_ closure: ((UICollectionViewCell) -> Void)? = nil)

    Parameters

    closure

    closure to run for each cell after update has been completed.

  • Returns CollectionViewUpdater, configured to work with CoreDataStorage and NSFetchedResultsController updates.

    Precondition

    UICollectionView instance on delegate should not be nil.

    Declaration

    Swift

    open func coreDataUpdater() -> CollectionViewUpdater
  • Registers closure to be executed, when UICollectionViewDataSource.collectionView(_:canMoveItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func canMove<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDataSrouce.(_:moveItemAt:to:) method is called for cellClass.

    Warning

    This method requires items to be moved without animations, since animation has already happened when user moved those cells. If you use MemoryStorage, it’s appropriate to call memoryStorage.moveItemWithoutAnimation(from:to:) method to achieve desired behavior.

    See also

    ‘collectionView:moveRowAt:to:’ method

    Declaration

    Swift

    open func moveItemAtTo(_ closure: @escaping (_ sourceIndexPath: IndexPath, _ destinationIndexPath: IndexPath) -> Void)
  • Registers closure to be executed, when UICollectionViewDataSource.indexTitlesForCollectionView(_:) method is called.

    Declaration

    Swift

    open func indexTitles(_ closure: @escaping () -> [String]?)
  • Registers closure to be executed when UICollectionViewDataSource.collectionView(_:indexPathForIndexTitle:) method is called.

    Declaration

    Swift

    open func indexPathForIndexTitle(_ closure: @escaping (String, Int) -> IndexPath)
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didSelectItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func didSelect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:shouldSelectItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func shouldSelect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:shouldDeselectItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func shouldDeselect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didDeselectItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func didDeselect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:shouldHighlightItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func shouldHighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didHighlightItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func didHighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didUnhighlightItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func didUnhighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:willDisplayCell:forItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func willDisplay<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:) method is called for supplementaryClass of kind.

    Declaration

    Swift

    open func willDisplaySupplementaryView<View>(_ supplementaryClass: View.Type, forElementKind kind: String, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:) method is called for supplementaryClass of UICollectionElementKindSectionHeader.

    Declaration

    Swift

    open func willDisplayHeaderView<View>(_ headerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:) method is called for supplementaryClass of UICollectionElementKindSectionFooter.

    Declaration

    Swift

    open func willDisplayFooterView<View>(_ footerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didEndDisplaying:forItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func didEndDisplaying<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:) method is called for supplementaryClass of kind.

    Declaration

    Swift

    open func didEndDisplayingSupplementaryView<View>(_ supplementaryClass: View.Type, forElementKind kind: String, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:) method is called for headerClass of UICollectionElementKindSectionHeader.

    Declaration

    Swift

    open func didEndDisplayingHeaderView<View>(_ headerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:) method is called for footerClass of UICollectionElementKindSectionFooter.

    Declaration

    Swift

    open func didEndDisplayingFooterView<View>(_ footerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView, View : ModelTransfer
  • Undocumented

    Declaration

    Swift

    open func shouldShowMenu<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Undocumented

    Declaration

    Swift

    open func canPerformAction<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Undocumented

    Declaration

    Swift

    open func performAction<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed, when UICollectionViewDelegate.collectionView(_:canFocusItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func canFocus<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed when UICollectionViewDelegate.collectionView(_:shouldUpdateFocusInContext:) method is called.

    Declaration

    Swift

    open func shouldUpdateFocus(_ closure: @escaping (UICollectionViewFocusUpdateContext) -> Bool)
  • Registers closure tp be executed when UICollectionViewDelegate.collectionView(_:didUpdateFocusIn:with:) method is called.

    Declaration

    Swift

    open func didUpdateFocus(_ closure: @escaping (UICollectionViewFocusUpdateContext, UIFocusAnimationCoordinator) -> Void)
  • Registers closure to be executed when UICollectionViewDelegate.indexPathForPreferredFocusedView(in:) method is called

    Declaration

    Swift

    open func indexPathForPreferredFocusedView(_ closure: @escaping () -> IndexPath?)
  • Registers closure to be executed when UICollectionViewDelegate.targetIndexPathForMoveFromItemAt(_:toProposed:) method is called for cellClass

    Declaration

    Swift

    open func targetIndexPathForMovingItem<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (IndexPath, Cell, Cell.ModelType, IndexPath) -> IndexPath) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed when UICollectionViewDelegate.collectionView(_:targetContentOffsetForProposedContentOffset:) method is called.

    Declaration

    Swift

    open func targetContentOffsetForProposedContentOffset(_ closure: @escaping (CGPoint) -> CGPoint)
  • Registers closure to be executed when UICollectionViewDelegate.collectionView(_:shouldSpringLoadItemAt:) method is called for cellClass.

    Declaration

    Swift

    open func shouldSpringLoad<Cell:ModelTransfer>(_ cellClass: Cell.Type, _ closure: @escaping (UISpringLoadedInteractionContext, Cell, Cell.ModelType, IndexPath) -> Bool)
        where Cell: UICollectionViewCell
  • Undocumented

    Declaration

    Swift

    open func shouldBeginMultipleSelectionInteraction<Cell:ModelTransfer>(for cellClass: Cell.Type,
                                                                       _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool)
        where Cell: UICollectionViewCell
  • Undocumented

    Declaration

    Swift

    open func didBeginMultipleSelectionInteraction<Cell:ModelTransfer>(for cellClass: Cell.Type,
                                                                    _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void)
        where Cell: UICollectionViewCell
  • Undocumented

    Declaration

    Swift

    open func didEndMultipleSelectionInteraction(_ closure: @escaping () -> Void)
  • Undocumented

    Declaration

    Swift

    open func contextMenuConfiguration<Cell:ModelTransfer>(for cellClass: Cell.Type,
                                                        _ closure: @escaping (CGPoint, Cell, Cell.ModelType, IndexPath) -> UIContextMenuConfiguration?)
        where Cell: UICollectionViewCell
  • Undocumented

    Declaration

    Swift

    open func previewForHighlightingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)
  • Undocumented

    Declaration

    Swift

    open func previewForDismissingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)
  • Undocumented

    Declaration

    Swift

    open func canEdit<Model>(_ modelType: Model.Type, _ closure: @escaping (Model, IndexPath) -> Bool)

UICollectionViewDelegateFlowLayout

  • Registers closure to be executed to determine cell size in UICollectionViewDelegateFlowLayout.collectionView(_:sizeForItemAt:) method, when it’s called for cell which model is of itemType.

    Declaration

    Swift

    open func sizeForCell<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
  • Registers closure to be executed to determine header size in UICollectionViewDelegateFlowLayout.collectionView(_:layout:referenceSizeForHeaderViewInSection:) method, when it’s called for header which model is of itemType.

    Declaration

    Swift

    open func referenceSizeForHeaderView<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
  • Registers closure to be executed to determine footer size in UICollectionViewDelegateFlowLayout.collectionView(_:layout:referenceSizeForFooterViewInSection:) method, when it’s called for footer which model is of itemType.

    Declaration

    Swift

    open func referenceSizeForFooterView<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
  • Registers closure to be executed when UICollectionViewDelegate.collectionView(_:transitionLayoutForOldLayout:toNewLayout:) method is called

    Declaration

    Swift

    open func transitionLayout(_ closure: @escaping (_ oldLayout: UICollectionViewLayout, _ newLayout: UICollectionViewLayout) -> UICollectionViewTransitionLayout)
  • Registers closure to be executed when UICollectionViewDelegateFlowLayout.collectionView(_:layout:insetForSectionAt:) method is called.

    Declaration

    Swift

    open func insetForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> UIEdgeInsets)
  • Registers closure to be executed when UICollectionViewDelegateFlowLayout.collectionView(_:layout:minimumLineSpacingForSectionAt:) method is called.

    Declaration

    Swift

    open func minimumLineSpacingForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> CGFloat)
  • Registers closure to be executed when UICollectionViewDelegateFlowLayout.collectionView(_:layout:insetForSectionAt:) method is called.

    Declaration

    Swift

    open func minimumInteritemSpacingForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> CGFloat)
  • Undocumented

    Declaration

    Swift

    func configureEvents<T>(for klass: T.Type, _ closure: (T.Type, T.ModelType.Type) -> Void) where T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func configure<T>(_ cellClass: T.Type, _ closure: @escaping (T, T.ModelType, IndexPath) -> Void) where T : UICollectionViewCell, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func configureHeader<T>(_ headerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func configureFooter<T>(_ footerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func configureSupplementary<T>(_ supplementaryClass: T.Type, ofKind kind: String, _ closure: @escaping (T, T.ModelType, IndexPath) -> Void) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNiblessSupplementary<T>(_ supplementaryClass: T.Type, forKind kind: String, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNiblessHeader<T>(_ headerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNiblessFooter<T>(_ footerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNibless<T>(_ cellClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionViewCell, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNibNamed<T>(_ nibName: String, forSupplementary supplementaryClass: T.Type, ofKind kind: String, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNibNamed<T>(_ nibName: String, forHeader headerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNibNamed<T>(_ nibName: String, forFooter footerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView, T : ModelTransfer
  • Undocumented

    Declaration

    Swift

    func registerNibNamed<T>(_ nibName: String, for cellClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionViewCell, T : ModelTransfer
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:itemsForBeginning:at:) method is called for cellClass.

    Declaration

    Swift

    open func itemsForBeginningDragSession<Cell>(from cellClass: Cell.Type, _ closure: @escaping (UIDragSession, Cell, Cell.ModelType, IndexPath) -> [UIDragItem]) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:itemsForAddingTo:at:point:) method is called for cellClass

    Declaration

    Swift

    open func itemsForAddingToDragSession<Cell>(from cellClass: Cell.Type, _ closure: @escaping (UIDragSession, CGPoint, Cell, Cell.ModelType, IndexPath) -> [UIDragItem]) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:dragPreviewParametersForRowAt:) method is called for cellClass

    Declaration

    Swift

    open func dragPreviewParameters<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> UIDragPreviewParameters?) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:dragSessionWillBegin:) method is called.

    Declaration

    Swift

    open func dragSessionWillBegin(_ closure: @escaping (UIDragSession) -> Void)
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:dragSessionDidEnd:) method is called.

    Declaration

    Swift

    open func dragSessionDidEnd(_ closure: @escaping (UIDragSession) -> Void)
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:dragSessionAllowsMoveOperation) method is called.

    Declaration

    Swift

    open func dragSessionAllowsMoveOperation(_ closure: @escaping (UIDragSession) -> Bool)
  • Registers closure to be executed when UICollectionViewDragDelegate.collectionView(_:dragSessionIsRestrictedToDraggingApplication:) method is called.

    Declaration

    Swift

    open func dragSessionIsRestrictedToDraggingApplication(_ closure: @escaping (UIDragSession) -> Bool)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:performDropWith:) method is called.

    Declaration

    Swift

    open func performDropWithCoordinator(_ closure: @escaping (UICollectionViewDropCoordinator) -> Void)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:canHandle:) method is called.

    Declaration

    Swift

    open func canHandleDropSession(_ closure: @escaping (UIDropSession) -> Bool)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:dropSessionDidEnter:) method is called.

    Declaration

    Swift

    open func dropSessionDidEnter(_ closure: @escaping (UIDropSession) -> Void)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:dropSessionDidUpdate:withDestination:) method is called.

    Declaration

    Swift

    open func dropSessionDidUpdate(_ closure: @escaping (UIDropSession, IndexPath?) -> UICollectionViewDropProposal)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:dropSessionDidExit:) method is called.

    Declaration

    Swift

    open func dropSessionDidExit(_ closure: @escaping (UIDropSession) -> Void)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:dropSessionDidEnd:) method is called.

    Declaration

    Swift

    open func dropSessionDidEnd(_ closure: @escaping (UIDropSession) -> Void)
  • Registers closure to be executed when UICollectionViewDropDelegate.collectionView(_:dropPreviewParametersForRowAt:) method is called.

    Declaration

    Swift

    open func dropPreviewParameters(_ closure: @escaping (IndexPath) -> UIDragPreviewParameters?)
  • Convenience method for dropping item into placeholder. Returns DTCollectionViewDropPlaceholderContext, which is a replacement for UICollectionViewDropPlaceholderContext, that automatically handles drop if you are using MemoryStorage. It also automatically dispatches insertion to DispatchQueue.main.

    Declaration

    Swift

    open func drop(_ item: UIDragItem, to placeholder: UICollectionViewDropPlaceholder,
                   with coordinator: UICollectionViewDropCoordinator) -> DTCollectionViewDropPlaceholderContext
  • Registers mapping for cellClass. Mapping will automatically check for nib with the same name as cellClass and register it, if it is found. If cell is designed in storyboard, please set mapping.cellRegisteredByStoryboard property to true inside of mapping closure.

    Note

    handler closure is called before update(with:) method.

    Declaration

    Swift

    open func register<T:ModelTransfer>(_ cellClass:T.Type, mapping: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil,
                                        handler: @escaping (T, T.ModelType, IndexPath) -> Void = { _, _, _ in }) where T: UICollectionViewCell

    Parameters

    cellClass

    UICollectionViewCell subclass type, conforming to ModelTransfer protocol.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when cell is dequeued.

  • Registers mapping from modelType to cellClass. Mapping will automatically check for nib with the same name as cellClass and register it, if it is found. If cell is designed in storyboard, please set mapping.cellRegisteredByStoryboard property to true inside of mapping closure.

    Declaration

    Swift

    open func register<Cell, Model>(_ cellClass: Cell.Type, for modelType: Model.Type, mapping: ((ViewModelMapping<Cell, Model>) -> Void)? = nil, handler: @escaping (Cell, Model, IndexPath) -> Void) where Cell : UICollectionViewCell

    Parameters

    cellClass

    UICollectionViewCell to register

    modelType

    Model type, which is mapped to cellClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when cell is dequeued.

  • Registers mapping for headerClass. UICollectionView.elementKindSectionHeader is used as a supplementary kind. Mapping will automatically check for nib with the same name as headerClass and register it, if it is found. If supplementary view is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Note

    handler closure is called before update(with:) method.

    Declaration

    Swift

    open func registerHeader<View:ModelTransfer>(_ headerClass : View.Type,
                                              mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil,
                                              handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View: UICollectionReusableView

    Parameters

    headerClass

    UICollectionReusableView class to register

    modelType

    Model type, which is mapped to headerClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when supplementary view is dequeued.

  • Registers mapping from modelType to headerClass. UICollectionView.elementKindSectionHeader is used as a supplementary kind. Mapping will automatically check for nib with the same name as headerClass and register it, if it is found. If header is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Declaration

    Swift

    open func registerHeader<View:UICollectionReusableView, Model>(_ headerClass: View.Type,
                                                                   for modelType: Model.Type,
                                                                   mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil,
                                                                   handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })

    Parameters

    headerClass

    UICollectionReusableView class to register

    modelType

    Model type, which is mapped to headerClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when header is dequeued.

  • Registers mapping for footerClass. UICollectionView.elementKindSectionFooter is used as a supplementary kind. Mapping will automatically check for nib with the same name as footerClass and register it, if it is found. If supplementary view is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Note

    handler closure is called before update(with:) method.

    Declaration

    Swift

    open func registerFooter<View:ModelTransfer>(_ footerClass: View.Type,
                                              mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil,
                                              handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View:UICollectionReusableView

    Parameters

    footerClass

    UICollectionReusableView class to register

    modelType

    Model type, which is mapped to footerClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when supplementary view is dequeued.

  • Registers mapping from modelType to footerClass. UICollectionView.elementKindSectionFooter is used as a supplementary kind. Mapping will automatically check for nib with the same name as footerClass and register it, if it is found. If footer is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Declaration

    Swift

    open func registerFooter<View:UICollectionReusableView, Model>(_ footerClass: View.Type,
                                                                   for modelType: Model.Type,
                                                                   mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil,
                                                                   handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })

    Parameters

    footerClass

    UICollectionReusableView class to register

    modelType

    Model type, which is mapped to footerClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when footer is dequeued.

  • Registers mapping for footerClass. Mapping will automatically check for nib with the same name as supplementaryClass and register it, if it is found. If supplementary view is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Note

    handler closure is called before update(with:) method.

    Declaration

    Swift

    open func registerSupplementary<View:ModelTransfer>(_ supplementaryClass: View.Type,
                                                     ofKind kind: String,
                                                     mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil,
                                                     handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View:UICollectionReusableView

    Parameters

    supplementaryClass

    UICollectionReusableView class to register

    kind

    supplementary view kind

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when supplementary view is dequeued.

  • Registers mapping from modelType to supplementaryClass. Mapping will automatically check for nib with the same name as supplementaryClass and register it, if it is found. If supplementary view is designed in storyboard, please set mapping.supplementaryRegisteredByStoryboard property to true inside of mapping closure.

    Declaration

    Swift

    open func registerSupplementary<View:UICollectionReusableView, Model>(_ supplementaryClass: View.Type,
                                                                          for modelType: Model.Type,
                                                                          ofKind kind: String,
                                                                          mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil,
                                                                          handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })

    Parameters

    footerClass

    UICollectionReusableView class to register

    modelType

    Model type, which is mapped to supplementaryClass.

    mapping

    mapping configuration closure, executed before any registration or dequeue is performed.

    handler

    configuration closure, that is run when supplementary view is dequeued.

  • Unregisters cellClass from DTCollectionViewManager and UICollectionView.

    Declaration

    Swift

    open func unregister<Cell>(_ cellClass: Cell.Type) where Cell : UICollectionViewCell, Cell : ModelTransfer
  • Unregisters headerClass from DTCollectionViewManager and UICollectionView.

    Declaration

    Swift

    open func unregisterHeader<View>(_ headerClass: View.Type) where View : UICollectionReusableView, View : ModelTransfer
  • Unregisters footerClass from DTCollectionViewManager and UICollectionView.

    Declaration

    Swift

    open func unregisterFooter<View>(_ headerClass: View.Type) where View : UICollectionReusableView, View : ModelTransfer
  • Unregisters supplementaryClass of kind from DTCollectionViewManager and UICollectionView.

    Declaration

    Swift

    open func unregisterSupplementary<View>(_ supplementaryClass: View.Type, ofKind kind: String) where View : UICollectionReusableView, View : ModelTransfer