Create Poll Options
Overview
LMFeedCreatePollOptionsView is a customizable view designed for creating poll options. It allows users to add, view, and manage poll options.
File Location:
LMFeedCreatePollOptionsView.swift
Protocol
LMFeedCreatePollOptionsViewProtocol
This protocol defines methods for poll options related events:
onCrossButtonTapped(for id: Int): Called when the user taps onXbutton for an optiontextValueChanged(for id: Int, newValue: String?): Called when the user changes text of optiononAddNewOptionTapped(): User taps to add new option
UI Elements
containerView: A container view that holds all the subviewsanswerLabel: A label indicating the answer options sectionoptionStack: A table view for displaying the poll optionsaddOptionView: A view for adding new poll optionsaddOptionImage: An image view displaying an icon for adding optionsaddOptionText: A label prompting the user to add an option
Data Variables
delegate: A delegate conforming to the LMFeedCreatePollOptionsViewProtocoldata: An array of LMFeedCreatePollOptionWidget.ContentModel representing the poll options
Methods
configure(with data: [LMFeedCreatePollOptionWidget.ContentModel], delegate: LMFeedCreatePollOptionsViewProtocol?): Configures the view with provided data and delegateupdateOptions(with data: [LMFeedCreatePollOptionWidget.ContentModel]): Updates the optionStack with new data
Customisation
CustomCreatePollQuestionView.swift
class CustomCreatePollQuestionView: LMFeedCreatePollOptionsView {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .green
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.createPollQuestionView = CustomCreatePollQuestionView.self
// ...
return true
}