Remove header and footer support,this is unnecessary
This commit is contained in:
@@ -167,8 +167,6 @@ @interface DoricFlowLayoutNode () <UICollectionViewDataSource, UICollectionViewD
|
||||
|
||||
@property(nonatomic, copy) NSString *onLoadMoreFuncId;
|
||||
@property(nonatomic, copy) NSString *loadMoreViewId;
|
||||
@property(nonatomic, copy) NSString *headerViewId;
|
||||
@property(nonatomic, copy) NSString *footerViewId;
|
||||
@property(nonatomic, assign) BOOL loadMore;
|
||||
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
|
||||
@property(nonatomic, copy) NSString *onScrollFuncId;
|
||||
@@ -207,14 +205,6 @@ - (UICollectionView *)build {
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)hasHeader {
|
||||
return self.headerViewId && self.headerViewId.length > 0;
|
||||
}
|
||||
|
||||
- (BOOL)hasFooter {
|
||||
return self.footerViewId && self.footerViewId.length > 0;
|
||||
}
|
||||
|
||||
- (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||
if ([@"scrollable" isEqualToString:name]) {
|
||||
self.view.scrollEnabled = [prop boolValue];
|
||||
@@ -254,36 +244,19 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
|
||||
self.onScrollFuncId = prop;
|
||||
} else if ([@"onScrollEnd" isEqualToString:name]) {
|
||||
self.onScrollEndFuncId = prop;
|
||||
} else if ([@"header" isEqualToString:name]) {
|
||||
self.headerViewId = prop;
|
||||
} else if ([@"footer" isEqualToString:name]) {
|
||||
self.footerViewId = prop;
|
||||
} else {
|
||||
[super blendView:view forPropName:name propValue:prop];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)itemModelAt:(NSUInteger)position {
|
||||
if (self.hasHeader && position == 0) {
|
||||
return [self subModelOf:self.headerViewId];
|
||||
}
|
||||
if (self.hasFooter && position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1) {
|
||||
return [self subModelOf:self.footerViewId];
|
||||
}
|
||||
if (self.loadMore && position >= self.itemCount + (self.hasHeader ? 1 : 0)) {
|
||||
if (self.loadMore && position >= self.itemCount) {
|
||||
if (self.loadMoreViewId && self.loadMoreViewId.length > 0) {
|
||||
return [self subModelOf:self.loadMoreViewId];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
if (self.hasHeader) {
|
||||
position--;
|
||||
}
|
||||
NSString *viewId = self.itemViewIds[@(position)];
|
||||
if (viewId && viewId.length > 0) {
|
||||
return [self subModelOf:viewId];
|
||||
@@ -366,7 +339,7 @@ - (void)callLoadMore {
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return self.itemCount + (self.loadMore ? 1 : 0) + (self.hasHeader ? 1 : 0) + (self.hasFooter ? 1 : 0);
|
||||
return self.itemCount + (self.loadMore ? 1 : 0);
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
@@ -374,17 +347,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
||||
NSDictionary *model = [self itemModelAt:position];
|
||||
NSDictionary *props = model[@"props"];
|
||||
NSString *identifier = props[@"identifier"] ?: @"doricCell";
|
||||
if (self.hasHeader && position == 0) {
|
||||
identifier = @"doricHeaderCell";
|
||||
} else if (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1) {
|
||||
identifier = @"doricFooterCell";
|
||||
} else if (self.loadMore
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0)
|
||||
if (self.loadMore
|
||||
&& position >= self.itemCount
|
||||
&& self.onLoadMoreFuncId) {
|
||||
identifier = @"doricLoadMoreCell";
|
||||
[self callLoadMore];
|
||||
@@ -402,15 +366,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
||||
node.viewId = model[@"id"];
|
||||
[node blend:props];
|
||||
BOOL fillWidth = [props[@"fullSpan"] boolValue]
|
||||
|| (self.hasHeader && position == 0)
|
||||
|| (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1)
|
||||
|| (self.loadMore
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0));
|
||||
|| (self.loadMore && position >= self.itemCount);
|
||||
if (fillWidth) {
|
||||
node.view.width = collectionView.width;
|
||||
} else {
|
||||
@@ -457,15 +413,7 @@ - (NSInteger)doricFlowLayoutColumnCount {
|
||||
|
||||
- (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
|
||||
NSUInteger position = (NSUInteger) indexPath.row;
|
||||
if ((self.hasHeader && position == 0)
|
||||
|| (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1)
|
||||
|| (self.loadMore
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0))) {
|
||||
if (self.loadMore && position >= self.itemCount) {
|
||||
return YES;
|
||||
} else {
|
||||
NSDictionary *model = [self itemModelAt:position];
|
||||
|
@@ -53,8 +53,6 @@ @interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
||||
@property(nonatomic, copy) NSString *onLoadMoreFuncId;
|
||||
@property(nonatomic, copy) NSString *renderItemFuncId;
|
||||
@property(nonatomic, copy) NSString *loadMoreViewId;
|
||||
@property(nonatomic, copy) NSString *headerViewId;
|
||||
@property(nonatomic, copy) NSString *footerViewId;
|
||||
@property(nonatomic, assign) BOOL loadMore;
|
||||
@property(nonatomic, assign) NSUInteger loadAnchor;
|
||||
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
|
||||
@@ -95,14 +93,6 @@ - (UITableView *)build {
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)hasHeader {
|
||||
return self.headerViewId && self.headerViewId.length > 0;
|
||||
}
|
||||
|
||||
- (BOOL)hasFooter {
|
||||
return self.footerViewId && self.footerViewId.length > 0;
|
||||
}
|
||||
|
||||
- (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||
if ([@"scrollable" isEqualToString:name]) {
|
||||
self.view.scrollEnabled = [prop boolValue];
|
||||
@@ -136,17 +126,13 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[prop unsignedIntegerValue] inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
|
||||
});
|
||||
} else if ([@"header" isEqualToString:name]) {
|
||||
self.headerViewId = prop;
|
||||
} else if ([@"footer" isEqualToString:name]) {
|
||||
self.footerViewId = prop;
|
||||
} else {
|
||||
[super blendView:view forPropName:name propValue:prop];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.itemCount + (self.loadMore ? 1 : 0) + (self.hasHeader ? 1 : 0) + (self.hasFooter ? 1 : 0);
|
||||
return self.itemCount + (self.loadMore ? 1 : 0);
|
||||
}
|
||||
|
||||
- (void)callLoadMore {
|
||||
@@ -162,17 +148,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
||||
NSDictionary *props = model[@"props"];
|
||||
NSString *reuseId = props[@"identifier"];
|
||||
self.itemActions[@(position)] = props[@"actions"];
|
||||
if (self.hasHeader && position == 0) {
|
||||
reuseId = @"doricHeaderCell";
|
||||
} else if (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1) {
|
||||
reuseId = @"doricFooterCell";
|
||||
} else if (self.loadMore
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0)
|
||||
if (self.loadMore
|
||||
&& position >= self.itemCount
|
||||
&& self.onLoadMoreFuncId) {
|
||||
reuseId = @"doricLoadMoreCell";
|
||||
[self callLoadMore];
|
||||
@@ -260,26 +237,13 @@ - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView tra
|
||||
}
|
||||
|
||||
- (NSDictionary *)itemModelAt:(NSUInteger)position {
|
||||
if (self.hasHeader && position == 0) {
|
||||
return [self subModelOf:self.headerViewId];
|
||||
}
|
||||
if (self.hasFooter && position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
+ (self.hasHeader ? 1 : 0)
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1) {
|
||||
return [self subModelOf:self.footerViewId];
|
||||
}
|
||||
if (self.loadMore && position >= self.itemCount + (self.hasHeader ? 1 : 0)) {
|
||||
if (self.loadMore && position >= self.itemCount) {
|
||||
if (self.loadMoreViewId && self.loadMoreViewId.length > 0) {
|
||||
return [self subModelOf:self.loadMoreViewId];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
if (self.hasHeader) {
|
||||
position--;
|
||||
}
|
||||
NSString *viewId = self.itemViewIds[@(position)];
|
||||
if (viewId && viewId.length > 0) {
|
||||
return [self subModelOf:viewId];
|
||||
|
Reference in New Issue
Block a user