diff --git a/src/components/comment/view/commentView.js b/src/components/comment/view/commentView.js index fcb679d27..7a0dbe157 100644 --- a/src/components/comment/view/commentView.js +++ b/src/components/comment/view/commentView.js @@ -1,5 +1,5 @@ import React, { PureComponent, Fragment } from 'react'; -import { View, Text } from 'react-native'; +import { View, Text, TouchableWithoutFeedback } from 'react-native'; import ActionSheet from 'react-native-actionsheet'; import { injectIntl } from 'react-intl'; @@ -48,6 +48,7 @@ class CommentView extends PureComponent { fetchPost, handleDeleteComment, handleOnEditPress, + handleOnLongPress, handleOnReplyPress, handleOnUserPress, isLoggedIn, @@ -56,115 +57,121 @@ class CommentView extends PureComponent { marginLeft, voteCount, intl, - author, mainAuthor = { mainAuthor }, } = this.props; const { isShowSubComments, isPressedShowButton } = this.state; return ( - - - - - - {isLoggedIn && ( - - - - {voteCount} - handleOnReplyPress && handleOnReplyPress(comment)} - iconType="MaterialIcons" - /> - {currentAccountUsername === comment.author && ( - - handleOnEditPress && handleOnEditPress(comment)} - iconType="MaterialIcons" - /> - {!comment.children && !voteCount && ( - - this.ActionSheet.show()} - iconType="MaterialIcons" - /> - (this.ActionSheet = o)} - options={[ - intl.formatMessage({ id: 'alert.delete' }), - intl.formatMessage({ id: 'alert.cancel' }), - ]} - title={intl.formatMessage({ id: 'alert.delete' })} - destructiveButtonIndex={0} - cancelButtonIndex={1} - onPress={index => { - index === 0 ? handleDeleteComment(comment.permlink) : null; - }} - /> - - )} - - )} - - )} - {isShowMoreButton && ( - - this._showSubCommentsToggle()} - text={!isPressedShowButton ? `${comment.children} more replies` : ''} - /> - + + + + + + + {isLoggedIn && ( + + + + {voteCount} + handleOnReplyPress && handleOnReplyPress(comment)} + iconType="MaterialIcons" + /> + {currentAccountUsername === comment.author && ( + + handleOnEditPress && handleOnEditPress(comment)} + iconType="MaterialIcons" + /> + {!comment.children && !voteCount && ( + + this.ActionSheet.show()} + iconType="MaterialIcons" + /> + (this.ActionSheet = o)} + options={[ + intl.formatMessage({ id: 'alert.delete' }), + intl.formatMessage({ id: 'alert.cancel' }), + ]} + title={intl.formatMessage({ id: 'alert.delete' })} + destructiveButtonIndex={0} + cancelButtonIndex={1} + onPress={index => { + index === 0 ? handleDeleteComment(comment.permlink) : null; + }} + /> + + )} + + )} + + )} + {isShowMoreButton && ( + + this._showSubCommentsToggle()} + text={!isPressedShowButton ? `${comment.children} more replies` : ''} + /> + + )} + + {isShowSubComments && commentNumber > 0 && ( + )} - {isShowSubComments && commentNumber > 0 && ( - - )} - + ); } } diff --git a/src/components/comments/container/commentsContainer.js b/src/components/comments/container/commentsContainer.js index 3a971aba4..86f8fa035 100644 --- a/src/components/comments/container/commentsContainer.js +++ b/src/components/comments/container/commentsContainer.js @@ -1,18 +1,22 @@ import React, { Component } from 'react'; import { withNavigation } from 'react-navigation'; import { connect } from 'react-redux'; +import { injectIntl } from 'react-intl'; +import get from 'lodash/get'; import { getComments, deleteComment } from '../../../providers/steem/dsteem'; // Services and Actions +import { writeToClipboard } from '../../../utils/clipboard'; +import { toastNotification } from '../../../redux/actions/uiAction'; // Middleware // Constants -import { default as ROUTES } from '../../../constants/routeNames'; +import ROUTES from '../../../constants/routeNames'; // Component -import { CommentsView } from '..'; +import CommentsView from '../view/commentsView'; /* * Props Name Description Value @@ -163,6 +167,27 @@ class CommentsContainer extends Component { }); }; + _handleCommentCopyAction = (index, selectedComment) => { + const { dispatch, intl } = this.props; + + switch (index) { + case 0: + writeToClipboard(`https://steemit.com${get(selectedComment, 'url')}`).then(() => { + dispatch( + toastNotification( + intl.formatMessage({ + id: 'alert.copied', + }), + ), + ); + }); + break; + + default: + break; + } + }; + render() { const { comments: _comments, selectedPermlink } = this.state; const { @@ -196,6 +221,7 @@ class CommentsContainer extends Component { isLoggedIn={isLoggedIn} fetchPost={fetchPost} handleDeleteComment={this._handleDeleteComment} + handleCommentCopyAction={this._handleCommentCopyAction} {...this.props} /> ); @@ -208,4 +234,4 @@ const mapStateToProps = state => ({ pinCode: state.account.pin, }); -export default withNavigation(connect(mapStateToProps)(CommentsContainer)); +export default withNavigation(connect(mapStateToProps)(injectIntl(CommentsContainer))); diff --git a/src/components/comments/view/commentsView.js b/src/components/comments/view/commentsView.js index 9de1cfcf9..3be5d5571 100644 --- a/src/components/comments/view/commentsView.js +++ b/src/components/comments/view/commentsView.js @@ -1,7 +1,11 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, Fragment } from 'react'; import { FlatList } from 'react-native'; +import ActionSheet from 'react-native-actionsheet'; +import get from 'lodash/get'; +import { injectIntl } from 'react-intl'; // Components +// eslint-disable-next-line import/no-cycle import { Comment } from '../../comment'; // Styles @@ -15,7 +19,10 @@ class CommentsView extends PureComponent { constructor(props) { super(props); - this.state = {}; + this.state = { + selectedComment: null, + }; + this.commentMenu = React.createRef(); } // Component Life Cycles @@ -24,6 +31,11 @@ class CommentsView extends PureComponent { _keyExtractor = item => item.permlink; + _openCommentMenu = item => { + this.setState({ selectedComment: item }); + this.commentMenu.current.show(); + }; + render() { const { mainAuthor, @@ -40,36 +52,56 @@ class CommentsView extends PureComponent { isShowSubComments, marginLeft, handleDeleteComment, + handleCommentCopyAction, + intl, } = this.props; + const { selectedComment } = this.state; return ( - ( - 0} - voteCount={item.net_votes} - isShowSubComments={isShowSubComments} - key={item.permlink} - marginLeft={marginLeft} - /> - )} - /> + + ( + 0} + voteCount={item.net_votes} + isShowSubComments={isShowSubComments} + key={item.permlink} + marginLeft={marginLeft} + handleOnLongPress={() => this._openCommentMenu(item)} + /> + )} + /> + handleCommentCopyAction(index, selectedComment)} + /> + ); } } -export default CommentsView; +export default injectIntl(CommentsView); diff --git a/src/components/postCard/view/postCardView.js b/src/components/postCard/view/postCardView.js index dbd4416d1..ca7f2d397 100644 --- a/src/components/postCard/view/postCardView.js +++ b/src/components/postCard/view/postCardView.js @@ -120,10 +120,10 @@ class PostCardView extends Component { {content.vote_count} - + {content.children} - + ); diff --git a/src/components/postElements/body/view/postBodyView.js b/src/components/postElements/body/view/postBodyView.js index 5976a28a5..46814cbae 100644 --- a/src/components/postElements/body/view/postBodyView.js +++ b/src/components/postElements/body/view/postBodyView.js @@ -1,7 +1,5 @@ import React, { PureComponent, Fragment } from 'react'; -import { - Dimensions, Linking, Alert, TouchableOpacity, Text, -} from 'react-native'; +import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native'; import { withNavigation } from 'react-navigation'; import { injectIntl } from 'react-intl'; import FastImage from 'react-native-fast-image'; @@ -48,7 +46,7 @@ class PostBody extends PureComponent { if (!url) return; const { intl } = this.props; - Linking.canOpenURL(url).then((supported) => { + Linking.canOpenURL(url).then(supported => { if (supported) { Linking.openURL(url); } else { @@ -148,7 +146,7 @@ class PostBody extends PureComponent { }; render() { - const { body, isComment } = this.props; + const { body, isComment, textSelectable = true } = this.props; const _initialDimensions = isComment ? { width: WIDTH - 50, height: 80 } : { width: WIDTH, height: 216 }; @@ -166,13 +164,21 @@ class PostBody extends PureComponent { a: (htmlAttribs, children, convertedCSSStyles, passProps) => { if (passProps.parentWrapper === 'Text') { return ( - this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}> + this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)} + > {children} ); } return ( - this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}> + this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)} + > {children} ); @@ -185,7 +191,7 @@ class PostBody extends PureComponent { html={body} onLinkPress={(evt, href, hrefatr) => this._handleOnLinkPress(evt, href, hrefatr)} containerStyle={isComment ? styles.commentContainer : styles.container} - textSelectable + textSelectable={textSelectable} tagsStyles={isComment ? { img: { height: 120 } } : styles} ignoredTags={['script']} debug={false} diff --git a/src/components/postView/view/postDisplayView.js b/src/components/postView/view/postDisplayView.js index 115d520b9..0a7fc23c6 100644 --- a/src/components/postView/view/postDisplayView.js +++ b/src/components/postView/view/postDisplayView.js @@ -185,8 +185,8 @@ class PostDisplayView extends PureComponent { - Posted by {author || post.author} -{' '} + Posted by + {author || post.author} {formatedTime} {/* {isPostEnd && this._getTabBar()} */} diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index a85f266d5..9d0561a5c 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -199,7 +199,8 @@ }, "post": { "reblog_alert": "Are you sure you want to reblog?", - "removed_hint": "The post was removed by" + "removed_hint": "The post was removed by", + "copy_link": "Copy Link" }, "drafts": { "title": "Drafts", diff --git a/src/screens/transfer/screen/transferScreen.js b/src/screens/transfer/screen/transferScreen.js index 470235c89..111472222 100644 --- a/src/screens/transfer/screen/transferScreen.js +++ b/src/screens/transfer/screen/transferScreen.js @@ -1,4 +1,3 @@ -/* eslint-disable no-restricted-globals */ import React, { Fragment, Component } from 'react'; import { Text, View, WebView, ScrollView, TouchableOpacity } from 'react-native'; import ActionSheet from 'react-native-actionsheet';