-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathSelectableRow.swift
51 lines (46 loc) · 1.73 KB
/
SelectableRow.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
import KsApi
import Prelude
public struct SelectableRow {
public let isSelected: Bool
public let params: DiscoveryParams
public enum lens {
public static let isSelected = Lens<SelectableRow, Bool>(
view: { $0.isSelected },
set: { SelectableRow(isSelected: $0, params: $1.params) }
)
public static let params = Lens<SelectableRow, DiscoveryParams>(
view: { $0.params },
set: { SelectableRow(isSelected: $1.isSelected, params: $0) }
)
}
}
public extension Lens where Whole == SelectableRow, Part == DiscoveryParams {
public var social: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.social
}
public var staffPicks: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.staffPicks
}
public var starred: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.starred
}
public var category: Lens<SelectableRow, KsApi.Category?> {
return SelectableRow.lens.params..DiscoveryParams.lens.category
}
public var hasLiveStreams: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.hasLiveStreams
}
public var includePOTD: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.includePOTD
}
public var recommended: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.recommended
}
public var backed: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params..DiscoveryParams.lens.backed
}
}
extension SelectableRow: Equatable {}
public func == (lhs: SelectableRow, rhs: SelectableRow) -> Bool {
return lhs.isSelected == rhs.isSelected && lhs.params == rhs.params
}