iOS: fix ListNode's internal inconsistency
This commit is contained in:
parent
271a70bc4b
commit
6512841f82
@ -66,6 +66,9 @@ @interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
|||||||
@property(nonatomic, copy) NSString *beforeDraggingFuncId;
|
@property(nonatomic, copy) NSString *beforeDraggingFuncId;
|
||||||
@property(nonatomic, copy) NSString *onDraggingFuncId;
|
@property(nonatomic, copy) NSString *onDraggingFuncId;
|
||||||
@property(nonatomic, copy) NSString *onDraggedFuncId;
|
@property(nonatomic, copy) NSString *onDraggedFuncId;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) NSUInteger rowCount;
|
||||||
|
@property(nonatomic, assign) BOOL needReload;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricListNode
|
@implementation DoricListNode
|
||||||
@ -142,7 +145,7 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
self.view.bounces = [prop boolValue];
|
self.view.bounces = [prop boolValue];
|
||||||
} else if ([@"itemCount" isEqualToString:name]) {
|
} else if ([@"itemCount" isEqualToString:name]) {
|
||||||
self.itemCount = [prop unsignedIntegerValue];
|
self.itemCount = [prop unsignedIntegerValue];
|
||||||
[self.view reloadData];
|
self.needReload = true;
|
||||||
} else if ([@"renderItem" isEqualToString:name]) {
|
} else if ([@"renderItem" isEqualToString:name]) {
|
||||||
if (![self.renderItemFuncId isEqualToString:prop]) {
|
if (![self.renderItemFuncId isEqualToString:prop]) {
|
||||||
self.loadAnchor = -1;
|
self.loadAnchor = -1;
|
||||||
@ -151,7 +154,7 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
[self removeSubModel:obj];
|
[self removeSubModel:obj];
|
||||||
}];
|
}];
|
||||||
[self.itemViewIds removeAllObjects];
|
[self.itemViewIds removeAllObjects];
|
||||||
[self.view reloadData];
|
self.needReload = true;
|
||||||
}
|
}
|
||||||
} else if ([@"batchCount" isEqualToString:name]) {
|
} else if ([@"batchCount" isEqualToString:name]) {
|
||||||
self.batchCount = [prop unsignedIntegerValue];
|
self.batchCount = [prop unsignedIntegerValue];
|
||||||
@ -163,7 +166,7 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
BOOL loadMore = [prop boolValue];
|
BOOL loadMore = [prop boolValue];
|
||||||
if (loadMore != self.loadMore) {
|
if (loadMore != self.loadMore) {
|
||||||
self.loadMore = loadMore;
|
self.loadMore = loadMore;
|
||||||
[self.view reloadData];
|
self.needReload = true;
|
||||||
}
|
}
|
||||||
} else if ([@"onScroll" isEqualToString:name]) {
|
} else if ([@"onScroll" isEqualToString:name]) {
|
||||||
self.onScrollFuncId = prop;
|
self.onScrollFuncId = prop;
|
||||||
@ -187,8 +190,21 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)blend:(NSDictionary *)props {
|
||||||
|
self.needReload = false;
|
||||||
|
[super blend:props];
|
||||||
|
if (self.needReload) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
self.rowCount = self.itemCount + (self.loadMore ? 1 : 0);
|
||||||
|
[self.view reloadData];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.needReload = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||||
return self.itemCount + (self.loadMore ? 1 : 0);
|
return self.rowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)callLoadMore {
|
- (void)callLoadMore {
|
||||||
@ -358,7 +374,7 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
|||||||
if ([viewId isEqualToString:obj]) {
|
if ([viewId isEqualToString:obj]) {
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
[UIView performWithoutAnimation:^{
|
[UIView performWithoutAnimation:^{
|
||||||
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
|
NSUInteger itemCount = self.rowCount;
|
||||||
if (itemCount <= [key integerValue] || currentCount != itemCount) {
|
if (itemCount <= [key integerValue] || currentCount != itemCount) {
|
||||||
[self.view reloadData];
|
[self.view reloadData];
|
||||||
return;
|
return;
|
||||||
@ -382,7 +398,7 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
|
|||||||
if (old && [old isEqualToNumber:@(height)]) {
|
if (old && [old isEqualToNumber:@(height)]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSUInteger currentCount = self.itemCount + (self.loadMore ? 1 : 0);
|
NSUInteger currentCount = self.rowCount;
|
||||||
self.itemHeights[@(position)] = @(height);
|
self.itemHeights[@(position)] = @(height);
|
||||||
if (@available(iOS 12.0, *)) {
|
if (@available(iOS 12.0, *)) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
@ -394,9 +410,8 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
|
|||||||
[node requestLayout];
|
[node requestLayout];
|
||||||
}
|
}
|
||||||
[UIView performWithoutAnimation:^{
|
[UIView performWithoutAnimation:^{
|
||||||
NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0);
|
NSUInteger itemCount = self.rowCount;
|
||||||
if (itemCount <= position || currentCount != itemCount) {
|
if (itemCount <= position || currentCount != itemCount) {
|
||||||
[self.view reloadData];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:position inSection:0];
|
||||||
|
Reference in New Issue
Block a user