From 695fe62fff0c9e24c02b6e1298e0a4bbb5c88749 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Tue, 20 Feb 2018 14:59:39 +0100 Subject: [PATCH] [MM-9321] Add a "+" button to make it easy to add Emoji Reactions (#1455) --- app/components/post/post.js | 6 ++-- app/components/post_body/post_body.js | 7 ++++- app/components/reactions/reactions.js | 41 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/components/post/post.js b/app/components/post/post.js index 5d19962a7..872dfbf46 100644 --- a/app/components/post/post.js +++ b/app/components/post/post.js @@ -17,7 +17,7 @@ import PostHeader from 'app/components/post_header'; import PostProfilePicture from 'app/components/post_profile_picture'; import {NavigationTypes} from 'app/constants'; import {emptyFunction} from 'app/utils/general'; -import {preventDoubleTap} from 'app/utils/tap'; +import {preventDoubleTap, wrapWithPreventDoubleTap} from 'app/utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; import {getToolTipVisible} from 'app/utils/tooltip'; @@ -184,7 +184,7 @@ class Post extends PureComponent { this.props.actions.addReaction(post.id, emoji); } - handleAddReaction = () => { + handleAddReaction = wrapWithPreventDoubleTap(() => { const {intl, navigator, post, theme} = this.props; MaterialIcon.getImageSource('close', 20, theme.sidebarHeaderTextColor). @@ -206,7 +206,7 @@ class Post extends PureComponent { } }); }); - } + }); handleFailedPostPress = () => { const options = { diff --git a/app/components/post_body/post_body.js b/app/components/post_body/post_body.js index b985fe9c6..1a9d90217 100644 --- a/app/components/post_body/post_body.js +++ b/app/components/post_body/post_body.js @@ -296,7 +296,12 @@ class PostBody extends PureComponent { isReplyPost={isReplyPost} /> {this.renderFileAttachments()} - {hasReactions && } + {hasReactions && + + } ); } diff --git a/app/components/reactions/reactions.js b/app/components/reactions/reactions.js index 1772e4499..fc62047ec 100644 --- a/app/components/reactions/reactions.js +++ b/app/components/reactions/reactions.js @@ -5,9 +5,13 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import { StyleSheet, + Text, + TouchableOpacity, View } from 'react-native'; +import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; + import Reaction from './reaction'; export default class Reactions extends PureComponent { @@ -18,6 +22,7 @@ export default class Reactions extends PureComponent { removeReaction: PropTypes.func.isRequired }).isRequired, highlightedReactions: PropTypes.array.isRequired, + onAddReaction: PropTypes.func.isRequired, postId: PropTypes.string.isRequired, reactions: PropTypes.object.isRequired, theme: PropTypes.object.isRequired @@ -55,9 +60,26 @@ export default class Reactions extends PureComponent { } render() { + const {reactions} = this.props; + const styles = getStyleSheet(this.props.theme); + + if (!reactions.size) { + return null; + } + + const addMoreReactions = ( + + {'+'} + + ); + return ( {this.renderReactions()} + {addMoreReactions} ); } @@ -70,3 +92,22 @@ const style = StyleSheet.create({ alignItems: 'flex-start' } }); + +const getStyleSheet = makeStyleSheetFromTheme((theme) => { + return { + more: { + color: theme.linkColor + }, + reaction: { + alignItems: 'center', + borderRadius: 2, + borderColor: changeOpacity(theme.linkColor, 0.4), + borderWidth: 1, + flexDirection: 'row', + marginRight: 6, + marginVertical: 5, + paddingVertical: 2, + paddingHorizontal: 6 + } + }; +});