@@ -19,6 +19,7 @@ typealias TextMessageCollectionCell = ContainerCollectionViewCell<MessageContain
1919typealias URLCollectionCell = ContainerCollectionViewCell < MessageContainerView < EditingAccessoryView , MainContainerView < AvatarView , URLView , StatusView > > >
2020typealias ImageCollectionCell = ContainerCollectionViewCell < MessageContainerView < EditingAccessoryView , MainContainerView < AvatarView , ImageView , StatusView > > >
2121typealias TitleCollectionCell = ContainerCollectionViewCell < UILabel >
22+ typealias DateSeparatorCollectionCell = ContainerCollectionViewCell < DateSeparatorView >
2223typealias UserTitleCollectionCell = ContainerCollectionViewCell < SwappingContainerView < EdgeAligningView < UILabel > , UIImageView > >
2324typealias TypingIndicatorCollectionCell = ContainerCollectionViewCell < MessageContainerView < EditingAccessoryView , MainContainerView < AvatarPlaceholderView , TextMessageView , VoidViewFactory > > >
2425
@@ -56,6 +57,7 @@ final class DefaultChatCollectionDataSource: NSObject, ChatCollectionDataSource
5657 collectionView. register ( ImageCollectionCell . self, forCellWithReuseIdentifier: ImageCollectionCell . reuseIdentifier)
5758 collectionView. register ( TitleCollectionCell . self, forCellWithReuseIdentifier: TitleCollectionCell . reuseIdentifier)
5859 collectionView. register ( UserTitleCollectionCell . self, forCellWithReuseIdentifier: UserTitleCollectionCell . reuseIdentifier)
60+ collectionView. register ( DateSeparatorCollectionCell . self, forCellWithReuseIdentifier: DateSeparatorCollectionCell . reuseIdentifier)
5961 collectionView. register ( TypingIndicatorCollectionCell . self, forCellWithReuseIdentifier: TypingIndicatorCollectionCell . reuseIdentifier)
6062 collectionView. register ( TextTitleView . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: TextTitleView . reuseIdentifier)
6163 collectionView. register ( TextTitleView . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionFooter, withReuseIdentifier: TextTitleView . reuseIdentifier)
@@ -173,13 +175,10 @@ final class DefaultChatCollectionDataSource: NSObject, ChatCollectionDataSource
173175 return cell
174176 }
175177
176- private func createDateTitle( collectionView: UICollectionView , indexPath: IndexPath , alignment: ChatItemAlignment , title: String ) -> TitleCollectionCell {
177- let cell = collectionView. dequeueReusableCell ( withReuseIdentifier: TitleCollectionCell . reuseIdentifier, for: indexPath) as! TitleCollectionCell
178- cell. customView. preferredMaxLayoutWidth = ( collectionView. collectionViewLayout as? CollectionViewChatLayout ) ? . layoutFrame. width ?? collectionView. frame. width
179- cell. customView. text = title
180- cell. customView. textColor = . gray
181- cell. customView. numberOfLines = 0
182- cell. customView. font = . preferredFont( forTextStyle: . caption2)
178+ private func createDateTitle( collectionView: UICollectionView , indexPath: IndexPath , alignment: ChatItemAlignment , title: String ) -> DateSeparatorCollectionCell {
179+ let cell = collectionView. dequeueReusableCell ( withReuseIdentifier: DateSeparatorCollectionCell . reuseIdentifier, for: indexPath) as! DateSeparatorCollectionCell
180+ cell. customView. labelView. preferredMaxLayoutWidth = ( collectionView. collectionViewLayout as? CollectionViewChatLayout ) ? . layoutFrame. width ?? collectionView. frame. width
181+ cell. customView. labelView. text = title
183182 cell. contentView. layoutMargins = UIEdgeInsets ( top: 2 , left: 0 , bottom: 2 , right: 0 )
184183 return cell
185184 }
@@ -318,6 +317,15 @@ extension DefaultChatCollectionDataSource: ChatLayoutDelegate {
318317 true
319318 }
320319
320+ func pinningTypeForItem( _ chatLayout: CollectionViewChatLayout ,
321+ at indexPath: IndexPath ) -> ChatItemPinningType ? {
322+ let cell = sections [ indexPath. section] . cells [ indexPath. item]
323+ guard case . date = cell else {
324+ return nil
325+ }
326+ return . top
327+ }
328+
321329 public func sizeForItem( _ chatLayout: CollectionViewChatLayout , of kind: ItemKind , at indexPath: IndexPath ) -> ItemSize {
322330 switch kind {
323331 case . cell:
0 commit comments