MCPcopy
hub / github.com/BlueWallet/BlueWallet / renderFormattedText

Function renderFormattedText

screen/settings/IsItMyAddress.tsx:99–125  ·  view source on GitHub ↗
(text: string, values: { [key: string]: string })

Source from the content-addressed store, hash-verified

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

Callers 1

IsItMyAddressFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected