import { useState } from "react"; import { Image, StyleSheet, Text, View } from "react-native"; import { SvgUri } from "react-native-svg"; import { native, useThemedStyles } from "../lib/native"; /** Use the catalog artwork, matching web, with a local fallback for missing logos. */ export function ConnectorIcon({ name, logo }: { name: string; logo?: string | null }) { const styles = useThemedStyles(createStyles); const [failedLogo, setFailedLogo] = useState(null); const uri = logo && logo !== failedLogo ? logo : null; return ( {uri ? ( /\.svg(?:[?#]|$)/i.test(uri) ? ( setFailedLogo(uri)} /> ) : ( setFailedLogo(uri)} style={styles.image} /> ) ) : ( {name[0]} )} ); } function createStyles() { return StyleSheet.create({ frame: { width: 36, height: 36, borderRadius: 10, backgroundColor: native.fillPressed, alignItems: "center", justifyContent: "center", overflow: "hidden", }, image: { width: 28, height: 28 }, letter: { color: native.label, fontSize: 16, fontWeight: "600" }, }); }