Skip to main content

Poll Option View

Overview

The LMChatPollOptionView is a custom view component designed to display individual poll option.

Functionality

ProtocolsProtocols

LMChatDisplayPollWidgetProtocol

  • func didTapVoteCountButton(optionID: String): Triggered when poll option vote count is tapped
  • func didTapToVote(optionID: String): Triggered when poll option is tapped on

UI Components

  • outerStackView: A vertical LMStackView containing the main components.
  • progressView: A UIProgressView showing the percentage of votes for the option.
  • voteCountContainer: An LMView containing the vote count button.
  • voteCount: An LMButton displaying the number of votes.
  • innerContainerView: An LMView holding the main content of the poll option.
  • checkmarkIcon: An LMImageView indicating if the option is selected.
  • checkMarkIconStackView: An LMStackView containing the checkmark icon.

Properties

  • selectedPollColor: The color used for selected poll options.
  • notSelectedPollColor: The color used for non-selected poll options.
  • delegate: A weak reference to the LMChatDisplayPollWidgetProtocol delegate.
  • optionID: The ID of the current poll option.

Methods

  • didTapVoteCount(): Handles taps on the vote count button.
  • didTapVote(): Handles taps on the poll option itself.
  • configure(with data: ContentModel, delegate: LMChatDisplayPollWidgetProtocol?): Configures the view with the provided poll option data.

Customization

CustomPollOptionView.swift
class CustomPollOptionView: LMChatPollOptionView {
override func configure(with data: ContentModel, delegate: LMChatDisplayPollWidgetProtocol?) {
super.configure(with: data, delegate: delegate)
// Customize data configuration behavior
}

override var selectedPollColor: UIColor {
// Return a custom color for selected poll options
return .blue
}

override var notSelectedPollColor: UIColor {
// Return a custom color for non-selected poll options
return .lightGray
}
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.pollOptionView = CustomPollOptionView.self
// ...
return true
}