Skip to main content

LMCreatePostMedia

The LMCreatePostMedia component handles the media section of the post creation screen. It allows users to attach various media types (images, videos, documents, polls, and links) to their posts and provides functionality for previewing, managing, and removing attachments.

LMFeedPostContent

Overview

LMCreatePostMedia provides the following functionality:

  • Displays previews of attached media (images, videos, polls, and documents).
  • Allows users to add more attachments to their post.
  • Supports conditional rendering based on the attachment types.
  • Provides cancel functionality for each attachment type.

Callbacks & Props

The component supports callback through context values, which are configured within the CreatePost component. It supports the following customizable properties:

PropertyTypeDescription
postToEditbooleanIndicates whether the post is in edit mode.
handleDocumentfunctionMethod to handle document attachment.
handleGalleryfunctionMethod to handle gallery attachment (images, videos).
allAttachmentarrayList of all media attachments.
formattedMediaAttachmentsarrayList of formatted media attachments (images, videos).
formattedPollAttachmentsarrayList of formatted poll attachments.
formattedDocumentAttachmentsarrayList of formatted document attachments.
formattedLinkAttachmentsarrayList of formatted link attachments.
removeMediaAttachmentfunctionFunction to remove media attachments.
removePollAttachmentfunctionFunction to remove poll attachments.
removeDocumentAttachmentfunctionFunction to remove document attachments.
removeSingleAttachmentfunctionFunction to remove a single attachment.
showLinkPreviewbooleanFlag to control the display of the link preview section.
setShowLinkPreviewfunctionFunction to set the link preview state.

Customisations with Styles

PropertyTypeDescription
addMoreAttachmentsButtonobjectCustom styles for the "Add More Attachments" button.
mediaobjectCustom styles for the media section of the post.

Example Usage

To use this component, make sure to wrap it within a CreatePostProvider. Here’s an example:

import React, { useEffect } from "react";
import { View } from "react-native";
import {
LMCreatePostMedia,
CreatePostProvider,
STYLES,
} from "@likeminds.community/feed-rn-core";

const CreatePostScreen = () => {

// to customise ui
useEffect(() => {
STYLES.setPostListStyles({
media: {
image: {
height: 10,
width: 10,
},
},
});
}, []);
return (
<View style={{ flex: 1 }}>
<LMCreatePostMedia />
{/* Additional CreatePost components */}
</View>
);
};

export default CreatePostScreen;