Skip to main content

Create Poll Screen

Overview

The LMChatCreatePollViewController is a view controller that manages the creation of polls. It provides a user interface for inputting poll questions, options, expiry dates, and other poll-related settings.

Functionality

Protocols

LMChatCreatePollViewDelegate

  • updatePollDetails(with data: LMChatCreatePollDataModel): Called when poll creation is complete, passing the final poll data to the delegate.
  • cancelledPollCreation(): Invoked when the user cancels the poll creation process.

Protocols Implemented

This view controller implements the following protocols:

  • LMChatCreatePollQuestionViewProtocol
  • LMChatCreatePollMetaViewProtocol
  • LMChatGeneralPickerProtocol
  • LMChatTimePickerProtocol

UI Components

  • containerView: An LMView that serves as the main container.
  • containerScrollView: A UIScrollView for scrollable content.
  • containerStackView: An LMStackView that holds the main UI elements.
  • pollQuestionHeaderView: An LMChatCreatePollHeader for the poll question.
  • pollOptionView: An LMChatCreatePollQuestionView for poll options.
  • pollExpiryDateView: An LMChatCreatePollDateView for setting the poll expiry date.
  • pollMetaOptionsView: An LMChatCreatePollMetaView for additional poll settings.
  • advancedOptionButton: An LMButton for toggling advanced options.

Methods

  • onTapAdvancedOption(): Handles taps on the advanced options button.
  • openDatePicker(): Opens the date picker for poll expiry.
  • didTapDoneButton(): Handles taps on the done button.
  • dismissPollWidget(): Dismisses the poll creation view.

Customization

To customize the LMChatCreatePollViewController, subclass it and override the necessary methods:

CustomCreatePollViewController
class CustomCreatePollViewController: LMChatCreatePollViewController {
override func setupAppearance() {
super.setupAppearance()
// Add custom appearance setup here
}

override func didTapDoneButton() {
super.didTapDoneButton()
// Add custom handling here
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.createPollScreen = CustomCreatePollViewController.self
// ...
return true
}