Screen: LMFeedCreatePollFragment
LMFeedCreatePollFragment
allows users to create polls within the LikeMinds feed system. It provides an interface for adding poll questions, options, and configuring advanced settings like expiration time and anonymous voting.
GitHub Link to LMFeedCreatePollFragment
View Style: LMFeedCreatePollFragmentViewStyle
LMFeedCreatePollFragmentViewStyle
defines the visual style and structure of the LMFeedCreatePollFragment. The following fields are available for customization:
Field Name | Description | Type |
---|---|---|
headerViewStyle | Style for the header of the create poll screen. | LMFeedHeaderViewStyle |
authorViewStyle | Defines the style for the author view. | LMFeedPostHeaderViewStyle |
pollQuestionTitleViewStyle | Style for the poll question title. | LMFeedTextStyle |
pollQuestionViewStyle | Style for the poll question input field. | LMFeedEditTextStyle |
pollOptionsTitleViewStyle | Style for the poll options title. | LMFeedTextStyle |
pollAddOptionViewStyle | Style for the "add poll option" button. | LMFeedTextStyle |
pollExpiryTimeTitleViewStyle | Style for the poll expiry time title. | LMFeedTextStyle |
pollExpiryTimeViewStyle | Style for the poll expiry time selector. | LMFeedTextStyle |
pollAdvanceOptionViewStyle | Style for advanced options section. | LMFeedTextStyle |
pollAdvanceOptionSwitchViewStyle | Style for the advanced option toggle switches. | LMFeedSwitchStyle |
pollOptionsViewStyle | Style for the list of poll options. | LMFeedCreatePollOptionViewStyle |
pollDropdownViewStyle | Style for dropdown menus in the poll creation screen. | LMFeedTextStyle |
GitHub Link to LMFeedCreatePollFragmentViewStyle
Customization available in LMFeedCreatePollFragment
Header Customizations
- customizeCreatePollHeader(headerView: LMFeedHeaderView): Allows customization of the poll creation header.
Author View Customizations
- customizeAuthorView(authorView: LMFeedPostHeaderView): Customizes the appearance of the author view.
Poll Content Customizations
- customizePollQuestion(tvPollQuestionTitle: LMFeedTextView, etPollQuestion: LMFeedEditText): Customizes the input field for the poll question.
- customizePollOptions(tvPollOptionsTitle: LMFeedTextView, tvAddOption: LMFeedTextView): Customizes the poll options layout.
- customizePollExpiryTime(tvPollExpiryTitle: LMFeedTextView, tvPollExpiryTime: LMFeedTextView): Customizes the poll expiry time selector.
Advanced Options Customizations
- customizeAdvancedOptionTitle(tvAdvancedOptions: LMFeedTextView): Customizes the title for advanced options.
- customizeAdvanceOptionSwitchOptions(switchAnonymousPoll: LMFeedSwitch, switchLiveResults: LMFeedSwitch, switchAddNewOptions: LMFeedSwitch): Customizes the toggle switches for advanced options.
Interactions available in LMFeedCreatePollFragment
Navigation Interactions
onNavigationIconClicked()
: Handles clicks on the navigation icon.
Poll Option Interactions
onAddPollOptionClicked()
: Handles adding a new poll option.
Poll Settings Interactions
onPollExpiryTimeClicked()
: Handles the selection of poll expiry time.onAdvancedSettingsClicked()
: Handles clicks on the advanced settings button.
Submission Interactions
onPollSubmitClicked()
: Handles the submission of the created poll.
Usage Example
In this example, we're customizing the following elememts of the create poll fragment:
- Header View Appearance: Change the title
- Click Listeners: Override behavior for poll expiry time clicked
Steps to customize
Step 1: Create CustomCreatePollFragment
Start by extending LMFeedCreatePollFragment
and create a custom class, say CustomCreatePollFragment
.
class CustomCreatePollFragment : LMFeedCreatePollFragment() {
// We will override methods in the next step
}
Step 2: Override and Customize Methods
You can customize various aspects of the edit post screen by overriding specific functions.
If you're providing your own custom layout or binding, you must override all lifecycle functions, especially:
onCreateView
onViewCreated
onResume
onPause
onDestroyView
class CustomCreatePollFragment : LMFeedCreatePollFragment() {
override fun customizeCreatePollHeader(headerView: LMFeedHeaderView) {
super.customizeCreatePollHeader(headerView)
headerView.setTitleText("Custom Title")
}
override fun onPollExpiryTimeClicked() {
super.onPollExpiryTimeClicked()
// Write your logic
}
}
Step 3: Pass CustomCreatePollFragment
for Navigation
You now need to ensure that your fragment is returned wherever the edit 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 edit post fragment here
LMFeedCore.setCreatePollFragment(CustomCreatePollFragment())