ashfurrow / ARCollectionViewMasonryLayout

MIT License
185 stars 16 forks source link

Fixed header and footer support. #13

Closed dblock closed 10 years ago

dblock commented 10 years ago

Removed leadingView and trailingView, all these do is adjust margins, we don't use that at Artsy and I don't see how this can be useful. You just say "this is a view from which to take some margin on top or bottom". Bottom does nothing really other than give you some more scroll space. I think it would be useful to be able to insert a random view on top/bottom of the scroll though without having to supply a height and a reusable view, which is https://github.com/AshFurrow/ARCollectionViewMasonryLayout/issues/8.

Added optional header in the same vein as the footer via headerHeight and headerViewClass.

Updated documentation.

ashfurrow commented 10 years ago

Looks good!

orta commented 10 years ago

breaking backward dep with leadingView and trailingView should probably mean a v.2 release FWIW

dblock commented 10 years ago

@orta those leading trailing views do nothing other than a leading margin. Trailing does nothing.

ashfurrow commented 10 years ago

So where did we fall on this? Good to merge?

orta commented 10 years ago

me and db paired on it earlier, he might just push new stuff

ashfurrow commented 10 years ago

Cool cool.

dblock commented 10 years ago

Sat down with @orta and rewritten this whole mess using ARCollectionViewMasonryLayoutDelegate. So now if you want to add a header or a footer, you no longer need to manipulate the layout, you do this on the view-controller.

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    // return a header and/or footer view, must be a UICollectionReusableView
    // kind is one of UICollectionElementKindSectionHeader or UICollectionElementKindSectionFooter
    UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kind forIndexPath:indexPath];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ARCollectionViewMasonryLayout *)collectionViewLayout dimensionForHeaderAtIndexPath:(NSIndexPath *)indexPath
{
    return 20; // header length
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ARCollectionViewMasonryLayout *)collectionViewLayout dimensionForFooterAtIndexPath:(NSIndexPath *)indexPath
{
    return 10; // footer length
}

This is ready to merge if green, but needs another code-review.

ashfurrow commented 10 years ago

Cool. Will do.

ashfurrow commented 10 years ago

Looks solid.

dblock commented 10 years ago

This is :green_apple: