iOS:fix Image async load in FlexLayout
This commit is contained in:
parent
c730a25df8
commit
f6ce6843e3
@ -31,11 +31,17 @@ - (CGSize)sizeThatFits:(CGSize)size {
|
|||||||
[view.doricLayout measure:size];
|
[view.doricLayout measure:size];
|
||||||
[view configureLayoutWithBlock:^(YGLayout *layout) {
|
[view configureLayoutWithBlock:^(YGLayout *layout) {
|
||||||
layout.isEnabled = YES;
|
layout.isEnabled = YES;
|
||||||
if (layout.width.unit == YGUnitUndefined || layout.width.unit == YGUnitAuto) {
|
if (layout.width.unit == YGUnitUndefined
|
||||||
layout.width = YGPointValue(view.doricLayout.measuredWidth);
|
|| layout.width.unit == YGUnitAuto) {
|
||||||
|
if (!view.doricLayout.undefined) {
|
||||||
|
layout.width = YGPointValue(view.doricLayout.measuredWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (layout.height.unit == YGUnitUndefined || layout.height.unit == YGUnitAuto) {
|
if (layout.height.unit == YGUnitUndefined
|
||||||
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
|| layout.height.unit == YGUnitAuto) {
|
||||||
|
if (!view.doricLayout.undefined) {
|
||||||
|
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -222,6 +228,9 @@ - (void)requestLayout {
|
|||||||
if ([view isKindOfClass:[DoricFlexView class]]) {
|
if ([view isKindOfClass:[DoricFlexView class]]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (view.doricLayout.undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (view.doricLayout.measuredWidth != view.width || view.doricLayout.measuredHeight != view.height) {
|
if (view.doricLayout.measuredWidth != view.width || view.doricLayout.measuredHeight != view.height) {
|
||||||
view.doricLayout.widthSpec = DoricLayoutJust;
|
view.doricLayout.widthSpec = DoricLayoutJust;
|
||||||
view.doricLayout.heightSpec = DoricLayoutJust;
|
view.doricLayout.heightSpec = DoricLayoutJust;
|
||||||
|
@ -114,11 +114,13 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
if ([@"imageUrl" isEqualToString:name]) {
|
if ([@"imageUrl" isEqualToString:name]) {
|
||||||
__weak typeof(self) _self = self;
|
__weak typeof(self) _self = self;
|
||||||
__block BOOL async = NO;
|
__block BOOL async = NO;
|
||||||
|
view.doricLayout.undefined = YES;
|
||||||
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
|
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
if (self.placeHolderColor || self.errorColor) {
|
if (self.placeHolderColor || self.errorColor) {
|
||||||
self.view.contentMode = self.contentMode;
|
self.view.contentMode = self.contentMode;
|
||||||
}
|
}
|
||||||
|
view.doricLayout.undefined = NO;
|
||||||
if (error) {
|
if (error) {
|
||||||
[[self currentErrorImage] also:^(UIImage *it) {
|
[[self currentErrorImage] also:^(UIImage *it) {
|
||||||
self.view.image = it;
|
self.view.image = it;
|
||||||
@ -132,11 +134,11 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
@{@"width": @(image.size.width), @"height": @(image.size.height)},
|
@{@"width": @(image.size.width), @"height": @(image.size.height)},
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
DoricSuperNode *node = self.superNode;
|
|
||||||
while (node.superNode != nil) {
|
|
||||||
node = node.superNode;
|
|
||||||
}
|
|
||||||
if (async) {
|
if (async) {
|
||||||
|
DoricSuperNode *node = self.superNode;
|
||||||
|
while (node.superNode != nil) {
|
||||||
|
node = node.superNode;
|
||||||
|
}
|
||||||
[node requestLayout];
|
[node requestLayout];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,8 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
|
|||||||
@property(nonatomic, assign) CGFloat measuredX;
|
@property(nonatomic, assign) CGFloat measuredX;
|
||||||
@property(nonatomic, assign) CGFloat measuredY;
|
@property(nonatomic, assign) CGFloat measuredY;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) BOOL undefined;
|
||||||
|
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
- (void)measure:(CGSize)targetSize;
|
- (void)measure:(CGSize)targetSize;
|
||||||
|
Reference in New Issue
Block a user