Swiftgram/AsyncDisplayKit/ASVisibilityProtocols.h
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

46 lines
1.6 KiB
Objective-C

//
// ASVisibilityProtocols.h
// Pods
//
// Created by Garrett Moon on 4/27/16.
//
//
#import "ASLayoutRangeType.h"
ASLayoutRangeMode ASLayoutRangeModeForVisibilityDepth(NSUInteger visibilityDepth);
@protocol ASVisibilityDepth <NSObject>
/**
* @abstract Represents the number of user actions necessary to reach the view controller. An increased visibility
* depth indicates a higher number of user interactions for the view controller to be visible again. For example,
* an onscreen navigation controller's top view controller should have a visibility depth of 0. The view controller
* one from the top should have a visibility deptch of 1 as should the root view controller in the stack (because
* the user can hold the back button to pop to the root view controller).
*
* Visibility depth is used to automatically adjust ranges on range controllers (and thus free up memory) and can
* be used to reduce memory usage of other items as well.
*/
- (NSInteger)visibilityDepth;
- (void)visibilityDepthDidChange;
@end
/**
* @abstract Container view controllers should adopt this protocol to indicate that they will manage their child's
* visibilityDepth. For example, ASNavigationController adopts this protocol and manages its childrens visibility
* depth.
*
* If you adopt this protocol, you *must* also emit visibilityDepthDidChange messages to child view controllers.
*
* @param childViewController Expected to return the visibility depth of the child view controller.
*/
@protocol ASManagesChildVisibilityDepth <ASVisibilityDepth>
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController;
@end