diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java index e58f2aa6..ee88ca92 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowAdapter.java @@ -67,9 +67,11 @@ class FlowAdapter extends RecyclerView.Adapter { holder.flowLayoutItemNode.setId(jsObject.getProperty("id").asString().value()); holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject()); } - if (holder.flowLayoutItemNode.fullSpan - || this.flowLayoutNode.loadMore - && position >= this.itemCount) { + boolean fullSpan = this.flowLayoutNode.loadMore && position >= this.itemCount; + if (holder.flowLayoutItemNode.fullSpan != null) { + fullSpan = holder.flowLayoutItemNode.fullSpan; + } + if (fullSpan) { StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, holder.itemView.getLayoutParams().height diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutItemNode.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutItemNode.java index 20f9143e..fcee9c11 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutItemNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutItemNode.java @@ -32,7 +32,7 @@ import pub.doric.shader.StackNode; @DoricPlugin(name = "FlowLayoutItem") public class FlowLayoutItemNode extends StackNode { public String identifier = ""; - public boolean fullSpan = false; + public Boolean fullSpan = null; public FlowLayoutItemNode(DoricContext doricContext) { super(doricContext); diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java index a81a5613..95f53dd0 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java @@ -104,9 +104,6 @@ public class FlowLayoutNode extends SuperNode implements IDoricScr private int itemCount = 0; private boolean scrollable = true; - String headerViewId; - String footerViewId; - public FlowLayoutNode(DoricContext doricContext) { super(doricContext); this.flowAdapter = new FlowAdapter(this); @@ -214,12 +211,6 @@ public class FlowLayoutNode extends SuperNode implements IDoricScr } this.onScrollEndFuncId = prop.asString().value(); break; - case "header": - this.headerViewId = prop.asString().value(); - break; - case "footer": - this.footerViewId = prop.asString().value(); - break; default: super.blend(view, name, prop); break; diff --git a/doric-demo/src/FlowLayoutDemo.ts b/doric-demo/src/FlowLayoutDemo.ts index 3541cd0f..5dd4f775 100644 --- a/doric-demo/src/FlowLayoutDemo.ts +++ b/doric-demo/src/FlowLayoutDemo.ts @@ -55,6 +55,7 @@ class FlowDemo extends Panel { { backgroundColor: colors[500 % colors.length], height: 50, + fullSpan: true, layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST), }) }).in(rootView) diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m index ac3d0f20..2ddc1f4c 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m @@ -365,9 +365,12 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection DoricFlowLayoutItemNode *node = cell.viewNode; node.viewId = model[@"id"]; [node blend:props]; - BOOL fillWidth = [props[@"fullSpan"] boolValue] - || (self.loadMore && position >= self.itemCount); - if (fillWidth) { + + BOOL fullSpan = self.loadMore && position >= self.itemCount; + if (props[@"fullSpan"]) { + fullSpan = [props[@"fullSpan"] boolValue]; + } + if (fullSpan) { node.view.width = collectionView.width; } else { node.view.width = (collectionView.width - (self.columnCount - 1) * self.columnSpace) / self.columnCount; @@ -413,12 +416,12 @@ - (NSInteger)doricFlowLayoutColumnCount { - (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath { NSUInteger position = (NSUInteger) indexPath.row; - if (self.loadMore && position >= self.itemCount) { - return YES; - } else { - NSDictionary *model = [self itemModelAt:position]; - return [model[@"props"][@"fullSpan"] boolValue]; + BOOL fullSpan = self.loadMore && position >= self.itemCount; + NSDictionary *model = [self itemModelAt:position]; + if (model[@"props"][@"fullSpan"]) { + fullSpan = [model[@"props"][@"fullSpan"] boolValue]; } + return fullSpan; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 89807c4a..328402d1 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -857,7 +857,7 @@ declare module 'doric/lib/src/widget/flowlayout' { identifier?: string; /** * When set to true, the item will layout using all span area. - * HeaderView, footerView or loadMoreView is always true by default. + * LoadMoreView is default to true. */ fullSpan?: boolean; } diff --git a/doric-js/lib/src/widget/flowlayout.d.ts b/doric-js/lib/src/widget/flowlayout.d.ts index d8836611..86ab8612 100644 --- a/doric-js/lib/src/widget/flowlayout.d.ts +++ b/doric-js/lib/src/widget/flowlayout.d.ts @@ -8,7 +8,7 @@ export declare class FlowLayoutItem extends Stack { identifier?: string; /** * When set to true, the item will layout using all span area. - * HeaderView, footerView or loadMoreView is always true by default. + * LoadMoreView is default to true. */ fullSpan?: boolean; }