DTCollectionViewManager Versions Save

Protocol-oriented UICollectionView management, powered by generics and associated types.

11.0.0

1 year ago

Added

  • Support for UICollectionViewDelegate.collectionView(_:canPerformPrimaryActionForItemAt:) and UICollectionViewDelegate.collectionView(_:performPrimaryActionForItemAt:) delegate methods on iOS 16 and tvOS 16.
  • Support for UICollectionViewDelegate.collectionView(_:contextMenuConfigurationForItemsAt:point:), UICollectionViewDelegate.collectionView(_:contextMenuConfiguration:highlightPreviewForItemAt:) and UICollectionViewDelegate.collectionView(_:contextMenuConfiguration:dismissalPreviewForItemAt: methods on iOS 16.
  • Support for UIHostingConfiguration on iOS 16 / tvOS 16 / macCatalyst 16:
manager.registerHostingConfiguration(for: Post.self) { _, post, _ in
    UIHostingConfiguration {
        PostView(post: post)
    }
}

It's also possible to incorporate UIKit cell states by simply adding additional parameter to registration:

manager.registerHostingConfiguration(for: Post.self) { state, _, post, _ in
    UIHostingConfiguration {
        PostView(post: post, isSelected: state.isSelected)
    }
}

Additionally, it's possible to customize UICollectionViewCell being used to host SwiftUI view, for example for list cells:

manager.registerHostingConfiguration(for: Post.self, cell: UICollectionViewListCell.self) { _, post, _ in
    UIHostingConfiguration {
        PostView(post: post)
    }
}
  • Support for events, wrapping UICollectionViewDataSourcePrefetching protocol.
manager.register(PostCell.self) { mapping in
    mapping.prefetch { model, indexPath in }
    mapping.cancelPrefetch { model, indexPath in }
}

Please note, that while datasource methods are called once per array of indexPaths, events for models will be called individually, so single model (and indexPath) is passed to each event. Theoretically, this should make prefetching and cancellation easier, since you no longer need to walk through array and find all data models, you can operate on a single data model at a time.

Deprecated

  • Cell / View events, registered with DTCollectionViewManager are soft-deprecated. Please use events in mapping instead:

Deprecated:

    manager.register(PostCell.self)
    manager.didSelect(PostCell.self) { postCell, post, indexPath in }

Recommended:

    manager.register(PostCell.self) { mapping in
        mapping.didSelect { postCell, post, indexPath in }
    }

While previously main benefits for second syntax were mostly syntactic, now with support for SwiftUI it will be hard to actually specialize hosting cells (and might be impossible when iOS 16 hosting configuration is supported), so only second syntax will work for all kinds of cells, and first syntax can only work for non-SwiftUI cells. New delegate methods for UICollectionView (starting with iOS 16 / tvO 16 SDK) will be added only as extension to mapping protocols, not DTCollectionViewManager itself.

11.0.0-beta.1

1 year ago

Introducing support for SwiftUI!

Registering SwiftUI views as content for collection view cells:

manager.registerHostingCell(for: Post.self) { model, indexPath in
    PostSwiftUIView(model: model)
}

This method is supported on iOS 13+ / tvOS 13+ / macCatalyst 13+.

Please note, that this integration is not supported by Apple, therefore it comes with several workarounds, read more about those in SwiftUI support document

Added

  • HostingCellViewModelMapping - CellViewModelMapping subclass to register mappings fro SwiftUI views.
  • HostingCollectionViewCell - UICollectionViewCell subclass , implementing container for SwiftUI view embedded into it.
  • HostingCollectionViewCellConfiguration - configuration for SwiftUI views hosting inside HostingCollectionViewCell.

Changed

  • Event reactions are now defined in protocol extension instead of extending former ViewModelMapping protocol, thus allowing to call those methods not only for UIKit mappings, but SwiftUI-hosted cells as well.

Breaking

  • ViewModelMapping class and it's protocol have been split into multiple classes and protocols for better subclassability (for example CellViewModelMapping / CollectionViewCellModelMapping). Please note, that while technically this is breaking, it's very unlikely to break anything in code, since this type is only present in mapping closures, and public interfaces did not change at all.

10.0.0

2 years ago

Added

  • Wrappers for collectionView:selectionFollowsFocusForItemAtIndexPath: delegate method.
  • Wrappers for iOS 15 UICollectionViewDelegate.collectionView(_:targetIndexPathForMoveOfItemFromOriginalIndexPath:atCurrentIndexPath:toProposedIndexPath:) delegate method.

Removed

  • Wrappers for collectionView:willCommitMenuWithAnimator delegate method, that was only briefly available in Xcode 12, and was removed by Apple in one of Xcode 12 releases.

Changed

  • To align version numbers between DTModelStorage, DTTableViewManager and DTCollectionViewManager, DTCollectionViewManager will not have 9.x release, instead it's being released as 10.x.

Deprecated

  • targetIndexPathForMovingItem deprecated on iOS / tvOS 15 and higher, because delegate method collectionView:targetIndexPathForMoveFromItemAt:toProposedIndexPath: was deprecated in favor of newer method.

9.0.0-beta.1

2 years ago

7.1.3

3 years ago

Fixed

  • Build issues with Xcode 12.5 / Xcode 12.4 and lower.

7.1.2

3 years ago

Fixed

  • Build issue for Xcode 12.4, now compatible with both Xcode 12.5 and 12.4 and lower

7.1.1

3 years ago

Note: This is backwards-compatibility release, it only fixes build issue with Xcode 12.5. For future development please consider migrating to DTCollectionViewManager 8.

Fixed

  • Build issues with Xcode 12.5

8.2.0

3 years ago

Changed

  • UICollectionViewDatasource.indexTitles(for:) and UICollectionViewDatasource.collectionView(_: indexPathForIndexTitle:at:) methods and events now require iOS 14 (and seem to be working only on iOS 14) as per SDK changes in Xcode 12.5.

Fixed

  • Xcode 12.5 / Swift 5.4 warnings
  • Cell and supplementary view anomaly verification now correctly checks if corresponding subclasses respond to init(frame:) initializer.

8.1.0

3 years ago

This release fixes a critical issue with cell and supplementary reuse on iOS 14 / tvOS 14. If you are using 8.x release, it's highly recommended to upgrade to this release.

Changed

  • UICollectionView.CellRegistration and UICollectionView.SupplementaryRegistration on iOS 14 / tvOS 14 are now created once per mapping, thus properly allowing cell and supplementary reuse.

Deprecated

  • DTCollectionViewManagerAnomaly.differentCellReuseIdentifier. If you are using cells from code or from xib, please use empty reuseIdentifier, because on iOS 14 / tvOS 14 reuseIdentifiers are being set by UICollectionView.CellRegistration object. If you are using storyboards, set reuseIdentifier of the cell to cell subclass name.

8.0.1

3 years ago

Fixed

  • Typo, that caused anomalies to trigger when using events for UICollectionViewLayout(thanks, @RenGate).