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
trueif the section has supplementary views,falseotherwise.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
idA unique identifier for the section.
cellsThe cells in the section.
headerThe header for the section.
footerThe footer for the section.
supplementaryViewsThe supplementary views in the section.
-
Initializes a section.
Declaration
Swift
public init<Cell: CellViewModel>( id: UniqueIdentifier, cells: [Cell] )Parameters
idA unique identifier for the section.
cellsThe 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
idA unique identifier for the section.
cellsThe cells in the section.
headerThe header for the section.
footerThe footer for the section.
supplementaryViewsThe 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
idA unique identifier for the section.
cellsThe cells in the section.
headerThe header for the section.
footerThe footer for the section.
supplementaryViewsThe 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
idA unique identifier for the section.
cellsThe cells in the section.
headerThe header for the section.
footerThe footer for the section.
supplementaryViewsThe 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
idA unique identifier for the section.
cellsThe cells in the section.
headerThe header for the section.
footerThe footer for the section.
supplementaryViewsThe supplementary views in the section.
-
Returns the cell for the specified
id.Declaration
Swift
public func cellViewModel(for id: UniqueIdentifier) -> AnyCellViewModel?Parameters
idThe 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
idThe identifier for the supplementary view.
Return Value
The supplementary view, if it exists.
View on GitHub