// // TableCellModel.swift // VDS // // Created by Nadigadda, Sumanth on 02/05/24. // import Foundation import UIKit import VDSTokens /// Fetches the estimated height of component for said width public protocol ComponentHeight { func estimatedHeight(for width: CGFloat) -> CGFloat? } /// Model that represent the content of each cell of Table component public struct TableItemModel { /// Default cell height public var defaultHeight: CGFloat { return 50.0 } public var bottomLine: Line.Style? /// Component to be show in the Table cell public var component: UIView & ComponentHeight public init(bottomLine: Line.Style? = nil, component: UIView & ComponentHeight) { self.bottomLine = bottomLine self.component = component } } /// Confirming protocol ``ComponentHeight`` to determine the height, based on the width 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 } }