DTTableViewManager v8.0.0 Release Notes
Release Date: 2020-10-27 // about 4 years ago-
No data yet π
You can check the official repo
Previous changes from v8.0.0-beta.1
-
β Added
- Cell and supplementary view events are now available inside mapping closure directly, for example:
// Previous releases manager.register(PostCell.self) manager.didSelect(PostCell.self) { cell, model, indexPath in // React to selection } // New manager.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 } }
π Please note, that headers and footers only support mapping-style event registration, if they inherit from
UITableViewHeaderFooterView
.TableViewConfiguration
semanticHeaderHeight
andsemanticFooterHeight
, that specify whetherDTTableViewManager
should deploy custom logic intableView(_ tableView: UITableView, heightForHeaderInSection section: Int)
andtableView(_ tableView: UITableView, heightForFooterInSection section: Int)
. This logic includes checking whether header and footer models exist in storage, returningUITableView.automaticDimension
for sections, whose header and footer models are Strings (for table section titles), as well as returning minimal height for cases where data model is not there(which happens to be different forUITableView.Style.plain
andUITableView.Style.grouped
). Those properties default to true, but if you want to use self-sizing table view sections headers or footers, which may improve perfomance, consider turning those off:
manager.configuration.semanticHeaderHeight = false manager.configuration.semanticFooterHeight = false
Please note, that even when those properties are set to false, corresponding
UITableViewDelegate
methods will still be called in two cases:- Your
DTTableViewManageable
instance implements them - You register a
heightForHeader(withItem:_:)
orheightForFooter(withItem:_:)
closures onDTTableViewManager
instance.
π₯ 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.
ViewModelMapping
is now a generic class, that captures view and model information(ViewModelMapping).
π Fixed
indentationLevelForCell
closure now correctly returnsInt
instead ofCGFloat
.- Several event API's have been improved to allow returning nil for methods, that accept nil as a valid value:
contextMenuConfiguration
,previewForHighlightingContextMenu
,previewForDismissingContextMenu
.
π Changed
- π Generic placeholders for cell/model/view methods have been improved for better readability.
π 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:)
as a replacements for all of those methods. For more information on those changes, please read [migration guide](Documentation/Migration%20guides/8.0%20Migration%20Guide.md). - All non-deprecated registration methods now have an additional
handler
closure, that allows to configure cells/headers/footers that are dequeued from UITableView. This is a direct replacement forconfigure(_:_:
,configureHeader(_:_:)
,configureFooter(_:_:)
, that are all now deprecated. Please note, that handler closure is called beforeDTModelTransfer.update(with:)
method. - π§
DTTableViewManager.configureEvents(for:_:)
, it's functionality has become unnecessary since mapping closure of cell/header/footer registration now captures both cell and model type information for such events. - π
DTTableViewManager.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 UITableViewDiffableDataSource instead
. - β‘οΈ
TableViewUpdater.usesLegacyTableViewUpdateMethods
property.