-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/make-emojis-larger-in-other-message-contexts #15611
Closed
josemak25
wants to merge
11
commits into
Expensify:main
from
josemak25:fix/make-emojis-larger-in-other-message-contexts
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7702aa6
add platform based styles
josemak25 9f61d17
add platform based variables
josemak25 d869d26
add emoji surrogate regex to emoji regex constants
josemak25 799d4ec
use TextEmoji on initial settings page
josemak25 17aaa12
use TextEmoji on details page
josemak25 713a6cf
use TextEmoji on report action item fragment
josemak25 35881af
add TextEmoji util methods
josemak25 a1d7e40
use TextEmoji on menu item component
josemak25 7f60e6c
add isMenuItem props to TextEmoji to fix tooltip menuitem item
josemak25 a75333a
add PR changes and left comments on suggested changes
josemak25 445ac39
add fix to empty char check
josemak25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,52 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import Text from './Text'; | ||
import * as EmojiUtils from '../libs/EmojiUtils'; | ||
import * as StyleUtils from '../styles/StyleUtils'; | ||
import stylePropTypes from '../styles/stylePropTypes'; | ||
|
||
const propTypes = { | ||
/** The message text to render */ | ||
children: PropTypes.string.isRequired, | ||
|
||
/** The message text additional style */ | ||
style: stylePropTypes, | ||
|
||
/** The emoji text additional style */ | ||
emojiContainerStyle: stylePropTypes, | ||
|
||
/** The plain text additional style */ | ||
plainTextContainerStyle: stylePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
style: [], | ||
}; | ||
|
||
const TextEmoji = (props) => { | ||
const words = EmojiUtils.getAllEmojiFromText(props.children); | ||
const propsStyle = StyleUtils.parseStyleAsArray(props.style); | ||
|
||
return _.map(words, ({text, isEmoji}, index) => (isEmoji | ||
? ( | ||
<View key={`${text}_${index}`} style={props.emojiContainerStyle}> | ||
<Text style={propsStyle}> | ||
{text} | ||
</Text> | ||
</View> | ||
) : ( | ||
<View key={`${text}_${index}`} style={props.plainTextContainerStyle}> | ||
<Text> | ||
{text} | ||
</Text> | ||
</View> | ||
))); | ||
}; | ||
|
||
TextEmoji.displayName = 'TextEmoji'; | ||
TextEmoji.defaultProps = defaultProps; | ||
TextEmoji.propTypes = propTypes; | ||
|
||
export default TextEmoji; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what this regex represents? I was not able to figure it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the algorithm, we were expected to capture emojis in a text, though while doing this we need to be careful when we capture emojis that are surrogate pairs.
Surrogate pair Emojis are emojis that can be made up of multiple values that are overlayed on each other to get the final displayed representation.
An example of this is the cloud face emoji made up of 2 different emoji (face emoji and cloud emoji) combined together.
If we split the cloud face emoji we would end up with both separate emojis, so from our algorithm, we need to identify these sorts of surrogate pairs and have them combined back together to maintain the original emoji
Read more on surrogate pair characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for that explanation.
Maybe what we should do then is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we should include some comments to explain what this regex is about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roryabraham
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roryabraham @parasharrajat
@roryabraham @parasharrajat this would prolong this task by extra few days should we try to fix this regex issue.
I would suggest we go with the former implementation which worked perfectly avoiding the need for this regex
d
fix also if it helps I would put a comment on it explaining every step of the algorithm and also remove all the other functions that aren't needed.