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
_handleOnVotersPress = (activeVotes) => {
const { navigation } = this.props;
const { navigation, post } = this.props;
navigation.navigate({
routeName: ROUTES.SCREENS.VOTERS,
params: {
activeVotes,
},
// TODO: make unic
key: post.permlink + Math.random(),
});
};

View File

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

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import {
View, Text, FlatList, TouchableHighlight, SafeAreaView,
View, Text, FlatList, TouchableOpacity, SafeAreaView,
} from 'react-native';
import FastImage from 'react-native-fast-image';
@ -58,7 +58,8 @@ class SearchModalView extends PureComponent {
data={searchResults.data}
showsVerticalScrollIndicator={false}
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.searchItemImageWrapper}>
{item.image && (
@ -74,7 +75,7 @@ class SearchModalView extends PureComponent {
{item.text && <Text style={styles.searchItemText}>{item.text}</Text>}
</View>
</View>
</TouchableHighlight>
</TouchableOpacity>
)}
keyExtractor={(post, index) => index.toString()}
removeClippedSubviews

View File

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

View File

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