import React from 'react' import { Image, StyleSheet, Text, View } from 'react-native' import { SvgUri } from 'react-native-svg' import Logo from 'src/images/Logo' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Shadow, Spacing, getShadowStyle } from 'src/styles/styles' const DAPP_IMAGE_SIZE = 40 interface Props { dappImageUrl?: string dappName: string } export default function Logos({ dappImageUrl, dappName }: Props) { if (!dappImageUrl) { return null } let isDappImageSvg = false try { const parsedUrl = new URL(dappImageUrl ?? '') isDappImageSvg = parsedUrl.pathname.toLowerCase().endsWith('.svg') } catch (error) { // do nothing if the url cannot be parsed } return ( {isDappImageSvg ? ( ) : dappImageUrl ? ( ) : ( {dappName.charAt(0).toUpperCase()} )} ) } const styles = StyleSheet.create({ logoContainer: { flexDirection: 'row', }, logoShadow: { ...getShadowStyle(Shadow.SoftLight), borderRadius: 100, }, logoBackground: { justifyContent: 'center', alignItems: 'center', height: DAPP_IMAGE_SIZE, width: DAPP_IMAGE_SIZE, borderRadius: 100, backgroundColor: Colors.backgroundPrimary, }, dappImage: { height: DAPP_IMAGE_SIZE, width: DAPP_IMAGE_SIZE, borderRadius: 100, backgroundColor: Colors.backgroundPrimary, marginLeft: -4, }, placeholderLogoBackground: { backgroundColor: Colors.backgroundPrimary, marginRight: -Spacing.Small12, borderColor: Colors.borderPrimary, borderWidth: 1, }, placeholderLogoText: { ...typeScale.titleMedium, lineHeight: undefined, color: Colors.contentSecondary, }, })