Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UIColor+MapsMeColor.mm « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: be32bc62614feea106d01cdb0ccaa2ed89698e17 (plain)
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#import "UIColor+MapsMeColor.h"

namespace
{

CGFloat const alpha04 = 0.04;
CGFloat const alpha12 = 0.12;
CGFloat const alpha26 = 0.26;
CGFloat const alpha30 = 0.3;
CGFloat const alpha40 = 0.4;
CGFloat const alpha54 = 0.54;
CGFloat const alpha70 = 0.7;
CGFloat const alpha80 = 0.8;
CGFloat const alpha87 = 0.87;
CGFloat const alpha90 = 0.9;
CGFloat const alpha100 = 1.;

BOOL isNightMode = NO;

CGFloat scaled(CGFloat f)
{
  return f / 255.;
}

NSDictionary<NSString *, UIColor *> * night =
@{
  @"primaryDark" : [UIColor colorWithRed:scaled(25.) green:scaled(30) blue:scaled(35.) alpha:alpha100],
  @"primary" : [UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha100],
  // Light green color
  @"primaryLight" : [UIColor colorWithRed:scaled(65.) green:scaled(70.) blue:scaled(75.) alpha:alpha100],
  @"menuBackground" : [UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha80],
  @"downloadBadgeBackground" : [UIColor colorWithRed:scaled(230.) green:scaled(70.) blue:scaled(60.) alpha:alpha100],
  // Background color && press color
  @"pressBackground" : [UIColor colorWithRed:scaled(50.) green:scaled(54.) blue:scaled(58.) alpha:alpha100],
  // Red color (use for status closed in place page)
  @"red" : [UIColor colorWithRed:scaled(230.) green:scaled(70.) blue:scaled(60.) alpha:alpha100],
  @"errorPink" : [UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha26],
  // Orange color (use for status 15 min in place page)
  @"orange" : [UIColor colorWithRed:250. green:scaled(190.) blue:scaled(10.) alpha:alpha100],
  // Blue color (use for links and phone numbers)
  @"linkBlue" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha100],
  @"linkBlueHighlighted" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
  @"linkBlueDark" : [UIColor colorWithRed:scaled(200.) green:scaled(180.) blue:scaled(110.) alpha:alpha100],
  @"blackPrimaryText" : [UIColor colorWithWhite:1. alpha:alpha90],
  @"blackSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha70],
  @"blackHintText" : [UIColor colorWithWhite:1. alpha:alpha30],
  @"blackDividers" : [UIColor colorWithWhite:1. alpha:alpha12],
  @"white" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha100],
  @"whiteSecondaryText" : [UIColor colorWithWhite:0. alpha:alpha70],
  @"whiteHintText" : [UIColor colorWithWhite:0. alpha:alpha26],
  @"buttonDisabledBlueText" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30],
  @"alertBackground" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha90],
  @"blackOpaque" : [UIColor colorWithWhite:1. alpha:alpha04]
};

NSDictionary<NSString *, UIColor *> * day =
@{
  @"primaryDark" : [UIColor colorWithRed:scaled(24.) green:scaled(128) blue:scaled(68.) alpha:alpha100],
  @"primary" : [UIColor colorWithRed:scaled(32.) green:scaled(152.) blue:scaled(82.) alpha:alpha100],
  // Light green color
  @"primaryLight" : [UIColor colorWithRed:scaled(36.) green:scaled(180.) blue:scaled(98.) alpha:alpha100],
  @"menuBackground" : [UIColor colorWithWhite:1. alpha:alpha80],
  @"downloadBadgeBackground" : [UIColor colorWithRed:scaled(255.) green:scaled(55.) blue:scaled(35.) alpha:alpha100],
  // Background color && press color
  @"pressBackground" : [UIColor colorWithRed:scaled(245.) green:scaled(245.) blue:scaled(245.) alpha:alpha100],
  // Red color (use for status closed in place page)
  @"red" : [UIColor colorWithRed:scaled(230.) green:scaled(15.) blue:scaled(35.) alpha:alpha100],
  @"errorPink" : [UIColor colorWithRed:scaled(246.) green:scaled(60.) blue:scaled(51.) alpha:alpha12],
  // Orange color (use for status 15 min in place page)
  @"orange" : [UIColor colorWithRed:1. green:scaled(120.) blue:scaled(5.) alpha:alpha100],
  // Blue color (use for links and phone numbers)
  @"linkBlue" : [UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha100],
  @"linkBlueHighlighted" : [UIColor colorWithRed:scaled(30.) green:scaled(150.) blue:scaled(240.) alpha:alpha30],
  @"linkBlueDark" : [UIColor colorWithRed:scaled(25.) green:scaled(135.) blue:scaled(215.) alpha:alpha100],
  @"blackPrimaryText" : [UIColor colorWithWhite:0. alpha:alpha87],
  @"blackSecondaryText" : [UIColor colorWithWhite:0. alpha:alpha54],
  @"blackHintText" : [UIColor colorWithWhite:0. alpha:alpha26],
  @"blackDividers" : [UIColor colorWithWhite:0. alpha:alpha12],
  @"white" : [UIColor colorWithWhite:1. alpha:alpha100],
  @"whiteSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha54],
  @"whiteHintText" : [UIColor colorWithWhite:1. alpha:alpha30],
  @"buttonDisabledBlueText" :[UIColor colorWithRed:scaled(3.) green:scaled(122.) blue:scaled(255.) alpha:alpha26],
  @"alertBackground" : [UIColor colorWithWhite:1. alpha:alpha90],
  @"blackOpaque" : [UIColor colorWithWhite:0. alpha:alpha04]
};

UIColor * color(SEL cmd)
{
  return (isNightMode ? night : day)[NSStringFromSelector(cmd)];
}

} // namespace

@implementation UIColor (MapsMeColor)

+ (void)setNightMode:(BOOL)mode
{
  isNightMode = mode;
}

+ (BOOL)isNightMode
{
  return isNightMode;
}

- (UIColor *)opposite
{
  NSString * key = [[(isNightMode ? day : night) allKeysForObject:self] firstObject];
  return key == nil ? nil : (isNightMode ? night : day)[key];
}

// Dark green color
+ (UIColor *)primaryDark
{
  return color(_cmd);
}

// Green color
+ (UIColor *)primary
{
  return color(_cmd);
}

// Light green color
+ (UIColor *)primaryLight
{
  return color(_cmd);
}

// Use for opaque fullscreen
+ (UIColor *)fadeBackground
{
  return [UIColor colorWithWhite:0. alpha:alpha80];
}

+ (UIColor *)menuBackground
{
  return color(_cmd);
}

+ (UIColor *)downloadBadgeBackground
{
  return color(_cmd);
}
// Background color && press color
+ (UIColor *)pressBackground
{
  return color(_cmd);
}
// Red color (use for status closed in place page)
+ (UIColor *)red
{
  return color(_cmd);
}
// Yellow color (use for hotel's stars)
+ (UIColor *)yellow
{
  return [UIColor colorWithRed:scaled(255.) green:scaled(200.) blue:scaled(40.) alpha:alpha100];
}
// Green color (use for booking rating)
+ (UIColor *)green
{
  return [UIColor colorWithRed:scaled(85.) green:scaled(139.) blue:scaled(47.) alpha:alpha100];
}
// Pink background for invalid fields
+ (UIColor *)errorPink
{
  return color(_cmd);
}
// Orange color (use for status 15 min in place page)
+ (UIColor *)orange
{
  return color(_cmd);
}

// Blue color (use for links and phone numbers)
+ (UIColor *)linkBlue
{
  return color(_cmd);
}

+ (UIColor *)linkBlueHighlighted
{
  return color(_cmd);
}

+ (UIColor *)linkBlueDark
{
  return color(_cmd);
}

+ (UIColor *)blackPrimaryText
{
  return color(_cmd);
}

+ (UIColor *)blackSecondaryText
{
  return color(_cmd);
}

+ (UIColor *)blackStatusBarBackground
{
  return [UIColor colorWithWhite:0. alpha:alpha40];
}

+ (UIColor *)blackHintText
{
  return color(_cmd);
}

+ (UIColor *)blackDividers
{
  return color(_cmd);
}

+ (UIColor *)white
{
  return color(_cmd);
}

+ (UIColor *)whitePrimaryText
{
  return [UIColor colorWithWhite:1. alpha:alpha87];
}

+ (UIColor *)whitePrimaryTextHighlighted
{
  // use only for highlighted colors!
  return [UIColor colorWithWhite:1. alpha:alpha30];
}

+ (UIColor *)whiteSecondaryText
{
  return color(_cmd);
}

+ (UIColor *)whiteHintText
{
  return color(_cmd);
}

+ (UIColor *)whiteDividers
{
  return [UIColor colorWithWhite:1. alpha:alpha12];
}

+ (UIColor *)buttonDisabledBlueText
{
  return color(_cmd);
}

+ (UIColor *)buttonHighlightedBlueText
{
  return [UIColor colorWithRed:scaled(3.) green:scaled(122.) blue:scaled(255.) alpha:alpha54];
}

+ (UIColor *)alertBackground
{
  return color(_cmd);
}

+ (UIColor *)blackOpaque
{
  return color(_cmd);
}

+ (UIColor *)bookingBackground
{
  return [UIColor colorWithRed:scaled(25.) green:scaled(69.) blue:scaled(125.) alpha:alpha100];
}

+ (UIColor *)colorWithName:(NSString *)colorName
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
  return [[UIColor class] performSelector:NSSelectorFromString(colorName)];
#pragma clang diagnostic pop
}

@end