@momo-kits/avatar 0.0.62-alpha.2 → 0.0.62-alpha.5

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.
Files changed (2) hide show
  1. package/Avatar.js +42 -20
  2. package/package.json +1 -1
package/Avatar.js CHANGED
@@ -118,8 +118,8 @@ const avatarSize = (size) => {
118
118
  switch (size) {
119
119
  case 'tiny':
120
120
  return {
121
- width: 16,
122
- height: 16,
121
+ width: 24,
122
+ height: 24,
123
123
  };
124
124
  case 'small': {
125
125
  return {
@@ -154,7 +154,7 @@ const shortName = (size) => {
154
154
  switch (size) {
155
155
  case 'tiny':
156
156
  return {
157
- fontSize: ScaleSize(8),
157
+ fontSize: ScaleSize(10),
158
158
  lineHeight: 16,
159
159
  };
160
160
  case 'small':
@@ -256,19 +256,32 @@ const Avatar = ({
256
256
  // const subIconSizeStyle = this.mapSubIconSize(size);
257
257
  if (subIcon && shape === 'circle' && size !== 'tiny') {
258
258
  return (
259
- <View style={styles.subIcon}>
260
- <Image
261
- source={subIcon}
262
- style={[
263
- {
264
- width: iconWidth,
265
- height: iconHeight,
266
- borderRadius: iconRadius,
267
- bottom: iconWidth / 2 - 2,
268
- right: iconWidth / 2 - 2,
269
- },
270
- ]}
271
- />
259
+ <View
260
+ style={[
261
+ styles.subIcon,
262
+ size === 'large' && {
263
+ bottom: 2,
264
+ right: 2,
265
+ },
266
+ size === 'giant' && {
267
+ bottom: 4,
268
+ right: 4,
269
+ },
270
+ ]}>
271
+ {typeof subIcon === 'string' ? (
272
+ <Image
273
+ source={subIcon}
274
+ style={[
275
+ {
276
+ width: iconWidth,
277
+ height: iconHeight,
278
+ borderRadius: iconRadius,
279
+ },
280
+ ]}
281
+ />
282
+ ) : (
283
+ subIcon()
284
+ )}
272
285
  </View>
273
286
  );
274
287
  }
@@ -277,7 +290,18 @@ const Avatar = ({
277
290
  const renderTopIcon = () => {
278
291
  if (topIcon && shape === 'circle' && size !== 'tiny') {
279
292
  return (
280
- <View style={styles.topIcon}>
293
+ <View
294
+ style={[
295
+ styles.topIcon,
296
+ size === 'large' && {
297
+ top: 2,
298
+ right: 2,
299
+ },
300
+ size === 'giant' && {
301
+ top: 4,
302
+ right: 4,
303
+ },
304
+ ]}>
281
305
  <Image
282
306
  source={topIcon}
283
307
  style={[
@@ -285,8 +309,6 @@ const Avatar = ({
285
309
  width: iconWidth,
286
310
  height: iconHeight,
287
311
  borderRadius: iconRadius,
288
- top: iconWidth / 2 - 2,
289
- right: iconWidth / 2 - 2,
290
312
  },
291
313
  ]}
292
314
  />
@@ -387,7 +409,7 @@ Avatar.propTypes = {
387
409
  PropTypes.number,
388
410
  PropTypes.string,
389
411
  ]),
390
- subIcon: PropTypes.string,
412
+ subIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
391
413
  topIcon: PropTypes.string,
392
414
  subIconSource: PropTypes.oneOfType([
393
415
  PropTypes.shape({ uri: PropTypes.string }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/avatar",
3
- "version": "0.0.62-alpha.2",
3
+ "version": "0.0.62-alpha.5",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},