Skip to main content

Poll Display Widget

Overview

LMFeedDisplayPollOptionWidget represents a widget for displaying individual poll options and their associated information.

LMFeedDisplayPollOptionWidget

UI Elements:

  • outerStackView: A stack view that holds the entire content of the widget
  • progressView: A progress view that shows the vote percentage
  • voteCountContainer: A view that contains the vote count button
  • voteCount: A button that displays the vote count
  • innerContainerView: A view that holds the poll option text and added by label
  • checkmarkIcon: An image view that displays a checkmark if the option is selected

Data Variables:

  • selectedPollColor: The color used for selected poll options
  • notSelectedPollColor: The color used for non-selected poll options
  • delegate: The delegate that conforms to LMFeedDisplayPollOptionWidgetProtocol
  • optionID: The identifier of the poll option

Methods:

  • configure(with data: ContentModel, delegate: LMFeedDisplayPollOptionWidgetProtocol?): configures the widget with data from a ContentModel instance and sets the delegate.

Customisation:

CustomDisplayPollWidget.swift
class CustomDisplayPollWidget: LMFeedDisplayPollOptionWidget {
override func setupAppearance() {
super.setupAppearance()

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