SectionViewModel
public struct SectionViewModel : DiffableViewModel
extension SectionViewModel: Collection, RandomAccessCollection
extension SectionViewModel: CustomDebugStringConvertible
Represents a section of items in a collection.
-
A unique id for this model.
Declaration
Swift
public let id: UniqueIdentifier
-
The cells in the section.
Declaration
Swift
public let cells: [AnyCellViewModel]
-
The header for the section.
Declaration
Swift
public let header: AnySupplementaryViewModel?
-
The footer for the section.
Declaration
Swift
public let footer: AnySupplementaryViewModel?
-
The supplementary views in the section.
Declaration
Swift
public let supplementaryViews: [AnySupplementaryViewModel]
-
Returns
true
if the section has supplementary views,false
otherwise.Declaration
Swift
public var hasSupplementaryViews: Bool { get }
-
Initializes a section.
Declaration
Swift
public init( id: UniqueIdentifier, cells: [AnyCellViewModel] = [], header: AnySupplementaryViewModel? = nil, footer: AnySupplementaryViewModel? = nil, supplementaryViews: [AnySupplementaryViewModel] = [] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
header
The header for the section.
footer
The footer for the section.
supplementaryViews
The supplementary views in the section.
-
Initializes a section.
Declaration
Swift
public init<Cell: CellViewModel>( id: UniqueIdentifier, cells: [Cell] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
-
Initializes a section.
Declaration
Swift
public init<Header: SupplementaryHeaderViewModel, Footer: SupplementaryFooterViewModel>( id: UniqueIdentifier, cells: [AnyCellViewModel] = [], header: Header?, footer: Footer?, supplementaryViews: [AnySupplementaryViewModel] = [] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
header
The header for the section.
footer
The footer for the section.
supplementaryViews
The supplementary views in the section.
-
Initializes a section.
Declaration
Swift
public init<Cell: CellViewModel, Header: SupplementaryHeaderViewModel, Footer: SupplementaryFooterViewModel>( id: UniqueIdentifier, cells: [Cell], header: Header?, footer: Footer?, supplementaryViews: [AnySupplementaryViewModel] = [] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
header
The header for the section.
footer
The footer for the section.
supplementaryViews
The supplementary views in the section.
-
Initializes a section.
Declaration
Swift
public init<Cell: CellViewModel, View: SupplementaryViewModel>( id: UniqueIdentifier, cells: [Cell], header: AnySupplementaryViewModel? = nil, footer: AnySupplementaryViewModel? = nil, supplementaryViews: [View] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
header
The header for the section.
footer
The footer for the section.
supplementaryViews
The supplementary views in the section.
-
Initializes a section.
Declaration
Swift
public init< Cell: CellViewModel, Header: SupplementaryHeaderViewModel, Footer: SupplementaryFooterViewModel, View: SupplementaryViewModel> ( id: UniqueIdentifier, cells: [Cell], header: Header?, footer: Footer?, supplementaryViews: [View] )
Parameters
id
A unique identifier for the section.
cells
The cells in the section.
header
The header for the section.
footer
The footer for the section.
supplementaryViews
The supplementary views in the section.
-
Returns the cell for the specified
id
.Declaration
Swift
public func cellViewModel(for id: UniqueIdentifier) -> AnyCellViewModel?
Parameters
id
The identifier for the cell.
Return Value
The cell, if it exists.
-
Returns the supplementary view for the specified
id
.Declaration
Swift
public func supplementaryViewModel(for id: UniqueIdentifier) -> AnySupplementaryViewModel?
Parameters
id
The identifier for the supplementary view.
Return Value
The supplementary view, if it exists.