// // TableCellModel.swift // VDS // // Created by Nadigadda, Sumanth on 02/05/24. // import Foundation import UIKit import VDSTokens public protocol ComponentHeight { func estimatedHeight(for width: CGFloat) -> CGFloat? } public struct TableItemModel { public var defaultHeight: CGFloat { return 50.0 } public var bottomLine: Line.Style? public var component: UIView & ComponentHeight public init(bottomLine: Line.Style? = nil, component: UIView & ComponentHeight) { self.bottomLine = bottomLine self.component = component } } extension Label: ComponentHeight { public func estimatedHeight(for width: CGFloat) -> CGFloat? { let maxbounds = CGSize(width: width, height: CGFloat.greatestFiniteMagnitude) return self.sizeThatFits(maxbounds).height } } extension Icon: ComponentHeight { public func estimatedHeight(for width: CGFloat) -> CGFloat? { return intrinsicContentSize.height } }