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