Skip to main content

Screen: LMFeedCreatePostFragment

LMFeedCreatePostFragment provides the interface for creating new posts in the LikeMinds feed system. It supports various post types, including text, images, videos, documents, and polls, allowing users to compose rich content with advanced customization options.
GitHub Link to LMFeedCreatePostFragment


View Style: LMFeedCreatePostFragmentViewStyle

LMFeedCreatePostFragmentViewStyle defines the visual style and structure of the LMFeedCreatePostFragment. The following fields are available for customization:

Field NameDescriptionType
headerViewStyleStyle for the header of the create post screen.LMFeedHeaderViewStyle
authorViewStyleDefines the style for the author view.LMFeedPostHeaderViewStyle
selectTopicsChipStyleStyle for the topic selection chip.LMFeedChipStyle
editChipStyleStyle for the edit chip in the post composer.LMFeedChipStyle
postComposerStyleStyle for the main post composer.LMFeedEditTextStyle
postHeadingComposerStyleStyle for the heading composer in posts.LMFeedEditTextStyle
postHeadingLimitTextStyleStyle for the heading character limit display.LMFeedTextStyle
addMoreButtonStyleStyle for the "Add More" button.LMFeedButtonStyle
backgroundColorBackground color for the create post fragment.Int

GitHub Link to LMFeedCreatePostFragmentViewStyle


Customization available in LMFeedCreatePostFragment

Header Customizations

  • customizeCreatePostHeaderView(headerViewCreatePost: LMFeedHeaderView): Allows customization of the header view in the create post fragment.

Author and Topics Customizations

  • customizeAuthorView(authorView: LMFeedPostHeaderView): Customizes the author view in the post composer.
  • customizeTopicsGroup(topicsGroup: LMFeedChipGroup): Customizes the topics group in the post composer.

Post Content Customizations

  • customizePostComposer(etPostComposer: LMFeedEditText): Customizes the main post composer for text content.
  • customizePostHeadingComposer(etPostHeadingComposer: LMFeedEditText): Customizes the heading composer.
  • customizePostHeadingLimit(tvPostHeadingLimitTextView: LMFeedTextView): Customizes the display of character limits for post headings.

Attachments Customizations

  • customizePostImageAttachment(imageMediaView: LMFeedPostImageMediaView): Customizes the image attachment section.
  • customizePostVideoAttachment(videoMediaView: LMFeedPostVideoMediaView): Customizes the video attachment section.
  • customizePostLinkViewAttachment(linkMediaView: LMFeedPostLinkMediaView): Customizes the link view attachment section.
  • customizePostDocumentsAttachment(documentsMediaView: LMFeedPostDocumentsMediaView): Customizes the document attachment section.
  • customizePostPollAttachment(pollView: LMFeedPostPollView): Customizes the poll attachment section.
  • customizePostMultipleMedia(multipleMediaView: LMFeedPostMultipleMediaView): Customizes the display of multiple media attachments.
  • customizeAddMoreButton(btnAddMoreMedia: LMFeedButton): Customizes the "Add More" button for additional attachments.

Interactions available in LMFeedCreatePostFragment

Media Attachments Interactions

  • onAttachImageClicked(): Handles clicks for attaching images.
  • onAttachVideoClicked(): Handles clicks for attaching videos.
  • onAttachDocumentClicked(): Handles clicks for attaching documents.

Poll Attachments Interactions

  • onAddPollClicked(): Handles adding a new poll to the post.
  • onPollAttachmentEditClicked(): Handles editing the poll attachment.

Media and Document Interactions

  • onPostDocumentMediaClicked(position: Int, parentPosition: Int, attachmentViewData: LMFeedAttachmentViewData): Handles clicks on document or media attachments in the post.
  • onMediaRemovedClicked(position: Int, mediaType: String): Handles removal of media attachments.

Usage Example

In this example, we're customizing the following elements of the create post screen:

  • Header View Appearance: Change the title.
  • Click Listeners: Override behavior for attach image click.

Steps to customize

Step 1: Create CustomCreatePostFragment

Start by extending LMFeedCreatePostFragment and create a custom class, say CustomCreatePostFragment.

class CustomCreatePostFragment : LMFeedCreatePostFragment() {
// We will override methods in the next step
}

Step 2: Override and Customize Methods

You can customize various aspects of the create post screen by overriding specific functions.

note

If you're providing your own custom layout or binding, you must override all lifecycle functions, especially:

  • onCreateView
  • onViewCreated
  • onResume
  • onPause
  • onDestroyView
class CustomCreatePostFragment : LMFeedCreatePostFragment() {

override fun customizeCreatePostHeaderView(headerViewCreatePost: LMFeedHeaderView) {
super.customizeCreatePostHeaderView(headerViewCreatePost)

headerViewCreatePost.setTitleText("Custom Title")
}

override fun onAttachImageClicked() {
super.onAttachImageClicked()

// Write your logic
}
}

Step 3: Pass CustomCreatePostFragment for Navigation

You now need to ensure that your fragment is returned wherever the create post screen is launched.

val application = this
val theme = LMFeedTheme.SOCIAL_FEED
val enablePushNotifications = false
val deviceId = null
val domain = "ENTER YOUR DOMAIN HERE"
val lmFeedCoreCallback = null

LMFeedCore.setup(
application = application,
theme,
enablePushNotifications = enablePushNotifications,
deviceId = deviceId,
domain = domain,
lmFeedCoreCallback = lmFeedCoreCallback
)

// Set your custom create post fragment here
LMFeedCore.setCreatePostFragment(CustomCreatePostFragment())