DTCollectionViewManager v8.0.0-beta.1 Release Notes

Release Date: 2020-09-02 // over 3 years ago
  • πŸ“š This is a major release with some breaking changes, please read DTCollectionViewManager 8.0 Migration Guide

    πŸ†• New

    • Cell and supplementary view events are now available inside mapping closure directly, for example:

      // Previous releasesmanager.register(PostCell.self) manager.didSelect(PostCell.self) { cell, model, indexPath in// React to selection}// Newmanager.register(PostCell.self) { mapping in mapping.didSelect { cell, model, indexPath in } }

    Those events are now tied to ViewModelMapping instance, which means, that events, registered this way, will only trigger, if mapping condition of current mapping applies. For example:

    manager.register(PostCell.self) { mapping in mapping.condition = .section(0) mapping.didSelect { cell, model, indexPath in// This closure will only get called, when user selects cell in the first section } } manager.register(PostCell.self) { mapping in mapping.condition = .section(1) mapping.didSelect { cell, model, indexPath in// This closure will only get called, when user selects cell in the second section } }
    
    • It's now possible to register collection view cells, that don't conform to DTModelTransfer protocol:

      manager.register(UICollectionViewCell.self, String.self) { cell, indexPath, model in// configure cell with model which is of type String when passed into configuration closure.}

    πŸ”§ This is particularly useful on iOS / tvOS 14 and higher, where you can configure UICollectionViewListCell without needing to subclass it.
    πŸ‘ Cells, registered in this way, can safely coexist with cells, that conform to DTModelTransfer protocol. Conditional mappings are also supported (multiple trailing closures syntax available in Swift 5.3):

    manager.register(UICollectionViewCell.self, for: String.self) { $0.condition = .section(0) } handler { cell, indexPath, model in// configure cell with model which is of type String when passed into configuration closure.}
    
    • βž• Added event reaction for UICollectionViewDelegate.collectionView(_:canEditItemAt:) delegate method.
    • βž• Added event reactions for tvOS 13 TVCollectionViewDelegateFullScreenLayout protocol from TVUIKit framework.
    • πŸ†• New readme and in-depth documentation, split into several sections for developer convenience.

    πŸ”„ Changed

    • On iOS/tvOS 14 and higher, cell and supplementary views now use UICollectionView.dequeueConfiguredReusableCell and UICollectionView.dequeueConfiguredReusableSupplementary to be dequeued.
    • ⚑️ DTModelTransfer update(with:) method for such cells and supplementary views is called immediately after dequeueConfiguredReusableCell \ dequeueConfiguredReusableSupplementary return.
    • πŸ‘ Generic placeholders for cell/model/view methods have been improved for better readability.

    πŸ’₯ Breaking

    πŸš€ This release requires Swift 5.3. Minimum iOS / tvOS deployment targets are unchanged (iOS 11, tvOS 11).

    πŸš€ Some context: this release heavily relies on where clauses on contextually generic declarations, that are only available in Swift 5.3 - SE-0267.

    • πŸ”§ Cells, headers and footers created in storyboard now need to be explicitly configured in view mapping:

      register(StoryboardCell.self) { mapping in mapping.cellRegisteredByStoryboard = true}registerHeader(StoryboardHeader.self) { mapping in mapping.supplementaryRegisteredByStoryboard = true}

    • All non-deprecated registration methods now have an additional handler closure, that allows to configure cells/headers/footers/supplementary views that are dequeued from UICollectionView. This is a direct replacement for configure(_:_:, configureHeader(_:_:), configureFooter(_:_:) and configureSupplementary(_:ofKind:_:, that are all now deprecated.

    • ⚑️ On iOS / tvOS 14 / Xcode 12 and higher handler closure, that is passed to registration methods, is used to call new dequeueConfiguredReusableCell(using:for:item:) and dequeueConfiguredReusableSupplementary(using:for:) methods on UICollectionView. Please note, that handler closure is called before DTModelTransfer.update(with:) method because of how new UICollectionView dequeue API works.

    • ViewModelMapping is now a generic class, that captures view and model information(ViewModelMapping<T,U>).

    • ⚑️ CollectionViewUpdater.batchUpdatesInProgress property was removed.

    πŸ—„ Deprecated

    • Several cell/header/footer/supplementary view registration methods have been deprecated to unify registration logic. Please use register(_:mapping:handler:), registerHeader(_:mapping:handler:), registerFooter(_:mapping:handler:) and registerSupplementary(_:forKind:mapping:handler:) as a replacements for all of those methods. For more information on those changes, please read migration guide
    • πŸ”§ DTCollectionViewManager.configureEvents(for:_:), it's functionality has become unnecessary since mapping closure of cell/supplementary registration now captures both cell and model type information for such events.
    • πŸ“š DTCollectionViewManager.configureDiffableDataSource(modelProvider:) for non-hashable data models. Please use configureDiffableDataSource method for models, that are Hashable. From Apple's documentation: If you’re working in a Swift codebase, always use UICollectionViewDiffableDataSource instead.

    πŸ›  Fixed

    • Supplementary views now correctly use ViewModelMapping.reuseIdentifier instead of falling back to name of the view class.
    • Several event API's have been improved to allow returning nil for methods, that accept nil as a valid value:
      contextMenuConfiguration, previewForHighlightingContextMenu, previewForDismissingContextMenu