Skip to content

Commit

Permalink
Merge pull request #3565 from Portkey-Wallet/feature/eoa-dev1.0.0-acc…
Browse files Browse the repository at this point in the history
…ount

feat: 🎸 CommonAvatar support localImage
  • Loading branch information
y-ptk authored Jan 21, 2025
2 parents d96a48c + 4105d61 commit 1924484
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/mobile-aelf/js/components/CommonAvatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import Svg, { IconName } from 'components/Svg';
import { pTd } from 'utils/unit';
import { Text, TextStyle, View, ViewStyle } from 'react-native';
import { StyleSheet } from 'react-native';
// import { StyleSheet } from 'react-native';
import { defaultColors } from 'assets/theme';
import { checkIsSvgUrl } from 'utils';
import { SvgCssUri } from 'react-native-svg/css';
Expand All @@ -16,6 +16,7 @@ export interface CommonAvatarProps {
hasBorder?: boolean;
svgName?: IconName;
imageUrl?: string;
localImage?: number;
shapeType?: 'square' | 'circular';
style?: ViewStyle & TextStyle;
color?: string;
Expand All @@ -35,6 +36,7 @@ export default function CommonAvatar(props: CommonAvatarProps) {
style = {},
color,
imageUrl,
localImage,
shapeType = 'circular',
hasBorder,
resizeMode = 'contain',
Expand Down Expand Up @@ -96,8 +98,8 @@ export default function CommonAvatar(props: CommonAvatarProps) {
);
}

if (imageUrl && !loadError) {
return checkIsSvgUrl(imageUrl) ? (
if ((imageUrl || localImage) && !loadError) {
return imageUrl && checkIsSvgUrl(imageUrl) ? (
<View style={[styles.avatarWrap, shapeType === 'square' && styles.squareStyle, sizeStyle, style]}>
<SvgCssUri
uri={imageUrl}
Expand All @@ -111,9 +113,13 @@ export default function CommonAvatar(props: CommonAvatarProps) {
resizeMode={resizeMode}
style={[styles.avatarWrap, shapeType === 'square' && styles.squareStyle, sizeStyle, style as any]}
onError={() => setLoadError(true)}
source={{
uri: imageUrl,
}}
source={
localImage
? localImage
: {
uri: imageUrl,
}
}
/>
);
}
Expand All @@ -131,7 +137,7 @@ export default function CommonAvatar(props: CommonAvatarProps) {
</View>
);
}
const getStyles = makeStyles(theme => ({
const getStyles = makeStyles(() => ({
avatarWrap: {
width: pTd(48),
height: pTd(48),
Expand Down

0 comments on commit 1924484

Please sign in to comment.