mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-04 07:05:20 +03:00
using icons for all assets if available
This commit is contained in:
parent
7154cedd4d
commit
70acc2f650
BIN
src/assets/hbd_icon.png
Normal file
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
BIN
src/assets/hive_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@ -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} />
|
||||
|
@ -18,6 +18,6 @@ export default EStyleSheet.create({
|
||||
logo: {
|
||||
height: 30,
|
||||
width: 30,
|
||||
borderRadius: 15,
|
||||
|
||||
} as ImageStyle,
|
||||
})
|
@ -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>
|
||||
|
@ -50,6 +50,7 @@ export const CoinSummary = ({
|
||||
return (
|
||||
<View>
|
||||
<CoinBasics
|
||||
assetId={id}
|
||||
iconUrl={coinData.iconUrl}
|
||||
valuePairs={valuePairs}
|
||||
extraData={extraDataPairs}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user