Skip to main content

Poll Display View

Overview

LMFeedDisplayPollView is a customizable view designed to display poll details and handle user interactions related to poll voting.

LMFeedCreatePollQuestionView

Protocol

LMFeedPostPollCellProtocol

A protocol that defines delegate methods for handling actions related to poll interactions.

  • didTapSubmitVote(for postID: String, pollID: String): This function is called when the user taps the submit button to cast their vote in the poll.

  • editVoteTapped(for postID: String, pollID: String): This function is called when the user taps the label or button to edit their previously cast vote.

  • didTapVoteCountButton(for postID: String, pollID: String, optionID: String?): This function is called when the user taps the button or label to view the vote count for a specific option in the poll.

  • didTapToVote(for postID: String, pollID: String, optionID: String): This function is called when the user selects a specific poll option to cast their vote.

  • didTapAddOption(for postID: String, pollID: String): This function is called when the user taps the button to add a new option to the poll.

UI Elements

  • bottomStack: A vertical stack view to hold the bottom UI elements
  • submitButton: A button for submitting the vote
  • bottomMetaStack: A horizontal stack view to hold metadata labels
  • answerTitleLabel: A label for displaying the answer title
  • editVoteLabel: A label for editing the vote
  • addOptionButton: A button for adding a new poll option

Data Varialbes

  • delegate: A delegate conforming to the LMFeedPostPollCellProtocol
  • postID: The post ID associated with the poll
  • pollID: The poll ID associated with the poll

Methods

  • configure(with data: ContentModel, delegate: LMFeedPostPollCellProtocol?): Configures the view with the provided content model and delegate.

Customisation

CustomDisplayPollView.swift
class CustomDisplayPollView: LMFeedDisplayPollView {
override func setupAppearance() {
super.setupAppearance()

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