| 97 | }, [matchingWallets]); |
| 98 | |
| 99 | const renderFormattedText = (text: string, values: { [key: string]: string }) => { |
| 100 | const regex = /\{(\w+)\}/g; |
| 101 | const parts = []; |
| 102 | let lastIndex = 0; |
| 103 | let match; |
| 104 | let index = 0; |
| 105 | |
| 106 | while ((match = regex.exec(text)) !== null) { |
| 107 | if (match.index > lastIndex) { |
| 108 | parts.push(<Text key={`text-${index++}`}>{text.substring(lastIndex, match.index)}</Text>); |
| 109 | } |
| 110 | const value = values[match[1]]; |
| 111 | if (value) { |
| 112 | const isLabel = match[1] === 'label'; |
| 113 | parts.push( |
| 114 | <Text key={`bold-${index++}`} selectable style={isLabel ? styles.boldText : undefined}> |
| 115 | {value} |
| 116 | </Text>, |
| 117 | ); |
| 118 | } |
| 119 | lastIndex = regex.lastIndex; |
| 120 | } |
| 121 | if (lastIndex < text.length) { |
| 122 | parts.push(<Text key={`text-${index++}`}>{text.substring(lastIndex)}</Text>); |
| 123 | } |
| 124 | return parts; |
| 125 | }; |
| 126 | |
| 127 | return ( |
| 128 | <SettingsScrollView |