chore: add not stable cell height cache back

This commit is contained in:
CMK 2021-07-03 03:31:49 +08:00
parent 0fc1aed004
commit c6e2e867e1
1 changed files with 27 additions and 27 deletions

View File

@ -189,33 +189,33 @@ extension NotificationViewController {
extension NotificationViewController: StatusTableViewControllerAspect { } extension NotificationViewController: StatusTableViewControllerAspect { }
// MARK: - TableViewCellHeightCacheableContainer // MARK: - TableViewCellHeightCacheableContainer
//extension NotificationViewController: TableViewCellHeightCacheableContainer { extension NotificationViewController: TableViewCellHeightCacheableContainer {
// var cellFrameCache: NSCache<NSNumber, NSValue> { var cellFrameCache: NSCache<NSNumber, NSValue> {
// viewModel.cellFrameCache viewModel.cellFrameCache
// } }
//
// func cacheTableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { func cacheTableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
// guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let diffableDataSource = viewModel.diffableDataSource else { return }
// guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
// let key = item.hashValue let key = item.hashValue
// let frame = cell.frame let frame = cell.frame
// viewModel.cellFrameCache.setObject(NSValue(cgRect: frame), forKey: NSNumber(value: key)) viewModel.cellFrameCache.setObject(NSValue(cgRect: frame), forKey: NSNumber(value: key))
// } }
//
// func handleTableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { func handleTableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
// guard let diffableDataSource = viewModel.diffableDataSource else { return UITableView.automaticDimension } guard let diffableDataSource = viewModel.diffableDataSource else { return UITableView.automaticDimension }
// guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return UITableView.automaticDimension } guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return UITableView.automaticDimension }
// guard let frame = viewModel.cellFrameCache.object(forKey: NSNumber(value: item.hashValue))?.cgRectValue else { guard let frame = viewModel.cellFrameCache.object(forKey: NSNumber(value: item.hashValue))?.cgRectValue else {
// if case .bottomLoader = item { if case .bottomLoader = item {
// return TimelineLoaderTableViewCell.cellHeight return TimelineLoaderTableViewCell.cellHeight
// } else { } else {
// return UITableView.automaticDimension return UITableView.automaticDimension
// } }
// } }
//
// return ceil(frame.height) return ceil(frame.height)
// } }
//} }
// MARK: - UITableViewDelegate // MARK: - UITableViewDelegate