using icons for all assets if available

This commit is contained in:
Nouman Tahir 2022-12-16 23:30:39 +05:00
parent 7154cedd4d
commit 70acc2f650
7 changed files with 37 additions and 11 deletions

BIN
src/assets/hbd_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
src/assets/hive_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -3,27 +3,50 @@ import { View, ViewStyle } from 'react-native';
import FastImage from 'react-native-fast-image';
import styles from '../styles/assetIcon.styles';
import HIVE_ENGINE_ICON from '../../../../assets/hive_engine.png';
import HBD_ICON from '../../../../assets/hbd_icon.png';
import HIVE_ICON from '../../../../assets/hive_icon.png';
import ECENCY_ICON from '../../../../assets/ecency-logo.png';
import { ASSET_IDS } from '../../../../constants/defaultAssets';
interface AssetIconProps {
id:ASSET_IDS
iconUrl: string;
id:string;
iconUrl?: string;
isEngine?: boolean;
iconSize?: number;
containerStyle?: ViewStyle;
}
export const AssetIcon = ({ iconUrl, isEngine, containerStyle, iconSize }: AssetIconProps) => {
export const AssetIcon = ({id, iconUrl, isEngine, containerStyle, iconSize }: AssetIconProps) => {
if (iconSize) {
}
const _logoStyle = iconSize
? { ...styles.logo, width: iconSize, height: iconSize, borderRadius: iconSize / 2 }
? { ...styles.logo, width: iconSize, height: iconSize}
: styles.logo;
let _iconSource = iconUrl && {uri:iconUrl};
if(!_iconSource){
switch(id){
case ASSET_IDS.HBD:
_iconSource = HBD_ICON;
break;
case ASSET_IDS.HIVE:
case ASSET_IDS.HP:
_iconSource = HIVE_ICON;
break;
case ASSET_IDS.ECENCY:
_iconSource = ECENCY_ICON;
break;
}
}
if(!_iconSource){
return null;
}
return (
<View style={containerStyle}>
<FastImage style={_logoStyle} resizeMode="cover" source={{ uri: iconUrl }} />
<FastImage style={_logoStyle} resizeMode="contain" source={_iconSource} />
{isEngine && (
<View style={styles.hiveEngineWrapper}>
<FastImage style={styles.hiveEngineLogo} resizeMode="contain" source={HIVE_ENGINE_ICON} />

View File

@ -18,6 +18,6 @@ export default EStyleSheet.create({
logo: {
height: 30,
width: 30,
borderRadius: 15,
} as ImageStyle,
})

View File

@ -6,6 +6,7 @@ import { DataPair } from '../../../redux/reducers/walletReducer';
import styles from './children.styles';
interface CoinBasicsProps {
assetId:string;
valuePairs: DataPair[];
extraData: DataPair[];
coinSymbol: string;
@ -15,24 +16,27 @@ interface CoinBasicsProps {
}
export const CoinBasics = ({
assetId,
valuePairs,
extraData,
coinSymbol,
percentChange,
iconUrl,
isEngine,
onInfoPress,
}: CoinBasicsProps) => {
const intl = useIntl();
const _renderCoinHeader = (
<>
{iconUrl && (
<AssetIcon
id={assetId}
iconUrl={iconUrl}
iconSize={56}
containerStyle={styles.iconContainer}
isEngine={true}
isEngine={isEngine}
/>
)}
<View style={styles.coinTitleContainer}>
<Text style={styles.textCoinTitle}>{coinSymbol}</Text>
</View>

View File

@ -50,6 +50,7 @@ export const CoinSummary = ({
return (
<View>
<CoinBasics
assetId={id}
iconUrl={coinData.iconUrl}
valuePairs={valuePairs}
extraData={extraDataPairs}

View File

@ -74,7 +74,6 @@ export const AssetCard = ({
const _renderHeader = (
<View style={styles.cardHeader}>
{iconUrl && (
<AssetIcon
id={id}
iconUrl={iconUrl}
@ -82,7 +81,6 @@ export const AssetCard = ({
containerStyle={styles.logoContainer}
iconSize={32}
/>
)}
<View style={styles.cardTitleContainer}>
<Text style={styles.textTitle}>{symbol}</Text>
<Text style={styles.textSubtitle}>{_name}</Text>