14
14
@implementation SomoDataSourceProvider
15
15
{
16
16
NSString * _reuseIdentifier;
17
- SomoCollectionViewNumberOfSectionBlock _sectionsBlock;
18
- SomoCollectionViewNumberOfRowInsSections _rowsBlock;
19
- SomoTableViewCellBlock _tableViewCellBlock;
20
- SomoTableViewCellHeightBlock _heightBlock;
21
- SomoCollectionViewCellBlock _collectionViewCellBlock;
22
- SomoCollectionViewLayoutSize _sizeBlock;
23
- SomoCollectionViewLayoutEdgeInsets _insetsBlock;
24
- SomoCollectionViewLayoutMinimumLineSpacing _minimumLineSpacingBlock;
25
- SomoCollectionViewLayoutMinimumInteritemSpacing _minimumInteritemSpacingBlock;
26
- SomoCollectionViewLayoutReferenceSizeForHeader _referenceSizeForHeaderBlock;
27
- SomoCollectionViewLayoutReferenceSizeForFooter _referenceSizeForFooterBlock;
17
+ // SomoCollectionViewNumberOfSectionBlock _sectionsBlock;
18
+ // SomoCollectionViewNumberOfRowInsSections _rowsBlock;
19
+ // SomoTableViewCellBlock _tableViewCellBlock;
20
+ // SomoTableViewCellHeightBlock _heightBlock;
21
+ // SomoCollectionViewCellBlock _collectionViewCellBlock;
22
+ // SomoCollectionViewLayoutSize _sizeBlock;
23
+ // SomoCollectionViewLayoutEdgeInsets _insetsBlock;
24
+ // SomoCollectionViewLayoutMinimumLineSpacing _minimumLineSpacingBlock;
25
+ // SomoCollectionViewLayoutMinimumInteritemSpacing _minimumInteritemSpacingBlock;
26
+ // SomoCollectionViewLayoutReferenceSizeForHeader _referenceSizeForHeaderBlock;
27
+ // SomoCollectionViewLayoutReferenceSizeForFooter _referenceSizeForFooterBlock;
28
28
}
29
29
30
30
- (instancetype )initWithCellReuseIdentifier : (NSString *)reuseIdentifier {
@@ -39,57 +39,62 @@ + (instancetype)dataSourceProviderWithCellReuseIdentifier:(NSString *)reuseIdent
39
39
return [[[self class ] alloc ] initWithCellReuseIdentifier: reuseIdentifier];
40
40
}
41
41
42
- - (instancetype )initWithTableViewCellBlock : (SomoTableViewCellBlock)block heightBlock : (SomoTableViewCellHeightBlock)heightBlock {
43
- if (self = [super init ]) {
44
- _tableViewCellBlock = block;
45
- _heightBlock = heightBlock;
46
- _numberOfRowsInSection = 30 ;
47
- }
48
- return self;
49
- }
50
-
51
- - (instancetype )initWithCollectionViewCellBlock : (SomoCollectionViewCellBlock)block
52
- sections : (SomoCollectionViewNumberOfSectionBlock)sections
53
- rows : (SomoCollectionViewNumberOfRowInsSections)rows
54
- size : (SomoCollectionViewLayoutSize)size
55
- edgeInsets : (SomoCollectionViewLayoutEdgeInsets)edgeInsets
56
- minimumLineSpacing : (SomoCollectionViewLayoutMinimumLineSpacing)minimumLineSpacing
57
- minimumInteritemSpacing : (SomoCollectionViewLayoutMinimumInteritemSpacing)minimumInteritemSpacing
58
- referenceSizeForHeader : (SomoCollectionViewLayoutReferenceSizeForHeader)referenceSizeForHeader
59
- referenceSizeForFooter : (SomoCollectionViewLayoutReferenceSizeForFooter)referenceSizeForFooter {
60
- if (self = [super init ]) {
61
- _collectionViewCellBlock = block;
62
- _sectionsBlock = sections;
63
- _rowsBlock = rows;
64
- _numberOfRowsInSection = 30 ;
65
- _sizeBlock = size;
66
- _insetsBlock = edgeInsets;
67
- _minimumLineSpacingBlock = minimumLineSpacing;
68
- _minimumInteritemSpacingBlock = minimumInteritemSpacing;
69
- _referenceSizeForHeaderBlock = referenceSizeForHeader;
70
- _referenceSizeForFooterBlock = referenceSizeForFooter;
71
- }
72
- return self;
73
- }
42
+ // - (instancetype)initWithTableViewCellBlock:(SomoTableViewCellBlock)block heightBlock:(SomoTableViewCellHeightBlock)heightBlock{
43
+ // if (self = [super init]) {
44
+ // _tableViewCellBlock = block;
45
+ // _heightBlock = heightBlock;
46
+ // _numberOfRowsInSection = 30;
47
+ // }
48
+ // return self;
49
+ // }
50
+ //
51
+ // - (instancetype)initWithCollectionViewCellBlock:(SomoCollectionViewCellBlock)block
52
+ // sections:(SomoCollectionViewNumberOfSectionBlock)sections
53
+ // rows:(SomoCollectionViewNumberOfRowInsSections)rows
54
+ // size:(SomoCollectionViewLayoutSize)size
55
+ // edgeInsets:(SomoCollectionViewLayoutEdgeInsets)edgeInsets
56
+ // minimumLineSpacing:(SomoCollectionViewLayoutMinimumLineSpacing)minimumLineSpacing
57
+ // minimumInteritemSpacing:(SomoCollectionViewLayoutMinimumInteritemSpacing)minimumInteritemSpacing
58
+ // referenceSizeForHeader:(SomoCollectionViewLayoutReferenceSizeForHeader)referenceSizeForHeader
59
+ // referenceSizeForFooter:(SomoCollectionViewLayoutReferenceSizeForFooter)referenceSizeForFooter{
60
+ // if (self = [super init]) {
61
+ // _collectionViewCellBlock = block;
62
+ // _sectionsBlock = sections;
63
+ // _rowsBlock = rows;
64
+ // _numberOfRowsInSection = 30;
65
+ // _sizeBlock = size;
66
+ // _insetsBlock = edgeInsets;
67
+ // _minimumLineSpacingBlock = minimumLineSpacing;
68
+ // _minimumInteritemSpacingBlock = minimumInteritemSpacing;
69
+ // _referenceSizeForHeaderBlock = referenceSizeForHeader;
70
+ // _referenceSizeForFooterBlock = referenceSizeForFooter;
71
+ // }
72
+ // return self;
73
+ // }
74
+
75
+ // - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
76
+ // return <#expression#>
77
+ // }
74
78
75
79
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
76
80
return self.numberOfRowsInSection ;
77
81
}
78
82
79
- - (CGFloat )tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
80
- if (_reuseIdentifier) {
81
- return tableView.rowHeight ;
82
- }else {
83
- return _heightBlock (tableView, indexPath);
84
- }
85
- }
86
-
83
+ // - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
84
+ // if (_reuseIdentifier) {
85
+ // return tableView.rowHeight;
86
+ // }else{
87
+ // return _heightBlock(tableView, indexPath);
88
+ // }
89
+ // }
90
+
87
91
- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
88
- if (_reuseIdentifier) {
89
- return [tableView dequeueReusableCellWithIdentifier: _reuseIdentifier forIndexPath: indexPath];
90
- }else {
91
- return _tableViewCellBlock (tableView,indexPath);
92
- }
92
+ return [tableView dequeueReusableCellWithIdentifier: _reuseIdentifier forIndexPath: indexPath];
93
+ // if (_reuseIdentifier) {
94
+ // return [tableView dequeueReusableCellWithIdentifier:_reuseIdentifier forIndexPath:indexPath];
95
+ // }else{
96
+ // return _tableViewCellBlock(tableView,indexPath);
97
+ // }
93
98
}
94
99
95
100
- (void )tableView : (UITableView *)tableView willDisplayCell : (UITableViewCell *)cell forRowAtIndexPath : (NSIndexPath *)indexPath {
@@ -98,48 +103,50 @@ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)ce
98
103
99
104
#pragma mark - collection
100
105
101
- - (NSInteger )numberOfSectionsInCollectionView : (UICollectionView *)collectionView {
102
- return _sectionsBlock (collectionView);
103
- }
106
+ // - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
107
+ // return _sectionsBlock(collectionView);
108
+ // }
104
109
105
110
- (NSInteger )collectionView : (UICollectionView *)collectionView numberOfItemsInSection : (NSInteger )section {
106
- return _rowsBlock (collectionView,section);
111
+ // return _rowsBlock(collectionView,section);
112
+ return _numberOfRowsInSection;
107
113
}
108
114
109
115
- (__kindof UICollectionViewCell *)collectionView : (UICollectionView *)collectionView cellForItemAtIndexPath : (NSIndexPath *)indexPath {
110
- if (_reuseIdentifier) {
111
- return [collectionView dequeueReusableCellWithReuseIdentifier: _reuseIdentifier forIndexPath: indexPath];
112
- }else {
113
- return _collectionViewCellBlock (collectionView, indexPath);
114
- }
116
+ return [collectionView dequeueReusableCellWithReuseIdentifier: _reuseIdentifier forIndexPath: indexPath];
117
+ // if (_reuseIdentifier) {
118
+ //
119
+ // }else{
120
+ // return _collectionViewCellBlock(collectionView, indexPath);
121
+ // }
115
122
}
116
123
117
124
- (void )collectionView : (UICollectionView *)collectionView willDisplayCell : (UICollectionViewCell *)cell forItemAtIndexPath : (NSIndexPath *)indexPath {
118
125
[cell beginSomo ];
119
126
}
120
127
121
- - (CGSize )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath : (NSIndexPath *)indexPath {
122
- return _sizeBlock ? _sizeBlock (collectionView,collectionViewLayout,indexPath) : CGSizeZero ;
123
- }
124
-
125
- - (UIEdgeInsets)collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex : (NSInteger )section {
126
- return _insetsBlock ? _insetsBlock (collectionView,collectionViewLayout,section) : UIEdgeInsetsZero;
127
- }
128
-
129
- - (CGFloat )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex : (NSInteger )section {
130
- return _minimumLineSpacingBlock ? _minimumLineSpacingBlock (collectionView,collectionViewLayout,section) : 0 .f ;
131
- }
132
-
133
- - (CGFloat )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex : (NSInteger )section {
134
- return _minimumInteritemSpacingBlock ? _minimumInteritemSpacingBlock (collectionView,collectionViewLayout,section) : 0 .f ;
135
- }
136
-
137
- - (CGSize )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection : (NSInteger )section {
138
- return _referenceSizeForHeaderBlock ? _referenceSizeForHeaderBlock (collectionView,collectionViewLayout,section) : CGSizeZero ;
139
- }
140
-
141
- - (CGSize )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection : (NSInteger )section {
142
- return _referenceSizeForFooterBlock ? _referenceSizeForFooterBlock (collectionView,collectionViewLayout,section) : CGSizeZero ;
143
- }
128
+ // - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
129
+ // return _sizeBlock ? _sizeBlock(collectionView,collectionViewLayout,indexPath) : CGSizeZero;
130
+ // }
131
+ //
132
+ // - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
133
+ // return _insetsBlock ? _insetsBlock(collectionView,collectionViewLayout,section) : UIEdgeInsetsZero;
134
+ // }
135
+ //
136
+ // - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
137
+ // return _minimumLineSpacingBlock ? _minimumLineSpacingBlock(collectionView,collectionViewLayout,section) : 0.f;
138
+ // }
139
+ //
140
+ // - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
141
+ // return _minimumInteritemSpacingBlock ? _minimumInteritemSpacingBlock(collectionView,collectionViewLayout,section) : 0.f;
142
+ // }
143
+ //
144
+ // - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
145
+ // return _referenceSizeForHeaderBlock ? _referenceSizeForHeaderBlock(collectionView,collectionViewLayout,section) : CGSizeZero;
146
+ // }
147
+ //
148
+ // - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
149
+ // return _referenceSizeForFooterBlock ? _referenceSizeForFooterBlock(collectionView,collectionViewLayout,section) : CGSizeZero;
150
+ // }
144
151
145
152
@end
0 commit comments