| 1 |
//
|
|
| 2 |
// ChatLayout
|
|
| 3 |
// ChatLayoutPositionSnapshot.swift
|
|
| 4 |
// https://github.com/ekazaev/ChatLayout
|
|
| 5 |
//
|
|
| 6 |
// Created by Eugene Kazaev in 2020-2023.
|
|
| 7 |
// Distributed under the MIT license.
|
|
| 8 |
//
|
|
| 9 |
// Become a sponsor:
|
|
| 10 |
// https://github.com/sponsors/ekazaev
|
|
| 11 |
//
|
|
| 12 |
|
|
| 13 |
import Foundation
|
|
| 14 |
import UIKit
|
|
| 15 |
|
|
| 16 |
/// Represents content offset position expressed by the specific item and it offset from the top or bottom edge.
|
|
| 17 |
public struct ChatLayoutPositionSnapshot: Hashable {
|
|
| 18 |
|
|
| 19 |
/// Represents the edge.
|
|
| 20 |
public enum Edge: Hashable {
|
|
| 21 |
|
|
| 22 |
/// Top edge of the `UICollectionView`
|
|
| 23 |
case top
|
|
| 24 |
|
|
| 25 |
/// Bottom edge of the `UICollectionView`
|
|
| 26 |
case bottom
|
|
| 27 |
|
|
| 28 |
}
|
|
| 29 |
|
|
| 30 |
/// Item's `IndexPath`
|
|
| 31 |
public var indexPath: IndexPath
|
|
| 32 |
|
|
| 33 |
/// Kind of item at the `indexPath`
|
|
| 34 |
public var kind: ItemKind
|
|
| 35 |
|
|
| 36 |
/// The edge of the offset.
|
|
| 37 |
public var edge: Edge
|
|
| 38 |
|
|
| 39 |
/// The offset from the `edge`.
|
|
| 40 |
public var offset: CGFloat
|
|
| 41 |
|
|
| 42 |
/// Constructor
|
|
| 43 |
/// - Parameters:
|
|
| 44 |
/// - indexPath: Item's `IndexPath`
|
|
| 45 |
/// - edge: The edge of the offset.
|
|
| 46 |
/// - offset: The offset from the `edge`.
|
|
| 47 |
/// - kind: Kind of item at the `indexPath`
|
|
| 48 |
public init(indexPath: IndexPath,
|
|
| 49 |
kind: ItemKind,
|
|
| 50 |
edge: Edge,
|
|
| 51 |
offset: CGFloat = 0) {
|
! |
| 52 |
self.indexPath = indexPath
|
! |
| 53 |
self.edge = edge
|
! |
| 54 |
self.offset = offset
|
! |
| 55 |
self.kind = kind
|
! |
| 56 |
}
|
! |
| 57 |
|
|
| 58 |
}
|
|