diff --git a/doric-demo/src/ListDemo.ts b/doric-demo/src/ListDemo.ts index ce8f9686..78422259 100644 --- a/doric-demo/src/ListDemo.ts +++ b/doric-demo/src/ListDemo.ts @@ -50,9 +50,9 @@ class ListVH extends ViewHolder { itemCount: 0, layoutConfig: { widthSpec: LayoutSpec.MOST, - heightSpec: LayoutSpec.JUST, - weight: 1 + heightSpec: LayoutSpec.FIT, }, + backgroundColor: Color.YELLOW, }) ], { diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m index 56c3b883..3d2f4495 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m @@ -296,6 +296,13 @@ - (void)callItem:(NSUInteger)position size:(CGSize)size { return; } self.itemSizeInfo[@(position)] = [NSValue valueWithCGSize:size]; + if (self.view.doricLayout.widthSpec == DoricLayoutFit || self.view.doricLayout.heightSpec == DoricLayoutFit) { + DoricSuperNode *node = self.superNode; + while (node.superNode != nil) { + node = node.superNode; + } + [node requestLayout]; + } [self.view.collectionViewLayout invalidateLayout]; } diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index 2924d975..44515f60 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -35,6 +35,9 @@ @interface DoricTableView : UITableView @end @implementation DoricTableView +- (CGSize)sizeThatFits:(CGSize)size { + return [super sizeThatFits:size]; +} @end @@ -232,7 +235,7 @@ - (void)blendSubNode:(NSDictionary *)subModel { @try { [self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } - @catch(id exception) { + @catch (id exception) { [self.doricContext.driver.registry onException:exception inContext:self.doricContext]; } }]; @@ -251,6 +254,13 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height { self.itemHeights[@(position)] = @(height); if (@available(iOS 10.0, *)) { dispatch_async(dispatch_get_main_queue(), ^{ + if (self.view.doricLayout.heightSpec == DoricLayoutFit) { + DoricSuperNode *node = self.superNode; + while (node.superNode != nil) { + node = node.superNode; + } + [node requestLayout]; + } [UIView performWithoutAnimation:^{ NSUInteger itemCount = self.itemCount + (self.loadMore ? 1 : 0); if (itemCount <= position || currentCount != itemCount) { @@ -261,13 +271,20 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height { @try { [self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } - @catch(id exception) { + @catch (id exception) { [self.doricContext.driver.registry onException:exception inContext:self.doricContext]; } }]; }); } else { dispatch_async(dispatch_get_main_queue(), ^{ + if (self.view.doricLayout.heightSpec == DoricLayoutFit) { + DoricSuperNode *node = self.superNode; + while (node.superNode != nil) { + node = node.superNode; + } + [node requestLayout]; + } [self.view reloadData]; }); }