Skip to main content

Chat Screen

Overview

The LMChatFeedViewController is responsible for managing a feed of chat conversations, including both group chats and direct messages (DMs). It implements a segmented control to switch between these two types of conversations and uses a page view controller to manage the content.

Functionality

UI Components

  • containerStackView: A vertical LMStackView that holds the main UI components.
  • segmentControl: A UISegmentedControl for switching between Group and DM views.
  • pageContainerView: An LMView that contains the page view controller.
  • pageController: A UIPageViewController for managing the different feed pages.

Properties

  • viewControllers: An array of UIViewController instances representing the different pages.
  • currentPageIndex: An integer tracking the currently displayed page index.

Methods

  • setupSegmentControl(): Configures the appearance and behavior of the segment control.
  • setupPageController(): Configures the page view controller and adds it to the view hierarchy.
  • addControllers(): Adds the necessary view controllers to the viewControllers array.
  • segmentChanged(_:): Handles changes in the segment control selection.

Customization

CustomChatFeedViewController.swift
class CustomChatFeedViewController: LMChatFeedViewController {
override func setupAppearance() {
super.setupAppearance()
containerStackView.backgroundColor = .lightGray
}

override func setupSegmentControl() {
super.setupSegmentControl()
segmentControl.backgroundColor = .blue
segmentControl.selectedSegmentTintColor = .white
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.chatFeedScreen = CustomChatFeedViewController.self
// ...
return true
}