Skip to content

Commit

Permalink
Better AssetLogo
Browse files Browse the repository at this point in the history
  • Loading branch information
mvaivre authored and nop33 committed Oct 16, 2023
1 parent e0a70ca commit 231598c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/AssetLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ const AssetLogo = ({ assetId, size, style }: AssetLogoProps) => {
const theme = useTheme()
const token = useAppSelector((state) => selectAssetInfoById(state, assetId))
const nft = useAppSelector((s) => selectNFTById(s, assetId))
const isNft = !!nft

const imageUrl = token?.logoURI || nft?.image

return (
<AssetLogoStyled {...{ assetId, style, size }} logoURI={imageUrl} isNft={!!nft}>
<AssetLogoStyled {...{ assetId, style, size }} logoURI={imageUrl} isNft={isNft}>
{imageUrl ? (
<LogoImageContainer>
<LogoImage source={{ uri: imageUrl }} transition={500} contentFit="contain" contentPosition="center" />
<LogoImageContainer isNft={isNft}>
<LogoImage
source={{ uri: imageUrl }}
transition={500}
contentFit={isNft ? 'cover' : 'contain'}
contentPosition="center"
/>
</LogoImageContainer>
) : assetId === ALPH.id ? (
<>
Expand Down Expand Up @@ -87,10 +93,14 @@ const AssetLogoStyled = styled.View<AssetLogoProps & { logoURI: TokenInfo['logoU
`}
`

const LogoImageContainer = styled.View`
padding: 5px;
const LogoImageContainer = styled.View<{ isNft: boolean }>`
height: 100%;
width: 100%;
${({ isNft }) =>
!isNft &&
css`
padding: 10%;
`}
`

const LogoImage = styled(Image)`
Expand Down

0 comments on commit 231598c

Please sign in to comment.