mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 21:01:31 +03:00
Added tag search for search modal
This commit is contained in:
parent
3103fef132
commit
cdc546b660
@ -41,17 +41,28 @@ class SearchModalContainer extends PureComponent {
|
||||
if (text && text !== '@' && text !== '#') {
|
||||
if (text[0] === '@') {
|
||||
lookupAccounts(text.substr(1)).then((res) => {
|
||||
const users = res.map(item => ({ author: item }));
|
||||
const users = res.map(item => ({
|
||||
image: `https://steemitimages.com/u/${item}/avatar/small`,
|
||||
text: item,
|
||||
}));
|
||||
this.setState({ searchResults: { type: 'user', data: users } });
|
||||
});
|
||||
} else if (text[0] === '#') {
|
||||
getTrendingTags(text.substr(1)).then((res) => {
|
||||
console.log('res :', res);
|
||||
// TODO:
|
||||
const tags = res.map(item => ({
|
||||
text: `#${item.name}`,
|
||||
}));
|
||||
|
||||
this.setState({ searchResults: { type: 'tag', data: tags } });
|
||||
});
|
||||
} else {
|
||||
search({ q: text }).then((res) => {
|
||||
res.results = res.results.filter(item => item.title !== '');
|
||||
res.results = res.results
|
||||
.filter(item => item.title !== '')
|
||||
.map(item => ({
|
||||
image: item.img_url || `https://steemitimages.com/u/${item.author}/avatar/small`,
|
||||
text: item.title,
|
||||
}));
|
||||
this.setState({ searchResults: { type: 'content', data: res.results } });
|
||||
});
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export default EStyleSheet.create({
|
||||
borderColor: '$primaryGray',
|
||||
},
|
||||
searchItemText: {
|
||||
color: '$primaryDarkGray',
|
||||
color: '$white',
|
||||
marginLeft: 10,
|
||||
},
|
||||
});
|
||||
|
@ -77,19 +77,19 @@ class SearchModalView extends PureComponent {
|
||||
renderItem={({ item }) => (
|
||||
<TouchableHighlight onPress={() => handleOnPressListItem(searchResults.type, item)}>
|
||||
<View style={styles.searhItems}>
|
||||
<View style={{ flex: 1 }}>
|
||||
{item.image && (
|
||||
<FastImage
|
||||
source={{
|
||||
uri:
|
||||
searchResults.type === 'user'
|
||||
? `https://steemitimages.com/u/${item.author}/avatar/small`
|
||||
: item.img_url
|
||||
|| `https://steemitimages.com/u/${item.author}/avatar/small`,
|
||||
uri: item.image,
|
||||
}}
|
||||
style={styles.searchItemImage}
|
||||
/>
|
||||
<Text style={styles.searchItemText}>
|
||||
{searchResults.type === 'user' ? item.author : item.title}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
<View style={{ flex: 7 }}>
|
||||
{item.text && <Text style={styles.searchItemText}>{item.text}</Text>}
|
||||
</View>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user