voters screen bug fixed

This commit is contained in:
u-e 2019-03-18 21:16:09 +03:00
parent 3e100a18b1
commit 7dc3fb8c6a
6 changed files with 38 additions and 10 deletions

View File

@ -34,13 +34,15 @@ class PostDisplayContainer extends Component {
// Component Functions // Component Functions
_handleOnVotersPress = (activeVotes) => { _handleOnVotersPress = (activeVotes) => {
const { navigation } = this.props; const { navigation, post } = this.props;
navigation.navigate({ navigation.navigate({
routeName: ROUTES.SCREENS.VOTERS, routeName: ROUTES.SCREENS.VOTERS,
params: { params: {
activeVotes, activeVotes,
}, },
// TODO: make unic
key: post.permlink + Math.random(),
}); });
}; };

View File

@ -1,5 +1,6 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { withNavigation } from 'react-navigation'; import { withNavigation } from 'react-navigation';
import { connect } from 'react-redux';
// Services and Actions // Services and Actions
import { search } from '../../../providers/esteem/esteem'; import { search } from '../../../providers/esteem/esteem';
@ -45,6 +46,7 @@ class SearchModalContainer extends PureComponent {
const users = res.map(item => ({ const users = res.map(item => ({
image: `https://steemitimages.com/u/${item}/avatar/small`, image: `https://steemitimages.com/u/${item}/avatar/small`,
text: item, text: item,
...item,
})); }));
this.setState({ searchResults: { type: 'user', data: users } }); this.setState({ searchResults: { type: 'user', data: users } });
}); });
@ -52,6 +54,7 @@ class SearchModalContainer extends PureComponent {
getTrendingTags(text.substr(1)).then((res) => { getTrendingTags(text.substr(1)).then((res) => {
const tags = res.map(item => ({ const tags = res.map(item => ({
text: `#${item.name}`, text: `#${item.name}`,
...item,
})); }));
this.setState({ searchResults: { type: 'tag', data: tags } }); this.setState({ searchResults: { type: 'tag', data: tags } });
@ -63,6 +66,7 @@ class SearchModalContainer extends PureComponent {
.map(item => ({ .map(item => ({
image: item.img_url || `https://steemitimages.com/u/${item.author}/avatar/small`, image: item.img_url || `https://steemitimages.com/u/${item.author}/avatar/small`,
text: item.title, text: item.title,
...item,
})); }));
this.setState({ searchResults: { type: 'content', data: res.results } }); this.setState({ searchResults: { type: 'content', data: res.results } });
}); });
@ -71,7 +75,7 @@ class SearchModalContainer extends PureComponent {
}; };
_handleOnPressListItem = (type, item) => { _handleOnPressListItem = (type, item) => {
const { navigation, handleOnClose } = this.props; const { navigation, handleOnClose, username } = this.props;
let routeName = null; let routeName = null;
let params = null; let params = null;
let key = null; let key = null;
@ -81,7 +85,7 @@ class SearchModalContainer extends PureComponent {
switch (type) { switch (type) {
case 'user': case 'user':
routeName = ROUTES.SCREENS.PROFILE; routeName = item.text === username ? ROUTES.TABBAR.PROFILE : ROUTES.SCREENS.PROFILE;
params = { params = {
username: item.text, username: item.text,
}; };
@ -118,6 +122,7 @@ class SearchModalContainer extends PureComponent {
render() { render() {
const { searchResults } = this.state; const { searchResults } = this.state;
const { handleOnClose, isOpen, placeholder } = this.props; const { handleOnClose, isOpen, placeholder } = this.props;
return ( return (
<SearchModalView <SearchModalView
searchResults={searchResults} searchResults={searchResults}
@ -132,4 +137,8 @@ class SearchModalContainer extends PureComponent {
} }
} }
export default withNavigation(SearchModalContainer); const mapStateToProps = state => ({
username: state.account.currentAccount.name,
});
export default connect(mapStateToProps)(withNavigation(SearchModalContainer));

View File

@ -67,7 +67,7 @@ export default EStyleSheet.create({
borderColor: '$primaryGray', borderColor: '$primaryGray',
}, },
searchItemText: { searchItemText: {
color: '$white', color: '$pureWhite',
marginLeft: 10, marginLeft: 10,
}, },
}); });

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { import {
View, Text, FlatList, TouchableHighlight, SafeAreaView, View, Text, FlatList, TouchableOpacity, SafeAreaView,
} from 'react-native'; } from 'react-native';
import FastImage from 'react-native-fast-image'; import FastImage from 'react-native-fast-image';
@ -58,7 +58,8 @@ class SearchModalView extends PureComponent {
data={searchResults.data} data={searchResults.data}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
renderItem={({ item }) => ( renderItem={({ item }) => (
<TouchableHighlight onPress={() => handleOnPressListItem(searchResults.type, item)}> // TODO: Make it quick ui component
<TouchableOpacity onPress={() => handleOnPressListItem(searchResults.type, item)}>
<View style={styles.searhItems}> <View style={styles.searhItems}>
<View style={styles.searchItemImageWrapper}> <View style={styles.searchItemImageWrapper}>
{item.image && ( {item.image && (
@ -74,7 +75,7 @@ class SearchModalView extends PureComponent {
{item.text && <Text style={styles.searchItemText}>{item.text}</Text>} {item.text && <Text style={styles.searchItemText}>{item.text}</Text>}
</View> </View>
</View> </View>
</TouchableHighlight> </TouchableOpacity>
)} )}
keyExtractor={(post, index) => index.toString()} keyExtractor={(post, index) => index.toString()}
removeClippedSubviews removeClippedSubviews

View File

@ -1,5 +1,8 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
// Constants
import ROUTES from '../../../constants/routeNames';
// Component // Component
import VotersDisplayView from '../view/votersDisplayView'; import VotersDisplayView from '../view/votersDisplayView';
@ -15,6 +18,18 @@ class VotersDisplayContainer extends PureComponent {
this.state = {}; this.state = {};
} }
handleOnUserPress = (username) => {
const { navigation } = this.props;
navigation.navigate({
routeName: ROUTES.SCREENS.PROFILE,
params: {
username,
},
key: username,
});
};
render() { render() {
const { votes } = this.props; const { votes } = this.props;

View File

@ -19,7 +19,7 @@ class VotersDisplayView extends PureComponent {
// Component Functions // Component Functions
_renderItem = (item, index) => { _renderItem = (item, index) => {
const { intl } = this.props; const { handleOnUserPress } = this.props;
const value = `$ ${item.value}`; const value = `$ ${item.value}`;
const percent = `${item.percent}%`; const percent = `${item.percent}%`;
@ -27,11 +27,12 @@ class VotersDisplayView extends PureComponent {
<UserListItem <UserListItem
index={index} index={index}
username={item.voter} username={item.voter}
// description={intl.formatRelative(item.time)}
description={getTimeFromNow(item.time)} description={getTimeFromNow(item.time)}
isHasRightItem isHasRightItem
isRightColor={item.is_down_vote} isRightColor={item.is_down_vote}
rightText={value} rightText={value}
handleOnPress={handleOnUserPress(item.voter)}
isClickable
subRightText={percent} subRightText={percent}
/> />
); );