Skip to content

Commit

Permalink
Merge branch 'master' into basher/add-collection-conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
benasher44 authored Aug 28, 2018
2 parents 535d58c + 04812d8 commit e69beed
Show file tree
Hide file tree
Showing 69 changed files with 245 additions and 216 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ This release closes the [0.2.0 milestone](https://github.com/plangrid/ReactiveLi

- `TableSectionViewModel` and `CollectionSectionViewModel` now implement `Collection` ([#135](https://github.com/plangrid/ReactiveLists/pull/135), [@benasher44](https://github.com/benasher44))

0.1.4
-----

This release closes the [0.1.4 milestone](https://github.com/plangrid/ReactiveLists/milestone/7).

### Fixed

Don't store an empty model for the first non-nil differ. ([#137](https://github.com/plangrid/ReactiveLists/pull/137), [@benasher44](https://github.com/benasher44))

0.1.3
-----

Expand Down
2 changes: 1 addition & 1 deletion ReactiveLists.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ReactiveLists"
s.version = "0.1.3"
s.version = "0.1.4"

s.summary = "React-like API for UITableView and UICollectionView"
s.homepage = "https://github.com/plangrid/ReactiveLists"
Expand Down
5 changes: 3 additions & 2 deletions Sources/CollectionViewDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class CollectionViewDriver: NSObject {

private var _shouldDeselectUponSelection: Bool

private var _differ: CollectionViewDiffCalculator<DiffingKey, DiffingKey>?
// internal for testing
var _differ: CollectionViewDiffCalculator<DiffingKey, DiffingKey>?
private let _automaticDiffingEnabled: Bool
private var _didReceiveFirstNonNilNonEmptyValue = false

Expand Down Expand Up @@ -144,7 +145,7 @@ public class CollectionViewDriver: NSObject {
self.collectionView.reloadData()

if self._automaticDiffingEnabled
&& self.collectionViewModel != nil
&& !nextStateNilOrEmpty
&& !self._didReceiveFirstNonNilNonEmptyValue {
// Special case for the first non-nil value
// Now that we have this initial state, setup the differ with that initial state,
Expand Down
5 changes: 3 additions & 2 deletions Sources/TableViewDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ open class TableViewDriver: NSObject {

private let _shouldDeselectUponSelection: Bool

private var _differ: TableViewDiffCalculator<DiffingKey, DiffingKey>?
// internal for testing
var _differ: TableViewDiffCalculator<DiffingKey, DiffingKey>?
private let _automaticDiffingEnabled: Bool
private var _didReceiveFirstNonNilNonEmptyValue = false

Expand Down Expand Up @@ -171,7 +172,7 @@ open class TableViewDriver: NSObject {
self.tableView.reloadData()

if self._automaticDiffingEnabled
&& self.tableViewModel != nil
&& !nextStateNilOrEmpty
&& !self._didReceiveFirstNonNilNonEmptyValue {
// Special case for the first non-nil value
// Now that we have this initial state, setup the differ with that initial state,
Expand Down
9 changes: 9 additions & 0 deletions Tests/CollectionView/CollectionViewDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ final class CollectionViewDriverTests: XCTestCase {
XCTAssertEqual(footer?.accessibilityIdentifier, "access_footer+0")
}

/// The setting an empty model shouldn't trigger diffing setup
func testDifferNotSetForEmptyModel() {
let collectionView = TestCollectionView(frame: .zero, collectionViewLayout: UICollectionViewLayout())
let dataSource = CollectionViewDriver(collectionView: collectionView)
XCTAssertNil(dataSource._differ)
dataSource.collectionViewModel = CollectionViewModel(sectionModels: [])
XCTAssertNil(dataSource._differ)
}

private func _getItem(_ path: IndexPath) -> TestCollectionViewCell? {
guard let cell = self._collectionViewDataSource.collectionView(self._collectionView,
cellForItemAt: path) as? TestCollectionViewCell else { return nil }
Expand Down
9 changes: 9 additions & 0 deletions Tests/TableView/TableViewDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ final class TableViewDriverTests: XCTestCase {
XCTAssertNil(defaultCellViewModel.accessoryButtonTapped)
XCTAssertFalse(defaultCellViewModel.shouldIndentWhileEditing)
}

/// The setting an empty model shouldn't trigger diffing setup
func testDifferNotSetForEmptyModel() {
let tableView = TestTableView()
let dataSource = TableViewDriver(tableView: tableView)
XCTAssertNil(dataSource._differ)
dataSource.tableViewModel = TableViewModel(sectionModels: [])
XCTAssertNil(dataSource._differ)
}
}

// MARK: Test data generation
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/CollectionViewDriver.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ <h4>Declaration</h4>
<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">collectionViewModel</span><span class="p">:</span> <span class="nf">CollectionViewModel</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">collectionViewModel</span><span class="p">:</span> <span class="kt"><a href="../Structs/CollectionViewModel.html">CollectionViewModel</a></span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -366,7 +366,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
4 changes: 2 additions & 2 deletions docs/Classes/TableViewDriver.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ <h4>Declaration</h4>
<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">tableViewModel</span><span class="p">:</span> <span class="nf">TableViewModel</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">tableViewModel</span><span class="p">:</span> <span class="kt"><a href="../Structs/TableViewModel.html">TableViewModel</a></span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -430,7 +430,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/TableViewDriver/TableRefreshContext.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/SupplementaryViewKind.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/ViewRegistrationMethod.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Guides.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h1>Guides</h1>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
10 changes: 5 additions & 5 deletions docs/Protocols/CollectionCellViewModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ <h1>CollectionCellViewModel</h1>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">accessibilityFormat</span><span class="p">:</span> <span class="nf">CellAccessibilityFormat</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">accessibilityFormat</span><span class="p">:</span> <span class="kt">CellAccessibilityFormat</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -200,7 +200,7 @@ <h4>Default Implementation</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">shouldHighlight</span><span class="p">:</span> <span class="nf">Bool</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">shouldHighlight</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>

</div>
</div>
Expand Down Expand Up @@ -235,7 +235,7 @@ <h4>Default Implementation</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">didSelect</span><span class="p">:</span> <span class="nf">DidSelectClosure</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">didSelect</span><span class="p">:</span> <span class="kt">DidSelectClosure</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -270,7 +270,7 @@ <h4>Default Implementation</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">didDeselect</span><span class="p">:</span> <span class="nf">DidDeselectClosure</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">didDeselect</span><span class="p">:</span> <span class="kt">DidDeselectClosure</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -329,7 +329,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
6 changes: 3 additions & 3 deletions docs/Protocols/CollectionSupplementaryViewModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h4>Default Implementation</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">viewInfo</span><span class="p">:</span> <span class="nf">SupplementaryViewInfo</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">viewInfo</span><span class="p">:</span> <span class="kt"><a href="../Structs/SupplementaryViewInfo.html">SupplementaryViewInfo</a></span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -208,7 +208,7 @@ <h4>Default Implementation</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">height</span><span class="p">:</span> <span class="nf">CGFloat</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">height</span><span class="p">:</span> <span class="kt">CGFloat</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -267,7 +267,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-07-16)</p>
<p>&copy; 2018 <a class="link" href="https://twitter.com/PlanGrid" target="_blank" rel="external">PlanGrid</a>. All rights reserved. (Last updated: 2018-08-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
Loading

0 comments on commit e69beed

Please sign in to comment.