Skip to content

Commit 2d29367

Browse files
committed
Added right to left languages support
1 parent a8e39b4 commit 2d29367

File tree

86 files changed

+4283
-3820
lines changed

Some content is hidden

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

86 files changed

+4283
-3820
lines changed

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 = '0.2.6'
3+
s.version = '0.3.0'
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

+29
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public final class ChatLayout: UICollectionViewLayout {
7575

7676
// MARK: Inherited Properties
7777

78+
/// The direction of the language you used when designing `ChatLayout` layout.
79+
public override var developmentLayoutDirection: UIUserInterfaceLayoutDirection {
80+
return .leftToRight
81+
}
82+
83+
/// A Boolean value that indicates whether the horizontal coordinate system is automatically flipped at appropriate times.
84+
public override var flipsHorizontallyInOppositeLayoutDirection: Bool {
85+
return _flipsHorizontallyInOppositeLayoutDirection
86+
}
87+
7888
/// Custom layoutAttributesClass is `ChatLayoutAttributes`.
7989
public override class var layoutAttributesClass: AnyClass {
8090
return ChatLayoutAttributes.self
@@ -149,12 +159,31 @@ public final class ChatLayout: UICollectionViewLayout {
149159
// animations up-to-date as items are self-sized. If we don't keep these copies up-to-date, then
150160
// animations will start from the estimated height.
151161
private var attributesForPendingAnimations = [ItemKind: [IndexPath: ChatLayoutAttributes]]()
162+
152163
private var invalidatedAttributes = [ItemKind: Set<IndexPath>]()
153164

154165
private var dontReturnAttributes: Bool = true
155166

156167
private var currentPositionSnapshot: ChatLayoutPositionSnapshot?
157168

169+
private let _flipsHorizontallyInOppositeLayoutDirection: Bool
170+
171+
// MARK: Constructors
172+
173+
/// - Parameters:
174+
/// - flipsHorizontallyInOppositeLayoutDirection: Indicates whether the horizontal coordinate
175+
/// system is automatically flipped at appropriate times. In practice, this is used to support
176+
/// right-to-left layout.
177+
public init(flipsHorizontallyInOppositeLayoutDirection: Bool = true) {
178+
self._flipsHorizontallyInOppositeLayoutDirection = flipsHorizontallyInOppositeLayoutDirection
179+
super.init()
180+
}
181+
182+
required init?(coder aDecoder: NSCoder) {
183+
self._flipsHorizontallyInOppositeLayoutDirection = true
184+
super.init(coder: aDecoder)
185+
}
186+
158187
// MARK: Custom Methods
159188

160189
/// Get current offset of the item closest to the provided edge.

ChatLayout/Classes/Extras/ImageMaskedView.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ public final class ImageMaskedView<CustomView: UIView>: UIView {
8888

8989
private func updateMask() {
9090
UIView.performWithoutAnimation {
91+
let multiplier = effectiveUserInterfaceLayoutDirection == .leftToRight ? 1 : -1
9192
switch maskTransformation {
9293
case .flippedVertically:
93-
imageView.transform = CGAffineTransform(scaleX: -1, y: 1)
94+
imageView.transform = CGAffineTransform(scaleX: CGFloat(multiplier * -1), y: 1)
9495
case .asIs:
95-
imageView.transform = CGAffineTransform(scaleX: 1, y: 1)
96+
imageView.transform = CGAffineTransform(scaleX: CGFloat(multiplier * 1), y: 1)
9697
}
9798
}
9899
}

Example/Tests/StateControllerProcessUpdatesTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,5 +379,5 @@ class StateControllerProcessUpdatesTests: XCTestCase {
379379
}
380380
}
381381
}
382-
382+
383383
}

docs/Classes/CellLayoutContainerView.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 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-09-07)</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-09-08)</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

+116-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -342,6 +342,60 @@ <h3 class="section-name"><p>Inherited Properties</p>
342342
</div>
343343
</div>
344344
<ul class="item-container">
345+
<li class="item">
346+
<div>
347+
<code>
348+
<a name="/c:@M@ChatLayout@objc(cs)ChatLayout(py)developmentLayoutDirection"></a>
349+
<a name="//apple_ref/swift/Property/developmentLayoutDirection" class="dashAnchor"></a>
350+
<a class="token" href="#/c:@M@ChatLayout@objc(cs)ChatLayout(py)developmentLayoutDirection">developmentLayoutDirection</a>
351+
</code>
352+
</div>
353+
<div class="height-container">
354+
<div class="pointer-container"></div>
355+
<section class="section">
356+
<div class="pointer"></div>
357+
<div class="abstract">
358+
<p>The direction of the language you used when designing <code>ChatLayout</code> layout.</p>
359+
360+
</div>
361+
<div class="declaration">
362+
<h4>Declaration</h4>
363+
<div class="language">
364+
<p class="aside-title">Swift</p>
365+
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">override</span> <span class="k">var</span> <span class="nv">developmentLayoutDirection</span><span class="p">:</span> <span class="kt">UIUserInterfaceLayoutDirection</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
366+
367+
</div>
368+
</div>
369+
</section>
370+
</div>
371+
</li>
372+
<li class="item">
373+
<div>
374+
<code>
375+
<a name="/c:@M@ChatLayout@objc(cs)ChatLayout(py)flipsHorizontallyInOppositeLayoutDirection"></a>
376+
<a name="//apple_ref/swift/Property/flipsHorizontallyInOppositeLayoutDirection" class="dashAnchor"></a>
377+
<a class="token" href="#/c:@M@ChatLayout@objc(cs)ChatLayout(py)flipsHorizontallyInOppositeLayoutDirection">flipsHorizontallyInOppositeLayoutDirection</a>
378+
</code>
379+
</div>
380+
<div class="height-container">
381+
<div class="pointer-container"></div>
382+
<section class="section">
383+
<div class="pointer"></div>
384+
<div class="abstract">
385+
<p>A Boolean value that indicates whether the horizontal coordinate system is automatically flipped at appropriate times.</p>
386+
387+
</div>
388+
<div class="declaration">
389+
<h4>Declaration</h4>
390+
<div class="language">
391+
<p class="aside-title">Swift</p>
392+
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">override</span> <span class="k">var</span> <span class="nv">flipsHorizontallyInOppositeLayoutDirection</span><span class="p">:</span> <span class="kt">Bool</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
393+
394+
</div>
395+
</div>
396+
</section>
397+
</div>
398+
</li>
345399
<li class="item">
346400
<div>
347401
<code>
@@ -425,6 +479,66 @@ <h4>Declaration</h4>
425479
</li>
426480
</ul>
427481
</div>
482+
<div class="task-group">
483+
<div class="task-name-container">
484+
<a name="/Constructors"></a>
485+
<a name="//apple_ref/swift/Section/Constructors" class="dashAnchor"></a>
486+
<div class="section-name-container">
487+
<a class="section-name-link" href="#/Constructors"></a>
488+
<h3 class="section-name"><p>Constructors</p>
489+
</h3>
490+
</div>
491+
</div>
492+
<ul class="item-container">
493+
<li class="item">
494+
<div>
495+
<code>
496+
<a name="/s:10ChatLayoutAAC027flipsHorizontallyInOppositeB9DirectionABSb_tcfc"></a>
497+
<a name="//apple_ref/swift/Method/init(flipsHorizontallyInOppositeLayoutDirection:)" class="dashAnchor"></a>
498+
<a class="token" href="#/s:10ChatLayoutAAC027flipsHorizontallyInOppositeB9DirectionABSb_tcfc">init(flipsHorizontallyInOppositeLayoutDirection:<wbr>)</a>
499+
</code>
500+
</div>
501+
<div class="height-container">
502+
<div class="pointer-container"></div>
503+
<section class="section">
504+
<div class="pointer"></div>
505+
<div class="abstract">
506+
507+
</div>
508+
<div class="declaration">
509+
<h4>Declaration</h4>
510+
<div class="language">
511+
<p class="aside-title">Swift</p>
512+
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">flipsHorizontallyInOppositeLayoutDirection</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">)</span></code></pre>
513+
514+
</div>
515+
</div>
516+
<div>
517+
<h4>Parameters</h4>
518+
<table class="graybox">
519+
<tbody>
520+
<tr>
521+
<td>
522+
<code>
523+
<em>flipsHorizontallyInOppositeLayoutDirection</em>
524+
</code>
525+
</td>
526+
<td>
527+
<div>
528+
<p>Indicates whether the horizontal coordinate
529+
system is automatically flipped at appropriate times. In practice, this is used to support
530+
right-to-left layout.</p>
531+
</div>
532+
</td>
533+
</tr>
534+
</tbody>
535+
</table>
536+
</div>
537+
</section>
538+
</div>
539+
</li>
540+
</ul>
541+
</div>
428542
<div class="task-group">
429543
<div class="task-name-container">
430544
<a name="/Custom%20Methods"></a>
@@ -1105,7 +1219,7 @@ <h4>Declaration</h4>
11051219
</article>
11061220
</div>
11071221
<section class="footer">
1108-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
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-09-08)</p>
11091223
<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>
11101224
</section>
11111225
</body>

docs/Classes/ChatLayoutAttributes.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 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-09-07)</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-09-08)</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>

docs/Classes/ChatLayoutInvalidationContext.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -197,7 +197,7 @@ <h4>Declaration</h4>
197197
</article>
198198
</div>
199199
<section class="footer">
200-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
200+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
201201
<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>
202202
</section>
203203
</body>

docs/Classes/ContainerCollectionReusableView.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -373,7 +373,7 @@ <h4>Parameters</h4>
373373
</article>
374374
</div>
375375
<section class="footer">
376-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
376+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
377377
<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>
378378
</section>
379379
</body>

docs/Classes/ContainerCollectionViewCell.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -373,7 +373,7 @@ <h4>Parameters</h4>
373373
</article>
374374
</div>
375375
<section class="footer">
376-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
376+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
377377
<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>
378378
</section>
379379
</body>

docs/Classes/EdgeAligningView.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -357,7 +357,7 @@ <h4>Parameters</h4>
357357
</article>
358358
</div>
359359
<section class="footer">
360-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
360+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
361361
<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>
362362
</section>
363363
</body>

docs/Classes/EdgeAligningView/Edge.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -277,7 +277,7 @@ <h4>Declaration</h4>
277277
</article>
278278
</div>
279279
<section class="footer">
280-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
280+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
281281
<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>
282282
</section>
283283
</body>

docs/Classes/ImageMaskedView.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -397,7 +397,7 @@ <h4>Declaration</h4>
397397
</article>
398398
</div>
399399
<section class="footer">
400-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
400+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
401401
<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>
402402
</section>
403403
</body>

docs/Classes/MessageContainerView.html

+2-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 0.2.5 Docs
24+
ChatLayout 0.3.0 Docs
2525
</a>
2626
(100% documented)
2727
</p>
@@ -343,7 +343,7 @@ <h4>Parameters</h4>
343343
</article>
344344
</div>
345345
<section class="footer">
346-
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-07)</p>
346+
<p>&copy; 2020 <a class="link" href="https://github.com/ekazaev" target="_blank" rel="external">Evgeny Kazaev</a>. All rights reserved. (Last updated: 2020-09-08)</p>
347347
<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>
348348
</section>
349349
</body>

0 commit comments

Comments
 (0)