Skip to content

Commit c3abbbb

Browse files
committed
Added SwappingContainerView.
1 parent ee2876c commit c3abbbb

File tree

84 files changed

+3163
-158
lines changed

Some content is hidden

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

84 files changed

+3163
-158
lines changed

.jazzy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ custom_categories:
2929
- CellLayoutContainerView
3030
- CellLayoutContainerViewAlignment
3131
- EdgeAligningView
32+
- SwappingContainerView
3233
- ImageMaskedView
3334
- ImageMaskedViewTransformation
3435
- RoundedCornersContainerView

ChatLayout.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Pod::Spec.new do |s|
22
s.name = 'ChatLayout'
3-
s.version = '1.2.19'
3+
s.version = '1.2.20'
44
s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
5-
s.swift_version = '5.7'
5+
s.swift_version = '5.8'
66

77
s.description = <<-DESC
88
ChatLayout is a Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the

ChatLayout/Classes/Extras/EdgeAligningView.swift

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public final class EdgeAligningView<CustomView: UIView>: UIView {
4242
}
4343
lastConstraintsUpdateEdges = nil
4444
setNeedsUpdateConstraints()
45+
setNeedsLayout()
4546
}
4647
}
4748

@@ -178,6 +179,7 @@ public final class EdgeAligningView<CustomView: UIView>: UIView {
178179
self.flexibleConstraints = flexibleConstraints
179180
self.centerConstraints = centerConstraints
180181
setNeedsUpdateConstraints()
182+
setNeedsLayout()
181183
}
182184

183185
private func buildCenterConstraints(_ view: UIView) -> (centerX: NSLayoutConstraint, centerY: NSLayoutConstraint) {

ChatLayout/Classes/Extras/SwappingContainerView.swift

+362
Large diffs are not rendered by default.

Example/ChatLayout/Chat/Controller/DefaultChatController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ final class DefaultChatController: ChatController {
8181
guard let self else {
8282
return
8383
}
84-
let messagesSplitByDay = self.messages
84+
let messagesSplitByDay = messages
8585
.map { Message(id: $0.id,
8686
date: $0.date,
8787
data: self.convert($0.data),
@@ -241,7 +241,7 @@ extension DefaultChatController: RandomDataProviderDelegate {
241241
return
242242
}
243243
var finished = false
244-
self.messages = self.messages.map { message in
244+
messages = messages.map { message in
245245
guard !finished, message.status != .received, message.status != .read else {
246246
if message.id == lastReceivedUUID {
247247
finished = true
@@ -271,7 +271,7 @@ extension DefaultChatController: RandomDataProviderDelegate {
271271
return
272272
}
273273
var finished = false
274-
self.messages = self.messages.map { message in
274+
messages = messages.map { message in
275275
guard !finished, message.status != .read else {
276276
if message.id == lastReadUUID {
277277
finished = true

Example/ChatLayout/Chat/Controller/Image Loader/CachingImageLoader.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public struct CachingImageLoader<C: AsyncKeyValueCaching>: ImageLoader where C.C
3232
completion(result)
3333
return
3434
}
35-
self.loader.loadImage(from: url, completion: { result in
35+
loader.loadImage(from: url, completion: { result in
3636
switch result {
3737
case let .success(image):
38-
try? self.cache.store(entity: image, for: imageKey)
38+
try? cache.store(entity: image, for: imageKey)
3939
completion(.success(image))
4040
case .failure:
4141
completion(result)

Example/ChatLayout/Chat/Model/DefaultRandomDataProvider.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ final class DefaultRandomDataProvider: RandomDataProvider {
104104
guard let self else {
105105
return
106106
}
107-
let messages = self.createBunchOfMessages(number: 50)
107+
let messages = createBunchOfMessages(number: 50)
108108
if messages.count > 10 {
109-
self.lastReceivedUUID = messages[messages.count - 10].id
109+
lastReceivedUUID = messages[messages.count - 10].id
110110
}
111111
if messages.count > 3 {
112-
self.lastReadUUID = messages[messages.count - 3].id
112+
lastReadUUID = messages[messages.count - 3].id
113113
}
114114
DispatchQueue.main.async {
115115
completion(messages)
@@ -122,7 +122,7 @@ final class DefaultRandomDataProvider: RandomDataProvider {
122122
guard let self else {
123123
return
124124
}
125-
let messages = self.createBunchOfMessages(number: 50)
125+
let messages = createBunchOfMessages(number: 50)
126126

127127
DispatchQueue.main.async {
128128
completion(messages)

Example/ChatLayout/Chat/View/ChatViewController.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ extension ChatViewController: UIScrollViewDelegate {
299299
return
300300
}
301301
// Reloading the content without animation just because it looks better is the scrolling is in process.
302-
let animated = !self.isUserInitiatedScrolling
303-
self.processUpdates(with: sections, animated: animated, requiresIsolatedProcess: false) {
302+
let animated = !isUserInitiatedScrolling
303+
processUpdates(with: sections, animated: animated, requiresIsolatedProcess: false) {
304304
self.currentControllerActions.options.remove(.loadingPreviousMessages)
305305
}
306306
}
@@ -329,12 +329,12 @@ extension ChatViewController: UIScrollViewDelegate {
329329
guard let self else {
330330
return
331331
}
332-
self.collectionView.contentOffset = CGPoint(x: self.collectionView.contentOffset.x, y: initialOffset + (delta * percentage))
332+
collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x, y: initialOffset + (delta * percentage))
333333
if percentage == 1.0 {
334-
self.animator = nil
334+
animator = nil
335335
let positionSnapshot = ChatLayoutPositionSnapshot(indexPath: IndexPath(item: 0, section: 0), kind: .footer, edge: .bottom)
336-
self.chatLayout.restoreContentOffset(with: positionSnapshot)
337-
self.currentInterfaceActions.options.remove(.scrollingToBottom)
336+
chatLayout.restoreContentOffset(with: positionSnapshot)
337+
currentInterfaceActions.options.remove(.scrollingToBottom)
338338
completion?()
339339
}
340340
}
@@ -461,7 +461,7 @@ extension ChatViewController: ChatControllerDelegate {
461461
guard let self else {
462462
return
463463
}
464-
self.processUpdates(with: sections, animated: animated, requiresIsolatedProcess: requiresIsolatedProcess, completion: completion)
464+
processUpdates(with: sections, animated: animated, requiresIsolatedProcess: requiresIsolatedProcess, completion: completion)
465465
})
466466
currentInterfaceActions.add(reaction: reaction)
467467
return
@@ -599,10 +599,10 @@ extension ChatViewController: InputBarAccessoryViewDelegate {
599599
return
600600
}
601601
guard let messageText else {
602-
self.currentInterfaceActions.options.remove(.sendingMessage)
602+
currentInterfaceActions.options.remove(.sendingMessage)
603603
return
604604
}
605-
self.scrollToBottom(completion: {
605+
scrollToBottom(completion: {
606606
self.chatController.sendMessage(.text(messageText)) { sections in
607607
self.currentInterfaceActions.options.remove(.sendingMessage)
608608
self.processUpdates(with: sections, animated: true, requiresIsolatedProcess: false)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ final class ImageController {
5656
guard let self else {
5757
return
5858
}
59-
self.delegate?.reloadMessage(with: self.messageId)
59+
delegate?.reloadMessage(with: messageId)
6060
}
6161
}
6262
case let .image(image):

Example/ChatLayout/Chat/View/Other/ManualAnimator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private extension CGFloat {
8686
guard self < 1.0 else {
8787
return 1.0
8888
}
89-
return ((self * self) / (2.0 * ((self * self) - self) + 1.0))
89+
return (self * self) / (2.0 * ((self * self) - self) + 1.0)
9090
}
9191

9292
var quadraticEaseInOut: CGFloat {

Example/ChatLayout/Chat/View/URL View/URLController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ final class URLController {
4949
return
5050
}
5151

52-
try? metadataCache.store(entity: metadata, for: self.url)
52+
try? metadataCache.store(entity: metadata, for: url)
5353

5454
DispatchQueue.main.async { [weak self] in
5555
guard let self else {
5656
return
5757
}
58-
self.delegate?.reloadMessage(with: self.messageId)
58+
delegate?.reloadMessage(with: messageId)
5959
}
6060
}
6161
}

Example/Podfile.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
PODS:
2-
- ChatLayout (1.2.19):
3-
- ChatLayout/Ultimate (= 1.2.19)
4-
- ChatLayout/Core (1.2.19)
5-
- ChatLayout/Extras (1.2.19):
2+
- ChatLayout (1.2.20):
3+
- ChatLayout/Ultimate (= 1.2.20)
4+
- ChatLayout/Core (1.2.20)
5+
- ChatLayout/Extras (1.2.20):
66
- ChatLayout/Core
7-
- ChatLayout/Ultimate (1.2.19):
7+
- ChatLayout/Ultimate (1.2.20):
88
- ChatLayout/Core
99
- ChatLayout/Extras
1010
- DifferenceKit (1.3.0):
@@ -35,7 +35,7 @@ EXTERNAL SOURCES:
3535
:path: "../"
3636

3737
SPEC CHECKSUMS:
38-
ChatLayout: afb0909b884b54e618a5b13db52be5f79fba5cff
38+
ChatLayout: 6c92dd2c744e32f89310cad07bd1f4a61005be9d
3939
DifferenceKit: ab185c4d7f9cef8af3fcf593e5b387fb81e999ca
4040
FPSCounter: 884afec377de66637808c4f52ecc3b85a404732b
4141
InputBarAccessoryView: 1d7b0a672b36e370f01f264b3907ef39d03328e3

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.8
22

33
import PackageDescription
44

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b97c279a50984376ab2649f5a7d09e69)](https://www.codacy.com/gh/ekazaev/ChatLayout/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=ekazaev/ChatLayout&amp;utm_campaign=Badge_Grade)
1313
[![Swift Package Manager](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://github.com/apple/swift-package-manager)
1414
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BA51D.svg?style=flat)](https://github.com/Carthage/Carthage)
15-
[![Swift 5.7](https://img.shields.io/badge/language-Swift5.7-orange.svg?style=flat)](https://developer.apple.com/swift)
15+
[![Swift 5.8](https://img.shields.io/badge/language-Swift5.8-orange.svg?style=flat)](https://developer.apple.com/swift)
1616
[![Platform iOS](https://img.shields.io/badge/platform-iOS%2012%20—%20iOS%2016-yellow.svg)](https://www.apple.com/ios)
1717

1818
<p align="center">

docs/Classes/CellLayoutContainerView.html

+11-2
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 1.2.19 Docs
24+
ChatLayout 1.2.20 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -112,6 +112,15 @@
112112
<li class="nav-group-task">
113113
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
114114
</li>
115+
<li class="nav-group-task">
116+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
117+
</li>
118+
<li class="nav-group-task">
119+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
120+
</li>
121+
<li class="nav-group-task">
122+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
123+
</li>
115124
<li class="nav-group-task">
116125
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
117126
</li>
@@ -455,7 +464,7 @@ <h4>Parameters</h4>
455464
</article>
456465
</div>
457466
<section class="footer">
458-
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-04-07)</p>
467+
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-05-19)</p>
459468
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
460469
</section>
461470
</body>

docs/Classes/ChatLayoutAttributes.html

+11-2
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 1.2.19 Docs
24+
ChatLayout 1.2.20 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -112,6 +112,15 @@
112112
<li class="nav-group-task">
113113
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
114114
</li>
115+
<li class="nav-group-task">
116+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
117+
</li>
118+
<li class="nav-group-task">
119+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
120+
</li>
121+
<li class="nav-group-task">
122+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
123+
</li>
115124
<li class="nav-group-task">
116125
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
117126
</li>
@@ -414,7 +423,7 @@ <h4>Declaration</h4>
414423
</article>
415424
</div>
416425
<section class="footer">
417-
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-04-07)</p>
426+
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-05-19)</p>
418427
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
419428
</section>
420429
</body>

docs/Classes/ChatLayoutInvalidationContext.html

+11-2
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 1.2.19 Docs
24+
ChatLayout 1.2.20 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -112,6 +112,15 @@
112112
<li class="nav-group-task">
113113
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
114114
</li>
115+
<li class="nav-group-task">
116+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
117+
</li>
118+
<li class="nav-group-task">
119+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
120+
</li>
121+
<li class="nav-group-task">
122+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
123+
</li>
115124
<li class="nav-group-task">
116125
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
117126
</li>
@@ -199,7 +208,7 @@ <h4>Declaration</h4>
199208
</article>
200209
</div>
201210
<section class="footer">
202-
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-04-07)</p>
211+
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-05-19)</p>
203212
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
204213
</section>
205214
</body>

docs/Classes/CollectionViewChatLayout.html

+11-2
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 1.2.19 Docs
24+
ChatLayout 1.2.20 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -112,6 +112,15 @@
112112
<li class="nav-group-task">
113113
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
114114
</li>
115+
<li class="nav-group-task">
116+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
117+
</li>
118+
<li class="nav-group-task">
119+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
120+
</li>
121+
<li class="nav-group-task">
122+
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
123+
</li>
115124
<li class="nav-group-task">
116125
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
117126
</li>
@@ -1345,7 +1354,7 @@ <h4>Declaration</h4>
13451354
</article>
13461355
</div>
13471356
<section class="footer">
1348-
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-04-07)</p>
1357+
<p>&copy; 2023 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2023-05-19)</p>
13491358
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
13501359
</section>
13511360
</body>

0 commit comments

Comments
 (0)