mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
bff35fda61
* build: Swiftlint plugin * build: Swiftformat plugin * build: Swiftformat plugin * build: Swiftformat bash command * style: Swiftformat rules * style: Swiftformat applied to codebase * style: Ignore Tests for Swiftlint * Update bundler * Update changelog and migration guide * style: Ignore Example for Swiftlint * chore: Changelog * Update Xcode version for ci_pr_tests.yml * Update ci_pr_framework.yml * Update ci_pr_example.yml * chore: Changelog Co-authored-by: Jakub Kaspar <kaspikk@gmail.com>
63 lines
1.5 KiB
Swift
63 lines
1.5 KiB
Swift
//
|
|
// CustomLayoutExampleViewController.swift
|
|
// ChatExample
|
|
//
|
|
// Created by Vignesh J on 30/04/21.
|
|
// Copyright © 2021 MessageKit. All rights reserved.
|
|
//
|
|
|
|
import Kingfisher
|
|
import MapKit
|
|
import MessageKit
|
|
import UIKit
|
|
|
|
class CustomLayoutExampleViewController: BasicExampleViewController {
|
|
// MARK: Internal
|
|
|
|
override func configureMessageCollectionView() {
|
|
super.configureMessageCollectionView()
|
|
messagesCollectionView.register(CustomTextMessageContentCell.self)
|
|
messagesCollectionView.messagesDataSource = self
|
|
messagesCollectionView.messagesLayoutDelegate = self
|
|
messagesCollectionView.messagesDisplayDelegate = self
|
|
}
|
|
|
|
// MARK: - MessagesLayoutDelegate
|
|
|
|
override func textCellSizeCalculator(
|
|
for _: MessageType,
|
|
at _: IndexPath,
|
|
in _: MessagesCollectionView)
|
|
-> CellSizeCalculator?
|
|
{
|
|
textMessageSizeCalculator
|
|
}
|
|
|
|
// MARK: - MessagesDataSource
|
|
|
|
override func textCell(
|
|
for message: MessageType,
|
|
at indexPath: IndexPath,
|
|
in messagesCollectionView: MessagesCollectionView)
|
|
-> UICollectionViewCell?
|
|
{
|
|
let cell = messagesCollectionView.dequeueReusableCell(
|
|
CustomTextMessageContentCell.self,
|
|
for: indexPath)
|
|
cell.configure(
|
|
with: message,
|
|
at: indexPath,
|
|
in: messagesCollectionView,
|
|
dataSource: self,
|
|
and: textMessageSizeCalculator)
|
|
|
|
return cell
|
|
}
|
|
|
|
// MARK: Private
|
|
|
|
private lazy var textMessageSizeCalculator = CustomTextLayoutSizeCalculator(
|
|
layout: self.messagesCollectionView
|
|
.messagesCollectionViewFlowLayout)
|
|
}
|