-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathUserLenses.swift
198 lines (160 loc) · 7.62 KB
/
UserLenses.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import Prelude
extension User {
public enum lens {
public static let avatar = Lens<User, User.Avatar>(
view: { $0.avatar },
set: { User(avatar: $0, facebookConnected: $1.facebookConnected, id: $1.id, isFriend: $1.isFriend,
liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name, newsletters: $1.newsletters,
notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let facebookConnected = Lens<User, Bool?>(
view: { $0.facebookConnected },
set: { User(avatar: $1.avatar, facebookConnected: $0, id: $1.id, isFriend: $1.isFriend,
liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name, newsletters: $1.newsletters,
notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let id = Lens<User, Int>(
view: { $0.id },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $0, isFriend: $1.isFriend,
liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name, newsletters: $1.newsletters,
notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let isFriend = Lens<User, Bool?>(
view: { $0.isFriend },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id, isFriend: $0,
liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name, newsletters: $1.newsletters,
notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let liveAuthToken = Lens<User, String?>(
view: { $0.liveAuthToken },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $0, location: $1.location, name: $1.name,
newsletters: $1.newsletters, notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let location = Lens<User, Location?>(
view: { $0.location },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $0, name: $1.name,
newsletters: $1.newsletters, notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let name = Lens<User, String>(
view: { $0.name },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $1.location, name: $0,
newsletters: $1.newsletters, notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let newsletters = Lens<User, User.NewsletterSubscriptions>(
view: { $0.newsletters },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name,
newsletters: $0, notifications: $1.notifications, social: $1.social, stats: $1.stats) }
)
public static let notifications = Lens<User, User.Notifications>(
view: { $0.notifications },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name,
newsletters: $1.newsletters, notifications: $0, social: $1.social, stats: $1.stats) }
)
public static let social = Lens<User, Bool?>(
view: { $0.social },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name,
newsletters: $1.newsletters, notifications: $1.notifications, social: $0, stats: $1.stats) }
)
public static let stats = Lens<User, User.Stats>(
view: { $0.stats },
set: { User(avatar: $1.avatar, facebookConnected: $1.facebookConnected, id: $1.id,
isFriend: $1.isFriend, liveAuthToken: $1.liveAuthToken, location: $1.location, name: $1.name,
newsletters: $1.newsletters, notifications: $1.notifications, social: $1.social, stats: $0) }
)
}
}
extension Lens where Whole == User, Part == User.Avatar {
public var large: Lens<User, String?> {
return User.lens.avatar..User.Avatar.lens.large
}
public var medium: Lens<User, String> {
return User.lens.avatar..User.Avatar.lens.medium
}
public var small: Lens<User, String> {
return User.lens.avatar..User.Avatar.lens.small
}
}
extension Lens where Whole == User, Part == User.NewsletterSubscriptions {
public var arts: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.arts
}
public var games: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.games
}
public var happening: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.happening
}
public var invent: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.invent
}
public var promo: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.promo
}
public var weekly: Lens<User, Bool?> {
return User.lens.newsletters..User.NewsletterSubscriptions.lens.weekly
}
}
extension Lens where Whole == User, Part == User.Notifications {
public var backings: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.backings
}
public var comments: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.comments
}
public var follower: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.follower
}
public var friendActivity: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.friendActivity
}
public var postLikes: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.postLikes
}
public var creatorTips: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.creatorTips
}
public var creatorDigest: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.creatorDigest
}
public var updates: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.updates
}
public var mobileBackings: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobileBackings
}
public var mobileComments: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobileComments
}
public var mobileFollower: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobileFollower
}
public var mobileFriendActivity: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobileFriendActivity
}
public var mobilePostLikes: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobilePostLikes
}
public var mobileUpdates: Lens<User, Bool?> {
return User.lens.notifications..User.Notifications.lens.mobileUpdates
}
}
extension Lens where Whole == User, Part == User.Stats {
public var backedProjectsCount: Lens<User, Int?> {
return User.lens.stats..User.Stats.lens.backedProjectsCount
}
public var createdProjectsCount: Lens<User, Int?> {
return User.lens.stats..User.Stats.lens.createdProjectsCount
}
public var memberProjectsCount: Lens<User, Int?> {
return User.lens.stats..User.Stats.lens.memberProjectsCount
}
public var starredProjectsCount: Lens<User, Int?> {
return User.lens.stats..User.Stats.lens.starredProjectsCount
}
}