Skip to main content

Create Poll Options

Overview

LMFeedCreatePollOptionsView is a customizable view designed for creating poll options. It allows users to add, view, and manage poll options.

LMFeedCreatePollOptionsView

Protocol

LMFeedCreatePollOptionsViewProtocol

This protocol defines methods for poll options related events:

  • onCrossButtonTapped(for id: Int): Called when the user taps on X button for an option
  • textValueChanged(for id: Int, newValue: String?): Called when the user changes text of option
  • onAddNewOptionTapped(): User taps to add new option

UI Elements

  • containerView: A container view that holds all the subviews
  • answerLabel: A label indicating the answer options section
  • optionStack: A table view for displaying the poll options
  • addOptionView: A view for adding new poll options
  • addOptionImage: An image view displaying an icon for adding options
  • addOptionText: A label prompting the user to add an option

Data Variables

  • delegate: A delegate conforming to the LMFeedCreatePollOptionsViewProtocol
  • data: An array of LMFeedCreatePollOptionWidget.ContentModel representing the poll options

Methods

  • configure(with data: [LMFeedCreatePollOptionWidget.ContentModel], delegate: LMFeedCreatePollOptionsViewProtocol?): Configures the view with provided data and delegate

  • updateOptions(with data: [LMFeedCreatePollOptionWidget.ContentModel]): Updates the optionStack with new data

Customisation

CustomCreatePollQuestionView.swift
class CustomCreatePollQuestionView: LMFeedCreatePollOptionsView {
override func setupAppearance() {
super.setupAppearance()

containerView.backgroundColor = .green
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.createPollQuestionView = CustomCreatePollQuestionView.self
// ...
return true
}