Skip to content

Commit

Permalink
Merge branch 'release/0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
chiahsien committed Sep 21, 2014
2 parents 00d070d + 8322f77 commit 025939f
Show file tree
Hide file tree
Showing 15 changed files with 2,161 additions and 50 deletions.
92 changes: 92 additions & 0 deletions CHTCollectionViewWaterfallLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

#import <UIKit/UIKit.h>

/**
* Enumerated structure to define direction in which items can be rendered.
*/
typedef NS_ENUM (NSUInteger, CHTCollectionViewWaterfallLayoutItemRenderDirection) {
CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst,
CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight,
CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft
};

/**
* Constants that specify the types of supplementary views that can be presented using a waterfall layout.
*/
Expand Down Expand Up @@ -46,6 +55,21 @@ extern NSString *const CHTCollectionElementKindSectionFooter;
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

@optional
/**
* Asks the delegate for the column count in a section
*
* @param collectionView
* The collection view object displaying the waterfall layout.
* @param collectionViewLayout
* The layout object requesting the information.
* @param section
* The section.
*
* @return
* The original column count for that section. Must be greater than 0.
*/
- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout columnCountForSection:(NSInteger)section;

/**
* Asks the delegate for the height of the header view in the specified section.
*
Expand Down Expand Up @@ -106,6 +130,42 @@ extern NSString *const CHTCollectionElementKindSectionFooter;
*/
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;

/**
* Asks the delegate for the header insets in the specified section.
*
* @param collectionView
* The collection view object displaying the waterfall layout.
* @param collectionViewLayout
* The layout object requesting the information.
* @param section
* The index of the section whose header insets are being requested.
*
* @discussion
* If you do not implement this method, the waterfall layout uses the value in its headerInset property.
*
* @return
* The headerInsets for the section.
*/
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForHeaderInSection:(NSInteger)section;

/**
* Asks the delegate for the footer insets in the specified section.
*
* @param collectionView
* The collection view object displaying the waterfall layout.
* @param collectionViewLayout
* The layout object requesting the information.
* @param section
* The index of the section whose footer insets are being requested.
*
* @discussion
* If you do not implement this method, the waterfall layout uses the value in its footerInset property.
*
* @return
* The footerInsets for the section.
*/
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForFooterInSection:(NSInteger)section;

/**
* Asks the delegate for the minimum spacing between two items in the same column
* in the specified section. If this method is not implemented, the
Expand Down Expand Up @@ -185,6 +245,28 @@ extern NSString *const CHTCollectionElementKindSectionFooter;
*/
@property (nonatomic, assign) CGFloat footerHeight;

/**
* @brief The margins that are used to lay out the header for each section.
* @discussion
* These insets are applied to the headers in each section.
* They represent the distance between the top of the collection view and the top of the content items
* They also indicate the spacing on either side of the header. They do not affect the size of the headers or footers themselves.
*
* Default: UIEdgeInsetsZero
*/
@property (nonatomic, assign) UIEdgeInsets headerInset;

/**
* @brief The margins that are used to lay out the footer for each section.
* @discussion
* These insets are applied to the footers in each section.
* They represent the distance between the top of the collection view and the top of the content items
* They also indicate the spacing on either side of the footer. They do not affect the size of the headers or footers themselves.
*
* Default: UIEdgeInsetsZero
*/
@property (nonatomic, assign) UIEdgeInsets footerInset;

/**
* @brief The margins that are used to lay out content in each section.
* @discussion
Expand All @@ -196,10 +278,20 @@ extern NSString *const CHTCollectionElementKindSectionFooter;
*/
@property (nonatomic, assign) UIEdgeInsets sectionInset;

/**
* @brief The direction in which items will be rendered in subsequent rows.
* @discussion
* The direction in which each item is rendered. This could be left to right (CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight), right to left (CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft), or shortest column fills first (CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst).
*
* Default: CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst
*/
@property (nonatomic, assign) CHTCollectionViewWaterfallLayoutItemRenderDirection itemRenderDirection;

/**
* @brief The calculated width of an item in the specified section.
* @discussion
* The width of an item is calculated based on number of columns, the collection view width, and the horizontal insets for that section.
*/
- (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section;

@end
Loading

0 comments on commit 025939f

Please sign in to comment.