Home

Awesome

ChatLayout

Release Version Documentation Codecov Codacy Badge Swift Package Manager Carthage compatible Swift 5.10 Platform iOS

<p align="center"> <img src="https://habrastorage.org/webt/ji/ba/dj/jibadjc0hul-fzfwxm2w0ywdutg.png" alt="ChatLayout logo"/> </p>

Table of contents

About

ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView.

Features

What ChatLayout doesn't provide (And why it is good)

ChatLayout is the custom UICollectionViewLayout, so:

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

ChatLayout is available through CocoaPods, Carthage and SwiftPM. See the Example app for the usage details.

If you are using cocoapods you can install the whole package using pod 'ChatLayout'. If you do not need the additional components provided, you can install only the layout itself using pod 'ChatLayout/Core'

Contributing

ChatLayout is in active development, and we welcome your contributions.

If you’d like to contribute to this repo, please read the contribution guidelines.

Todo

About UICollectionViewDiffableDataSource

ChatLayout can process any update commands that you send to your UICollectionView, so you can use UICollectionViewDiffableDataSource as well.

About Supplementary Views

It can be tempting and it may look like it is the right way to go, but do not use supplementary views to decorate your messages or groups of them. UICollectionView processes them in a different order: UICollectionViewCells first and only after switches to UICollectionReusableViews. You will most likely face some unexpected behaviour during the animation. I strongly advice you against using sections at all.

About Texture

ChatLayout can be used together with Texture to improve the auto-layout performance. But keep in mind that it's default wrapper is hardcoded to work exclusively with UICollectionViewFlowLayout. See issue. You will have to implement ChatLayoutDelegate yourself and propagate the node size manually.

About animation

If you see a strange or unexpected animation during the updates, check your data model and the commands you send to the UICollectionView's performBatchUpdates. Especialy if you are using some diffing algorithms like DifferenceKit. It is very possible that you are sending delete/insert commands when you expect to see reload. The easiest way to check it is by adding print("\(updateItems)") into ChatLayout.prepare(forCollectionViewUpdates:) method. ChatLayout doesn't know what you expected to see. It just processes your changes according to the commands it has received.

About sticky headers or footers

Sticky headers or footers are not supported by ChatLayout but your contributions are welcome.

License

ChatLayout is distributed under the MIT license.

ChatLayout is provided for your use, free-of-charge, on an as-is basis. We make no guarantees, promises or apologies. Caveat developer.

Articles

English:

Russian:

Sponsor this project

If you find this library useful, and especially if you are using it in production, please consider sponsoring this project here. I work on ChatLayout in my spare time, and your sponsorship would help me to continue developing and contributing to the Open Source community. Your support will enable me to dedicate more time and resources to this project, ensuring that it remains up-to-date and relevant for years to come.

Thank you for your consideration!

Author

Evgeny Kazaev, eugene.kazaev@gmail.com. Twitter ekazaev

I am happy to answer any questions you may have. Just create a new issue.