FlowLayoutItem add fullSpan attribute
This commit is contained in:
parent
9429c75834
commit
0e77c62e13
@ -69,7 +69,8 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
|
||||
holder.flowLayoutItemNode.setId(jsObject.getProperty("id").asString().value());
|
||||
holder.flowLayoutItemNode.blend(jsObject.getProperty("props").asObject());
|
||||
}
|
||||
if ((this.flowLayoutNode.hasHeader() && position == 0)
|
||||
if (holder.flowLayoutItemNode.fullSpan
|
||||
|| (this.flowLayoutNode.hasHeader() && position == 0)
|
||||
|| (this.flowLayoutNode.hasFooter() && position == this.getItemCount() - 1)
|
||||
|| this.flowLayoutNode.loadMore
|
||||
&& position == this.itemCount + (this.flowLayoutNode.hasHeader() ? 1 : 0)) {
|
||||
|
@ -32,6 +32,7 @@ import pub.doric.shader.StackNode;
|
||||
@DoricPlugin(name = "FlowLayoutItem")
|
||||
public class FlowLayoutItemNode extends StackNode {
|
||||
public String identifier = "";
|
||||
public boolean fullSpan = false;
|
||||
|
||||
public FlowLayoutItemNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
@ -42,6 +43,8 @@ public class FlowLayoutItemNode extends StackNode {
|
||||
protected void blend(FrameLayout view, String name, JSValue prop) {
|
||||
if ("identifier".equals(name)) {
|
||||
this.identifier = prop.asString().value();
|
||||
} else if ("fullSpan".equals(name)) {
|
||||
this.fullSpan = prop.asBoolean().value();
|
||||
} else {
|
||||
super.blend(view, name, prop);
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ class FlowDemo extends Panel {
|
||||
backgroundColor: colors[idx % colors.length],
|
||||
height: 50 + (idx % 3) * 20,
|
||||
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST),
|
||||
}).also(it => {
|
||||
if (idx == 15) {
|
||||
it.fullSpan = true
|
||||
}
|
||||
})
|
||||
},
|
||||
loadMore: true,
|
||||
|
@ -401,7 +401,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
||||
DoricFlowLayoutItemNode *node = cell.viewNode;
|
||||
node.viewId = model[@"id"];
|
||||
[node blend:props];
|
||||
BOOL fillWidth = (self.hasHeader && position == 0)
|
||||
BOOL fillWidth = [props[@"fullSpan"] boolValue]
|
||||
|| (self.hasHeader && position == 0)
|
||||
|| (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
@ -456,7 +457,7 @@ - (NSInteger)doricFlowLayoutColumnCount {
|
||||
|
||||
- (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
|
||||
NSUInteger position = (NSUInteger) indexPath.row;
|
||||
return (self.hasHeader && position == 0)
|
||||
if ((self.hasHeader && position == 0)
|
||||
|| (self.hasFooter
|
||||
&& position == self.itemCount
|
||||
+ (self.loadMore ? 1 : 0)
|
||||
@ -464,7 +465,12 @@ - (BOOL)doricFlowLayoutItemFullSpan:(NSIndexPath *)indexPath {
|
||||
+ (self.hasFooter ? 1 : 0)
|
||||
- 1)
|
||||
|| (self.loadMore
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0));
|
||||
&& position == self.itemCount + (self.hasHeader ? 1 : 0))) {
|
||||
return YES;
|
||||
} else {
|
||||
NSDictionary *model = [self itemModelAt:position];
|
||||
return [model[@"props"][@"fullSpan"] boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
|
@ -2931,6 +2931,10 @@ var FlowLayoutItem = /** @class */ (function (_super) {
|
||||
Property,
|
||||
__metadata$5("design:type", String)
|
||||
], FlowLayoutItem.prototype, "identifier", void 0);
|
||||
__decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", Boolean)
|
||||
], FlowLayoutItem.prototype, "fullSpan", void 0);
|
||||
return FlowLayoutItem;
|
||||
}(Stack));
|
||||
var FlowLayout = /** @class */ (function (_super) {
|
||||
|
@ -2211,6 +2211,10 @@ __decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", String)
|
||||
], FlowLayoutItem.prototype, "identifier", void 0);
|
||||
__decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", Boolean)
|
||||
], FlowLayoutItem.prototype, "fullSpan", void 0);
|
||||
class FlowLayout extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
@ -3732,6 +3732,10 @@ __decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", String)
|
||||
], FlowLayoutItem.prototype, "identifier", void 0);
|
||||
__decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", Boolean)
|
||||
], FlowLayoutItem.prototype, "fullSpan", void 0);
|
||||
class FlowLayout extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
4
doric-js/index.d.ts
vendored
4
doric-js/index.d.ts
vendored
@ -835,6 +835,10 @@ declare module 'doric/lib/src/widget/flowlayout' {
|
||||
* Set to reuse native view
|
||||
*/
|
||||
identifier?: string;
|
||||
/**
|
||||
* When set to true, the item will layout using all span area.
|
||||
*/
|
||||
fullSpan?: boolean;
|
||||
}
|
||||
export class FlowLayout extends Superview {
|
||||
allSubviews(): FlowLayoutItem[];
|
||||
|
4
doric-js/lib/src/widget/flowlayout.d.ts
vendored
4
doric-js/lib/src/widget/flowlayout.d.ts
vendored
@ -5,6 +5,10 @@ export declare class FlowLayoutItem extends Stack {
|
||||
* Set to reuse native view
|
||||
*/
|
||||
identifier?: string;
|
||||
/**
|
||||
* When set to true, the item will layout using all span area.
|
||||
*/
|
||||
fullSpan?: boolean;
|
||||
}
|
||||
export declare class FlowLayout extends Superview {
|
||||
private cachedViews;
|
||||
|
@ -31,6 +31,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], FlowLayoutItem.prototype, "identifier", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", Boolean)
|
||||
], FlowLayoutItem.prototype, "fullSpan", void 0);
|
||||
export class FlowLayout extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
@ -23,6 +23,12 @@ export class FlowLayoutItem extends Stack {
|
||||
*/
|
||||
@Property
|
||||
identifier?: string
|
||||
/**
|
||||
* When set to true, the item will layout using all span area.
|
||||
* HeaderView, footerView or loadMoreView is always true by default.
|
||||
*/
|
||||
@Property
|
||||
fullSpan?: boolean
|
||||
}
|
||||
|
||||
export class FlowLayout extends Superview {
|
||||
|
4
doric-web/dist/index.js
vendored
4
doric-web/dist/index.js
vendored
@ -3786,6 +3786,10 @@ __decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", String)
|
||||
], FlowLayoutItem.prototype, "identifier", void 0);
|
||||
__decorate$5([
|
||||
Property,
|
||||
__metadata$5("design:type", Boolean)
|
||||
], FlowLayoutItem.prototype, "fullSpan", void 0);
|
||||
class FlowLayout extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user