Skip to content

Releases: DenTelezhkin/DTCollectionViewManager

11.0.0

06 Oct 12:46
Compare
Choose a tag to compare

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

11 Jul 10:15
Compare
Choose a tag to compare

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

02 Dec 15:40
Compare
Choose a tag to compare

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

12 Jul 11:38
Compare
Choose a tag to compare
Releasing version 9.0.0-beta.1.

7.1.3

14 May 13:14
Compare
Choose a tag to compare

Fixed

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

7.1.2

14 May 12:26
Compare
Choose a tag to compare

Fixed

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

7.1.1

14 May 11:08
Compare
Choose a tag to compare

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

27 Apr 09:20
Compare
Choose a tag to compare

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

03 Mar 09:43
Compare
Choose a tag to compare

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

16 Dec 17:33
Compare
Choose a tag to compare

Fixed

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