Skip to content

Commit

Permalink
Attepmt to fix IOS 15.1 issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Kazaev committed Oct 28, 2021
1 parent 02c4972 commit d0edb6f
Show file tree
Hide file tree
Showing 67 changed files with 216 additions and 131 deletions.
2 changes: 1 addition & 1 deletion ChatLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ChatLayout'
s.version = '1.1.13'
s.version = '1.1.14'
s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
s.swift_version = '5.2'

Expand Down
31 changes: 29 additions & 2 deletions ChatLayout/Classes/Core/ChatLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public final class ChatLayout: UICollectionViewLayout {
return contentSize
}

/// There is an issue in IOS 15.1 that proposed content offset is being ignored by the UICollectionView when user is scrolling.
/// This flag enables a hack to compensate this offset later. You can disable it if necessary.
/// Bug reported: https://feedbackassistant.apple.com/feedback/9727104
public var enableIOS15_1Fix: Bool = true

// MARK: Internal Properties

var adjustedContentInset: UIEdgeInsets {
Expand Down Expand Up @@ -175,6 +180,12 @@ public final class ChatLayout: UICollectionViewLayout {

private let _flipsHorizontallyInOppositeLayoutDirection: Bool

// MARK: IOS 15.1 fix flags

private var needsIOS15_1IssueFix: Bool {
return enableIOS15_1Fix && isIOS15_1orHigher && isUserInitiatedScrolling && !controller.isAnimatedBoundsChange
}

// MARK: Constructors

/// Default constructor.
Expand Down Expand Up @@ -609,9 +620,16 @@ public final class ChatLayout: UICollectionViewLayout {
let collectionView = collectionView {
let minPossibleContentOffset = -collectionView.adjustedContentInset.top
let newProposedContentOffset = CGPoint(x: proposedContentOffset.x, y: max(minPossibleContentOffset, min(proposedContentOffset.y + controller.proposedCompensatingOffset, maxPossibleContentOffset.y)))
controller.proposedCompensatingOffset = 0
invalidationActions.formUnion([.shouldInvalidateOnBoundsChange])
return newProposedContentOffset
if needsIOS15_1IssueFix {
// This fix affects performance as UICollectionView will request cells event though they wont be visible on the screen.
// It also causes a small flickering as content offset is being fixed at `finalizeCollectionViewUpdates` instead.
controller.batchUpdateCompensatingOffset += controller.proposedCompensatingOffset
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset)
} else {
controller.proposedCompensatingOffset = 0
return newProposedContentOffset
}
}
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset)
}
Expand Down Expand Up @@ -949,3 +967,12 @@ var isIOS13orHigher: Bool {
return false
}
}

@inline(__always)
var isIOS15_1orHigher: Bool {
if #available(iOS 15.1, *) {
return true
} else {
return false
}
}
12 changes: 6 additions & 6 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PODS:
- ChatLayout (1.1.13):
- ChatLayout/Ultimate (= 1.1.13)
- ChatLayout/Core (1.1.13)
- ChatLayout/Extras (1.1.13):
- ChatLayout (1.1.14):
- ChatLayout/Ultimate (= 1.1.14)
- ChatLayout/Core (1.1.14)
- ChatLayout/Extras (1.1.14):
- ChatLayout/Core
- ChatLayout/Ultimate (1.1.13):
- ChatLayout/Ultimate (1.1.14):
- ChatLayout/Core
- ChatLayout/Extras
- DifferenceKit (1.2.0):
Expand Down Expand Up @@ -35,7 +35,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
ChatLayout: 3043e079e1b2e46239fc2f33bcbd3e679f1314cc
ChatLayout: 19b41ab293c2e3a07e79069506816c235cb51901
DifferenceKit: 5659c430bb7fe45876fa32ce5cba5d6167f0c805
FPSCounter: 884afec377de66637808c4f52ecc3b85a404732b
InputBarAccessoryView: 74d471ab1fa1736806be50328df79257e52865a9
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/CellLayoutContainerView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -457,7 +457,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
33 changes: 31 additions & 2 deletions docs/Classes/ChatLayout.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -481,6 +481,35 @@ <h4>Declaration</h4>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:10ChatLayoutAAC16enableIOS15_1FixSbvp"></a>
<a name="//apple_ref/swift/Property/enableIOS15_1Fix" class="dashAnchor"></a>
<a class="token" href="#/s:10ChatLayoutAAC16enableIOS15_1FixSbvp">enableIOS15_1Fix</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>There is an issue in IOS 15.1 that proposed content offset is being ignored by the UICollectionView when user is scrolling.
This flag enables a hack to compensate this offset later. You can disable it if necessary.
Bug reported: <a href="https://feedbackassistant.apple.com/feedback/9727104">https://feedbackassistant.apple.com/feedback/9727104</a></p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">enableIOS15_1Fix</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
Expand Down Expand Up @@ -1277,7 +1306,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/ChatLayoutAttributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -416,7 +416,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/ChatLayoutInvalidationContext.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -201,7 +201,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/ContainerCollectionReusableView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -377,7 +377,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/ContainerCollectionViewCell.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -377,7 +377,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/EdgeAligningView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -361,7 +361,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/EdgeAligningView/Edge.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -281,7 +281,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/ImageMaskedView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -401,7 +401,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/MessageContainerView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -347,7 +347,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/RoundedCornersContainerView.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -347,7 +347,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Core.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -435,7 +435,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Enums/CellLayoutContainerViewAlignment.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -281,7 +281,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/Enums/ChatItemAlignment.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
ChatLayout 1.1.10 Docs
ChatLayout 1.1.14 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -281,7 +281,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-07)</p>
<p>&copy; 2021 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2021-10-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
Expand Down
Loading

0 comments on commit d0edb6f

Please sign in to comment.