-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSectionViewModel.swift
61 lines (49 loc) · 1.25 KB
/
SectionViewModel.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by Jesse Squires
// https://www.jessesquires.com
//
// Documentation
// https://jessesquires.github.io/ReactiveCollectionsKit
//
// GitHub
// https://github.com/jessesquires/ReactiveCollectionsKit
//
// Copyright © 2019-present Jesse Squires
//
import Foundation
public struct SectionViewModel: DiffableViewModel {
public let id: UniqueIdentifier
public let cellViewModels: [AnyCellViewModel]
public init(id: UniqueIdentifier,
cells: [AnyCellViewModel]) {
self.id = id
self.cellViewModels = cells
}
}
// MARK: Collection, RandomAccessCollection
extension SectionViewModel: Collection, RandomAccessCollection {
/// :nodoc:
public var count: Int {
self.cellViewModels.count
}
/// :nodoc:
public var isEmpty: Bool {
self.cellViewModels.isEmpty
}
/// :nodoc:
public var startIndex: Int {
self.cellViewModels.startIndex
}
/// :nodoc:
public var endIndex: Int {
self.cellViewModels.endIndex
}
/// :nodoc:
public subscript(position: Int) -> AnyCellViewModel {
self.cellViewModels[position]
}
/// :nodoc:
public func index(after i: Int) -> Int {
self.cellViewModels.index(after: i)
}
}