Skip to main content

Create Poll

Overview

The LMFeedCreatePollScreen allows users to create poll by adding question, options. It provides various UI components and functionalities to facilitate the poll creation process.

LMFeedLikeListScreen

Protocols

LMFeedCreatePollProtocol

This protocol defines methods for poll related events:

  • updatePollDetails(with data: LMFeedCreatePollDataModel): Called when the user has created a poll and taps the "Done" button.
  • cancelledPollCreation: Called when the user taps on "Cancel" button.

Protocols Implemented

UI Components

  • containerView: The main container view.
  • containerScrollView: A scroll view that contains a vertical stack view for laying out the UI components
  • containerStackView: Vertical stack view holding all UI components
  • pollQuestionHeaderView: Instance of LMFeedCreatePollHeader for entering the poll question
  • pollOptionView: Instance of LMFeedCreatePollQuestionView for entering poll options
  • pollExpiryDateView: Instance of LMFeedCreatePollDateView for setting the poll expiry date
  • pollMetaOptionsView: Instance of LMFeedCreatePollMetaView for additional poll options (hidden by default)

Data Variables

  • pollDelegate: LMFeedCreatePollProtocol? - Delegate for poll creation events.

Action Handlers

  • onTapAdvancedOption() - Toggles the visibility of advanced options.
  • openDatePicker() - Opens the date picker for poll expiry.
  • didTapDoneButton() - Validates and submits the created poll.

Customization

CustomCreatePollScreen.swift
class CustomCreatePollScreen: LMFeedCreatePollScreen {
override func setupAppearance() {
super.setupAppearance()
view.backgroundColor = .lightGray
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Components.shared.createPollScreen = CustomCreatePollScreen.self
// ...
return true
}