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
true
if this section has zero cell view models,false
otherwise.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
diffingKey
a
String
key unique to this section that is used to diff sections automatically. Pass innil
if you are not using automatic diffing on this collection.cellViewModels
The cell view models contained in this section.
headerViewModel
A header view model for this section (defaults to
nil
).footerViewModel
A 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
headerTitle
The title for the header, or
nil
. Setting a title will cause a default header to be added to this section.headerHeight
The height of the default header, if one exists.
cellViewModels
The cell view models contained in this section.
footerTitle
The title for the footer, or
nil
. Setting a title will cause a default footeer to be added to this section.footerHeight
The height of the default footer, if one exists.
diffingKey
A diffing key.