Skip to main content

Post Detail

Overview

LikeMindsFeed SDK offers various Post Detail Screen implementations to cater to different use cases. These screens are responsible for displaying detailed information about a post, including comments and replies, with each variant optimized for specific content types or interactions.

In the Post Detail screen, the LikeMinds Feed SDK reuses the components from the Post List screen. While these cells share a similar UI, separate classes have been created for each to allow customization and extensibility.

LMFeedPostDetailScreen

UI Components

Data Variables

  • postData: Stores the post data conforming to LMPostViewData.
  • commentsData: An array of LMCommentViewData representing the comments and replies data.
  • isCommentingEnabled: A Boolean indicating whether commenting is enabled for the current user.

Callbacks

  • getCommentsRepliesProp: Fetches the replies for a given comment by post ID and comment ID, invoking a callback with the response.
  • addNewCommentProp: Adds a new comment to the specified post.
  • addNewReplyProp: Adds a new reply to a specific comment within a post.

For information about more callbacks, click here.

Customisation

The LMFeedContextStyles class allows you to customize the appearance of the LMPostContent. You can set the styles in postDetailStyle in LMFeedContextStyles.

PropertyTypeDescription
screenHeaderLMHeaderPropsCustomization for the screen header.
commentItemStyleCommentItemStyleCustomization for the individual comment item.
commentCountHeadingTextTextStyleStyling for the comment count heading text.
noCommentViewStyleViewStyleStyling for the view shown when there are no comments.
noCommentHeadingTextStyleTextStyleStyling for the heading text shown when there are no comments.
noCommentSubHeadingTextStyleTextStyleStyling for the subheading text shown when there are no comments.
replyingViewStyleReplyingViewStyleCustomization for the reply view.
userTaggingListStyleUserTaggingListStyleCustomization for the user tagging list.
commentTextInputStyleCommentTextInputStyleCustomization for the comment input text field.

CommentItemStyle

PropertyTypeDescription
onTapViewMoreFunctionCallback for when "View More" is tapped.
commentUserNameStyleTextStyleStyling for the comment username.
commentContentPropsLMTextPropsProps for the comment content text.
replyTextPropsReplyTextPropsCustomization for the reply text and icon.
repliesCountTextStyleTextStyleStyling for the replies count text.
timeStampStyleTextStyleStyling for the timestamp.
viewMoreRepliesPropsLMTextPropsProps for "View More Replies" text.
onTapRepliesFunctionCallback for tapping on replies.

ReplyTextProps

PropertyTypeDescription
textLMTextPropsCustomization for the reply button text.
iconLMIconPropsCustomization for the reply button icon.
onTapFunctionCallback for when the reply button is tapped.
placementStringPlacement of the icon relative to the text.
buttonStyleViewStyleStyling for the reply button.
isClickableBooleanWhether the reply button is clickable.

ReplyingViewStyle

PropertyTypeDescription
replyingViewViewStyleStyling for the replying view container.
replyingTextLMTextPropsCustomization for the replying text.
cancelReplyIconLMIconPropsCustomization for the cancel reply icon.

UserTaggingListStyle

PropertyTypeDescription
taggingListViewViewStyleStyling for the tagging list view.
userTagViewViewStyleStyling for the individual user tag view.
userTagNameStyleTextStyleStyling for the user tag name.

CommentTextInputStyle

PropertyTypeDescription
inputTextStyleTextStyleStyling for the input text field.
placeholderTextStringPlaceholder text for the input field.
placeholderTextColorStringColor for the placeholder text.
rightIconRightIconPropsCustomization for the icon on the right side of the input field.
textValueStyleTextStyleStyling for the text value in the input field.
mentionTextStyleTextStyleStyling for the mentioned users' text.
multilineFieldBooleanWhether the input field supports multiple lines.

RightIconProps

PropertyTypeDescription
textLMTextPropsCustomization for the right icon's text.
iconLMIconPropsCustomization for the right icon's icon.
onTapFunctionCallback for when the right icon is tapped.
placementStringPlacement of the icon relative to the text.
buttonStyleViewStyleStyling for the right icon's button.
isClickableBooleanWhether the right icon is clickable.

Few of the customisation like header customisation, turning on/off the autoplay, footer, etc are done using the postListStyle in LMFeedContextStyles

Usage Example

Step 1: Create Custom Screen and Wrapper

  • In your app, create a PostDetailsScreenWrapper file which will wrap the DetailsScreen within the PostDetailContextProvider along with UniversalFeedContextProvider so that the callbacks becomes accessible inside of the DetailsScreen.
  • Create postDetailScreenStyles for customisation and call the setCreatePostStyles to set the customisation.
import {
PostDetail,
usePostDetailContext,
useUniversalFeedContext,
} from "@likeminds.community/feed-rn-core";
import { Alert, Platform, Share } from "react-native";

const DetailsScreen = ({ navigation }) => {
const {
route,
getCommentsReplies,
addNewComment,
addNewReply,
commentLikeHandler,
handleDeleteComment,
handleEditComment,
handleReportComment,
handleScreenBackPress,
onCommentOverflowMenuClick,
} = usePostDetailContext();
const { addPollOption, addNewComment, addNewReply } =
useUniversalFeedContext();

// customised addNewComment callback
const customAddNewCommentProp = (postId) => {
console.log("before new comment");
addNewComment(postId);
console.log("after new comment", postId);
};
// customised addNewReply callback
const customAddNewReplyProp = (postId, commentId) => {
console.log("before add reply");
addNewReply(postId, commentId);
console.log("after add reply");
};

const postDetailScreenStyles = {
shouldHideSeparator: false,
noCommentViewStyle: {
backgroundColor: "red",
},
};

// post details screen customisation
if (postDetailScreenStyles) {
STYLES.setCreatePostStyles(postDetailScreenStyles);
}

return (
<PostDetail
route={route}
navigation={navigation}
addNewCommentProp={(id) => customAddNewCommentProp(id)}
addNewReplyProp={(postId, commentId) =>
customAddNewReplyProp(postId, commentId)
}
/>
);
};

export default DetailsScreen;

Step 2: Add the Custom Screen in App.tsx

  • In your App.tsx, create a Stack.Navigator in the NavigationContainer wrapped by LMOverlayProvider.
  • Add PostDetailsScreenWrapper as a Stack screen in your NavigationContainer.
import {
POST_DETAIL,
LMOverlayProvider,
STYLES,
} from "@likeminds.community/feed-rn-core";
import PostDetailsScreenWrapper from "<<path_to_PostDetailsScreenWrapper.tsx>>";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";

export const App = () => {
const Stack = createNativeStackNavigator();
return (
<LMOverlayProvider
myClient={myClient} // pass in the LMFeedClient created
apiKey={apiKey} // pass in the API Key generated
userName={userName} // pass in the logged-in user's name
userUniqueId={userUniqueID} // pass in the logged-in user's uuid
>
<NavigationContainer ref={navigationRef} independent={true}>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name={POST_DETAIL}
component={PostDetailsScreenWrapper}
/>
</Stack.Navigator>
</NavigationContainer>
</LMOverlayProvider>
);
};