Skip to content

Commit b09f80c

Browse files
committed
Minor updates
1 parent 8fcecfe commit b09f80c

File tree

73 files changed

+1071
-966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1071
-966
lines changed

ChatLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'ChatLayout'
3-
s.version = '0.4.5'
3+
s.version = '0.4.6'
44
s.summary = 'An alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
55
s.swift_version = '5.2'
66

ChatLayout/Classes/Core/ChatLayout.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ public final class ChatLayout: UICollectionViewLayout {
606606
super.finalizeCollectionViewUpdates()
607607
}
608608

609+
// MARK: - Cell Appearance Animation
610+
609611
/// Retrieves the starting layout information for an item being inserted into the collection view.
610612
public override func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
611613
var attributes: ChatLayoutAttributes?
@@ -679,6 +681,8 @@ public final class ChatLayout: UICollectionViewLayout {
679681
return attributes
680682
}
681683

684+
// MARK: - Supplementary View Appearance Animation
685+
682686
/// Retrieves the starting layout information for a supplementary view being inserted into the collection view.
683687
public override func initialLayoutAttributesForAppearingSupplementaryElement(ofKind elementKind: String, at elementIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
684688
var attributes: ChatLayoutAttributes?
@@ -696,7 +700,7 @@ public final class ChatLayout: UICollectionViewLayout {
696700

697701
if #available(iOS 13.0, *) {
698702
} else {
699-
if controller.reloadedIndexes.contains(initialIndexPath) || controller.reloadedSectionsIndexes.contains(elementIndexPath.section) {
703+
if controller.reloadedSectionsIndexes.contains(elementIndexPath.section) {
700704
// It is needed to position the new cell in the middle of the old cell on ios 12
701705
attributesForPendingAnimations[.cell]?[initialIndexPath] = attributes
702706
}
@@ -725,7 +729,7 @@ public final class ChatLayout: UICollectionViewLayout {
725729
attributes = controller.itemAttributes(for: finalIndexPath, kind: kind, at: .afterUpdate) ?? ChatLayoutAttributes(forSupplementaryViewOfKind: elementKind, with: elementIndexPath)
726730
attributes?.indexPath = elementIndexPath
727731
attributesForPendingAnimations[kind]?[elementIndexPath] = attributes
728-
if controller.reloadedIndexes.contains(elementIndexPath) || controller.reloadedSectionsIndexes.contains(elementIndexPath.section) || finalIndexPath != elementIndexPath {
732+
if controller.reloadedSectionsIndexes.contains(elementIndexPath.section) || finalIndexPath != elementIndexPath {
729733
attributes?.alpha = 0
730734
attributes?.transform = CGAffineTransform(scaleX: 0, y: 0)
731735
}

ChatLayout/Classes/Extras/ContainerCollectionViewCell.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public protocol ContainerCollectionViewCellDelegate: AnyObject {
1919

2020
/// Allows to override the call of `ContainerCollectionViewCell`/`ContainerCollectionReusableView`
2121
/// `UICollectionReusableView.preferredLayoutAttributesFitting(...)` and make the layout calculations.
22+
///
23+
/// **NB**: You must override it to avoid unnecessary autolayout calculations if you are providing exact cell size
24+
/// in `ChatLayoutDelegate.sizeForItem(...)` and return `layoutAttributes` without modifications.
2225
/// - Parameter layoutAttributes: `ChatLayoutAttributes` provided by `ChatLayout`
2326
/// - Returns: Modified `ChatLayoutAttributes` on nil if `UICollectionReusableView.preferredLayoutAttributesFitting(...)`
2427
/// should be called instead.

ChatLayout/Classes/Extras/MessageContainerView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public final class MessageContainerView<AccessoryViewFactory: StaticViewFactory,
7373

7474
if let accessoryView = accessoryView {
7575
stackView.addArrangedSubview(accessoryView)
76-
accessoryView.isHidden = true
7776
accessoryView.translatesAutoresizingMaskIntoConstraints = false
7877
}
7978

Example/ChatLayout/Chat/View/ChatViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ final class ChatViewController: UIViewController {
1818

1919
private enum ReactionTypes {
2020
case delayedUpdate
21-
case delayedReload
2221
}
2322

2423
private enum InterfaceActions {
@@ -128,8 +127,9 @@ final class ChatViewController: UIViewController {
128127
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
129128
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
130129
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
131-
dataSource.prepare(with: collectionView)
132130
collectionView.backgroundColor = .clear
131+
collectionView.showsHorizontalScrollIndicator = false
132+
dataSource.prepare(with: collectionView)
133133

134134
currentControllerActions.options.insert(.loadingInitialMessages)
135135
chatController.loadInitialMessages { sections in

Example/ChatLayout/Chat/View/Image/ImageController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ final class ImageController {
5353
guard let self = self else {
5454
return
5555
}
56-
self.image = try? result.get()
5756
self.delegate?.reloadMessage(with: self.messageId)
5857
}
5958
}

Example/ChatLayout/Chat/View/Image/ImageView.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ final class ImageView: UIView, ContainerCollectionViewCellDelegate {
4646
setupSize()
4747
}
4848

49+
// Uncomment to demonstrate the manual cell size calculation.
50+
// NB: Keep in mind that the cell itself is still using autolayout to layout it content. If you really want to speed up the
51+
// performance, You must layout the entire!!! `UICollectionCell` manually or using the tools
52+
// like [LayoutKit](https://github.com/linkedin/LayoutKit)
53+
// func preferredLayoutAttributesFitting(_ layoutAttributes: ChatLayoutAttributes) -> ChatLayoutAttributes? {
54+
// viewPortWidth = layoutAttributes.layoutFrame.width
55+
// switch controller.state {
56+
// case .loading:
57+
// layoutAttributes.frame.size.height = 100
58+
// return layoutAttributes
59+
// case let .image(image):
60+
// let maxWidth = min(viewPortWidth * Constants.maxWidth, image.size.width)
61+
// layoutAttributes.frame.size.height = image.size.height * maxWidth / image.size.width
62+
// return layoutAttributes
63+
// }
64+
// }
65+
4966
func setup(with controller: ImageController) {
5067
self.controller = controller
5168
}

docs/Classes/CellLayoutContainerView.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<header class="header">
2222
<p class="header-col header-col--primary">
2323
<a class="header-link" href="../index.html">
24-
ChatLayout 0.4.5 Docs
24+
ChatLayout 0.4.6 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -453,7 +453,7 @@ <h4>Parameters</h4>
453453
</article>
454454
</div>
455455
<section class="footer">
456-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-21)</p>
456+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-30)</p>
457457
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
458458
</section>
459459
</body>

docs/Classes/ChatLayout.html

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<header class="header">
2222
<p class="header-col header-col--primary">
2323
<a class="header-link" href="../index.html">
24-
ChatLayout 0.4.5 Docs
24+
ChatLayout 0.4.6 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -1103,6 +1103,19 @@ <h4>Declaration</h4>
11031103
</section>
11041104
</div>
11051105
</li>
1106+
</ul>
1107+
</div>
1108+
<div class="task-group">
1109+
<div class="task-name-container">
1110+
<a name="/Cell%20Appearance%20Animation"></a>
1111+
<a name="//apple_ref/swift/Section/Cell Appearance Animation" class="dashAnchor"></a>
1112+
<div class="section-name-container">
1113+
<a class="section-name-link" href="#/Cell%20Appearance%20Animation"></a>
1114+
<h3 class="section-name"><p>Cell Appearance Animation</p>
1115+
</h3>
1116+
</div>
1117+
</div>
1118+
<ul class="item-container">
11061119
<li class="item">
11071120
<div>
11081121
<code>
@@ -1157,6 +1170,19 @@ <h4>Declaration</h4>
11571170
</section>
11581171
</div>
11591172
</li>
1173+
</ul>
1174+
</div>
1175+
<div class="task-group">
1176+
<div class="task-name-container">
1177+
<a name="/Supplementary%20View%20Appearance%20Animation"></a>
1178+
<a name="//apple_ref/swift/Section/Supplementary View Appearance Animation" class="dashAnchor"></a>
1179+
<div class="section-name-container">
1180+
<a class="section-name-link" href="#/Supplementary%20View%20Appearance%20Animation"></a>
1181+
<h3 class="section-name"><p>Supplementary View Appearance Animation</p>
1182+
</h3>
1183+
</div>
1184+
</div>
1185+
<ul class="item-container">
11601186
<li class="item">
11611187
<div>
11621188
<code>
@@ -1219,7 +1245,7 @@ <h4>Declaration</h4>
12191245
</article>
12201246
</div>
12211247
<section class="footer">
1222-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-21)</p>
1248+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-30)</p>
12231249
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
12241250
</section>
12251251
</body>

docs/Classes/ChatLayoutAttributes.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<header class="header">
2222
<p class="header-col header-col--primary">
2323
<a class="header-link" href="../index.html">
24-
ChatLayout 0.4.5 Docs
24+
ChatLayout 0.4.6 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -385,7 +385,7 @@ <h4>Declaration</h4>
385385
</article>
386386
</div>
387387
<section class="footer">
388-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-21)</p>
388+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-10-30)</p>
389389
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
390390
</section>
391391
</body>

0 commit comments

Comments
 (0)