Swiftgram/Source/Details/ASCollectionGalleryLayoutDelegate.h
appleguy 465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9717d871dd16c4b07539f2f8208fc2b.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00

107 lines
3.5 KiB
Objective-C

//
// ASCollectionGalleryLayoutDelegate.h
// Texture
//
// Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import <AsyncDisplayKit/ASCollectionLayoutDelegate.h>
#import <AsyncDisplayKit/ASScrollDirection.h>
@class ASElementMap;
@class ASCollectionGalleryLayoutDelegate;
NS_ASSUME_NONNULL_BEGIN
@protocol ASCollectionGalleryLayoutPropertiesProviding <NSObject>
/**
* Returns the fixed size of each and every element.
*
* @discussion This method will only be called on main thread.
*
* @param delegate The calling object.
*
* @param elements All elements to be sized.
*
* @return The elements' size
*/
- (CGSize)galleryLayoutDelegate:(ASCollectionGalleryLayoutDelegate *)delegate sizeForElements:(ASElementMap *)elements;
@optional
/**
* Returns the minumum spacing to use between lines of items.
*
* @discussion This method will only be called on main thread.
*
* @discussion For a vertically scrolling layout, this value represents the minimum spacing between rows.
* For a horizontally scrolling one, it represents the minimum spacing between columns.
* It is not applied between the first line and the header, or between the last line and the footer.
* This is the same behavior as UICollectionViewFlowLayout's minimumLineSpacing.
*
* @param delegate The calling object.
*
* @param elements All elements in the layout.
*
* @return The interitem spacing
*/
- (CGFloat)galleryLayoutDelegate:(ASCollectionGalleryLayoutDelegate *)delegate minimumLineSpacingForElements:(ASElementMap *)elements;
/**
* Returns the minumum spacing to use between items in the same row or column, depending on the scroll directions.
*
* @discussion This method will only be called on main thread.
*
* @discussion For a vertically scrolling layout, this value represents the minimum spacing between items in the same row.
* For a horizontally scrolling one, it represents the minimum spacing between items in the same column.
* It is considered while fitting items into lines, but the actual final spacing between some items might be larger.
* This is the same behavior as UICollectionViewFlowLayout's minimumInteritemSpacing.
*
* @param delegate The calling object.
*
* @param elements All elements in the layout.
*
* @return The interitem spacing
*/
- (CGFloat)galleryLayoutDelegate:(ASCollectionGalleryLayoutDelegate *)delegate minimumInteritemSpacingForElements:(ASElementMap *)elements;
/**
* Returns the margins of each section.
*
* @discussion This method will only be called on main thread.
*
* @param delegate The calling object.
*
* @param elements All elements in the layout.
*
* @return The margins used to layout content in a section
*/
- (UIEdgeInsets)galleryLayoutDelegate:(ASCollectionGalleryLayoutDelegate *)delegate sectionInsetForElements:(ASElementMap *)elements;
@end
/**
* A thread-safe layout delegate that arranges items with the same size into a flow layout.
*
* @note Supplemenraty elements are not supported.
*/
AS_SUBCLASSING_RESTRICTED
@interface ASCollectionGalleryLayoutDelegate : NSObject <ASCollectionLayoutDelegate>
@property (nonatomic, weak) id<ASCollectionGalleryLayoutPropertiesProviding> propertiesProvider;
/**
* Designated initializer.
*
* @param scrollableDirections The scrollable directions of this layout. Must be either vertical or horizontal directions.
*/
- (instancetype)initWithScrollableDirections:(ASScrollDirection)scrollableDirections NS_DESIGNATED_INITIALIZER;
- (instancetype)init __unavailable;
@end
NS_ASSUME_NONNULL_END