Skip to content

Commit 6b4ec06

Browse files
committed
Updated documentation
1 parent 1e8cff1 commit 6b4ec06

File tree

13 files changed

+78
-37
lines changed

13 files changed

+78
-37
lines changed

ChatLayout/Classes/Core/CollectionViewChatLayout.swift

+15-8
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
import Foundation
1414
import UIKit
1515

16-
/// A collection view layout that can display items in a grid similar to `UITableView` but aligning them
17-
/// to the leading or trailing edge of the `UICollectionView`. Helps to maintain chat like behavior by keeping
18-
/// content offset from the bottom constant. Can deal with autosizing cells and supplementary views.
16+
/// A collection view layout designed to display items in a grid similar to `UITableView`, while aligning them to the
17+
/// leading or trailing edge of the `UICollectionView`. This layout facilitates chat-like behavior by maintaining
18+
/// a constant content offset from the bottom. Additionally, it is capable of handling autosizing cells and
19+
/// supplementary views.
20+
///
1921
/// ### Custom Properties:
2022
/// `CollectionViewChatLayout.delegate`
2123
///
@@ -433,7 +435,8 @@ public final class CollectionViewChatLayout: UICollectionViewLayout {
433435
}
434436

435437
/// Retrieves the layout attributes for the specified supplementary view.
436-
public override func layoutAttributesForSupplementaryView(ofKind elementKind: String, at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
438+
public override func layoutAttributesForSupplementaryView(ofKind elementKind: String,
439+
at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
437440
guard !dontReturnAttributes else {
438441
return nil
439442
}
@@ -479,7 +482,8 @@ public final class CollectionViewChatLayout: UICollectionViewLayout {
479482
// MARK: Context Invalidation
480483

481484
/// Asks the layout object if changes to a self-sizing cell require a layout update.
482-
public override func shouldInvalidateLayout(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> Bool {
485+
public override func shouldInvalidateLayout(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes,
486+
withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> Bool {
483487
let preferredAttributesItemPath = preferredAttributes.indexPath.itemPath
484488
guard let preferredMessageAttributes = preferredAttributes as? ChatLayoutAttributes,
485489
let item = controller.item(for: preferredAttributesItemPath, kind: preferredMessageAttributes.kind, at: state) else {
@@ -492,7 +496,8 @@ public final class CollectionViewChatLayout: UICollectionViewLayout {
492496
}
493497

494498
/// Retrieves a context object that identifies the portions of the layout that should change in response to dynamic cell changes.
495-
public override func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContext {
499+
public override func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes,
500+
withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContext {
496501
guard let preferredMessageAttributes = preferredAttributes as? ChatLayoutAttributes else {
497502
return super.invalidationContext(forPreferredLayoutAttributes: preferredAttributes, withOriginalAttributes: originalAttributes)
498503
}
@@ -789,7 +794,8 @@ public final class CollectionViewChatLayout: UICollectionViewLayout {
789794
// MARK: - Supplementary View Appearance Animation
790795

791796
/// Retrieves the starting layout information for a supplementary view being inserted into the collection view.
792-
public override func initialLayoutAttributesForAppearingSupplementaryElement(ofKind elementKind: String, at elementIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
797+
public override func initialLayoutAttributesForAppearingSupplementaryElement(ofKind elementKind: String,
798+
at elementIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
793799
var attributes: ChatLayoutAttributes?
794800

795801
let kind = ItemKind(elementKind)
@@ -828,7 +834,8 @@ public final class CollectionViewChatLayout: UICollectionViewLayout {
828834
}
829835

830836
/// Retrieves the final layout information for a supplementary view that is about to be removed from the collection view.
831-
public override func finalLayoutAttributesForDisappearingSupplementaryElement(ofKind elementKind: String, at elementIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
837+
public override func finalLayoutAttributesForDisappearingSupplementaryElement(ofKind elementKind: String,
838+
at elementIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
832839
var attributes: ChatLayoutAttributes?
833840

834841
let kind = ItemKind(elementKind)

ChatLayout/Classes/Core/Model/ItemModel.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ struct ItemModel {
5757
calculatedOnce = configuration.calculatedSize != nil
5858
}
5959

60-
// We are just resetting `calculatedSize` if needed as the actual size will be found in invalidationContext(forPreferredLayoutAttributes:, withOriginalAttributes:)
60+
// We are just resetting `calculatedSize` if needed as the actual size will be found in
61+
// `invalidationContext(forPreferredLayoutAttributes:, withOriginalAttributes:)`.
6162
// It is important for the rotation to keep previous frame size.
6263
mutating func resetSize() {
6364
guard let calculatedSize else {

ChatLayout/Classes/Core/Model/ItemSize.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import UIKit
1616
/// Represents desired item size.
1717
public enum ItemSize: Hashable {
1818

19-
/// Item size should be fully calculated by the `CollectionViewChatLayout`. Initial estimated size will be taken from `ChatLayoutSettings`.
19+
/// Item size should be fully calculated by the `CollectionViewChatLayout`.
20+
/// Initial estimated size will be taken from `ChatLayoutSettings`.
2021
case auto
2122

22-
/// Item size should be fully calculated by the `CollectionViewChatLayout`. Initial estimated size should be taken from the value provided.
23+
/// Item size should be fully calculated by the `CollectionViewChatLayout`.
24+
/// Initial estimated size should be taken from the value provided.
2325
case estimated(CGSize)
2426

2527
/// Item size should be exactly equal to the value provided.

ChatLayout/Classes/Core/Model/StateController.swift

+12-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,11 @@ final class StateController<Layout: ChatLayoutRepresentation> {
396396
}
397397
}
398398

399-
func update(preferredSize: CGSize, alignment: ChatItemAlignment, for itemPath: ItemPath, kind: ItemKind, at state: ModelState) {
399+
func update(preferredSize: CGSize,
400+
alignment: ChatItemAlignment,
401+
for itemPath: ItemPath,
402+
kind: ItemKind,
403+
at state: ModelState) {
400404
guard var item = item(for: itemPath, kind: kind, at: state) else {
401405
assertionFailure("Item at index path (\(itemPath.section) - \(itemPath.item)) does not exist.")
402406
return
@@ -840,7 +844,10 @@ final class StateController<Layout: ChatLayoutRepresentation> {
840844
}
841845
}
842846

843-
private func compensateOffsetIfNeeded(for itemPath: ItemPath, kind: ItemKind, action: CompensatingAction, visibleBounds: CGRect? = nil) {
847+
private func compensateOffsetIfNeeded(for itemPath: ItemPath,
848+
kind: ItemKind,
849+
action: CompensatingAction,
850+
visibleBounds: CGRect? = nil) {
844851
guard layoutRepresentation.keepContentOffsetAtBottomOnBatchUpdates else {
845852
return
846853
}
@@ -879,7 +886,9 @@ final class StateController<Layout: ChatLayoutRepresentation> {
879886

880887
}
881888

882-
private func compensateOffsetOfSectionIfNeeded(for sectionIndex: Int, action: CompensatingAction, visibleBounds: CGRect? = nil) {
889+
private func compensateOffsetOfSectionIfNeeded(for sectionIndex: Int,
890+
action: CompensatingAction,
891+
visibleBounds: CGRect? = nil) {
883892
guard layoutRepresentation.keepContentOffsetAtBottomOnBatchUpdates else {
884893
return
885894
}

ChatLayout/Classes/Extras/Extensions/NSLayoutAnchor+Extension.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@ import Foundation
1414
import UIKit
1515

1616
extension NSLayoutAnchor {
17-
@objc func constraint(equalTo anchor: NSLayoutAnchor<AnchorType>, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
17+
@objc func constraint(equalTo anchor: NSLayoutAnchor<AnchorType>,
18+
constant c: CGFloat = 0,
19+
priority: UILayoutPriority) -> NSLayoutConstraint {
1820
let constraint = constraint(equalTo: anchor, constant: c)
1921
constraint.priority = priority
2022
return constraint
2123
}
2224

23-
@objc func constraint(greaterThanOrEqualTo anchor: NSLayoutAnchor<AnchorType>, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
25+
@objc func constraint(greaterThanOrEqualTo anchor: NSLayoutAnchor<AnchorType>,
26+
constant c: CGFloat = 0,
27+
priority: UILayoutPriority) -> NSLayoutConstraint {
2428
let constraint = constraint(greaterThanOrEqualTo: anchor, constant: c)
2529
constraint.priority = priority
2630
return constraint
2731
}
2832

29-
@objc func constraint(lessThanOrEqualTo anchor: NSLayoutAnchor<AnchorType>, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
33+
@objc func constraint(lessThanOrEqualTo anchor: NSLayoutAnchor<AnchorType>,
34+
constant c: CGFloat = 0,
35+
priority: UILayoutPriority) -> NSLayoutConstraint {
3036
let constraint = constraint(lessThanOrEqualTo: anchor, constant: c)
3137
constraint.priority = priority
3238
return constraint

ChatLayout/Classes/Extras/Extensions/NSLayoutDimension+Extension.swift

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,49 @@ import Foundation
1414
import UIKit
1515

1616
extension NSLayoutDimension {
17-
@objc func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
17+
@objc func constraint(equalTo anchor: NSLayoutDimension,
18+
multiplier m: CGFloat = 1,
19+
constant c: CGFloat = 0,
20+
priority: UILayoutPriority) -> NSLayoutConstraint {
1821
let constraint = constraint(equalTo: anchor, multiplier: m, constant: c)
1922
constraint.priority = priority
2023
return constraint
2124
}
2225

23-
@objc func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
26+
@objc func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension,
27+
multiplier m: CGFloat = 1,
28+
constant c: CGFloat = 0,
29+
priority: UILayoutPriority) -> NSLayoutConstraint {
2430
let constraint = constraint(greaterThanOrEqualTo: anchor, multiplier: m, constant: c)
2531
constraint.priority = priority
2632
return constraint
2733
}
2834

29-
@objc func constraint(lessThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority) -> NSLayoutConstraint {
35+
@objc func constraint(lessThanOrEqualTo anchor: NSLayoutDimension,
36+
multiplier m: CGFloat = 1,
37+
constant c: CGFloat = 0,
38+
priority: UILayoutPriority) -> NSLayoutConstraint {
3039
let constraint = constraint(lessThanOrEqualTo: anchor, multiplier: m, constant: c)
3140
constraint.priority = priority
3241
return constraint
3342
}
3443

35-
@objc func constraint(equalToConstant c: CGFloat, priority: UILayoutPriority) -> NSLayoutConstraint {
44+
@objc func constraint(equalToConstant c: CGFloat,
45+
priority: UILayoutPriority) -> NSLayoutConstraint {
3646
let constraint = constraint(equalToConstant: c)
3747
constraint.priority = priority
3848
return constraint
3949
}
4050

41-
@objc func constraint(greaterThanOrEqualToConstant c: CGFloat, priority: UILayoutPriority) -> NSLayoutConstraint {
51+
@objc func constraint(greaterThanOrEqualToConstant c: CGFloat,
52+
priority: UILayoutPriority) -> NSLayoutConstraint {
4253
let constraint = constraint(greaterThanOrEqualToConstant: c)
4354
constraint.priority = priority
4455
return constraint
4556
}
4657

47-
@objc func constraint(lessThanOrEqualToConstant c: CGFloat, priority: UILayoutPriority) -> NSLayoutConstraint {
58+
@objc func constraint(lessThanOrEqualToConstant c: CGFloat,
59+
priority: UILayoutPriority) -> NSLayoutConstraint {
4860
let constraint = constraint(lessThanOrEqualToConstant: c)
4961
constraint.priority = priority
5062
return constraint

docs/Classes/CollectionViewChatLayout.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ <h1>CollectionViewChatLayout</h1>
154154

155155
</div>
156156
</div>
157-
<p>A collection view layout that can display items in a grid similar to <code>UITableView</code> but aligning them
158-
to the leading or trailing edge of the <code>UICollectionView</code>. Helps to maintain chat like behavior by keeping
159-
content offset from the bottom constant. Can deal with autosizing cells and supplementary views.</p>
157+
<p>A collection view layout designed to display items in a grid similar to <code>UITableView</code>, while aligning them to the
158+
leading or trailing edge of the <code>UICollectionView</code>. This layout facilitates chat-like behavior by maintaining
159+
a constant content offset from the bottom. Additionally, it is capable of handling autosizing cells and
160+
supplementary views.</p>
160161
<h3 id='custom-properties' class='heading'>Custom Properties:</h3>
161162

162163
<p><code><a href="../Classes/CollectionViewChatLayout.html#/s:10ChatLayout014CollectionViewaB0C8delegateAA0aB8Delegate_pSgvp">CollectionViewChatLayout.delegate</a></code></p>

docs/Core.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ <h1>Core</h1>
168168
<section class="section">
169169
<div class="pointer"></div>
170170
<div class="abstract">
171-
<p>A collection view layout that can display items in a grid similar to <code>UITableView</code> but aligning them
172-
to the leading or trailing edge of the <code>UICollectionView</code>. Helps to maintain chat like behavior by keeping
173-
content offset from the bottom constant. Can deal with autosizing cells and supplementary views.</p>
171+
<p>A collection view layout designed to display items in a grid similar to <code>UITableView</code>, while aligning them to the
172+
leading or trailing edge of the <code>UICollectionView</code>. This layout facilitates chat-like behavior by maintaining
173+
a constant content offset from the bottom. Additionally, it is capable of handling autosizing cells and
174+
supplementary views.</p>
174175
<h3 id='custom-properties' class='heading'>Custom Properties:</h3>
175176

176177
<p><code><a href="Classes/CollectionViewChatLayout.html#/s:10ChatLayout014CollectionViewaB0C8delegateAA0aB8Delegate_pSgvp">CollectionViewChatLayout.delegate</a></code></p>

docs/docsets/ChatLayout.docset/Contents/Resources/Documents/Classes/CollectionViewChatLayout.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ <h1>CollectionViewChatLayout</h1>
154154

155155
</div>
156156
</div>
157-
<p>A collection view layout that can display items in a grid similar to <code>UITableView</code> but aligning them
158-
to the leading or trailing edge of the <code>UICollectionView</code>. Helps to maintain chat like behavior by keeping
159-
content offset from the bottom constant. Can deal with autosizing cells and supplementary views.</p>
157+
<p>A collection view layout designed to display items in a grid similar to <code>UITableView</code>, while aligning them to the
158+
leading or trailing edge of the <code>UICollectionView</code>. This layout facilitates chat-like behavior by maintaining
159+
a constant content offset from the bottom. Additionally, it is capable of handling autosizing cells and
160+
supplementary views.</p>
160161
<h3 id='custom-properties' class='heading'>Custom Properties:</h3>
161162

162163
<p><code><a href="../Classes/CollectionViewChatLayout.html#/s:10ChatLayout014CollectionViewaB0C8delegateAA0aB8Delegate_pSgvp">CollectionViewChatLayout.delegate</a></code></p>

docs/docsets/ChatLayout.docset/Contents/Resources/Documents/Core.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ <h1>Core</h1>
168168
<section class="section">
169169
<div class="pointer"></div>
170170
<div class="abstract">
171-
<p>A collection view layout that can display items in a grid similar to <code>UITableView</code> but aligning them
172-
to the leading or trailing edge of the <code>UICollectionView</code>. Helps to maintain chat like behavior by keeping
173-
content offset from the bottom constant. Can deal with autosizing cells and supplementary views.</p>
171+
<p>A collection view layout designed to display items in a grid similar to <code>UITableView</code>, while aligning them to the
172+
leading or trailing edge of the <code>UICollectionView</code>. This layout facilitates chat-like behavior by maintaining
173+
a constant content offset from the bottom. Additionally, it is capable of handling autosizing cells and
174+
supplementary views.</p>
174175
<h3 id='custom-properties' class='heading'>Custom Properties:</h3>
175176

176177
<p><code><a href="Classes/CollectionViewChatLayout.html#/s:10ChatLayout014CollectionViewaB0C8delegateAA0aB8Delegate_pSgvp">CollectionViewChatLayout.delegate</a></code></p>

docs/docsets/ChatLayout.docset/Contents/Resources/Documents/search.json

+1-1
Large diffs are not rendered by default.

docs/docsets/ChatLayout.tgz

79 Bytes
Binary file not shown.

docs/search.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)