ChatLayoutDelegate

@MainActor
public protocol ChatLayoutDelegate : AnyObject

CollectionViewChatLayout delegate

  • shouldPresentHeader(_:at:) Default implementation

    CollectionViewChatLayout will call this method to ask if it should present the header in the current layout.

    Default Implementation

    Default implementation returns: false.

    Declaration

    Swift

    @available(*, deprecated, message: "Support for supplementary views is deprecated and will be discontinued in future versions.")
    @MainActor
    func shouldPresentHeader(
        _ chatLayout: CollectionViewChatLayout,
        at sectionIndex: Int
    ) -> Bool

    Parameters

    chatLayout
    sectionIndex

    Index of the section.

    Return Value

    Bool.

  • shouldPresentFooter(_:at:) Default implementation

    CollectionViewChatLayout will call this method to ask if it should present the footer in the current layout.

    Default Implementation

    Default implementation returns: false.

    Declaration

    Swift

    @available(*, deprecated, message: "Support for supplementary views is deprecated and will be discontinued in future versions.")
    @MainActor
    func shouldPresentFooter(
        _ chatLayout: CollectionViewChatLayout,
        at sectionIndex: Int
    ) -> Bool

    Parameters

    chatLayout
    sectionIndex

    Index of the section.

    Return Value

    Bool.

  • shouldPinHeaderToVisibleBounds(_:at:) Default implementation

    CollectionViewChatLayout will call this method to ask if it should pin (stick) the header to the visible bounds in the current layout.

    NB: This method will be called only if the ChatLayoutSettings.pinnableItems is set to .supplementaryViews

    Default Implementation

    Default implementation returns: false.

    Declaration

    Swift

    @available(*, deprecated, message: "Support for supplementary views is deprecated and will be discontinued in future versions.")
    @MainActor
    func shouldPinHeaderToVisibleBounds(
        _ chatLayout: CollectionViewChatLayout,
        at sectionIndex: Int
    ) -> Bool

    Parameters

    chatLayout
    sectionIndex

    Index of the section.

    Return Value

    Bool.

  • shouldPinFooterToVisibleBounds(_:at:) Default implementation

    CollectionViewChatLayout will call this method to ask if it should pin (stick) the footer to the visible bounds in the current layout.

    NB: This method will be called only if the ChatLayoutSettings.pinnableItems is set to .supplementaryViews

    Default Implementation

    Default implementation returns: false.

    Declaration

    Swift

    @available(*, deprecated, message: "Support for supplementary views is deprecated and will be discontinued in future versions.")
    @MainActor
    func shouldPinFooterToVisibleBounds(
        _ chatLayout: CollectionViewChatLayout,
        at sectionIndex: Int
    ) -> Bool

    Parameters

    chatLayout
    sectionIndex

    Index of the section.

    Return Value

    Bool.

  • pinningTypeForItem(_:at:) Default implementation

    CollectionViewChatLayout will call this method to ask if it should pin (stick) the cell to the visible bounds in the current layout.

    NB: This method will be called only if the ChatLayoutSettings.pinnableItems is set to .cells

    Default Implementation

    Default implementation returns: nil.

    Declaration

    Swift

    @MainActor
    func pinningTypeForItem(
        _ chatLayout: CollectionViewChatLayout,
        at indexPath: IndexPath
    ) -> ChatItemPinningType?

    Parameters

    chatLayout
    indexPath

    Index path of the cell.

    Return Value

    ChatItemPinningType to configure pinning behaviour or nil if pinning is not required.

  • sizeForItem(_:of:at:) Default implementation

    CollectionViewChatLayout will call this method to ask what size the item should have.

    NB:

    If you are trying to speed up the layout process by returning exact item sizes in this method - do not forget to change UICollectionReusableView.preferredLayoutAttributesFitting(...) method and do not call super.preferredLayoutAttributesFitting(...) there as it will measure the UIView using Autolayout Engine anyway.

    Default Implementation

    Default implementation returns: ItemSize.auto.

    Declaration

    Swift

    @MainActor
    func sizeForItem(
        _ chatLayout: CollectionViewChatLayout,
        of kind: ItemKind,
        at indexPath: IndexPath
    ) -> ItemSize

    Parameters

    chatLayout
    kind

    Type of element represented by ItemKind.

    indexPath

    Index path of the item.

    Return Value

    ItemSize.

  • alignmentForItem(_:of:at:) Default implementation

    CollectionViewChatLayout will call this method to ask what type of alignment the item should have.

    Default Implementation

    Default implementation returns: ChatItemAlignment.fullWidth.

    Declaration

    Swift

    @MainActor
    func alignmentForItem(
        _ chatLayout: CollectionViewChatLayout,
        of kind: ItemKind,
        at indexPath: IndexPath
    ) -> ChatItemAlignment

    Parameters

    chatLayout
    kind

    Type of element represented by ItemKind.

    indexPath

    Index path of the item.

    Return Value

    ChatItemAlignment.

  • Asks the delegate to modify a layout attributes instance so that it represents the initial visual state of an item being inserted.

    The originalAttributes instance is a reference type, and therefore can be modified directly.

    Default Implementation

    Default implementation sets a ChatLayoutAttributes.alpha to zero.

    Declaration

    Swift

    @MainActor
    func initialLayoutAttributesForInsertedItem(
        _ chatLayout: CollectionViewChatLayout,
        of kind: ItemKind,
        at indexPath: IndexPath,
        modifying originalAttributes: ChatLayoutAttributes,
        on state: InitialAttributesRequestType
    )
  • Asks the delegate to modify a layout attributes instance so that it represents the final visual state of an item being removed via UICollectionView.deleteSections(_:).

    The originalAttributes instance is a reference type, and therefore can be modified directly.

    Default Implementation

    Default implementation sets a ChatLayoutAttributes.alpha to zero.

    Declaration

    Swift

    @MainActor
    func finalLayoutAttributesForDeletedItem(
        _ chatLayout: CollectionViewChatLayout,
        of kind: ItemKind,
        at indexPath: IndexPath,
        modifying originalAttributes: ChatLayoutAttributes
    )
  • interItemSpacing(_:of:after:) Default implementation

    Returns the interval between items. If returns nil - the value from ChatLayoutSettings will be used.

    Default Implementation

    Default implementation returns: nil.

    Declaration

    Swift

    @MainActor
    func interItemSpacing(
        _ chatLayout: CollectionViewChatLayout,
        of kind: ItemKind,
        after indexPath: IndexPath
    ) -> CGFloat?
  • interSectionSpacing(_:after:) Default implementation

    Returns the interval between sections. If returns nil - the value from ChatLayoutSettings will be used.

    Default Implementation

    Default implementation returns: nil.

    Declaration

    Swift

    @MainActor
    func interSectionSpacing(
        _ chatLayout: CollectionViewChatLayout,
        after sectionIndex: Int
    ) -> CGFloat?