@momo-kits/avatar 0.0.61-beta.19 → 0.0.61-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Avatar.js +168 -24
- package/package.json +1 -1
package/Avatar.js
CHANGED
|
@@ -16,8 +16,7 @@ import {
|
|
|
16
16
|
IconSource,
|
|
17
17
|
Image,
|
|
18
18
|
ScaleSize,
|
|
19
|
-
|
|
20
|
-
} from '@momo-kits/core-v2';
|
|
19
|
+
} from '@momo-kits/core';
|
|
21
20
|
|
|
22
21
|
export const AvatarQuality = {
|
|
23
22
|
low: 'low',
|
|
@@ -31,6 +30,18 @@ export const AvatarSize = {
|
|
|
31
30
|
medium: 'medium',
|
|
32
31
|
large: 'large',
|
|
33
32
|
giant: 'giant',
|
|
33
|
+
size8: 'size8',
|
|
34
|
+
size24: 'size24',
|
|
35
|
+
size36: 'size36',
|
|
36
|
+
size44: 'size44',
|
|
37
|
+
size48: 'size48',
|
|
38
|
+
size52: 'size52',
|
|
39
|
+
size56: 'size56',
|
|
40
|
+
size64: 'size64',
|
|
41
|
+
size72: 'size72',
|
|
42
|
+
size80: 'size80',
|
|
43
|
+
size88: 'size88',
|
|
44
|
+
size96: 'size96',
|
|
34
45
|
};
|
|
35
46
|
|
|
36
47
|
const COLORS = [
|
|
@@ -107,7 +118,7 @@ const styles = StyleSheet.create({
|
|
|
107
118
|
});
|
|
108
119
|
|
|
109
120
|
const subIconSize = (width) => ({
|
|
110
|
-
|
|
121
|
+
tiny: {
|
|
111
122
|
width: 8,
|
|
112
123
|
height: 8,
|
|
113
124
|
borderRadius: 4,
|
|
@@ -127,6 +138,83 @@ const subIconSize = (width) => ({
|
|
|
127
138
|
height: 16,
|
|
128
139
|
borderRadius: 8,
|
|
129
140
|
},
|
|
141
|
+
size8: {
|
|
142
|
+
width: 8,
|
|
143
|
+
height: 8,
|
|
144
|
+
borderRadius: 4,
|
|
145
|
+
},
|
|
146
|
+
size24: {
|
|
147
|
+
width: 10,
|
|
148
|
+
height: 10,
|
|
149
|
+
borderRadius: 5,
|
|
150
|
+
},
|
|
151
|
+
size36: {
|
|
152
|
+
width: 10,
|
|
153
|
+
height: 10,
|
|
154
|
+
borderRadius: 5,
|
|
155
|
+
},
|
|
156
|
+
size44: {
|
|
157
|
+
width: 14,
|
|
158
|
+
height: 14,
|
|
159
|
+
borderRadius: 7,
|
|
160
|
+
},
|
|
161
|
+
size48: {
|
|
162
|
+
width: 14,
|
|
163
|
+
height: 14,
|
|
164
|
+
borderRadius: 7,
|
|
165
|
+
},
|
|
166
|
+
size52: {
|
|
167
|
+
width: 16,
|
|
168
|
+
height: 16,
|
|
169
|
+
borderRadius: 8,
|
|
170
|
+
},
|
|
171
|
+
size56: {
|
|
172
|
+
width: 16,
|
|
173
|
+
height: 16,
|
|
174
|
+
borderRadius: 8,
|
|
175
|
+
},
|
|
176
|
+
size64: {
|
|
177
|
+
width: 16,
|
|
178
|
+
height: 16,
|
|
179
|
+
borderRadius: 8,
|
|
180
|
+
top: -2,
|
|
181
|
+
left: -2,
|
|
182
|
+
},
|
|
183
|
+
size72: {
|
|
184
|
+
width: 18,
|
|
185
|
+
height: 18,
|
|
186
|
+
borderRadius: 9,
|
|
187
|
+
top: -3,
|
|
188
|
+
left: -3,
|
|
189
|
+
},
|
|
190
|
+
size80: {
|
|
191
|
+
width: 18,
|
|
192
|
+
height: 18,
|
|
193
|
+
borderRadius: 9,
|
|
194
|
+
top: -3,
|
|
195
|
+
left: -3,
|
|
196
|
+
},
|
|
197
|
+
size88: {
|
|
198
|
+
width: 18,
|
|
199
|
+
height: 18,
|
|
200
|
+
borderRadius: 9,
|
|
201
|
+
top: -4,
|
|
202
|
+
left: -4,
|
|
203
|
+
},
|
|
204
|
+
size96: {
|
|
205
|
+
width: 20,
|
|
206
|
+
height: 20,
|
|
207
|
+
borderRadius: 10,
|
|
208
|
+
top: -4,
|
|
209
|
+
left: -4,
|
|
210
|
+
},
|
|
211
|
+
giant: {
|
|
212
|
+
top: -5,
|
|
213
|
+
left: -5,
|
|
214
|
+
width: 24,
|
|
215
|
+
height: 24,
|
|
216
|
+
borderRadius: 12,
|
|
217
|
+
},
|
|
130
218
|
});
|
|
131
219
|
|
|
132
220
|
const avatarSize = (width) => ({
|
|
@@ -146,35 +234,95 @@ const avatarSize = (width) => ({
|
|
|
146
234
|
borderRadius: 20,
|
|
147
235
|
},
|
|
148
236
|
large: {
|
|
237
|
+
width: 60,
|
|
238
|
+
height: 60,
|
|
239
|
+
borderRadius: 30,
|
|
240
|
+
},
|
|
241
|
+
giant: {
|
|
242
|
+
width: 120,
|
|
243
|
+
height: 120,
|
|
244
|
+
borderRadius: 60,
|
|
245
|
+
},
|
|
246
|
+
size8: {
|
|
247
|
+
width: 8,
|
|
248
|
+
height: 8,
|
|
249
|
+
borderRadius: 4,
|
|
250
|
+
},
|
|
251
|
+
size24: {
|
|
252
|
+
width: 24,
|
|
253
|
+
height: 24,
|
|
254
|
+
borderRadius: 12,
|
|
255
|
+
},
|
|
256
|
+
size36: {
|
|
257
|
+
width: 36,
|
|
258
|
+
height: 36,
|
|
259
|
+
borderRadius: 18,
|
|
260
|
+
},
|
|
261
|
+
size44: {
|
|
262
|
+
width: 44,
|
|
263
|
+
height: 44,
|
|
264
|
+
borderRadius: 22,
|
|
265
|
+
},
|
|
266
|
+
size48: {
|
|
267
|
+
width: 48,
|
|
268
|
+
height: 48,
|
|
269
|
+
borderRadius: 24,
|
|
270
|
+
},
|
|
271
|
+
size52: {
|
|
272
|
+
width: 52,
|
|
273
|
+
height: 52,
|
|
274
|
+
borderRadius: 26,
|
|
275
|
+
},
|
|
276
|
+
size56: {
|
|
149
277
|
width: 56,
|
|
150
278
|
height: 56,
|
|
151
279
|
borderRadius: 28,
|
|
152
280
|
},
|
|
153
|
-
|
|
281
|
+
size64: {
|
|
282
|
+
width: 64,
|
|
283
|
+
height: 64,
|
|
284
|
+
borderRadius: 32,
|
|
285
|
+
},
|
|
286
|
+
size72: {
|
|
154
287
|
width: 72,
|
|
155
288
|
height: 72,
|
|
156
289
|
borderRadius: 36,
|
|
157
290
|
},
|
|
291
|
+
size80: {
|
|
292
|
+
width: 80,
|
|
293
|
+
height: 80,
|
|
294
|
+
borderRadius: 40,
|
|
295
|
+
},
|
|
296
|
+
size88: {
|
|
297
|
+
width: 88,
|
|
298
|
+
height: 88,
|
|
299
|
+
borderRadius: 44,
|
|
300
|
+
},
|
|
301
|
+
size96: {
|
|
302
|
+
width: 96,
|
|
303
|
+
height: 96,
|
|
304
|
+
borderRadius: 48,
|
|
305
|
+
},
|
|
158
306
|
});
|
|
159
307
|
|
|
160
308
|
const shortName = (width) => ({
|
|
161
309
|
tiny: {
|
|
162
|
-
fontSize: ScaleSize(
|
|
163
|
-
lineHeight: 16,
|
|
310
|
+
fontSize: ScaleSize(5, width),
|
|
164
311
|
},
|
|
165
312
|
small: {
|
|
166
|
-
fontSize: ScaleSize(
|
|
167
|
-
lineHeight: 20,
|
|
313
|
+
fontSize: ScaleSize(11, width),
|
|
168
314
|
},
|
|
169
315
|
medium: {
|
|
170
|
-
fontSize: ScaleSize(
|
|
171
|
-
|
|
316
|
+
fontSize: ScaleSize(15, width),
|
|
317
|
+
},
|
|
318
|
+
middle: {
|
|
319
|
+
fontSize: ScaleSize(16, width),
|
|
172
320
|
},
|
|
173
321
|
large: {
|
|
174
|
-
fontSize: ScaleSize(
|
|
322
|
+
fontSize: ScaleSize(20, width),
|
|
175
323
|
},
|
|
176
324
|
giant: {
|
|
177
|
-
fontSize: ScaleSize(
|
|
325
|
+
fontSize: ScaleSize(25, width),
|
|
178
326
|
},
|
|
179
327
|
});
|
|
180
328
|
|
|
@@ -263,14 +411,9 @@ export default class Avatar extends Component {
|
|
|
263
411
|
style={[
|
|
264
412
|
styles.shortNameView,
|
|
265
413
|
avatarStyle,
|
|
266
|
-
{
|
|
267
|
-
backgroundColor: color,
|
|
268
|
-
},
|
|
269
|
-
this.props.shape === 'square' && {
|
|
270
|
-
borderRadius: Radius.XS,
|
|
271
|
-
},
|
|
414
|
+
{ backgroundColor: color },
|
|
272
415
|
]}>
|
|
273
|
-
<Text
|
|
416
|
+
<Text.H4
|
|
274
417
|
style={[
|
|
275
418
|
this.props.custom
|
|
276
419
|
? styles.shortNameTextCustom
|
|
@@ -278,7 +421,7 @@ export default class Avatar extends Component {
|
|
|
278
421
|
shortNameStyle,
|
|
279
422
|
]}>
|
|
280
423
|
{shortedName}
|
|
281
|
-
</Text>
|
|
424
|
+
</Text.H4>
|
|
282
425
|
</View>
|
|
283
426
|
);
|
|
284
427
|
}
|
|
@@ -464,7 +607,6 @@ export default class Avatar extends Component {
|
|
|
464
607
|
cached,
|
|
465
608
|
extraPropsImage,
|
|
466
609
|
quality,
|
|
467
|
-
shape,
|
|
468
610
|
} = this.props;
|
|
469
611
|
const { hideSource } = this.state;
|
|
470
612
|
const avatarStyle = this.mapStyleFromSize(size);
|
|
@@ -523,8 +665,9 @@ export default class Avatar extends Component {
|
|
|
523
665
|
|
|
524
666
|
Avatar.propTypes = {
|
|
525
667
|
name: PropTypes.string,
|
|
668
|
+
resizeMode: PropTypes.string,
|
|
526
669
|
quality: PropTypes.oneOf(['low', 'medium', 'high']),
|
|
527
|
-
size: PropTypes.
|
|
670
|
+
size: PropTypes.any,
|
|
528
671
|
source: PropTypes.oneOfType([
|
|
529
672
|
PropTypes.shape({ uri: PropTypes.string }),
|
|
530
673
|
PropTypes.number,
|
|
@@ -539,9 +682,11 @@ Avatar.propTypes = {
|
|
|
539
682
|
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
540
683
|
onPress: PropTypes.func,
|
|
541
684
|
loading: PropTypes.bool,
|
|
685
|
+
cached: PropTypes.bool,
|
|
686
|
+
scaleSize: PropTypes.bool,
|
|
542
687
|
extraPropsImage: PropTypes.object,
|
|
688
|
+
number: PropTypes.string,
|
|
543
689
|
custom: PropTypes.bool,
|
|
544
|
-
shape: PropTypes.oneOf(['circle', 'square']),
|
|
545
690
|
};
|
|
546
691
|
|
|
547
692
|
Avatar.defaultProps = {
|
|
@@ -551,5 +696,4 @@ Avatar.defaultProps = {
|
|
|
551
696
|
quality: 'medium',
|
|
552
697
|
size: 'small',
|
|
553
698
|
custom: false,
|
|
554
|
-
shape: 'circle',
|
|
555
699
|
};
|