-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7578 from mananjadhav/feat/emoji-picker-singleton
PR 2: Made EmojiPicker a Singleton Component
- Loading branch information
Showing
10 changed files
with
254 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import {Pressable} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../../styles/styles'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import getButtonState from '../../libs/getButtonState'; | ||
import * as Expensicons from '../Icon/Expensicons'; | ||
import Tooltip from '../Tooltip'; | ||
import Icon from '../Icon'; | ||
import withLocalize, {withLocalizePropTypes} from '../withLocalize'; | ||
import * as EmojiPickerAction from '../../libs/actions/EmojiPickerAction'; | ||
|
||
const propTypes = { | ||
/** Flag to disable the emoji picker button */ | ||
isDisabled: PropTypes.bool, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
isDisabled: false, | ||
}; | ||
|
||
const EmojiPickerButton = (props) => { | ||
let emojiPopoverAnchor = null; | ||
return ( | ||
<Pressable | ||
ref={el => emojiPopoverAnchor = el} | ||
style={({hovered, pressed}) => ([ | ||
styles.chatItemEmojiButton, | ||
StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed)), | ||
])} | ||
disabled={props.isDisabled} | ||
onPress={() => EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor)} | ||
> | ||
{({hovered, pressed}) => ( | ||
<Tooltip text={props.translate('reportActionCompose.emoji')}> | ||
<Icon | ||
src={Expensicons.Emoji} | ||
fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed))} | ||
/> | ||
</Tooltip> | ||
)} | ||
</Pressable> | ||
); | ||
}; | ||
|
||
EmojiPickerButton.propTypes = propTypes; | ||
EmojiPickerButton.defaultProps = defaultProps; | ||
EmojiPickerButton.displayName = 'EmojiPickerButton'; | ||
export default withLocalize(EmojiPickerButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.