Overview of ChatLayout features and architecture
masterChatLayout is a custom UICollectionViewLayout designed as an alternative to MessageKit. Unlike many chat libraries, it does not require you to use a specific UIViewController or a modified UICollectionView. You instantiate your own standard UIKit components and simply apply the ChatLayout to your UICollectionView.
Key Features
- Dynamic Cell Sizes: Supports cells with varying heights using Auto Layout.
- Smooth Animations: Handles animated insertion, deletion, reloading, and moving of items.
- Content Anchoring: Keeps the content of the last visible item at the top or bottom during updates.
- Precise Scrolling: Provides tools for accurate scrolling to specific items.
- Sticky Cells: Supports pinned cells that behave like headers or footers.
- Agent Mode: Built-in support for agent-style chat interfaces.
Architectural Principles
- No View Controller Hacks: It does not rotate your
UICollectionViewupside-down or rely onUICollectionViewFlowLayoutmodifications. This allows you to use standardUIKitfeatures likeadjustedContextInsetsnormally. - Data Agnostic: It does not enforce a specific data model. You can use any diffing algorithm (like
DifferenceKit) orUICollectionViewDiffableDataSourceto manage your data. - Layout-Centric: It is strictly a
UICollectionViewLayout. It does not handle keyboard appearance or input controls; you are responsible for updating thecontentInsetsof yourUICollectionViewwhen the keyboard appears.