Skip to content

Commit

Permalink
Add empty list message and clear search on modal hide
Browse files Browse the repository at this point in the history
  • Loading branch information
wachunei committed Nov 16, 2020
1 parent 65a31a6 commit 539d1e7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/components/UI/Swaps/components/TokenSelectModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ const styles = StyleSheet.create({
},
resultsView: {
height: Device.isSmallDevice() ? 200 : 280,
marginTop: 10,
borderTopWidth: 1,
borderTopColor: colors.grey100
marginTop: 10
},
resultRow: {
borderBottomWidth: StyleSheet.hairlineWidth,
borderTopWidth: StyleSheet.hairlineWidth,
borderColor: colors.grey100
},
emptyList: {
marginVertical: 10,
marginHorizontal: 30
}
});

Expand Down Expand Up @@ -110,6 +112,15 @@ function TokenSelectModal({ isVisible, dismiss, title, tokens, onItemPress, excl

const handleSearchPress = () => searchInput?.current?.focus();

const renderEmptyList = useMemo(
() => (
<View style={styles.emptyList}>
<Text>No tokens match &ldquo;{searchString}&rdquo;</Text>
</View>
),
[searchString]
);

return (
<Modal
isVisible={isVisible}
Expand All @@ -119,6 +130,7 @@ function TokenSelectModal({ isVisible, dismiss, title, tokens, onItemPress, excl
swipeDirection="down"
propagateSwipe
avoidKeyboard
onModalHide={() => setSearchString('')}
style={styles.modal}
>
<SafeAreaView style={styles.modalView}>
Expand All @@ -144,6 +156,7 @@ function TokenSelectModal({ isVisible, dismiss, title, tokens, onItemPress, excl
data={tokenSearchResults}
renderItem={renderItem}
keyExtractor={item => item.address}
ListEmptyComponent={renderEmptyList}
/>
</SafeAreaView>
</Modal>
Expand Down

0 comments on commit 539d1e7

Please sign in to comment.