Skip to main content

LMCreatePostAnonymousCheckbox

The LMCreatePostAnonymousCheckbox component allows users to choose if they want to create a post anonymously. This checkbox is contextually aware and adapts based on the component's current state, such as post editing status and configuration settings.

GitHub File:

LMFeedPostContent

Overview​

LMCreatePostAnonymousCheckbox includes:

  • A customizable checkbox for enabling anonymous posting.
  • An optional hint text that provides guidance on anonymous posting.
  • Integration with CreatePostContext for managing anonymous post settings dynamically.

Props​

The component supports the following customization through context, these values need to be passed through CreatePost component.

Interaction Callbacks​

PropertyTypeDescription
handleOnAnonymousPostClickedPropfunctionOptional custom callback function for handling the anonymous post toggle.

Customisation Props​

PropertyTypeDescription
hintTextForAnonymousstringCustom hint text displayed alongside the checkbox (e.g., "Post anonymously to protect your privacy").
isAnonymousPostAllowedbooleanDetermines if anonymous posting is enabled for the community.

Example Usage​

To use this component, ensure that it's wrapped within a provider that supplies CreatePost context provider. Here’s an example of how to include LMCreatePostAnonymousCheckbox in a CreatePost screen:

Step 1: Create Custom Create Post Screen​

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

export default const CustomCreatePostScreen = () => {

const { handleOnAnonymousPostClicked } = useCreatePostContext()

const customOnCheckboxPress = () => {
// add your logic here
handleOnAnonymousPostClicked();
}

return (
<CreatePost handleOnAnonymousPostClickedProp={customOnCheckboxPress}>
{/* Add your own custom component or import from SDK */}
<LMCreatePostAnonymousCheckbox />
<CreatePost />
);
};

Step 2: Wrap with the context provider​

import React from "react";
import { View } from "react-native";
import {
CreatePostContextProvider,
UniversalFeedContextProvider
} from "@likeminds.community/feed-rn-core";
import CustomCreatePostScreen from "<path_to_the_file>"

export default const CustomCreatePostWrapper = () => {
<UniversalFeedContextProvider navigation={navigation} route={route}>
<CreatePostContextProvider navigation={navigation} route={route}>
<CustomCreatePostScreen />
</CreatePostContextProvider>
</UniversalFeedContextProvider>
}