diff --git a/src/components/basicUIElements/view/textWithIcon/textWithIconView.js b/src/components/basicUIElements/view/textWithIcon/textWithIconView.js index 9fb846dd4..c6fe97bc9 100644 --- a/src/components/basicUIElements/view/textWithIcon/textWithIconView.js +++ b/src/components/basicUIElements/view/textWithIcon/textWithIconView.js @@ -4,12 +4,20 @@ import { Icon } from '../../../icon'; import styles from './textWithIconStyles'; const TextWithIcon = ({ - iconName, text, isClickable, onPress, iconStyle, iconType, iconSize, + iconName, + text, + isClickable, + onPress, + iconStyle, + iconType, + iconSize, + wrapperStyle, + textStyle, }) => ( {isClickable || onPress ? ( onPress && onPress()} > @@ -19,7 +27,7 @@ const TextWithIcon = ({ name={iconName} iconType={iconType} /> - {text} + {text} ) : ( diff --git a/src/components/comment/index.js b/src/components/comment/index.js new file mode 100644 index 000000000..715ca649a --- /dev/null +++ b/src/components/comment/index.js @@ -0,0 +1,4 @@ +import Comment from './view/commentView'; + +export { Comment }; +export default Comment; diff --git a/src/components/comment/view/commentStyles.js b/src/components/comment/view/commentStyles.js new file mode 100644 index 000000000..cde0f67a9 --- /dev/null +++ b/src/components/comment/view/commentStyles.js @@ -0,0 +1,39 @@ +import EStyleSheet from 'react-native-extended-stylesheet'; + +export default EStyleSheet.create({ + leftIcon: { + color: '$iconColor', + }, + leftButton: { + marginLeft: 10, + }, + rightButton: { + backgroundColor: '$iconColor', + height: 18, + flexDirection: 'row-reverse', + borderRadius: 20, + }, + moreText: { + color: '$white', + fontSize: 10, + marginLeft: 12, + marginRight: 2, + }, + bodyWrapper: { + marginTop: -10, + }, + iconStyle: { + color: '$white', + marginRight: 12, + marginTop: 1, + }, + footerWrapper: { + flex: 1, + flexDirection: 'row', + }, + rightButtonWrapper: { + alignSelf: 'flex-end', + position: 'absolute', + right: 0, + }, +}); diff --git a/src/components/comment/view/commentView.js b/src/components/comment/view/commentView.js new file mode 100644 index 000000000..06a8ba178 --- /dev/null +++ b/src/components/comment/view/commentView.js @@ -0,0 +1,127 @@ +import React, { PureComponent, Fragment } from 'react'; +import { View } from 'react-native'; + +import { getTimeFromNow } from '../../../utils/time'; +// Constants + +// Components +import { PostBody, PostHeaderDescription } from '../../postElements'; +import { Upvote } from '../../upvote'; +import { IconButton } from '../../iconButton'; +import { Comments } from '../../comments'; +import { TextWithIcon } from '../../basicUIElements'; + +// Styles +import styles from './commentStyles'; + +class CommentView extends PureComponent { + /* Props + * ------------------------------------------------ + * @prop { type } name - Description.... + */ + + constructor(props) { + super(props); + this.state = { + isShowSubComments: props.isShowSubComments || false, + }; + } + + // Component Life Cycles + // Component Functions + + _showSubCommentsToggle = () => { + const { isShowSubComments } = this.state; + + this.setState({ isShowSubComments: !isShowSubComments }); + }; + + render() { + const { + avatarSize, + currentAccountUsername, + handleOnEditPress, + handleOnReplyPress, + handleOnUserPress, + isLoggedIn, + marginLeft, + isShowMoreButton, + comment, + commentNumber, + fetchPost, + isShowComments, + } = this.props; + const { isShowSubComments } = this.state; + + return ( + + + + + + {isLoggedIn && ( + + + handleOnReplyPress && handleOnReplyPress(comment)} + iconType="MaterialIcons" + /> + {currentAccountUsername === comment.author && ( + handleOnEditPress && handleOnEditPress(comment)} + iconType="MaterialIcons" + /> + )} + + )} + {isShowMoreButton && ( + + this._showSubCommentsToggle()} + text={`${comment.children} more replies`} + /> + + )} + + {isShowSubComments && commentNumber > 0 && ( + + )} + + + ); + } +} + +export default CommentView; diff --git a/src/components/comments/container/commentsContainer.js b/src/components/comments/container/commentsContainer.js index bbd0ca8a7..507b34654 100644 --- a/src/components/comments/container/commentsContainer.js +++ b/src/components/comments/container/commentsContainer.js @@ -82,29 +82,36 @@ class CommentsContainer extends Component { }; render() { - const { comments: _comments } = this.state; + const { comments: _comments, selectedPermlink } = this.state; const { isLoggedIn, commentCount, author, permlink, currentAccount, - isProfilePreview, + commentNumber, comments, + fetchPost, + isShowMoreButton, + selectedPermlink: _selectedPermlink, } = this.props; return ( ); } diff --git a/src/components/comments/view/commentsView.js b/src/components/comments/view/commentsView.js index 83f32b8dd..246902515 100644 --- a/src/components/comments/view/commentsView.js +++ b/src/components/comments/view/commentsView.js @@ -1,14 +1,8 @@ -import React, { PureComponent, Fragment } from 'react'; +import React, { PureComponent } from 'react'; import { View, FlatList } from 'react-native'; -import { getTimeFromNow } from '../../../utils/time'; -// Constants - // Components -import Comments from '../container/commentsContainer'; -import { PostBody, PostHeaderDescription } from '../../postElements'; -import { Upvote } from '../../upvote'; -import { IconButton } from '../../iconButton'; +import { Comment } from '../../comment'; // Styles // import styles from './commentStyles'; @@ -41,81 +35,37 @@ class CommentsView extends PureComponent { handleOnReplyPress, handleOnUserPress, isLoggedIn, - isProfilePreview, marginLeft, + isShowSubComments, fetchPost, + commentCount, } = this.props; return ( - - {!!comments && ( - ( - - - - - - {isLoggedIn && ( - - - handleOnReplyPress && handleOnReplyPress(item)} - iconType="MaterialIcons" - /> - {currentAccountUsername === item.author && ( - handleOnEditPress && handleOnEditPress(item)} - iconType="MaterialIcons" - /> - )} - - )} - - - {!isProfilePreview && ( - - {commentNumber !== 8 && ( - - )} - - )} - - )} - /> + ( + + 0} + comment={item} + marginLeft={marginLeft} + commentNumber={commentNumber} + fetchPost={fetchPost} + commentCount={commentCount || item.children} + isShowSubComments={isShowSubComments} + avatarSize={avatarSize} + currentAccountUsername={currentAccountUsername} + handleOnReplyPress={handleOnReplyPress} + handleOnEditPress={handleOnEditPress} + handleOnUserPress={handleOnUserPress} + isLoggedIn={isLoggedIn} + showComentsToggle={this._showComentsToggle} + /> + )} - + /> ); } }