Poll Content View
Overview
The LMChatPollContentView
is a subclass of LMChatMessageContentView specifically designed to display poll content within a chat message. It integrates the LMChatPollView to render poll information and manages the visibility of various UI elements based on the message state.
UI Components
pollDisplayView
: An instance ofLMChatPollView
that displays the poll content.cancelRetryContainerStackView
: A stack view containing cancel and retry buttons (inherited from superclass).loaderView
: A view to display loading state (inherited from superclass).retryView
: A view to display retry option for failed messages (inherited from superclass).
Methods
setDataView(_:index:)
: Updates the view with the provided message data and manages visibility of UI elements.pollDisplayPreview(_:)
: Configures and displays the poll content if available.updateRetryButton(_:)
: Updates the visibility of loader and retry views based on message status.prepareToResuse()
: Prepares the view for reuse in a table or collection view.
Customization
CustomChatPollContentView.swift
class CustomChatPollContentView: LMChatPollContentView {
override func setupViews() {
super.setupViews()
// Add custom views here
}
override func setupLayouts() {
super.setupLayouts()
// Modify layout constraints here
}
override func setDataView(_ data: LMChatMessageCell.ContentModel, index: IndexPath) {
super.setDataView(data, index: index)
// Customize data presentation here
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.pollContentView = CustomChatPollContentView.self
// ...
return true
}