From f9164cf0f19e561a78d70f3b0e67965a0e5c866e Mon Sep 17 00:00:00 2001 From: Danish Ahmed Mirza Date: Tue, 28 Jun 2022 20:11:52 +0530 Subject: [PATCH] Add ListEmptyComponent --- app/containers/EmojiPicker/Footer.tsx | 8 +++++--- app/containers/MessageBox/EmojiSearchbar.tsx | 20 ++++++++++++-------- app/containers/MessageBox/styles.ts | 11 ++++++++--- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/containers/EmojiPicker/Footer.tsx b/app/containers/EmojiPicker/Footer.tsx index cd602b621..e2972cbda 100644 --- a/app/containers/EmojiPicker/Footer.tsx +++ b/app/containers/EmojiPicker/Footer.tsx @@ -7,16 +7,18 @@ import { CustomIcon } from '../CustomIcon'; import styles from './styles'; import { IFooterProps } from './interfaces'; +const BUTTON_HIT_SLOP = { top: 15, right: 15, bottom: 15, left: 15 }; + const Footer = React.memo(({ onSearchPressed, onBackspacePressed }: IFooterProps) => { const { colors } = useTheme(); return ( - + - - + + ); diff --git a/app/containers/MessageBox/EmojiSearchbar.tsx b/app/containers/MessageBox/EmojiSearchbar.tsx index 433da45c8..ad46eaf1a 100644 --- a/app/containers/MessageBox/EmojiSearchbar.tsx +++ b/app/containers/MessageBox/EmojiSearchbar.tsx @@ -12,6 +12,8 @@ import CustomEmoji from '../EmojiPicker/CustomEmoji'; import database from '../../lib/database'; import styles from './styles'; +const BUTTON_HIT_SLOP = { top: 15, right: 15, bottom: 15, left: 15 }; + interface IEmojiSearchbarProps { openEmoji: () => void; onChangeText: (value: string) => void; @@ -61,29 +63,31 @@ const EmojiSearchbar = React.forwardRef( const emojiSize = 30; return ( - onEmojiSelected(emoji)}> + onEmojiSelected(emoji)}> {renderEmoji(emoji, emojiSize, baseUrl)} ); }; return ( - + renderItem(item)} showsHorizontalScrollIndicator={false} - keyExtractor={item => item.name || item.content} + ListEmptyComponent={() => ( + + {I18n.t('No_results_found')} + + )} + // @ts-ignore + keyExtractor={item => item.name || item} contentContainerStyle={styles.emojiListContainer} keyboardShouldPersistTaps='always' /> - + diff --git a/app/containers/MessageBox/styles.ts b/app/containers/MessageBox/styles.ts index 3ea66b6cb..f3b02dcc5 100644 --- a/app/containers/MessageBox/styles.ts +++ b/app/containers/MessageBox/styles.ts @@ -163,15 +163,20 @@ export default StyleSheet.create({ color: '#ffffff' }, emojiContainer: { justifyContent: 'center', marginHorizontal: 2 }, - emojiListContainer: { height: 50, paddingHorizontal: 5, marginVertical: 5 }, + emojiListContainer: { height: 50, paddingHorizontal: 5, marginVertical: 5, flexGrow: 1 }, emojiSearchbarContainer: { flexDirection: 'row', height: 50, - marginBottom: 10, + marginBottom: 15, justifyContent: 'center', alignItems: 'center' }, openEmojiKeyboard: { marginHorizontal: 10, justifyContent: 'center' }, emojiSearchbar: { padding: 10, borderRadius: 5 }, - textInputContainer: { justifyContent: 'center', marginBottom: 0, marginRight: 15 } + textInputContainer: { justifyContent: 'center', marginBottom: 0, marginRight: 15 }, + listEmptyComponent: { + width: '100%', + alignItems: 'center', + justifyContent: 'center' + } });