Skip to content

Commit

Permalink
Added SwappingContainerView.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekazaev committed May 19, 2023
1 parent ee2876c commit c3abbbb
Show file tree
Hide file tree
Showing 84 changed files with 3,163 additions and 158 deletions.
1 change: 1 addition & 0 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ custom_categories:
- CellLayoutContainerView
- CellLayoutContainerViewAlignment
- EdgeAligningView
- SwappingContainerView
- ImageMaskedView
- ImageMaskedViewTransformation
- RoundedCornersContainerView
Expand Down
4 changes: 2 additions & 2 deletions ChatLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Pod::Spec.new do |s|
s.name = 'ChatLayout'
s.version = '1.2.19'
s.version = '1.2.20'
s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
s.swift_version = '5.7'
s.swift_version = '5.8'

s.description = <<-DESC
ChatLayout is a Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the
Expand Down
2 changes: 2 additions & 0 deletions ChatLayout/Classes/Extras/EdgeAligningView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class EdgeAligningView<CustomView: UIView>: UIView {
}
lastConstraintsUpdateEdges = nil
setNeedsUpdateConstraints()
setNeedsLayout()
}
}

Expand Down Expand Up @@ -178,6 +179,7 @@ public final class EdgeAligningView<CustomView: UIView>: UIView {
self.flexibleConstraints = flexibleConstraints
self.centerConstraints = centerConstraints
setNeedsUpdateConstraints()
setNeedsLayout()
}

private func buildCenterConstraints(_ view: UIView) -> (centerX: NSLayoutConstraint, centerY: NSLayoutConstraint) {
Expand Down
362 changes: 362 additions & 0 deletions ChatLayout/Classes/Extras/SwappingContainerView.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class DefaultChatController: ChatController {
guard let self else {
return
}
let messagesSplitByDay = self.messages
let messagesSplitByDay = messages
.map { Message(id: $0.id,
date: $0.date,
data: self.convert($0.data),
Expand Down Expand Up @@ -241,7 +241,7 @@ extension DefaultChatController: RandomDataProviderDelegate {
return
}
var finished = false
self.messages = self.messages.map { message in
messages = messages.map { message in
guard !finished, message.status != .received, message.status != .read else {
if message.id == lastReceivedUUID {
finished = true
Expand Down Expand Up @@ -271,7 +271,7 @@ extension DefaultChatController: RandomDataProviderDelegate {
return
}
var finished = false
self.messages = self.messages.map { message in
messages = messages.map { message in
guard !finished, message.status != .read else {
if message.id == lastReadUUID {
finished = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public struct CachingImageLoader<C: AsyncKeyValueCaching>: ImageLoader where C.C
completion(result)
return
}
self.loader.loadImage(from: url, completion: { result in
loader.loadImage(from: url, completion: { result in
switch result {
case let .success(image):
try? self.cache.store(entity: image, for: imageKey)
try? cache.store(entity: image, for: imageKey)
completion(.success(image))
case .failure:
completion(result)
Expand Down
8 changes: 4 additions & 4 deletions Example/ChatLayout/Chat/Model/DefaultRandomDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ final class DefaultRandomDataProvider: RandomDataProvider {
guard let self else {
return
}
let messages = self.createBunchOfMessages(number: 50)
let messages = createBunchOfMessages(number: 50)
if messages.count > 10 {
self.lastReceivedUUID = messages[messages.count - 10].id
lastReceivedUUID = messages[messages.count - 10].id
}
if messages.count > 3 {
self.lastReadUUID = messages[messages.count - 3].id
lastReadUUID = messages[messages.count - 3].id
}
DispatchQueue.main.async {
completion(messages)
Expand All @@ -122,7 +122,7 @@ final class DefaultRandomDataProvider: RandomDataProvider {
guard let self else {
return
}
let messages = self.createBunchOfMessages(number: 50)
let messages = createBunchOfMessages(number: 50)

DispatchQueue.main.async {
completion(messages)
Expand Down
18 changes: 9 additions & 9 deletions Example/ChatLayout/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ extension ChatViewController: UIScrollViewDelegate {
return
}
// Reloading the content without animation just because it looks better is the scrolling is in process.
let animated = !self.isUserInitiatedScrolling
self.processUpdates(with: sections, animated: animated, requiresIsolatedProcess: false) {
let animated = !isUserInitiatedScrolling
processUpdates(with: sections, animated: animated, requiresIsolatedProcess: false) {
self.currentControllerActions.options.remove(.loadingPreviousMessages)
}
}
Expand Down Expand Up @@ -329,12 +329,12 @@ extension ChatViewController: UIScrollViewDelegate {
guard let self else {
return
}
self.collectionView.contentOffset = CGPoint(x: self.collectionView.contentOffset.x, y: initialOffset + (delta * percentage))
collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x, y: initialOffset + (delta * percentage))
if percentage == 1.0 {
self.animator = nil
animator = nil
let positionSnapshot = ChatLayoutPositionSnapshot(indexPath: IndexPath(item: 0, section: 0), kind: .footer, edge: .bottom)
self.chatLayout.restoreContentOffset(with: positionSnapshot)
self.currentInterfaceActions.options.remove(.scrollingToBottom)
chatLayout.restoreContentOffset(with: positionSnapshot)
currentInterfaceActions.options.remove(.scrollingToBottom)
completion?()
}
}
Expand Down Expand Up @@ -461,7 +461,7 @@ extension ChatViewController: ChatControllerDelegate {
guard let self else {
return
}
self.processUpdates(with: sections, animated: animated, requiresIsolatedProcess: requiresIsolatedProcess, completion: completion)
processUpdates(with: sections, animated: animated, requiresIsolatedProcess: requiresIsolatedProcess, completion: completion)
})
currentInterfaceActions.add(reaction: reaction)
return
Expand Down Expand Up @@ -599,10 +599,10 @@ extension ChatViewController: InputBarAccessoryViewDelegate {
return
}
guard let messageText else {
self.currentInterfaceActions.options.remove(.sendingMessage)
currentInterfaceActions.options.remove(.sendingMessage)
return
}
self.scrollToBottom(completion: {
scrollToBottom(completion: {
self.chatController.sendMessage(.text(messageText)) { sections in
self.currentInterfaceActions.options.remove(.sendingMessage)
self.processUpdates(with: sections, animated: true, requiresIsolatedProcess: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class ImageController {
guard let self else {
return
}
self.delegate?.reloadMessage(with: self.messageId)
delegate?.reloadMessage(with: messageId)
}
}
case let .image(image):
Expand Down
2 changes: 1 addition & 1 deletion Example/ChatLayout/Chat/View/Other/ManualAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private extension CGFloat {
guard self < 1.0 else {
return 1.0
}
return ((self * self) / (2.0 * ((self * self) - self) + 1.0))
return (self * self) / (2.0 * ((self * self) - self) + 1.0)
}

var quadraticEaseInOut: CGFloat {
Expand Down
4 changes: 2 additions & 2 deletions Example/ChatLayout/Chat/View/URL View/URLController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ final class URLController {
return
}

try? metadataCache.store(entity: metadata, for: self.url)
try? metadataCache.store(entity: metadata, for: url)

DispatchQueue.main.async { [weak self] in
guard let self else {
return
}
self.delegate?.reloadMessage(with: self.messageId)
delegate?.reloadMessage(with: messageId)
}
}
}
Expand Down
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.2.19):
- ChatLayout/Ultimate (= 1.2.19)
- ChatLayout/Core (1.2.19)
- ChatLayout/Extras (1.2.19):
- ChatLayout (1.2.20):
- ChatLayout/Ultimate (= 1.2.20)
- ChatLayout/Core (1.2.20)
- ChatLayout/Extras (1.2.20):
- ChatLayout/Core
- ChatLayout/Ultimate (1.2.19):
- ChatLayout/Ultimate (1.2.20):
- ChatLayout/Core
- ChatLayout/Extras
- DifferenceKit (1.3.0):
Expand Down Expand Up @@ -35,7 +35,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
ChatLayout: afb0909b884b54e618a5b13db52be5f79fba5cff
ChatLayout: 6c92dd2c744e32f89310cad07bd1f4a61005be9d
DifferenceKit: ab185c4d7f9cef8af3fcf593e5b387fb81e999ca
FPSCounter: 884afec377de66637808c4f52ecc3b85a404732b
InputBarAccessoryView: 1d7b0a672b36e370f01f264b3907ef39d03328e3
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.8

import PackageDescription

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![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)
[![Swift Package Manager](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://github.com/apple/swift-package-manager)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BA51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift 5.7](https://img.shields.io/badge/language-Swift5.7-orange.svg?style=flat)](https://developer.apple.com/swift)
[![Swift 5.8](https://img.shields.io/badge/language-Swift5.8-orange.svg?style=flat)](https://developer.apple.com/swift)
[![Platform iOS](https://img.shields.io/badge/platform-iOS%2012%20—%20iOS%2016-yellow.svg)](https://www.apple.com/ios)

<p align="center">
Expand Down
13 changes: 11 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.2.19 Docs
ChatLayout 1.2.20 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -112,6 +112,15 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
</li>
Expand Down Expand Up @@ -455,7 +464,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
13 changes: 11 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.2.19 Docs
ChatLayout 1.2.20 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -112,6 +112,15 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
</li>
Expand Down Expand Up @@ -414,7 +423,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
13 changes: 11 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.2.19 Docs
ChatLayout 1.2.20 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -112,6 +112,15 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
</li>
Expand Down Expand Up @@ -199,7 +208,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
13 changes: 11 additions & 2 deletions docs/Classes/CollectionViewChatLayout.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.2.19 Docs
ChatLayout 1.2.20 Docs
</a>
(100% documented)
</p>
Expand Down Expand Up @@ -112,6 +112,15 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/EdgeAligningView/Edge.html">– Edge</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView.html">SwappingContainerView</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Axis.html">– Axis</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/SwappingContainerView/Distribution.html">– Distribution</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Classes/ImageMaskedView.html">ImageMaskedView</a>
</li>
Expand Down Expand Up @@ -1345,7 +1354,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<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>
<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>
<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>
</section>
</body>
Expand Down
Loading

0 comments on commit c3abbbb

Please sign in to comment.