20 Commits

Author SHA1 Message Date
ricky
637c4f3a9f [ASTraitCollection] Remove traitCollectionContext from ASTraitCollection; add containerWindowSize
Passing around a pointer was leading to crashes as the ASVC was the sole owner of the context. There are cases where the VC would dealloc while its subnodes were laying out. This could lead to the subnodes accessing a garbage pointer.
2016-07-07 09:23:37 -07:00
Hannah Troisi
c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
ricky
501fed16aa nil out displayContext when we get a new one
Summary: Don't set the new one in the subnodes yet as this will cause ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection to return NO if only the displayContext changed.

Reviewers: garrett, levi, rmalik

Reviewed By: garrett, levi, rmalik

Subscribers: rmalik

Differential Revision: https://phabricator.pinadmin.com/D94320
2016-06-02 10:33:32 -07:00
Garrett Moon
af7a2f09d7 Add support for visibility depth
This adds support for the concept of visibility depth.

Visibility essentially defines the number of user actions it would
take a user to have a view controller visible. Knowing a view controllers
visibility depth allows view controllers to take action such as clearing
out memory that can be restored at a later date.

This patch also add two new view controller subclasses which adopt
the ASManagesChildVisibilityDepth protocol. Any view controller
that has child view controllers can adopt this protocol to indicate
to the child what they're visibility is. For example, ASNavigationController
will return a visibility depth of it's own visibilityDepth + 1 for
a view controller that would be revealed by tapping the back button.
2016-05-12 13:42:05 -07:00
rcancro
4b54144f55 Levi's comments 2016-05-11 10:21:11 -07:00
rcancro
9d622c7eac changed DisplayTraits to TraitCollection 2016-05-10 14:45:03 -07:00
rcancro
f828d079fa added nsobject based ASDisplayTraits class 2016-05-10 14:44:43 -07:00
rcancro
b4a6f87ca6 addressed some comments 2016-05-10 14:44:32 -07:00
rcancro
8bb4eba080 Initial attempt at implementing Display Traits
Initial attempt to get display traits working with ASEnvironment.

To get proper ASDisplayTraits support, you must use an ASViewController. The ASViewController implements UITraitCollection-related methods (`traitCollectionDidChange:`, `willTransitionToTraitCollection:withTransitionCoordinator:`, viewWillTransitionToSize:withTransitionCoordinator`) to update the internal ASDisplayTraits and propagate them to subnodes.

ASTableNode and ASCollectionNode don't actually have their cells as subnodes, so a little bit of trickery is involved (on `setEnvironment:` the table/collection node gets its data controllers completedNodes and propagates the new traits. see `ASDisplayTraitsCollectionTableSetEnvironmentState`). The data controller also passes the current display traits when creating new cells.

ASViewController also supports the ability to return a custom set of display traits. So if you have a modal dialog that should always be told it is in a compact size class, you can set the override block before displaying the VC.

A new example, called Display Traits, has been added. It shows how display traits can be used in a ASViewController with a normal ASDisplayNode as its root, as well as in ASViewControllers hosting table nodes and collection nodes. There is also an example of overriding the default display traits of a VC.

Please provide feedback!
2016-05-10 14:44:22 -07:00
Rahul Malik
a509b7523f Update interface of ASViewController to use lightweight generics. This allows
subclasses of ASViewController to specify the type of ASDisplayNode it
contains which allows for stronger type-checking and auto-completion against
the specified type.

Example Subclass Declaration:
@interface MyASViewController : ASViewController<MyASDisplayNodeSubclass *>
@end
2016-01-03 18:56:09 -08:00
Scott Goodson
882d4b336e Merge branch 'master' into pr/664 2015-12-25 14:32:41 -08:00
Scott Goodson
065625f246 Make ASCollectionView always create an ASCollectionNode. Add visibilityDidChange:, interfaceStateDidChange:fromState: 2015-12-22 21:46:46 -08:00
Adlai Holler
b4b88da8cd Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASCellNode.h
2015-11-02 09:36:46 -08:00
Levi McCallum
03bd1f4358 Expose ASViewController's constrained size for subclass customization 2015-10-27 11:40:43 -07:00
Adlai Holler
8bb9d173dc Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASDisplayNode+Subclasses.h
	AsyncDisplayKit/ASMultiplexImageNode.h
	AsyncDisplayKit/ASViewController.h
	AsyncDisplayKit/Details/ASDataController.h
2015-10-05 13:24:16 -07:00
Scott Goodson
a58844379c Implementation of Synchronous Concurrency features for AsyncDisplayKit 2.0
This provides internal features on _ASAsyncTransaction and ASDisplayNode to facilitate
implementing public API that allows clients to choose if they would prefer to block
on the completion of unfinished rendering, rather than allow a placeholder state to
become visible.

The internal features are:
-[_ASAsyncTransaction waitUntilComplete]
-[ASDisplayNode recursivelyEnsureDisplay]

Also provided are two such implementations:
-[ASCellNode setNeverShowPlaceholders:], which integrates with both Tables and Collections
-[ASViewController setNeverShowPlaceholders:], which should work with Nav and Tab controllers.

Lastly, on ASDisplayNode, a new property .shouldBypassEnsureDisplay allows individual node types
to exempt themselves from blocking the main thread on their display.

By implementing the feature at the ASCellNode level rather than ASTableView & ASCollectionView,
developers can retain fine-grained control on display characteristics.  For example, certain
cell types may be appropriate to display to the user with placeholders, whereas others may not.

Follow-up work will include unit tests, revisiting names, and the header locations of definitions.
2015-09-27 19:14:36 -07:00
Adlai Holler
717df1cfd2 Merge latest master and update Layout headers 2015-09-17 11:39:59 -07:00
Huy Nguyen
a864341710 Remove nonnull and nuulable annotations in ASViewController. Travis don't recognize them (yet). 2015-09-17 16:07:43 +03:00
Huy Nguyen
fcd76dbd19 Use nonnull annotation, instead of sanity check, for node property in ASViewController. 2015-09-17 15:59:37 +03:00
Huy Nguyen
07c0d78c71 Add ASViewController and update Multiplex sample to use it. 2015-09-17 15:58:21 +03:00