Update tooltip library (#1426)
* Update tooltip library * Feedback review * remove static field
This commit is contained in:
parent
bd3a5e1288
commit
418c1ce9ba
6 changed files with 62 additions and 10 deletions
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
import React, {PureComponent} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import ToolTip from 'react-native-tooltip';
|
||||
|
||||
import ToolTip from 'app/components/tooltip';
|
||||
|
||||
export default class OptionsContext extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {
|
|||
} from 'react-native';
|
||||
import {injectIntl, intlShape} from 'react-intl';
|
||||
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
||||
import {isToolTipShowing} from 'react-native-tooltip';
|
||||
|
||||
import PostBody from 'app/components/post_body';
|
||||
import PostHeader from 'app/components/post_header';
|
||||
|
|
@ -20,6 +19,7 @@ import {NavigationTypes} from 'app/constants';
|
|||
import {emptyFunction} from 'app/utils/general';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import {getToolTipVisible} from 'app/utils/tooltip';
|
||||
|
||||
import {Posts} from 'mattermost-redux/constants';
|
||||
import DelayedAction from 'mattermost-redux/utils/delayed_action';
|
||||
|
|
@ -265,7 +265,7 @@ class Post extends PureComponent {
|
|||
post
|
||||
} = this.props;
|
||||
|
||||
if (!isToolTipShowing) {
|
||||
if (!getToolTipVisible()) {
|
||||
if (onPress && post.state !== Posts.POST_DELETED && !isSystemMessage(post) && !isPostPendingOrFailed(post)) {
|
||||
preventDoubleTap(onPress, null, post);
|
||||
} else if (!isSearchResult && isPostEphemeral(post)) {
|
||||
|
|
@ -276,7 +276,7 @@ class Post extends PureComponent {
|
|||
|
||||
handleReply = () => {
|
||||
const {post, onReply} = this.props;
|
||||
if (!isToolTipShowing && onReply) {
|
||||
if (!getToolTipVisible() && onReply) {
|
||||
return preventDoubleTap(onReply, null, post);
|
||||
}
|
||||
|
||||
|
|
@ -322,13 +322,13 @@ class Post extends PureComponent {
|
|||
viewUserProfile = () => {
|
||||
const {isSearchResult} = this.props;
|
||||
|
||||
if (!isSearchResult && !isToolTipShowing) {
|
||||
if (!isSearchResult && !getToolTipVisible()) {
|
||||
preventDoubleTap(this.goToUserProfile, this);
|
||||
}
|
||||
};
|
||||
|
||||
toggleSelected = (selected) => {
|
||||
if (!isToolTipShowing) {
|
||||
if (!getToolTipVisible()) {
|
||||
this.setState({selected});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
39
app/components/tooltip.js
Normal file
39
app/components/tooltip.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, {PureComponent} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import RNToolTip from 'react-native-tooltip';
|
||||
|
||||
import {setToolTipVisible} from 'app/utils/tooltip';
|
||||
|
||||
export default class ToolTip extends PureComponent {
|
||||
static propTypes = {
|
||||
onHide: PropTypes.func,
|
||||
onShow: PropTypes.func
|
||||
};
|
||||
|
||||
handleHide = () => {
|
||||
if (this.props.onHide) {
|
||||
this.props.onHide();
|
||||
}
|
||||
setToolTipVisible(false);
|
||||
};
|
||||
|
||||
handleShow = () => {
|
||||
if (this.props.onShow) {
|
||||
this.props.onShow();
|
||||
}
|
||||
setToolTipVisible();
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<RNToolTip
|
||||
{...this.props}
|
||||
onHide={this.handleHide}
|
||||
onShow={this.handleShow}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
12
app/utils/tooltip.js
Normal file
12
app/utils/tooltip.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
let isToolTipVisible = false;
|
||||
|
||||
export function setToolTipVisible(visible = true) {
|
||||
isToolTipVisible = visible;
|
||||
}
|
||||
|
||||
export function getToolTipVisible() {
|
||||
return isToolTipVisible;
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
"react-native-status-bar-size": "0.3.3",
|
||||
"react-native-svg": "6.1.3",
|
||||
"react-native-tableview": "2.1.0",
|
||||
"react-native-tooltip": "enahum/react-native-tooltip",
|
||||
"react-native-tooltip": "5.2.0",
|
||||
"react-native-vector-icons": "4.5.0",
|
||||
"react-native-video": "2.0.0",
|
||||
"react-native-youtube": "1.1.0",
|
||||
|
|
|
|||
|
|
@ -5317,9 +5317,9 @@ react-native-tableview@2.1.0:
|
|||
dependencies:
|
||||
prop-types "^15.6.0"
|
||||
|
||||
react-native-tooltip@enahum/react-native-tooltip:
|
||||
version "5.1.1"
|
||||
resolved "https://codeload.github.com/enahum/react-native-tooltip/tar.gz/eb47f93a728813b58c01f23ec84f0b8b1bd70bd0"
|
||||
react-native-tooltip@5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-tooltip/-/react-native-tooltip-5.2.0.tgz#4358ea1e9bdcb49dad28bf5881440b0182927422"
|
||||
|
||||
react-native-vector-icons@4.5.0:
|
||||
version "4.5.0"
|
||||
|
|
|
|||
Loading…
Reference in a new issue