Skip to main content

Poll Result Cell

Overview

The LMChatPollResultCollectionCell is a custom collection view cell designed to display individual poll result options within a chat.

UI Components

  • stackView: A vertical LMStackView containing the vote count and title labels.
  • voteCountLabel: An LMLabel displaying the number of votes for the option.
  • voteTitleLabel: An LMLabel showing the title of the poll option.
  • sepratorView: An LMView used as a visual indicator for the selected option.

Properties

  • selectedPollColor: The color used for selected poll options (default: app tint color).
  • notSelectedPollColor: The color used for non-selected poll options (default: gray).

Methods

  • configure(with data: ContentModel): Configures the cell with the provided poll option data.

Customization

The LMChatPollResultCollectionCell can be customized by subclassing and overriding its methods:

CustomPollResultCell.swift
class CustomPollResultCell: LMChatPollResultCollectionCell {
override func configure(with data: ContentModel) {
super.configure(with: data)
// 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.resultPollOptionCell = CustomPollResultCell.self
// ...
return true
}