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 tappedfunc didTapToVote(optionID: String)
: Triggered when poll option is tapped on
UI Components
outerStackView
: A verticalLMStackView
containing the main components.progressView
: AUIProgressView
showing the percentage of votes for the option.voteCountContainer
: AnLMView
containing the vote count button.voteCount
: AnLMButton
displaying the number of votes.innerContainerView
: AnLMView
holding the main content of the poll option.checkmarkIcon
: AnLMImageView
indicating if the option is selected.checkMarkIconStackView
: AnLMStackView
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 theLMChatDisplayPollWidgetProtocol
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
}