Skip to main content

Topic View

Overview

LMFeedTopicView is a subclass of LMView designed to display a collection of topics or categories within a view. This view is typically used in a feed or post creation/edit flow to showcase the selected topics and provide options to edit or add new topics.

LMFeedTopicViewCell

LMFeedTopicView encompasses the following collection cells:

Protocols

LMFeedTopicViewCellProtocol

This protocol defines three methods for handling user interactions with the topic view:

  • didTapCrossButton(for topicId: String): Called when the user taps the cross button to remove a topic.
  • didTapEditButton(): Called when the user taps the edit button to modify the topics.
  • didTapSelectTopicButton(): Called when the user taps the "Select Topics" button to add new topics.

UI Components

  • containerView: The main container view that holds all the subviews.
  • stackView: A vertical stack view that holds the collection view and separator view.
  • collectionView: A LMFeedTopicCollectionView that displays the topics and additional buttons (edit, select).
  • separatorView: A view that acts as a separator or divider at the bottom of the topic view.

Data Variables

  • topics: An array of LMFeedTopicCollectionCellDataModel representing the topics to be displayed.
  • isEditFlow: A boolean indicating whether the edit icon should be shown.
  • isSelectFlow: A boolean indicating whether the "Select Topics" button should be shown.
  • delegate: A weak reference to an instance conforming to LMFeedTopicViewCellProtocol for handling user interactions.

Methods

  • configure(): Configures the topic view with the provided data. It updates the topics, edit flow, select flow, and separator visibility based on the data.

Customisation

CustomTopicFeed.swift
class CustomTopicFeed: LMFeedTopicView {
override func setupAppearance() {
super.setupAppearance()
backgroundColor = .green
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.topicFeedView = CustomTopicFeed.self
// ...
return true
}