DTTableViewManager v8.0.0 Release Notes

Release Date: 2020-10-27 // about 1 month ago

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 and semanticFooterHeight, that specify whether DTTableViewManager should deploy custom logic in tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) and tableView(_ tableView: UITableView, heightForFooterInSection section: Int). This logic includes checking whether header and footer models exist in storage, returning UITableView.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 for UITableView.Style.plain and UITableView.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:

    1. Your DTTableViewManageable instance implements them
    2. You register a heightForHeader(withItem:_:) or heightForFooter(withItem:_:) closures on DTTableViewManager 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 returns Int instead of CGFloat.
    • 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 for configure(_:_:, configureHeader(_:_:), configureFooter(_:_:) , that are all now deprecated. Please note, that handler closure is called before DTModelTransfer.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.