mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-08 07:02:25 +03:00
created all line clicable and added refreshing
This commit is contained in:
parent
f337dccc47
commit
9b8cf3b94f
@ -1,9 +1,10 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
|
||||
import { withNavigation } from 'react-navigation';
|
||||
// Services and Actions
|
||||
import { getLeaderboard } from '../../../providers/esteem/esteem';
|
||||
|
||||
// Utilities
|
||||
// Constants
|
||||
import ROUTES from '../../../constants/routeNames';
|
||||
|
||||
// Component
|
||||
import LeaderboardView from '../view/leaderboardView';
|
||||
@ -19,21 +20,46 @@ class LeaderboardContainer extends PureComponent {
|
||||
super(props);
|
||||
this.state = {
|
||||
users: null,
|
||||
refreshing: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Component Life Cycle Functions
|
||||
async componentDidMount() {
|
||||
const users = await getLeaderboard();
|
||||
|
||||
this.setState({ users });
|
||||
componentDidMount() {
|
||||
this._fetchLeaderBoard();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { users } = this.state;
|
||||
_handleOnUserPress = (username) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return <LeaderboardView users={users} handleOnUserPress={this._handleOnUserPress} />;
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.PROFILE,
|
||||
params: {
|
||||
username,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
_fetchLeaderBoard = async () => {
|
||||
this.setState({ refreshing: true });
|
||||
|
||||
const users = await getLeaderboard();
|
||||
|
||||
this.setState({ users, refreshing: false });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { users, refreshing } = this.state;
|
||||
|
||||
return (
|
||||
<LeaderboardView
|
||||
users={users}
|
||||
refreshing={refreshing}
|
||||
fetchLeaderBoard={this._fetchLeaderBoard}
|
||||
handleOnUserPress={this._handleOnUserPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default LeaderboardContainer;
|
||||
export default withNavigation(LeaderboardContainer);
|
||||
|
@ -2,8 +2,6 @@ import React, { PureComponent } from 'react';
|
||||
import { View, FlatList, Text } from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
// Constants
|
||||
|
||||
// Components
|
||||
import { UserListItem } from '../../basicUIElements';
|
||||
|
||||
@ -17,20 +15,28 @@ class LeaderboardView extends PureComponent {
|
||||
*/
|
||||
|
||||
// Component Functions
|
||||
_renderItem = (item, index) => (
|
||||
<UserListItem
|
||||
index={index}
|
||||
username={item._id}
|
||||
description={item.created}
|
||||
isHasRightItem
|
||||
isBlackRightColor
|
||||
rightText={item.count}
|
||||
itemIndex={index + 1}
|
||||
/>
|
||||
);
|
||||
_renderItem = (item, index) => {
|
||||
const { handleOnUserPress } = this.props;
|
||||
|
||||
return (
|
||||
<UserListItem
|
||||
index={index}
|
||||
username={item._id}
|
||||
description={item.created}
|
||||
isHasRightItem
|
||||
isClickable
|
||||
isBlackRightColor
|
||||
rightText={item.count}
|
||||
itemIndex={index + 1}
|
||||
handleOnPress={() => handleOnUserPress(item._id)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { users, intl } = this.props;
|
||||
const {
|
||||
users, intl, fetchLeaderBoard, refreshing,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
@ -41,8 +47,10 @@ class LeaderboardView extends PureComponent {
|
||||
</Text>
|
||||
<FlatList
|
||||
data={users}
|
||||
refreshing={refreshing}
|
||||
keyExtractor={item => item.voter}
|
||||
removeClippedSubviews={false}
|
||||
onRefresh={() => fetchLeaderBoard()}
|
||||
renderItem={({ item, index }) => this._renderItem(item, index)}
|
||||
/>
|
||||
</View>
|
||||
|
@ -34,6 +34,7 @@ class SearchModalContainer extends PureComponent {
|
||||
// Component Functions
|
||||
_handleCloseButton = () => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
navigation.goBack();
|
||||
};
|
||||
|
||||
|
@ -75,10 +75,12 @@ class ApplicationContainer extends Component {
|
||||
this.state = {
|
||||
isRenderRequire: true,
|
||||
isReady: false,
|
||||
isIos: Platform.OS !== 'android',
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = async () => {
|
||||
const { isIos } = this.state;
|
||||
let isConnected;
|
||||
|
||||
await NetInfo.isConnected.fetch().then((_isConnected) => {
|
||||
@ -86,7 +88,7 @@ class ApplicationContainer extends Component {
|
||||
});
|
||||
|
||||
NetInfo.isConnected.addEventListener('connectionChange', this._handleConntectionChange);
|
||||
BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
|
||||
if (!isIos) BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
|
||||
|
||||
if (isConnected) {
|
||||
this._fetchApp();
|
||||
@ -116,7 +118,10 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
|
||||
const { isIos } = this.state;
|
||||
|
||||
if (!isIos) BackHandler.removeEventListener('hardwareBackPress', this._onBackPress);
|
||||
|
||||
NetInfo.isConnected.removeEventListener('connectionChange', this._handleConntectionChange);
|
||||
clearInterval(this.globalInterval);
|
||||
}
|
||||
|
@ -39,19 +39,19 @@ class BookmarksScreen extends Component {
|
||||
const isFavorites = itemType === 'favorites';
|
||||
const text = isFavorites ? item.account : `${item.author}/${item.permlink}`;
|
||||
|
||||
if(item.author || item.account){
|
||||
if (item.author || item.account) {
|
||||
return (
|
||||
<UserListItem
|
||||
handleOnLongPress={() => this._handleLongPress(isFavorites ? item.account : item._id)}
|
||||
handleOnPress={() => (isFavorites
|
||||
? handleOnFavoritePress(item.account)
|
||||
: handleOnBookarkPress(item.permlink, item.author))
|
||||
}
|
||||
index={index}
|
||||
isClickable
|
||||
text={text}
|
||||
username={item.author}
|
||||
/>
|
||||
handleOnLongPress={() => this._handleLongPress(isFavorites ? item.account : item._id)}
|
||||
handleOnPress={() => (isFavorites
|
||||
? handleOnFavoritePress(item.account)
|
||||
: handleOnBookarkPress(item.permlink, item.author))
|
||||
}
|
||||
index={index}
|
||||
isClickable
|
||||
text={text}
|
||||
username={item.author}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user