iOS: optimze when updating cell do not cause size change, do not reload
This commit is contained in:
parent
c04994ab21
commit
72a4562885
@ -295,13 +295,23 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString *viewId = subModel[@"id"];
|
||||
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
|
||||
BOOL skipReload = NO;
|
||||
if (viewNode) {
|
||||
CGSize originSize = viewNode.view.frame.size;
|
||||
[viewNode blend:subModel[@"props"]];
|
||||
[viewNode.view.doricLayout apply];
|
||||
[viewNode requestLayout];
|
||||
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
|
||||
skipReload = YES;
|
||||
}
|
||||
} else {
|
||||
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
|
||||
[self recursiveMixin:subModel to:model];
|
||||
[self setSubModel:model in:viewId];
|
||||
}
|
||||
if (skipReload) {
|
||||
return;
|
||||
}
|
||||
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
|
||||
if ([viewId isEqualToString:obj]) {
|
||||
*stop = YES;
|
||||
|
@ -63,6 +63,11 @@ - (instancetype)init {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setText:(NSString *)text {
|
||||
[super setText:text];
|
||||
self.placeholderLabel.hidden = self.text.length > 0;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
self.placeholderLabel.hidden = self.text.length > 0;
|
||||
|
@ -279,13 +279,23 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString *viewId = subModel[@"id"];
|
||||
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
|
||||
BOOL skipReload = NO;
|
||||
if (viewNode) {
|
||||
CGSize originSize = viewNode.view.frame.size;
|
||||
[viewNode blend:subModel[@"props"]];
|
||||
[viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)];
|
||||
[viewNode requestLayout];
|
||||
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
|
||||
skipReload = YES;
|
||||
}
|
||||
} else {
|
||||
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
|
||||
[self recursiveMixin:subModel to:model];
|
||||
[self setSubModel:model in:viewId];
|
||||
}
|
||||
if (skipReload) {
|
||||
return;
|
||||
}
|
||||
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
|
||||
if ([viewId isEqualToString:obj]) {
|
||||
*stop = YES;
|
||||
|
@ -227,13 +227,23 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||
- (void)blendSubNode:(NSDictionary *)subModel {
|
||||
NSString *viewId = subModel[@"id"];
|
||||
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
|
||||
BOOL skipReload = NO;
|
||||
if (viewNode) {
|
||||
CGSize originSize = viewNode.view.frame.size;
|
||||
[viewNode blend:subModel[@"props"]];
|
||||
[viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)];
|
||||
[viewNode requestLayout];
|
||||
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
|
||||
skipReload = YES;
|
||||
}
|
||||
} else {
|
||||
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
|
||||
[self recursiveMixin:subModel to:model];
|
||||
[self setSubModel:model in:viewId];
|
||||
}
|
||||
if (skipReload) {
|
||||
return;
|
||||
}
|
||||
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
|
||||
if ([viewId isEqualToString:obj]) {
|
||||
*stop = YES;
|
||||
|
Reference in New Issue
Block a user