-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
SelectableRow.swift
54 lines (43 loc) · 1.56 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
52
53
54
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 {
var social: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.social
}
var staffPicks: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.staffPicks
}
var starred: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.starred
}
var category: Lens<SelectableRow, KsApi.Category?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.category
}
var includePOTD: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.includePOTD
}
var recommended: Lens<SelectableRow, Bool?> {
return SelectableRow.lens.params .. DiscoveryParams.lens.recommended
}
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
}