Flowlayout's loadMoreView supports fullSpan,default is false
This commit is contained in:
parent
738c072ee4
commit
f09f7859b9
@ -67,9 +67,11 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -104,9 +104,6 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> 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<RecyclerView> 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;
|
||||
|
@ -55,6 +55,7 @@ class FlowDemo extends Panel {
|
||||
{
|
||||
backgroundColor: colors[500 % colors.length],
|
||||
height: 50,
|
||||
fullSpan: true,
|
||||
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST),
|
||||
})
|
||||
}).in(rootView)
|
||||
|
@ -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 {
|
||||
|
2
doric-js/index.d.ts
vendored
2
doric-js/index.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
2
doric-js/lib/src/widget/flowlayout.d.ts
vendored
2
doric-js/lib/src/widget/flowlayout.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user