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.setId(jsObject.getProperty("id").asString().value());
|
||||||
holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject());
|
holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject());
|
||||||
}
|
}
|
||||||
if (holder.flowLayoutItemNode.fullSpan
|
boolean fullSpan = this.flowLayoutNode.loadMore && position >= this.itemCount;
|
||||||
|| this.flowLayoutNode.loadMore
|
if (holder.flowLayoutItemNode.fullSpan != null) {
|
||||||
&& position >= this.itemCount) {
|
fullSpan = holder.flowLayoutItemNode.fullSpan;
|
||||||
|
}
|
||||||
|
if (fullSpan) {
|
||||||
StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(
|
StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
holder.itemView.getLayoutParams().height
|
holder.itemView.getLayoutParams().height
|
||||||
|
@ -32,7 +32,7 @@ import pub.doric.shader.StackNode;
|
|||||||
@DoricPlugin(name = "FlowLayoutItem")
|
@DoricPlugin(name = "FlowLayoutItem")
|
||||||
public class FlowLayoutItemNode extends StackNode {
|
public class FlowLayoutItemNode extends StackNode {
|
||||||
public String identifier = "";
|
public String identifier = "";
|
||||||
public boolean fullSpan = false;
|
public Boolean fullSpan = null;
|
||||||
|
|
||||||
public FlowLayoutItemNode(DoricContext doricContext) {
|
public FlowLayoutItemNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
|
@ -104,9 +104,6 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
|||||||
private int itemCount = 0;
|
private int itemCount = 0;
|
||||||
private boolean scrollable = true;
|
private boolean scrollable = true;
|
||||||
|
|
||||||
String headerViewId;
|
|
||||||
String footerViewId;
|
|
||||||
|
|
||||||
public FlowLayoutNode(DoricContext doricContext) {
|
public FlowLayoutNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
this.flowAdapter = new FlowAdapter(this);
|
this.flowAdapter = new FlowAdapter(this);
|
||||||
@ -214,12 +211,6 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
|||||||
}
|
}
|
||||||
this.onScrollEndFuncId = prop.asString().value();
|
this.onScrollEndFuncId = prop.asString().value();
|
||||||
break;
|
break;
|
||||||
case "header":
|
|
||||||
this.headerViewId = prop.asString().value();
|
|
||||||
break;
|
|
||||||
case "footer":
|
|
||||||
this.footerViewId = prop.asString().value();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
super.blend(view, name, prop);
|
super.blend(view, name, prop);
|
||||||
break;
|
break;
|
||||||
|
@ -55,6 +55,7 @@ class FlowDemo extends Panel {
|
|||||||
{
|
{
|
||||||
backgroundColor: colors[500 % colors.length],
|
backgroundColor: colors[500 % colors.length],
|
||||||
height: 50,
|
height: 50,
|
||||||
|
fullSpan: true,
|
||||||
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST),
|
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST),
|
||||||
})
|
})
|
||||||
}).in(rootView)
|
}).in(rootView)
|
||||||
|
@ -365,9 +365,12 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
|||||||
DoricFlowLayoutItemNode *node = cell.viewNode;
|
DoricFlowLayoutItemNode *node = cell.viewNode;
|
||||||
node.viewId = model[@"id"];
|
node.viewId = model[@"id"];
|
||||||
[node blend:props];
|
[node blend:props];
|
||||||
BOOL fillWidth = [props[@"fullSpan"] boolValue]
|
|
||||||
|| (self.loadMore && position >= self.itemCount);
|
BOOL fullSpan = self.loadMore && position >= self.itemCount;
|
||||||
if (fillWidth) {
|
if (props[@"fullSpan"]) {
|
||||||
|
fullSpan = [props[@"fullSpan"] boolValue];
|
||||||
|
}
|
||||||
|
if (fullSpan) {
|
||||||
node.view.width = collectionView.width;
|
node.view.width = collectionView.width;
|
||||||
} else {
|
} else {
|
||||||
node.view.width = (collectionView.width - (self.columnCount - 1) * self.columnSpace) / self.columnCount;
|
node.view.width = (collectionView.width - (self.columnCount - 1) * self.columnSpace) / self.columnCount;
|
||||||
@ -413,12 +416,12 @@ - (NSInteger)doricFlowLayoutColumnCount {
|
|||||||
|
|
||||||
- (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
|
- (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
|
||||||
NSUInteger position = (NSUInteger) indexPath.row;
|
NSUInteger position = (NSUInteger) indexPath.row;
|
||||||
if (self.loadMore && position >= self.itemCount) {
|
BOOL fullSpan = self.loadMore && position >= self.itemCount;
|
||||||
return YES;
|
NSDictionary *model = [self itemModelAt:position];
|
||||||
} else {
|
if (model[@"props"][@"fullSpan"]) {
|
||||||
NSDictionary *model = [self itemModelAt:position];
|
fullSpan = [model[@"props"][@"fullSpan"] boolValue];
|
||||||
return [model[@"props"][@"fullSpan"] boolValue];
|
|
||||||
}
|
}
|
||||||
|
return fullSpan;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
- (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;
|
identifier?: string;
|
||||||
/**
|
/**
|
||||||
* When set to true, the item will layout using all span area.
|
* 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;
|
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;
|
identifier?: string;
|
||||||
/**
|
/**
|
||||||
* When set to true, the item will layout using all span area.
|
* 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;
|
fullSpan?: boolean;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user