Skip to content
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

Make ReactionPicker full screen with search by emoji title #780

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __tests__/__snapshots__/Storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/react_rocket.png",
}
}
Expand All @@ -3008,6 +3009,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand All @@ -3024,6 +3026,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/marioparty.gif",
}
}
Expand Down Expand Up @@ -3572,6 +3575,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/marioparty.gif",
}
}
Expand Down Expand Up @@ -3997,6 +4001,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/marioparty.gif",
}
}
Expand Down Expand Up @@ -4072,6 +4077,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/react_rocket.png",
}
}
Expand Down Expand Up @@ -4147,6 +4153,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down Expand Up @@ -6853,6 +6860,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down Expand Up @@ -7116,6 +7124,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down Expand Up @@ -7724,6 +7733,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down Expand Up @@ -9196,6 +9206,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down Expand Up @@ -14204,6 +14215,7 @@ exports[`Storyshots Message list 1`] = `
<Image
source={
Object {
"cache": "force-cache",
"uri": "https://open.rocket.chat/emoji-custom/nyan_rocket.png",
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/containers/EmojiPicker/CustomEmoji.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Image } from 'react-native';
import { ViewPropTypes, Image } from 'react-native';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use ViewPropTypes

import PropTypes from 'prop-types';

export default class CustomEmoji extends React.Component {
static propTypes = {
baseUrl: PropTypes.string.isRequired,
emoji: PropTypes.object.isRequired,
style: PropTypes.any
style: ViewPropTypes.style
}

shouldComponentUpdate() {
Expand All @@ -18,7 +18,7 @@ export default class CustomEmoji extends React.Component {
return (
<Image
style={style}
source={{ uri: `${ baseUrl }/emoji-custom/${ encodeURIComponent(emoji.content || emoji.name) }.${ emoji.extension }` }}
source={{ uri: `${ baseUrl }/emoji-custom/${ encodeURIComponent(emoji.content || emoji.name) }.${ emoji.extension }`, cache: 'force-cache' }}
/>
);
}
Expand Down
33 changes: 24 additions & 9 deletions app/containers/EmojiPicker/EmojiCategory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Text, TouchableOpacity } from 'react-native';
import { Text, TouchableOpacity, FlatList } from 'react-native';
import { emojify } from 'react-emojione';
import { responsive } from 'react-native-responsive-ui';
import { OptimizedFlatList } from 'react-native-optimized-flatlist';

import styles from './styles';
import CustomEmoji from './CustomEmoji';
Expand All @@ -14,16 +13,22 @@ const EMOJIS_PER_ROW = isIOS ? 8 : 9;

const renderEmoji = (emoji, size, baseUrl) => {
if (emoji.isCustom) {
return <CustomEmoji style={[styles.customCategoryEmoji, { height: size - 8, width: size - 8 }]} emoji={emoji} baseUrl={baseUrl} />;
return (
<CustomEmoji
style={[styles.customCategoryEmoji, { height: size - 8, width: size - 8 }]}
emoji={emoji}
baseUrl={baseUrl}
/>
);
}

return (
<Text style={[styles.categoryEmoji, { height: size, width: size, fontSize: size - 14 }]}>
{emojify(`:${ emoji }:`, { output: 'unicode' })}
</Text>
);
};


@responsive
export default class EmojiCategory extends React.Component {
static propTypes = {
Expand All @@ -33,7 +38,7 @@ export default class EmojiCategory extends React.Component {
onEmojiSelected: PropTypes.func,
emojisPerRow: PropTypes.number,
width: PropTypes.number
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?


constructor(props) {
super(props);
Expand All @@ -44,7 +49,13 @@ export default class EmojiCategory extends React.Component {
this.emojis = props.emojis;
}

shouldComponentUpdate() {
shouldComponentUpdate(nextProps) {
const { emojis: oldEmojis } = this.props;

if (nextProps.emojis.length !== oldEmojis.length) {
diegolmello marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

return false;
}

Expand All @@ -66,13 +77,17 @@ export default class EmojiCategory extends React.Component {
const { emojis } = this.props;

return (
<OptimizedFlatList
IlarionHalushka marked this conversation as resolved.
Show resolved Hide resolved
<FlatList
keyExtractor={item => (item.isCustom && item.content) || item}
data={emojis}
renderItem={({ item }) => this.renderItem(item, this.size)}
numColumns={EMOJIS_PER_ROW}
initialNumToRender={45}
getItemLayout={(data, index) => ({ length: this.size, offset: this.size * index, index })}
initialNumToRender={30}
getItemLayout={(data, index) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a function

length: this.size,
offset: this.size * index,
index
})}
removeClippedSubviews
{...scrollPersistTaps}
/>
Expand Down
Loading