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.

GitHub Files:

LMFeedPostDetailScreen

UI Components

Props

These props allow interaction handling for comments and replies in the PostDetail screen:

Interaction Callbacks

Prop NameTypeDescription
getCommentsRepliesPropFunctionFetches replies for a given comment by postId and commentId.
addNewCommentPropFunctionAdds a new comment to the specified post.
addNewReplyPropFunctionAdds a new reply to a specific comment within a post.

For more callback info, see the callback context source.


Styling Customizations

The STYLES class allows you to customize the appearance of the PostDetail screen using postDetailStyle.

PropertyTypeDescription
screenHeaderLMHeaderPropsCustomizes the screen header.
commentItemStyleCommentItemStyleCustomization for each comment item.
commentCountHeadingTextTextStyleStyle for comment count heading text.
noCommentViewStyleViewStyleStyle for view shown when no comments exist.
noCommentHeadingTextStyleTextStyleStyle for the heading when no comments exist.
noCommentSubHeadingTextStyleTextStyleStyle for the subheading when no comments exist.
replyingViewStyleReplyingViewStyleStyle for the reply view section.
userTaggingListStyleUserTaggingListStyleStyle for user tagging list items.
commentTextInputStyleCommentTextInputStyleStyle for the comment input text field.

CommentItemStyle

PropertyTypeDescription
onTapViewMoreFunctionCallback for "View More" tap.
commentUserNameStyleTextStyleStyle for commenter's name.
commentContentPropsLMTextPropsProps for comment content text.
replyTextPropsReplyTextPropsStyle for reply action text/icon.
repliesCountTextStyleTextStyleStyle for reply count text.
timeStampStyleTextStyleStyle for timestamp.
viewMoreRepliesPropsLMTextPropsProps for "View More Replies" text.
onTapRepliesFunctionCallback for tapping on replies.

ReplyTextProps

PropertyTypeDescription
textLMTextPropsStyle for the reply button text.
iconLMIconPropsIcon for the reply button.
onTapFunctionCallback when the reply button is tapped.
placementStringIcon placement relative to text.
buttonStyleViewStyleStyle for the reply button container.
isClickableBooleanIf the reply button is clickable.

ReplyingViewStyle

PropertyTypeDescription
replyingViewViewStyleStyle for the reply view container.
replyingTextLMTextPropsStyle for the reply text.
cancelReplyIconLMIconPropsIcon for canceling the reply action.

UserTaggingListStyle

PropertyTypeDescription
taggingListViewViewStyleStyle for the entire tagging list.
userTagViewViewStyleStyle for each tagged user item.
userTagNameStyleTextStyleStyle for each tagged user's name.

CommentTextInputStyle

PropertyTypeDescription
inputTextStyleTextStyleStyle for the comment input field.
placeholderTextStringPlaceholder text inside the input field.
placeholderTextColorStringColor for placeholder text.
rightIconRightIconPropsStyle and callback for the right-side icon.
textValueStyleTextStyleStyle for text inside the input field.
mentionTextStyleTextStyleStyle for mention text.
multilineFieldBooleanWhether the input field supports multiline.

RightIconProps

PropertyTypeDescription
textLMTextPropsStyle for icon-related text.
iconLMIconPropsIcon component itself.
onTapFunctionCallback when icon is tapped.
placementStringPlacement of icon relative to text.
buttonStyleViewStyleStyle for the icon button container.
isClickableBooleanWhether the icon is interactive.

Additional customizations like header, autoplay toggle, and footer can be handled via postListStyle in STYLES.

Usage Example

Step 1: Create the Details Screen Component

  • Define a CustomDetailsScreen component where you handle callbacks and apply screen-specific styles as per requirement.
import {
PostDetail,
usePostDetailContext,
useUniversalFeedContext,
} from "@likeminds.community/feed-rn-core";

const CustomDetailsScreen = ({ navigation }) => {
const {
route,
addNewComment,
addNewReply
} = usePostDetailContext();

// 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 CustomDetailsScreen;

Step 2: Wrap the Screen with Context Providers

  • Create a PostDetailsScreenWrapper that wraps the DetailsScreen with both PostDetailContextProvider and UniversalFeedContextProvider.
import CustomDetailsScreen from "<<path_to_DetailsScreen.tsx>>";
import {
PostDetailContextProvider,
UniversalFeedContextProvider,
} from "@likeminds.community/feed-rn-core";

const PostDetailsScreenWrapper = ({ navigation, route }) => {
return (
<UniversalFeedContextProvider navigation={navigation} route={route}>
<PostDetailContextProvider navigation={navigation} route={route}>
<CustomDetailsScreen />
</PostDetailContextProvider>
</UniversalFeedContextProvider>
);
};

export default PostDetailsScreenWrapper;

Step 3: 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>
);
};