mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-03 11:40:44 +03:00
Merge pull request #599 from esteemapp/bugfix/570
created parrent post comp
This commit is contained in:
commit
fe69a072b5
4
src/components/parentPost/index.js
Normal file
4
src/components/parentPost/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
import ParentPost from './view/parentPostView';
|
||||
|
||||
export { ParentPost };
|
||||
export default ParentPost;
|
25
src/components/parentPost/view/parentPostStyles.js
Normal file
25
src/components/parentPost/view/parentPostStyles.js
Normal file
@ -0,0 +1,25 @@
|
||||
import EStyleSheet from 'react-native-extended-stylesheet';
|
||||
|
||||
export default EStyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: '$primaryLightBackground',
|
||||
borderRadius: 5,
|
||||
borderWidth: 0.5,
|
||||
borderColor: '$primaryBlack',
|
||||
marginVertical: 20,
|
||||
marginHorizontal: 10,
|
||||
padding: 5,
|
||||
},
|
||||
title: {
|
||||
fontSize: 14,
|
||||
marginBottom: 5,
|
||||
color: '$primaryBlack',
|
||||
fontFamily: '$primaryFont',
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
description: {
|
||||
color: '$primaryBlack',
|
||||
fontFamily: '$primaryFont',
|
||||
fontSize: 10,
|
||||
},
|
||||
});
|
28
src/components/parentPost/view/parentPostView.js
Normal file
28
src/components/parentPost/view/parentPostView.js
Normal file
@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { View, Text, TouchableOpacity } from 'react-native';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
import styles from './parentPostStyles';
|
||||
|
||||
const ParentPost = ({ post, navigation }) => (
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity
|
||||
onPress={() => (navigation && navigation.navigate
|
||||
? navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
content: post,
|
||||
},
|
||||
key: post.permlink,
|
||||
})
|
||||
: null)
|
||||
}
|
||||
>
|
||||
<Text style={styles.title}>{post.title}</Text>
|
||||
<Text style={styles.description}>{post.summary}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
|
||||
export default withNavigation(ParentPost);
|
@ -75,17 +75,20 @@ class PostDisplayContainer extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { post, currentAccount, isLoggedIn } = this.props;
|
||||
const {
|
||||
currentAccount, isLoggedIn, parentPost, post,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<PostDisplayView
|
||||
handleOnVotersPress={this._handleOnVotersPress}
|
||||
handleOnReplyPress={this._handleOnReplyPress}
|
||||
handleOnEditPress={this._handleOnEditPress}
|
||||
currentAccount={currentAccount}
|
||||
fetchPost={this._fetchPost}
|
||||
post={post}
|
||||
handleOnEditPress={this._handleOnEditPress}
|
||||
handleOnReplyPress={this._handleOnReplyPress}
|
||||
handleOnVotersPress={this._handleOnVotersPress}
|
||||
isLoggedIn={isLoggedIn}
|
||||
parentPost={parentPost}
|
||||
post={post}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import { PostPlaceHolder, StickyBar, TextWithIcon } from '../../basicUIElements'
|
||||
import { Upvote } from '../../upvote';
|
||||
import { IconButton } from '../../iconButton';
|
||||
import { CommentsDisplay } from '../../commentsDisplay';
|
||||
import { ParentPost } from '../../parentPost';
|
||||
|
||||
// Styles
|
||||
import styles from './postDisplayStyles';
|
||||
@ -111,7 +112,7 @@ class PostDisplayView extends PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { post, fetchPost } = this.props;
|
||||
const { post, fetchPost, parentPost } = this.props;
|
||||
const { postHeight, scrollHeight, isLoadedComments } = this.state;
|
||||
|
||||
const isPostEnd = scrollHeight > postHeight;
|
||||
@ -123,6 +124,8 @@ class PostDisplayView extends PureComponent {
|
||||
return (
|
||||
<Fragment>
|
||||
<ScrollView style={styles.scroll} onScroll={event => this._handleOnScroll(event)}>
|
||||
{parentPost && <ParentPost post={parentPost} />}
|
||||
|
||||
<View style={styles.header}>
|
||||
{!post ? (
|
||||
<PostPlaceHolder />
|
||||
|
@ -71,6 +71,7 @@ class NotificationContainer extends Component {
|
||||
params: {
|
||||
author: data.author,
|
||||
permlink: data.permlink,
|
||||
isNotification: true,
|
||||
},
|
||||
key: data.permlink,
|
||||
});
|
||||
@ -107,7 +108,10 @@ class NotificationContainer extends Component {
|
||||
render() {
|
||||
const { isLoggedIn } = this.props;
|
||||
const {
|
||||
notifications, notificationLoading, readAllNotificationLoading, isDarkTheme,
|
||||
notifications,
|
||||
notificationLoading,
|
||||
readAllNotificationLoading,
|
||||
isDarkTheme,
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
|
@ -20,6 +20,8 @@ class PostContainer extends Component {
|
||||
post: null,
|
||||
error: null,
|
||||
isNewPost: false,
|
||||
isNotification: false,
|
||||
parentPost: null,
|
||||
};
|
||||
}
|
||||
|
||||
@ -27,15 +29,17 @@ class PostContainer extends Component {
|
||||
componentDidMount() {
|
||||
const { navigation } = this.props;
|
||||
const {
|
||||
content, permlink, author, isNewPost,
|
||||
content, permlink, author, isNewPost, isNotification,
|
||||
} = navigation.state && navigation.state.params;
|
||||
|
||||
if (isNewPost) this.setState({ isNewPost });
|
||||
|
||||
if (content) {
|
||||
this.setState({ post: content });
|
||||
} else {
|
||||
} else if (author && permlink) {
|
||||
this._loadPost(author, permlink);
|
||||
|
||||
if (isNotification) this.setState({ isNotification });
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,8 +56,8 @@ class PostContainer extends Component {
|
||||
|
||||
// Component Functions
|
||||
|
||||
_loadPost = async (author = null, permlink = null) => {
|
||||
const { currentAccount, isLoggedIn, navigation } = this.props;
|
||||
_loadPost = async (author = null, permlink = null, isParentPost = false) => {
|
||||
const { currentAccount, isLoggedIn } = this.props;
|
||||
const { post } = this.state;
|
||||
|
||||
const _author = author || post.author;
|
||||
@ -62,7 +66,11 @@ class PostContainer extends Component {
|
||||
await getPost(_author, _permlink, isLoggedIn && currentAccount.username)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
this.setState({ post: result });
|
||||
if (isParentPost) {
|
||||
this.setState({ parentPost: result });
|
||||
} else {
|
||||
this.setState({ post: result });
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -72,17 +80,22 @@ class PostContainer extends Component {
|
||||
|
||||
render() {
|
||||
const { currentAccount, isLoggedIn } = this.props;
|
||||
const { post, error, isNewPost } = this.state;
|
||||
const {
|
||||
error, isNewPost, parentPost, post, isNotification,
|
||||
} = this.state;
|
||||
|
||||
if (isNotification && post) this._loadPost(post.parent_author, post.parent_permlink, true);
|
||||
|
||||
return (
|
||||
<PostScreen
|
||||
currentAccount={currentAccount}
|
||||
error={error}
|
||||
isLoggedIn={isLoggedIn}
|
||||
post={post}
|
||||
fetchPost={this._loadPost}
|
||||
isFetchComments
|
||||
isLoggedIn={isLoggedIn}
|
||||
isNewPost={isNewPost}
|
||||
parentPost={parentPost}
|
||||
post={post}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -24,7 +24,13 @@ class PostScreen extends PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
post, currentAccount, isLoggedIn, fetchPost, isFetchComments, isNewPost,
|
||||
currentAccount,
|
||||
fetchPost,
|
||||
isFetchComments,
|
||||
isLoggedIn,
|
||||
isNewPost,
|
||||
parentPost,
|
||||
post,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -37,11 +43,12 @@ class PostScreen extends PureComponent {
|
||||
isNewPost={isNewPost}
|
||||
/>
|
||||
<PostDisplay
|
||||
post={post}
|
||||
currentAccount={currentAccount}
|
||||
isLoggedIn={isLoggedIn}
|
||||
fetchPost={fetchPost}
|
||||
isFetchComments={isFetchComments}
|
||||
isLoggedIn={isLoggedIn}
|
||||
parentPost={parentPost}
|
||||
post={post}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user