co-maps/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTableView.swift

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
868 B
Swift
Raw Normal View History

2025-11-22 13:58:55 +01:00
final class RouteManagerTableView: UITableView {
@IBOutlet private weak var tableViewHeight: NSLayoutConstraint!
enum HeightUpdateStyle {
case animated
case deferred
case off
}
var heightUpdateStyle = HeightUpdateStyle.deferred
private var scheduledUpdate: DispatchWorkItem?
override var contentSize: CGSize {
didSet {
guard contentSize != oldValue else { return }
scheduledUpdate?.cancel()
let update = { [weak self] in
guard let s = self else { return }
s.tableViewHeight.constant = s.contentSize.height
}
switch heightUpdateStyle {
case .animated: superview?.animateConstraints(animations: update)
case .deferred:
scheduledUpdate = DispatchWorkItem(block: update)
DispatchQueue.main.async(execute: scheduledUpdate!)
case .off: break
}
}
}
}