Added reblogs screen

This commit is contained in:
Mustafa Buyukcelebi 2019-08-12 13:03:48 +03:00
parent 301e56c8d4
commit 3f8b65a95b
10 changed files with 91 additions and 38 deletions

View File

@ -51,6 +51,18 @@ class PostDisplayContainer extends Component {
}); });
}; };
_handleOnReblogsPress = reblogs => {
const { navigation, post } = this.props;
navigation.navigate({
routeName: ROUTES.SCREENS.REBLOGS,
params: {
reblogs,
},
key: post.permlink + Math.random(),
});
};
_handleOnReplyPress = () => { _handleOnReplyPress = () => {
const { post, navigation } = this.props; const { post, navigation } = this.props;
@ -123,6 +135,7 @@ class PostDisplayContainer extends Component {
handleOnRemovePress={this._handleDeleteComment} handleOnRemovePress={this._handleDeleteComment}
handleOnReplyPress={this._handleOnReplyPress} handleOnReplyPress={this._handleOnReplyPress}
handleOnVotersPress={this._handleOnVotersPress} handleOnVotersPress={this._handleOnVotersPress}
handleOnReblogsPress={this._handleOnReblogsPress}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
isNewPost={isNewPost} isNewPost={isNewPost}
isPostUnavailable={isPostUnavailable} isPostUnavailable={isPostUnavailable}

View File

@ -71,6 +71,7 @@ class PostDisplayView extends PureComponent {
handleOnEditPress, handleOnEditPress,
handleOnReplyPress, handleOnReplyPress,
handleOnVotersPress, handleOnVotersPress,
handleOnReblogsPress,
isLoggedIn, isLoggedIn,
post, post,
} = this.props; } = this.props;
@ -101,6 +102,7 @@ class PostDisplayView extends PureComponent {
iconStyle={styles.barIcons} iconStyle={styles.barIcons}
iconType="MaterialIcons" iconType="MaterialIcons"
isClickable isClickable
onPress={() => handleOnReblogsPress && handleOnReblogsPress(get(post, 'reblogs'))}
text={get(post, 'reblogCount', 0)} text={get(post, 'reblogCount', 0)}
textMarginLeft={20} textMarginLeft={20}
/> />

View File

@ -326,5 +326,8 @@
"rewards": "REWARDS", "rewards": "REWARDS",
"percent": "PERCENT", "percent": "PERCENT",
"time": "TIME" "time": "TIME"
},
"reblog": {
"title": "Reblog Info"
} }
} }

View File

@ -23,6 +23,7 @@ export default {
BOOST_POST: `BoostPost${SCREEN_SUFFIX}`, BOOST_POST: `BoostPost${SCREEN_SUFFIX}`,
PROMOTE: `Promote${SCREEN_SUFFIX}`, PROMOTE: `Promote${SCREEN_SUFFIX}`,
FREE_ESTM: `FreeEstm${SCREEN_SUFFIX}`, FREE_ESTM: `FreeEstm${SCREEN_SUFFIX}`,
REBLOGS: `Reblogs${SCREEN_SUFFIX}`,
}, },
DRAWER: { DRAWER: {
MAIN: `Main${DRAWER_SUFFIX}`, MAIN: `Main${DRAWER_SUFFIX}`,

View File

@ -2,6 +2,8 @@ import { PureComponent } from 'react';
import { isBefore } from '../utils/time'; import { isBefore } from '../utils/time';
import ROUTES from '../constants/routeNames';
class AccountListContainer extends PureComponent { class AccountListContainer extends PureComponent {
/* Props /* Props
* ------------------------------------------------ * ------------------------------------------------
@ -54,6 +56,18 @@ class AccountListContainer extends PureComponent {
this.setState({ filterResult: _data }); this.setState({ filterResult: _data });
}; };
_handleOnUserPress = username => {
const { navigation } = this.props;
navigation.navigate({
routeName: ROUTES.SCREENS.PROFILE,
params: {
username,
},
key: username,
});
};
render() { render() {
const { data, filterResult } = this.state; const { data, filterResult } = this.state;
const { children } = this.props; const { children } = this.props;
@ -65,6 +79,7 @@ class AccountListContainer extends PureComponent {
filterResult, filterResult,
handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect, handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect,
handleSearch: this._handleSearch, handleSearch: this._handleSearch,
handleOnUserPress: this._handleOnUserPress,
}) })
); );
} }

View File

@ -24,6 +24,7 @@ import {
Boost, Boost,
Promote, Promote,
BoostPost, BoostPost,
Reblogs,
} from '../screens'; } from '../screens';
// Components // Components
@ -126,6 +127,12 @@ const stackNavigatior = createStackNavigator(
header: () => null, header: () => null,
}, },
}, },
[ROUTES.SCREENS.REBLOGS]: {
screen: Reblogs,
navigationOptions: {
header: () => null,
},
},
}, },
{ {
headerMode: 'none', headerMode: 'none',

View File

@ -18,6 +18,7 @@ import BoostPost from './boostPost/screen/boostPostScreen';
import Promote from './promote/screen/promoteScreen'; import Promote from './promote/screen/promoteScreen';
import SteemConnect from './steem-connect/steemConnect'; import SteemConnect from './steem-connect/steemConnect';
import Transfer from './transfer'; import Transfer from './transfer';
import Reblogs from './reblogs';
export { export {
Bookmarks, Bookmarks,
@ -40,4 +41,5 @@ export {
SteemConnect, SteemConnect,
Transfer, Transfer,
Voters, Voters,
Reblogs,
}; };

View File

@ -0,0 +1 @@
export { default } from './screen/reblogScreen';

View File

@ -1,50 +1,59 @@
import React, { PureComponent } from 'react'; import React from 'react';
import { View } from 'react-native'; import { View, FlatList } from 'react-native';
import { injectIntl } from 'react-intl'; import { useIntl } from 'react-intl';
// Constants // Constants
// Components // Components
import { BasicHeader } from '../../../components/basicHeader'; import { BasicHeader } from '../../../components/basicHeader';
import { FilterBar } from '../../../components/filterBar'; import { UserListItem } from '../../../components/basicUIElements';
import { VotersDisplay } from '../../../components/votersDisplay';
import AccountListContainer from '../../../containers/accountListContainer'; import AccountListContainer from '../../../containers/accountListContainer';
// Utils // Utils
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
import { getTimeFromNow } from '../../../utils/time';
class ReblogScreen extends PureComponent { const renderUserListItem = (item, index, handleOnUserPress) => {
render() { return (
const { intl, navigation } = this.props; <UserListItem
const headerTitle = intl.formatMessage({ index={index}
id: 'voters.voters_info', username={item.account}
}); description={getTimeFromNow(item.timestamp)}
handleOnPress={() => handleOnUserPress(item.account)}
isClickable
/>
);
};
const activeVotes = const ReblogScreen = ({ navigation }) => {
navigation.state && navigation.state.params && navigation.state.params.activeVotes; const intl = useIntl();
const headerTitle = intl.formatMessage({
id: 'reblog.title',
});
return ( const activeVotes =
<AccountListContainer data={activeVotes}> navigation.state && navigation.state.params && navigation.state.params.reblogs;
{({ data, filterResult, handleOnVotersDropdownSelect, handleSearch }) => (
<View style={globalStyles.container}>
<BasicHeader
title={`${headerTitle} (${data && data.length})`}
isHasSearch
handleOnSearch={text => handleSearch(text, 'voter')}
/>
<FilterBar
dropdownIconName="arrow-drop-down"
options={['REWARDS', 'PERCENT', 'TIME']}
defaultText="REWARDS"
onDropdownSelect={handleOnVotersDropdownSelect}
/>
<VotersDisplay key={Math.random()} votes={filterResult || data} />
</View>
)}
</AccountListContainer>
);
}
}
export default injectIntl(ReblogScreen); return (
<AccountListContainer data={activeVotes} navigation={navigation}>
{({ data, filterResult, handleSearch, handleOnUserPress }) => (
<View style={globalStyles.container}>
<BasicHeader
title={`${headerTitle} (${data && data.length})`}
isHasSearch
handleOnSearch={text => handleSearch(text, 'account')}
/>
<FlatList
data={filterResult || data}
keyExtractor={item => item.account}
removeClippedSubviews={false}
renderItem={({ item, index }) => renderUserListItem(item, index, handleOnUserPress)}
/>
</View>
)}
</AccountListContainer>
);
};
export default ReblogScreen;

View File

@ -67,8 +67,8 @@ export const parsePost = async (post, currentUserName, isPromoted) => {
}); });
} }
const postReblogs = await getPostReblogs(post); post.reblogs = await getPostReblogs(post);
post.reblogCount = postReblogs.length; post.reblogCount = post.reblogs.length;
return post; return post;
}; };