TableSectionViewModel
public struct TableSectionViewModel : DiffableViewModel
View model for a table view section.
-
Cells to be shown in this section.
Declaration
Swift
public let cellViewModels: [TableCellViewModel] -
View model for the header of this section.
Declaration
Swift
public let headerViewModel: TableSectionHeaderFooterViewModel? -
View model for the footer of this section.
Declaration
Swift
public let footerViewModel: TableSectionHeaderFooterViewModel? -
The key used by the diffing algorithm to uniquely identify this section. If you are using automatic diffing on the
TableViewDriver(which is enabled by default) you are required to provide a key that uniquely identifies this section.Typically you want to base this diffing key on data that is stored in the model. For example:
public var diffingKey = { group.identifier }Declaration
Swift
public var diffingKey: String -
Returns
trueif this section has zero cell view models,falseotherwise.Declaration
Swift
public var isEmpty: Bool { get } -
Initializes a
TableSectionViewModel.Declaration
Swift
public init( diffingKey: String?, cellViewModels: [TableCellViewModel], headerViewModel: TableSectionHeaderFooterViewModel? = nil, footerViewModel: TableSectionHeaderFooterViewModel? = nil )Parameters
diffingKeya
Stringkey unique to this section that is used to diff sections automatically. Pass innilif you are not using automatic diffing on this collection.cellViewModelsThe cell view models contained in this section.
headerViewModelA header view model for this section (defaults to
nil).footerViewModelA footer view model for this section (defaults to
nil). -
Initializes a
TableSectionViewModel.Declaration
Swift
public init( diffingKey: String?, headerTitle: String?, headerHeight: CGFloat?, cellViewModels: [TableCellViewModel], footerTitle: String? = nil, footerHeight: CGFloat? = 0 )Parameters
headerTitleThe title for the header, or
nil. Setting a title will cause a default header to be added to this section.headerHeightThe height of the default header, if one exists.
cellViewModelsThe cell view models contained in this section.
footerTitleThe title for the footer, or
nil. Setting a title will cause a default footeer to be added to this section.footerHeightThe height of the default footer, if one exists.
diffingKeyA diffing key.
View on GitHub
TableSectionViewModel Structure Reference