331 Commits

Author SHA1 Message Date
Huy Nguyen
74c6cca0b6 [ASDataController] Refactor ASDataController (#3017)
* Refactor ASDataController

Check optional methods in ASDataControllerSource

* Reimplement reloadData

* Refactor new code
- No more new/inserted contexts flag
- Encapsulate code shared between reloadData and updateWithChangeSet
- Remove dataControllerWillDeleteAllData delegate method
- Hierarchy changes no longer needs to conform to NSCopying
- Reword TODOs

* Forgot to call completion block of reloadData :P

* Completion block of -[ASDataController reloadDataWithCompletion:] is nullable

* Data queried from ASCollectionNode and ASTableNode should be in UIKit index space
- This helps to avoid immature node allocation, especially when node virtualization is a thing
- However, this means that -reloadDataInitiallyIfNeeded in ASCollectionNode and ASTableNode must wait until all updates are finished.

* ASDataController shouldn't assume that allocated nodes were also laid out

* Revert "Data queried from ASCollectionNode and ASTableNode should be in UIKit index space"

This reverts commit 7bc977b3808a92f484b297781d0f5b30aa258e17.

* -nodeAtIndexPath: of ASDataController now forces node allocation, with the assumption that clients absolutely need it.
- Revisit this when node virtualization is implemented.

* ASDataController only grab changeSet.completionHandler when needed because it'll be niled out

* Fix ASTableViewTests related to reloadData

* Fix testThatDeletedItemsAreMarkedInvisible in ASCollectionViewTests

* Minor changes in ASCollectionView and ASTableView

* ASCollectionView and ASTableView shouldn't call [super reloadData] before their data controller does anything

* Address comments

* Fuse reloadData into -updateWithChangeSet: of ASDataController

* reloadData shouldn't be called as if it's inside a batch
- It can't be used in conjuntion with other updates.
- Calling it inside a batch update during the initial load can cause data inconsistency thrown by UICollectionView/UITableView

* Refactor ASDataControllerDelegate and ASRangeControllerDelegate
- Replace delegate methods in these protocols with -willUpdateWithChangeSet and -didUpdateWithChangeSet.
- ASRangeController, ASCollectionView and ASTableView are simplified because of this.

* Fix mismatch between sorting orders in ASDataController

* Forgot to call completion handler of reload change sets

* Make sure ASCollectionView is compatible with the behavior of UICollectionView's reloadData
- Since UICollectionView's reloadData doesn't requery data source but defers until the next layout pass,  we need to wait until then to update range controller and do batch fetching.
- `-[ASCollectionView waitUntilAllUpdatesAreCommited]` needs to force a layout pass to make sure
everything is ready after it returns.

* testSectionIndexHandling of ASTableViewTests should only check visible nodes. Other nodes will be re-measured later.

* ASTableView is not ready until the first layout pass finished

* Address comments

* Bug fixes
2017-02-22 13:50:07 -08:00
Adlai Holler
b616248c20 Majorly Improve automaticallyAdjustsContentOffset (#3033)
* Majorly improve automaticallyAdjustsContentOffset

* Remove nodes from ASDataControllerDelegate & ASRangeControllerDelegate

* Do it after -endUpdates
2017-02-15 11:57:39 -08:00
Vadim Novoseltsev
b6935448d6 selectedBackgroundView (#2875) 2017-02-15 10:37:45 -08:00
Adlai Holler
a4c6d8912e Don't Skip Remeasurement On First Layout Pass (#3031)
* Don't Skip Remeasurement if Initial Bounds are Zero

* Remove misleading unit test
2017-02-14 16:28:26 -08:00
Adlai Holler
fab98b32ef Fix Pager Node Issues (#3028)
* Fix pager node and deprecate zeroContentInsets flag

* Do it with the visible state callback

* There we are

* Put viewController in node debug description
2017-02-14 14:10:51 -08:00
Adlai Holler
0badff651a Revert "Route setDelegate: to setAsyncDelegate: (#3007)" (#3023)
This reverts commit 5c8818d107252da8eb6a91cf88237916ec26f5ed.
2017-02-13 10:38:19 -08:00
Adlai Holler
5c8818d107 Route setDelegate: to setAsyncDelegate: (#3007)
* Make ASTableView/ASCollectionView delegate/dataSource unavailable, route setDelegate: to setAsyncDelegate:

* Remove deprecated method from example

* Drop down from unavailable to deprecated
2017-02-09 15:20:26 -08:00
Adlai Holler
a13b36d63f Allow UICollectionViewLayout to Provide Layout Inspector, Always Update Delegate (#3003)
* Allow UICollectionViewLayout to give us a layout inspector, always call the didChangeDelegate/didChangeDataSource on binding

* Make an assertion

* Update the tests

* Tests use actual layout inspector

* Be more consistent
2017-02-08 22:03:13 -08:00
Adlai Holler
abd9851ddd Restore IGListKit Build & Function (#2988) 2017-02-06 20:00:22 -08:00
Scott Goodson
f71eba77af [ASCollectionView] Finish support for interoperability with base-class UICollectionViewCells.
This also supports supplementary nodes. It builds off of Adlai's .interop flag but makes necessary
improvements for all of the delegate methods to work in practice with heterogenous cell types.
2017-02-04 20:40:44 -08:00
Michael Schneider
12e4e5b048 [Layout] Improve Layout System Abstraction (#2941)
* Improve Layout Abstraction

* Address naming comments

- Rename ASPrimitiveTraitEnvironment to ASTraitEnvironment
- Rename ASPrimitiveTraitCollectionPropagateDown to ASTraitCollectionPropagateDown
- Rename progagateNewPrimitiveTraitCollection: to propagateNewTraitCollection:
2017-02-03 13:04:20 -08:00
Adlai Holler
404795dc02 Remove Support for iOS 7 (#2930)
* Drop support for iOS 7

* Copy reference images

* Update deployment for sample projects

* Update version

* Update "Life Without Cocoapods"
2017-02-01 14:40:37 -08:00
Adlai Holler
38aac9d019 IGListKit Support II: Electric Boogaloo (#2942)
* Reimplement IGListKit support in a cleaner way

* Rename and fix some stuff

* Fix supplementaries more

* Update docs

* Update test

* Cleanup minor things

* Tweak it

* Indentation

* Remove irrelevant changes

* Break out cell into its own file

* Fix indentation

* Address feedback
2017-01-30 11:16:59 -08:00
Adlai Holler
295ed22c23 Improve Our Handling of Flow Layout Headers/Footers (#2939)
* Rejigger our flow layout supplementary support to make more sense.

* Support old protocol

* Update

* Update deprecation message

* Undeprecate insetForSection method, because it actually _does_ still work

* Update the tests

* Remove irrelevant junk

* Remove cast, add pragma
2017-01-27 15:58:43 -08:00
Huy Nguyen
38f1efd448 [ASDataController] Simplify data controller (#2923)
* Start removing ASChangeSetDataController

* Continue removing ASChangeSetDataController

* Remove unnecessary change

* ASDataController is no longer an abstract class, remove its assertion

* Get back beginUpdates and endUpdatesAnimated:completion in ASCollectionNode
2017-01-24 17:41:19 -08:00
aaronschubert0
b3be451486 [ASTableNode/ASCollectionNode] Inversion (#2891)
* Add inverted property to ASTableNode

* Add inverted property to ASCollectionNode

* Add example

* De-inform data controller and use different CATransform3D

* Add logic to pending state

* Add accessor for inverted property
2017-01-19 18:16:01 -08:00
Adlai Holler
e69a475d2b Minor Collection Simplifications (#2906)
* Minor collection simplifications

* Remove didChangeCollectionViewDataSource call, restrict subclassing ASCollectionViewFlowLayoutInspector
2017-01-19 13:57:03 -08:00
Adlai Holler
98a95a6907 Pin collection cellNode.frame = contentView.bounds (#2884) 2017-01-11 12:47:12 -08:00
Saif Al-Dilaimi
c85aa11dbb Adding section to passthrough properties (#2847)
* added accessoryType to ASCellNode

* Moved the passthrough properties in an own section in ASEditableTextNode

* added documentation and reverted ASEditableCellNode changes

* fixed code signing

* adding seperatorInset property as a passthrough property

* revert changes to project file

* moved setting properties to setNode:

* moved clipsToBounds to setNode
2017-01-09 18:26:51 -08:00
Adlai Holler
d65fe8b5fa Disable UICollectionView prefetching to improve scroll performance (#2861) 2017-01-04 13:30:23 -08:00
Adlai Holler
4a6ba2761b ASDataController: Correctly Handle Nil IndexPath in nodeForIndexPath: Methods (#2856)
* ASDataController: Correctly handle fetching node at nil index path (return nil).

* Be more aggressive, in order to avoid needlessly waiting for updates to complete
2017-01-03 14:45:16 -08:00
Adlai Holler
2ea7d4c1c0 By default, capture the current animation enabledness for collection/table updates (#2827) 2016-12-23 09:46:49 -05:00
Michael Schneider
57cd6a3ba8 [ASPagerNode] Fix content insets are wrong in pager node if root node of ASViewController and transition back (#2736)
* Fix content insets are wrong in pager node if root node of ASViewController and transition back

* Add unit test

* Improve test

* Fix test

* Move tests to ASPagerNodeTests
2016-12-12 16:05:09 -08:00
Adlai Holler
7de2decdcb Allow section-indexpaths in collection & table validation (#2727) 2016-12-07 13:36:15 -08:00
Adlai Holler
45c69ada36 Add some index path validation to avoid production crashes (#2716) 2016-12-05 16:37:44 -08:00
Adlai Holler
9bc58dc024 When not visible, only batch fetch to fill visible area 2016-12-05 15:00:39 -08:00
Adlai Holler
051b738236 Inject data source class name into update validation exceptions, deprecate suppression flag (#2692) 2016-12-01 17:30:36 -08:00
Garrett Moon
ba2268ac99 2611 rename fetch data (#2689)
* Replace fetch data with preload terminology
- Deprecate `-fetchData` and `-clearFetchedData` in favor of `-preload` and `-clearPreloadedData`
- Move `-setNeedsPreload`, `-recursivelyPreload` and `-recursivelyClearPreloadedData` to ASDisplayNode+FrameworkPrivate.h
- Update internal implementation, comments and tests

* Folllow up on #2642:
- Remove -preload and -clearPreloadedData in favor of -didEnterPreloadState and -didExitPreloadState.
- -didEnterPreloadState and -didExitPreloadState call the deprecated -fetchData and -clearFetchedData methods if they are overriden.

* Missed one in a test

* Get rid of behavior change for now.

* Revert more behavior changes, fix tests.

* Don't need these anymore.
2016-12-01 13:41:22 -08:00
Adlai Holler
df497b82c2 Improve Batch Fetching Call Pattern to Reduce Fetch Calls (#2675)
* Test & tweak batch fetching implementation

* Tighten the test

* Stop batch fetching at the end of range controller pass

* Clean up the test

* Still check for batch fetching after each frame when scrolling

* Ensure batch fetching happens for empty collection/table
2016-11-29 13:40:03 -08:00
Adlai Holler
6d01bbeb19 Let nodes deallocate naturally, manually trampoline UIKit ivars
Be more aggressive with main thread punting

Trampoline setting the dataSource/delegate onto the main thread

Short-circuit the supplementary nodes method if no data source

Don't rely on assertions

Mark variable unused to fix release builds

Handle ASCollectionNode/ASTableNode deallocation better

Add some comments about new macro
2016-11-21 00:46:57 +09:00
Garrett Moon
2284914c36 If you override the property, you need to specify __weak (#2631) 2016-11-19 07:42:44 +09:00
Hannah Trosi
6565b8348d collectionView 2016-11-17 16:46:07 +09:00
Michael Schneider
44aa582ceb Fix crash if batch update blocks are nil although method declaration allows nullable (#2599) 2016-11-14 10:15:11 +09:00
Hannah Troisi
edf2b669ae [ASCollectionViewLayoutInspecting] make -scrollableDirections required (#2543)
* [ASCollectionViewLayoutInspecting] make -scrollableDirections a required method

* doh!

* fixed?

* add assert per @appleguy's comment

* use self.layoutInspector, add check at the start of didChangeBounds...
2016-11-09 13:48:16 +09:00
Huy Nguyen
fb6d1830a0 Beter table/collection update history (#2562)
- Introduce thread-safe ASEventLog
- ASCollectionNode and ASTableNode share their event log with their ASDataController. The controller uses it to log change set submitting and finishing events.
- ASCollectionNode and ASTableNode print their data source and delegate in their debug description.
2016-11-08 16:44:49 -08:00
Adlai Holler
a6e2f8e5ab Finish Porting indexPath-Oriented Methods to ASTableNode/ASCollectionNode (#2527)
* Finish porting over the indexPath-oriented properties from table/collection view to node

* Make indexPathForSelectedRow a property
2016-11-01 15:03:46 -07:00
george-gw
d83f058f82 Deprecate indexPath-based Methods on ASTableView/ASCollectionView (#2498)
* Deprecated indexPath methods in ASTableView and ASTableNode and added several indexPath methods to ASTableNode and ASCollectionNode.

* Fixed incorrect doc.
Removed unnecessary __kindof.
2016-10-29 09:50:11 -07:00
Adlai Holler
627d146a5a Add scrollToItem: Method to Node, Handle Section Index Paths (#2462)
* Add scrollToItem: method to node, handle section index paths

* Update ASPagerNode.mm to use the node version

* Add some docs
2016-10-26 12:48:25 -07:00
Garrett Moon
5651606684 [ASCollectionView] layoutInspector can be nil'd at anytime making flags unsafe (#2473)
* Call layoutInspector before checking flags. Thanks @adlai!

* Don't create layout inspector with nil layout.
2016-10-26 11:42:29 -07:00
Adlai Holler
12534ee6fb Handle nil in selectItem/RowAtIndexPath: (#2477) 2016-10-24 20:11:47 -07:00
Adlai Holler
67489492ee Fix Uncalled Collection Delegate Methods (#2433)
* Fix batch fetching

* Fix not calling constrainedSizeForItemAtIndexPath:

* Fix constrainedSizeForItemAtIndexPath: not being called
2016-10-19 11:49:49 -07:00
Michael Schneider
ae9e128214 Layout inspector instance variable should be weak in ASCollectionView (#2405) 2016-10-17 10:51:54 -07:00
Adlai Holler
c2ea7cfeac [Umbrella] ASCollectionView -> ASCollectionNode Migration, Separate Index Spaces (#2372)
* Separate dataSource & UIKit index spaces

Beef up our supplementary node support

Make the API way better

Go nuts

Add a unit test for UICollectionView's handling of reloadData inside batch updates

Wrap indexPathForNode: in a cache

Convert index paths in delegate methods

Go back on table view

Put collection view back

Switch up the API

Move most ASCollectionView API to ASCollectionNode

Move most table logic over to ASTableNode

Do the things

More conversion work

Keep on keepin' on

Get table view delegate API done

More porting

Simplify

Clear the delegate

More cleanup

Move more stuff around

Remove pointless file

Re-add some API

Put back more API

Use the right flag

* Some cleanup

* Remove incorrect comment

* Tweak the API

* Put back a couple methods

* update example projects (note: ASCollectionView deprecation warnings expected)

* change reloadDataWithCompletion:nil --> reloadData

* Clean up rebase

* Make deprecated numberOfItemsInSection methods optional

* Use the right flag

* Address nits

* update ASDKTube, ASDKgram & ASViewController examples
2016-10-14 17:21:16 -07:00
Garrett Moon
1d28639301 [ASCollectionNode] Add scrollableDirections method to ASCollectionViewLayoutInspecting p… (#2381)
* Add scrollableDirections method to ASCollectionViewLayoutInspecting protocol

ASViewController's default method will not always return the correct scrollable
directions in cases where size changes may not have been applied. This allows
us to ignore this issue for a little while longer by allowing the layout
inspector to explicitly vend this.

* Better header, thanks @maicki!
2016-10-14 09:39:28 -07:00
Adlai Holler
60b40d8e1c Revert "Scrollable direction is invalid until a relayout. (#2375)" (#2377)
This reverts commit 9abae013a7c2510ead0ea7bf7cffdba54d7f9e08.
2016-10-13 11:24:57 -07:00
Garrett Moon
9abae013a7 Scrollable direction is invalid until a relayout. (#2375) 2016-10-13 10:51:23 -07:00
Adlai Holler
aece8365dd Adjust layoutAttributes logic to account for new iOS 10 behavior (#2354) 2016-10-06 19:42:36 -07:00
Adlai Holler
bb366d14f0 [ASCellNode] Restore Layout Attributes Fix + iOS 10 Modification (#2335)
* [ASCellNode] Fix applyLayoutAttributes not called, add readonly layoutAttributes property (#2321)

* Clear cell node layout attributes in didEndDisplayingCell: also
2016-10-05 17:31:46 -04:00
Adlai Holler
ba2e12010b [ASCollectionView] Only remeasure all nodes if bounds changed in a fixed dimension (#2343) 2016-10-04 18:12:34 -04:00
Adlai Holler
67045c07b8 Handle nil node blocks gracefully in production (#2338) 2016-10-03 20:06:13 -04:00