Skip to content

Commit 1e9776c

Browse files
committed
Added Hashable conformance
1 parent f96c33b commit 1e9776c

File tree

76 files changed

+1441
-243
lines changed

Some content is hidden

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

76 files changed

+1441
-243
lines changed

.jazzy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ custom_categories:
1717
- ChatLayoutInvalidationContext
1818
- ItemKind
1919
- ItemSize
20+
- ItemSize.CaseType
2021
- ChatItemAlignment
2122
- InitialAttributesRequestType
2223

ChatLayout.podspec

+1-1
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 = '1.2.12'
3+
s.version = '1.2.13'
44
s.summary = 'Chat UI Library. It uses custom UICollectionViewLayout to provide you full control over the presentation.'
55
s.swift_version = '5.7'
66

ChatLayout/Classes/Core/ChatLayoutDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
import UIKit
1515

1616
/// Represents the point in time when `CollectionViewChatLayout` asks about layout attributes modification.
17-
public enum InitialAttributesRequestType {
17+
public enum InitialAttributesRequestType: Hashable {
1818

1919
/// `UICollectionView` initially asks about the layout of an item.
2020
case initial

ChatLayout/Classes/Core/Model/ItemSize.swift

+37-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
import UIKit
1515

1616
/// Represents desired item size.
17-
public enum ItemSize {
17+
public enum ItemSize: Hashable {
1818

1919
/// Item size should be fully calculated by the `CollectionViewChatLayout`. Initial estimated size will be taken from `ChatLayoutSettings`.
2020
case auto
@@ -25,4 +25,40 @@ public enum ItemSize {
2525
/// Item size should be exactly equal to the value provided.
2626
case exact(CGSize)
2727

28+
/// Represents current item size case type.
29+
public enum CaseType: Hashable, CaseIterable {
30+
/// Represents `ItemSize.auto`
31+
case auto
32+
/// Represents `ItemSize.estimated`
33+
case estimated
34+
/// Represents `ItemSize.exact`
35+
case exact
36+
}
37+
38+
/// Returns current item size case type.
39+
public var caseType: CaseType {
40+
switch self {
41+
case .auto:
42+
return .auto
43+
case .estimated:
44+
return .estimated
45+
case .exact:
46+
return .exact
47+
}
48+
}
49+
50+
public func hash(into hasher: inout Hasher) {
51+
hasher.combine(caseType)
52+
switch self {
53+
case .auto:
54+
break
55+
case let .estimated(size):
56+
hasher.combine(size.width)
57+
hasher.combine(size.height)
58+
case let .exact(size):
59+
hasher.combine(size.width)
60+
hasher.combine(size.height)
61+
}
62+
}
63+
2864
}

Example/Podfile.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
PODS:
2-
- ChatLayout (1.2.12):
3-
- ChatLayout/Ultimate (= 1.2.12)
4-
- ChatLayout/Core (1.2.12)
5-
- ChatLayout/Extras (1.2.12):
2+
- ChatLayout (1.2.13):
3+
- ChatLayout/Ultimate (= 1.2.13)
4+
- ChatLayout/Core (1.2.13)
5+
- ChatLayout/Extras (1.2.13):
66
- ChatLayout/Core
7-
- ChatLayout/Ultimate (1.2.12):
7+
- ChatLayout/Ultimate (1.2.13):
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: 30ae110361a92083cdaf67ad164cc635bfc1b5b4
38+
ChatLayout: c37e188edd9a922d4c19d259703a29c63e0d18c6
3939
DifferenceKit: ab185c4d7f9cef8af3fcf593e5b387fb81e999ca
4040
FPSCounter: 884afec377de66637808c4f52ecc3b85a404732b
4141
InputBarAccessoryView: 1d7b0a672b36e370f01f264b3907ef39d03328e3

Example/Tests/HelpersTests.swift

+17
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,21 @@ final class HelpersTests: XCTestCase {
8888
XCTAssertEqual((150...250).map { $0 }.binarySearchRange(predicate: predicate), (150...200).map { $0 })
8989
XCTAssertEqual((150...170).map { $0 }.binarySearchRange(predicate: predicate), (150...170).map { $0 })
9090
}
91+
92+
func testItemSizeHasher() {
93+
let size = CGSize(width: 100, height: 100)
94+
var dictionary = [ItemSize: Int]()
95+
dictionary[.auto] = 0
96+
dictionary[.estimated(.zero)] = 1
97+
dictionary[.estimated(size)] = 2
98+
dictionary[.exact(.zero)] = 3
99+
dictionary[.exact(size)] = 4
100+
101+
XCTAssertEqual(dictionary[.auto], 0)
102+
XCTAssertEqual(dictionary[.estimated(.zero)], 1)
103+
XCTAssertEqual(dictionary[.estimated(size)], 2)
104+
XCTAssertEqual(dictionary[.exact(.zero)], 3)
105+
XCTAssertEqual(dictionary[.exact(size)], 4)
106+
}
107+
91108
}

docs/Classes/CellLayoutContainerView.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -452,7 +455,7 @@ <h4>Parameters</h4>
452455
</article>
453456
</div>
454457
<section class="footer">
455-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
458+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
456459
<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>
457460
</section>
458461
</body>

docs/Classes/ChatLayoutAttributes.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -411,7 +414,7 @@ <h4>Declaration</h4>
411414
</article>
412415
</div>
413416
<section class="footer">
414-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
417+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
415418
<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>
416419
</section>
417420
</body>

docs/Classes/ChatLayoutInvalidationContext.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -196,7 +199,7 @@ <h4>Declaration</h4>
196199
</article>
197200
</div>
198201
<section class="footer">
199-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
202+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
200203
<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>
201204
</section>
202205
</body>

docs/Classes/CollectionViewChatLayout.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -1303,7 +1306,7 @@ <h4>Declaration</h4>
13031306
</article>
13041307
</div>
13051308
<section class="footer">
1306-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
1309+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
13071310
<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>
13081311
</section>
13091312
</body>

docs/Classes/ContainerCollectionReusableView.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -372,7 +375,7 @@ <h4>Parameters</h4>
372375
</article>
373376
</div>
374377
<section class="footer">
375-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
378+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
376379
<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>
377380
</section>
378381
</body>

docs/Classes/ContainerCollectionViewCell.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -372,7 +375,7 @@ <h4>Parameters</h4>
372375
</article>
373376
</div>
374377
<section class="footer">
375-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
378+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
376379
<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>
377380
</section>
378381
</body>

docs/Classes/EdgeAligningView.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -356,7 +359,7 @@ <h4>Parameters</h4>
356359
</article>
357360
</div>
358361
<section class="footer">
359-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
362+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
360363
<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>
361364
</section>
362365
</body>

docs/Classes/EdgeAligningView/Edge.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -276,7 +279,7 @@ <h4>Declaration</h4>
276279
</article>
277280
</div>
278281
<section class="footer">
279-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
282+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
280283
<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>
281284
</section>
282285
</body>

docs/Classes/ImageMaskedView.html

+5-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.12 Docs
24+
ChatLayout 1.2.13 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -74,6 +74,9 @@
7474
<li class="nav-group-task">
7575
<a class="nav-group-task-link" href="../Enums/ItemSize.html">ItemSize</a>
7676
</li>
77+
<li class="nav-group-task">
78+
<a class="nav-group-task-link" href="../Enums/ItemSize/CaseType.html">– CaseType</a>
79+
</li>
7780
<li class="nav-group-task">
7881
<a class="nav-group-task-link" href="../Enums/ChatItemAlignment.html">ChatItemAlignment</a>
7982
</li>
@@ -396,7 +399,7 @@ <h4>Declaration</h4>
396399
</article>
397400
</div>
398401
<section class="footer">
399-
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-10-05)</p>
402+
<p>&copy; 2022 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external noopener">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2022-11-02)</p>
400403
<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>
401404
</section>
402405
</body>

0 commit comments

Comments
 (0)