js:change apis of declarable

This commit is contained in:
pengfei.zhou
2020-01-04 19:13:15 +08:00
committed by osborn
parent ce4f9203f2
commit 3b82935b24
20 changed files with 478 additions and 203 deletions

View File

@@ -605,28 +605,43 @@ class VLayout extends LinearLayout {
}
class HLayout extends LinearLayout {
}
function stack(views) {
function stack(views, config) {
const ret = new Stack;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
function hlayout(views) {
function hlayout(views, config) {
const ret = new HLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
function vlayout(views) {
function vlayout(views, config) {
const ret = new VLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
@@ -1305,10 +1320,22 @@ function list(config) {
}
return ret;
}
function listItem(item) {
function listItem(item, config) {
return (new ListItem).also((it) => {
it.layoutConfig = layoutConfig().most().configHeight(exports.LayoutSpec.FIT);
it.addChild(item);
it.layoutConfig = layoutConfig().fit();
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
@@ -1385,12 +1412,6 @@ __decorate$6([
Property,
__metadata$6("design:type", Function)
], Slider.prototype, "onPageSlided", void 0);
function slideItem(item) {
return (new SlideItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
it.addChild(item);
});
}
function slider(config) {
const ret = new Slider;
for (let key in config) {
@@ -1398,6 +1419,24 @@ function slider(config) {
}
return ret;
}
function slideItem(item, config) {
return (new SlideItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
/*
* Copyright [2019] [Doric.Pub]
@@ -1591,10 +1630,22 @@ function flowlayout(config) {
}
return ret;
}
function flowItem(item) {
function flowItem(item, config) {
return (new FlowLayoutItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
it.addChild(item);
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
@@ -1709,14 +1760,21 @@ __decorate$b([
Property,
__metadata$b("design:type", Function)
], Draggable.prototype, "onDrag", void 0);
function draggable(config, views) {
function draggable(views, config) {
const ret = new Draggable;
ret.layoutConfig = layoutConfig().fit();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
if (views instanceof View) {
ret.addChild(views);
}
for (let v of views) {
ret.addChild(v);
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}

View File

@@ -2053,28 +2053,43 @@ class VLayout extends LinearLayout {
}
class HLayout extends LinearLayout {
}
function stack(views) {
function stack(views, config) {
const ret = new Stack;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
function hlayout(views) {
function hlayout(views, config) {
const ret = new HLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
function vlayout(views) {
function vlayout(views, config) {
const ret = new VLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) {
ret.addChild(v);
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}
@@ -2753,10 +2768,22 @@ function list(config) {
}
return ret;
}
function listItem(item) {
function listItem(item, config) {
return (new ListItem).also((it) => {
it.layoutConfig = layoutConfig().most().configHeight(exports.LayoutSpec.FIT);
it.addChild(item);
it.layoutConfig = layoutConfig().fit();
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
@@ -2833,12 +2860,6 @@ __decorate$6([
Property,
__metadata$6("design:type", Function)
], Slider.prototype, "onPageSlided", void 0);
function slideItem(item) {
return (new SlideItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
it.addChild(item);
});
}
function slider(config) {
const ret = new Slider;
for (let key in config) {
@@ -2846,6 +2867,24 @@ function slider(config) {
}
return ret;
}
function slideItem(item, config) {
return (new SlideItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
/*
* Copyright [2019] [Doric.Pub]
@@ -3039,10 +3078,22 @@ function flowlayout(config) {
}
return ret;
}
function flowItem(item) {
function flowItem(item, config) {
return (new FlowLayoutItem).also((it) => {
it.layoutConfig = layoutConfig().fit();
it.addChild(item);
if (item instanceof View) {
it.addChild(item);
}
else {
item.forEach(e => {
it.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(it, key, Reflect.get(config, key, config), it);
}
}
});
}
@@ -3157,14 +3208,21 @@ __decorate$b([
Property,
__metadata$b("design:type", Function)
], Draggable.prototype, "onDrag", void 0);
function draggable(config, views) {
function draggable(views, config) {
const ret = new Draggable;
ret.layoutConfig = layoutConfig().fit();
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
if (views instanceof View) {
ret.addChild(views);
}
for (let v of views) {
ret.addChild(v);
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
}
return ret;
}