-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathJEKScrollableSectionCollectionViewLayout.h
More file actions
84 lines (70 loc) · 4.11 KB
/
JEKScrollableSectionCollectionViewLayout.h
File metadata and controls
84 lines (70 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// JEKScrollableSectionCollectionViewLayout.h
// Example Project
//
// Created by Joel Ekström on 2018-07-19.
// Copyright © 2018 Joel Ekström. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class JEKScrollViewConfiguration;
@interface JEKScrollableSectionCollectionViewLayout : UICollectionViewLayout
@property (nonatomic) CGFloat minimumInteritemSpacing;
@property (nonatomic) CGSize itemSize;
@property (nonatomic) CGSize headerReferenceSize;
@property (nonatomic) CGSize footerReferenceSize;
@property (nonatomic) CGSize estimatedItemSize;
@property (nonatomic) UIEdgeInsets sectionInset;
/**
The scroll view settings that will be applied to each horisontal section. Can be overridden
per section by implementing `collectionView:layout:scrollViewConfigurationForSection:`.
*/
@property (nonatomic, strong) JEKScrollViewConfiguration *defaultScrollViewConfiguration;
@property (nonatomic) BOOL showsHorizontalScrollIndicators __attribute__((deprecated("", "scrollViewConfiguration")));
/**
When YES, collectionView:viewForSupplementaryElementOfKind:atIndexPath:
will be queried with the kind JEKCollectionElementKindSectionBackground,
so you can optionally return a view to be used as a background for a section.
*/
@property (nonatomic) BOOL showsSectionBackgrounds;
extern NSString * const JEKCollectionElementKindSectionBackground;
@end
@interface JEKScrollViewConfiguration : NSObject
+ (instancetype)defaultConfiguration;
@property (nonatomic) BOOL bounces;
@property (nonatomic) BOOL alwaysBounceHorizontal;
@property (nonatomic) BOOL showsHorizontalScrollIndicator;
@property (nonatomic) UIEdgeInsets scrollIndicatorInsets;
@property (nonatomic) UIScrollViewIndicatorStyle indicatorStyle;
@property (nonatomic) UIScrollViewDecelerationRate decelerationRate;
@property (nonatomic, getter=isPagingEnabled) BOOL pagingEnabled;
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
@end
/**
Implement this delegate protocol to listen for scrolling events on different sections.
The protocol closely matches UIScrollViewDelegate. Simply conform to this protocol
instead of UICollectionViewDelegateFlowLayout and implement the required methods.
*/
@protocol JEKCollectionViewDelegateScrollableSectionLayout <UICollectionViewDelegateFlowLayout>
@optional
/**
Optional configuration of scroll view behavior per section. Return nil to use the
defaultScrollViewConfiguration set on the layout object.
*/
- (nullable JEKScrollViewConfiguration *)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout scrollViewConfigurationForSection:(NSUInteger)section;
/**
Return YES to use standard flow layout for a section. The section will have multiple
rows instead of being scrollable horizontally.
*/
- (BOOL)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout*)collectionViewLayout shouldUseFlowLayoutInSection:(NSInteger)section;
/**
Scroll view delegate functions for horizontal sections
*/
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout section:(NSUInteger)section didScrollToOffset:(CGFloat)horizontalOffset;
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout sectionWillBeginDragging:(NSUInteger)section;
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout sectionWillEndDragging:(NSUInteger)section withVelocity:(CGFloat)velocity targetOffset:(inout CGFloat *)targetHorizontalOffset;
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout sectionDidEndDragging:(NSUInteger)section willDecelerate:(BOOL)decelerate;
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout sectionWillBeginDecelerating:(NSUInteger)section;
- (void)collectionView:(UICollectionView *)collectionView layout:(JEKScrollableSectionCollectionViewLayout *)layout sectionDidEndDecelerating:(NSUInteger)section;
@end
NS_ASSUME_NONNULL_END