From 9d3edaaeb3a3a3593da9681901e7466562546507 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 1 Feb 2023 17:36:05 +0500 Subject: [PATCH] rendering empty content --- .../children/postComments.styles.tsx | 14 ++++++++++ .../postComments/container/postComments.tsx | 27 ++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 src/components/postComments/children/postComments.styles.tsx diff --git a/src/components/postComments/children/postComments.styles.tsx b/src/components/postComments/children/postComments.styles.tsx new file mode 100644 index 000000000..85df448be --- /dev/null +++ b/src/components/postComments/children/postComments.styles.tsx @@ -0,0 +1,14 @@ +import EStyleSheet from 'react-native-extended-stylesheet'; + +export default EStyleSheet.create({ + list: { + flex: 1, + }, + emptyText: { + color: '$primaryDarkGray', + fontSize: 16, + justifyContent: 'center', + marginTop: 5, + padding: 32, + }, +}); diff --git a/src/components/postComments/container/postComments.tsx b/src/components/postComments/container/postComments.tsx index c61cb90c1..dbac52f13 100644 --- a/src/components/postComments/container/postComments.tsx +++ b/src/components/postComments/container/postComments.tsx @@ -6,7 +6,7 @@ import React, { useMemo, useEffect, } from 'react'; -import { ActivityIndicator, Platform, RefreshControl } from 'react-native'; +import { ActivityIndicator, Platform, RefreshControl, Text } from 'react-native'; import { useIntl } from 'react-intl'; import { useNavigation } from '@react-navigation/native'; import { FlatList } from 'react-native-gesture-handler'; @@ -24,6 +24,7 @@ import { deleteComment } from '../../../providers/hive/dhive'; import { updateCommentCache } from '../../../redux/actions/cacheActions'; import { CommentCacheStatus } from '../../../redux/reducers/cacheReducer'; import { CommentsSection } from '../children/commentsSection'; +import styles from '../children/postComments.styles'; const PostComments = forwardRef( @@ -36,6 +37,7 @@ const PostComments = forwardRef( isLoading, onRefresh, handleOnCommentsLoaded, + handleOnReplyPress }, ref, ) => { @@ -242,10 +244,22 @@ const PostComments = forwardRef( ); - const _listEmptyComponent = () => { - return - } + const _renderEmptyContent = () => { + if (discussionQuery.isLoading) { + return null; + } + const _onPress = () => { + if (handleOnReplyPress) { + handleOnReplyPress(); + } + }; + return ( + + {intl.formatMessage({ id: 'comments.no_comments' })} + + ); + }; const _renderItem = ({ item, index }) => { return