import React, { memo, useCallback } from 'react'; import { View, Text, Linking, StyleSheet } from 'react-native'; import { strings } from '../../../../../locales/i18n'; import { useNavigation } from '@react-navigation/native'; import { useAppThemeFromContext, mockTheme } from '../../../../util/theme'; const createStyles = (colors: { background: { default: string }; text: { default: string }; border: { muted: string }; info: { default: string }; }) => StyleSheet.create({ descriptionContainer: { marginBottom: 10, borderBottomWidth: StyleSheet.hairlineWidth, borderColor: colors.border.muted, }, contentContainer: { flexDirection: 'row', alignItems: 'center', marginBottom: 4, }, numberStyle: { marginRight: 10, color: colors.text.default, }, link: { color: colors.info.default, }, description: { width: '94%', color: colors.text.default, }, }); interface DescriptionProps { description: string; clickableText: string | undefined; number: number; onClose?: () => void; isTokenDetectionLinkEnabled?: boolean; } const Description = (props: DescriptionProps) => { const { description, clickableText, number, onClose, isTokenDetectionLinkEnabled, } = props; const { colors } = useAppThemeFromContext() || mockTheme; const styles = createStyles(colors); const navigation = useNavigation(); const handlePress = useCallback(() => { if (number === 2) { Linking.openURL(strings('network_information.learn_more_url')); } else { onClose?.(); navigation.navigate('AddAsset', { assetType: 'token' }); } }, [navigation, onClose, number]); const handleNavigation = useCallback(() => { onClose?.(); navigation.navigate('SettingsView', { screen: 'SettingsFlow', params: { screen: 'AdvancedSettings', params: { scrollToBottom: true, isFullScreenModal: true, }, }, }); }, [navigation, onClose]); return ( {number}. {`${description} `} {clickableText && ( <> {isTokenDetectionLinkEnabled && ( <> {`${strings( 'network_information.enable_token_detection', )} `} {`${strings('network_information.or')} `} )} {clickableText} )} ); }; export default memo(Description);