Skip to content

Commit 3534bdc

Browse files
committed
Render custom token template rows at the top of the edit token scene
Specifically, if a field called "contractAddress' exists put it at the top
1 parent 39bbb41 commit 3534bdc

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

src/components/scenes/EditTokenScene.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,38 @@ function EditTokenSceneComponent(props: Props) {
187187
}
188188
})
189189

190+
const renderCustomTokenTemplateRows = () => {
191+
return customTokenTemplate
192+
.sort((a, b) => (a.key === 'contractAddress' ? -1 : 1))
193+
.map(item => {
194+
if (item.type === 'nativeAmount') return null
195+
return (
196+
<FilledTextInput
197+
key={item.key}
198+
aroundRem={0.5}
199+
autoCapitalize="none"
200+
autoCorrect={false}
201+
autoFocus={false}
202+
placeholder={translateDescription(item.displayName)}
203+
keyboardType={item.type === 'number' ? 'numeric' : 'default'}
204+
value={location.get(item.key) ?? ''}
205+
onChangeText={value =>
206+
setLocation(location => {
207+
const out = new Map(location)
208+
out.set(item.key, value.replace(/\s/g, ''))
209+
return out
210+
})
211+
}
212+
/>
213+
)
214+
})
215+
}
216+
190217
return (
191218
<SceneWrapper avoidKeyboard>
192219
<SceneHeader title={tokenId == null ? lstrings.title_add_token : lstrings.title_edit_token} underline />
193220
<ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContainer} scrollIndicatorInsets={SCROLL_INDICATOR_INSET_FIX}>
221+
{renderCustomTokenTemplateRows()}
194222
<FilledTextInput
195223
aroundRem={0.5}
196224
autoCapitalize="characters"
@@ -209,28 +237,6 @@ function EditTokenSceneComponent(props: Props) {
209237
value={displayName}
210238
onChangeText={setDisplayName}
211239
/>
212-
{customTokenTemplate.map(item => {
213-
if (item.type === 'nativeAmount') return null
214-
return (
215-
<FilledTextInput
216-
key={item.key}
217-
aroundRem={0.5}
218-
autoCapitalize="none"
219-
autoCorrect={false}
220-
autoFocus={false}
221-
placeholder={translateDescription(item.displayName)}
222-
keyboardType={item.type === 'number' ? 'numeric' : 'default'}
223-
value={location.get(item.key) ?? ''}
224-
onChangeText={value =>
225-
setLocation(location => {
226-
const out = new Map(location)
227-
out.set(item.key, value.replace(/\s/g, ''))
228-
return out
229-
})
230-
}
231-
/>
232-
)
233-
})}
234240
<FilledTextInput
235241
aroundRem={0.5}
236242
autoCorrect={false}

0 commit comments

Comments
 (0)