SectionViewModel
@MainActor
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] = [])
Parameters
id
A unique identifier for the section.
cells
The cells 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, 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.