feat:Android LinearNode setBaselineAligned false

This commit is contained in:
刘涛 2020-07-03 16:53:31 +08:00 committed by osborn
parent ae5ac30fb6
commit 787ea71862
24 changed files with 4510 additions and 4769 deletions

View File

@ -20,12 +20,12 @@ import android.graphics.drawable.ShapeDrawable;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import pub.doric.DoricContext;
import pub.doric.utils.DoricUtils;
import com.github.pengfeizhou.jscore.JSObject; import com.github.pengfeizhou.jscore.JSObject;
import com.github.pengfeizhou.jscore.JSValue; import com.github.pengfeizhou.jscore.JSValue;
import pub.doric.DoricContext;
import pub.doric.utils.DoricUtils;
/** /**
* @Description: com.github.penfeizhou.doric.shader * @Description: com.github.penfeizhou.doric.shader
* @Author: pengfei.zhou * @Author: pengfei.zhou
@ -94,7 +94,9 @@ public class LinearNode extends GroupNode<LinearLayout> {
@Override @Override
protected LinearLayout build() { protected LinearLayout build() {
return new MaximumLinearLayout(getContext()); LinearLayout linearLayout= new MaximumLinearLayout(getContext());
linearLayout.setBaselineAligned(false);
return linearLayout;
} }
@Override @Override

View File

@ -1,4 +1,4 @@
import { Panel, Group, scroller, vlayout, layoutConfig, LayoutSpec, Input, Gravity, log, input, text, Color, Text, InputType } from "doric"; import { Panel, Group, scroller, vlayout, layoutConfig, LayoutSpec, Input, Gravity, log, input, text, Color, Text, InputType, hlayout } from "doric";
import { title } from "./utils"; import { title } from "./utils";
@Entry @Entry
class TextDemo extends Panel { class TextDemo extends Panel {
@ -8,41 +8,40 @@ class TextDemo extends Panel {
[ [
title("Text Demo"), title("Text Demo"),
input({ input({
width : 100, width: 100,
height:100, height: 100,
inputType: InputType.Number, inputType: InputType.Number,
hintText: "number" hintText: "number"
}), }),
hlayout([
// input({ text({
// width : 100, text: "size 10",
// height:100, textSize: 10,
// inputType: InputType.NumberSigned, backgroundColor: Color.GREEN
// hintText: "NumberSigned" }),
// }), text({
text: "size 25",
// input({ textSize: 25,
// width : 100, backgroundColor: Color.BLUE
// height:100, }),
// inputType: InputType.Alphabet, text({
// hintText: "Alphabet" text: "size 18",
// }), textSize: 18,
backgroundColor: Color.LTGRAY,
// input({ })
// width : 100, ], {
// height:100, backgroundColor: Color.RED,
// inputType: InputType.Phone, height: 50,
// hintText: "Phone" gravity: Gravity.CenterX,
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST).configHeight(LayoutSpec.JUST),
// }), }),
text({ text({
text: "This is normal text", text: "This is normal text",
}), }),
text({ text({
text: "This is normal text with shadow ", text: "This is normal text with shadow ",
textSize: 20, textSize: 20,
shadow: { shadow: {
color: Color.parse("#1DD6DE"), color: Color.parse("#1DD6DE"),
offsetX: 0, offsetX: 0,
offsetY: 1, offsetY: 1,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -33,232 +33,228 @@ export function NativeCall(target, propertyKey, descriptor) {
}; };
return descriptor; return descriptor;
} }
let Panel = /** @class */ (() => { export class Panel {
class Panel { constructor() {
constructor() { this.destroyed = false;
this.destroyed = false; this.__root__ = new Root;
this.__root__ = new Root; this.headviews = new Map;
this.headviews = new Map; this.onRenderFinishedCallback = [];
this.onRenderFinishedCallback = []; this.__rendering__ = false;
this.__rendering__ = false; }
onCreate() { }
onDestroy() { }
onShow() { }
onHidden() { }
addHeadView(type, v) {
let map = this.headviews.get(type);
if (map) {
map.set(v.viewId, v);
} }
onCreate() { } else {
onDestroy() { } map = new Map;
onShow() { } map.set(v.viewId, v);
onHidden() { } this.headviews.set(type, map);
addHeadView(type, v) { }
}
allHeadViews() {
return this.headviews.values();
}
removeHeadView(type, v) {
if (this.headviews.has(type)) {
let map = this.headviews.get(type); let map = this.headviews.get(type);
if (map) { if (map) {
map.set(v.viewId, v); if (v instanceof View) {
} map.delete(v.viewId);
else {
map = new Map;
map.set(v.viewId, v);
this.headviews.set(type, map);
}
}
allHeadViews() {
return this.headviews.values();
}
removeHeadView(type, v) {
if (this.headviews.has(type)) {
let map = this.headviews.get(type);
if (map) {
if (v instanceof View) {
map.delete(v.viewId);
}
else {
map.delete(v);
}
}
}
}
clearHeadViews(type) {
if (this.headviews.has(type)) {
this.headviews.delete(type);
}
}
getRootView() {
return this.__root__;
}
getInitData() {
return this.__data__;
}
__init__(data) {
if (data) {
this.__data__ = JSON.parse(data);
}
}
__onCreate__() {
this.onCreate();
}
__onDestroy__() {
this.destroyed = true;
this.onDestroy();
}
__onShow__() {
this.onShow();
}
__onHidden__() {
this.onHidden();
}
__build__(frame) {
this.__root__.width = frame.width;
this.__root__.height = frame.height;
this.__root__.children.length = 0;
this.build(this.__root__);
}
__response__(viewIds, callbackId) {
const v = this.retrospectView(viewIds);
if (v === undefined) {
loge(`Cannot find view for ${viewIds}`);
}
else {
const argumentsList = [callbackId];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(v.responseCallback, v, argumentsList);
}
}
retrospectView(ids) {
return ids.reduce((acc, cur) => {
if (acc === undefined) {
if (cur === this.__root__.viewId) {
return this.__root__;
}
for (let map of this.headviews.values()) {
if (map.has(cur)) {
return map.get(cur);
}
}
return undefined;
} }
else { else {
if (Reflect.has(acc, "subviewById")) { map.delete(v);
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]);
}
return acc;
} }
}, undefined); }
} }
nativeRender(model) { }
return this.context.callNative("shader", "render", model); clearHeadViews(type) {
if (this.headviews.has(type)) {
this.headviews.delete(type);
} }
hookBeforeNativeCall() { }
if (Environment.platform !== 'web') { getRootView() {
this.__root__.clean(); return this.__root__;
}
getInitData() {
return this.__data__;
}
__init__(data) {
if (data) {
this.__data__ = JSON.parse(data);
}
}
__onCreate__() {
this.onCreate();
}
__onDestroy__() {
this.destroyed = true;
this.onDestroy();
}
__onShow__() {
this.onShow();
}
__onHidden__() {
this.onHidden();
}
__build__(frame) {
this.__root__.width = frame.width;
this.__root__.height = frame.height;
this.__root__.children.length = 0;
this.build(this.__root__);
}
__response__(viewIds, callbackId) {
const v = this.retrospectView(viewIds);
if (v === undefined) {
loge(`Cannot find view for ${viewIds}`);
}
else {
const argumentsList = [callbackId];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(v.responseCallback, v, argumentsList);
}
}
retrospectView(ids) {
return ids.reduce((acc, cur) => {
if (acc === undefined) {
if (cur === this.__root__.viewId) {
return this.__root__;
}
for (let map of this.headviews.values()) { for (let map of this.headviews.values()) {
for (let v of map.values()) { if (map.has(cur)) {
v.clean(); return map.get(cur);
}
}
return undefined;
}
else {
if (Reflect.has(acc, "subviewById")) {
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]);
}
return acc;
}
}, undefined);
}
nativeRender(model) {
return this.context.callNative("shader", "render", model);
}
hookBeforeNativeCall() {
if (Environment.platform !== 'web') {
this.__root__.clean();
for (let map of this.headviews.values()) {
for (let v of map.values()) {
v.clean();
}
}
}
}
hookAfterNativeCall() {
if (this.destroyed) {
return;
}
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
promises.push(this.nativeRender(model));
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
promises.push(this.nativeRender(model));
} }
} }
} }
} }
hookAfterNativeCall() { else {
if (this.destroyed) { Promise.resolve().then(() => {
return;
}
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
if (this.__root__.isDirty()) { if (this.__root__.isDirty()) {
const model = this.__root__.toModel(); const model = this.__root__.toModel();
promises.push(this.nativeRender(model)); promises.push(this.nativeRender(model));
this.__root__.clean();
} }
for (let map of this.headviews.values()) { for (let map of this.headviews.values()) {
for (let v of map.values()) { for (let v of map.values()) {
if (v.isDirty()) { if (v.isDirty()) {
const model = v.toModel(); const model = v.toModel();
promises.push(this.nativeRender(model)); promises.push(this.nativeRender(model));
v.clean();
} }
} }
} }
}
else {
Promise.resolve().then(() => {
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
promises.push(this.nativeRender(model));
this.__root__.clean();
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
promises.push(this.nativeRender(model));
v.clean();
}
}
}
});
}
if (this.__rendering__) {
//skip
Promise.all(promises).then(_ => {
});
}
else {
this.__rendering__ = true;
Promise.all(promises).then(_ => {
this.__rendering__ = false;
this.onRenderFinished();
});
}
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e();
}); });
this.onRenderFinishedCallback.length = 0;
} }
addOnRenderFinishedCallback(cb) { if (this.__rendering__) {
this.onRenderFinishedCallback.push(cb); //skip
Promise.all(promises).then(_ => {
});
}
else {
this.__rendering__ = true;
Promise.all(promises).then(_ => {
this.__rendering__ = false;
this.onRenderFinished();
});
} }
} }
__decorate([ onRenderFinished() {
NativeCall, this.onRenderFinishedCallback.forEach(e => {
__metadata("design:type", Function), e();
__metadata("design:paramtypes", [String]), });
__metadata("design:returntype", void 0) this.onRenderFinishedCallback.length = 0;
], Panel.prototype, "__init__", null); }
__decorate([ addOnRenderFinishedCallback(cb) {
NativeCall, this.onRenderFinishedCallback.push(cb);
__metadata("design:type", Function), }
__metadata("design:paramtypes", []), }
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__onCreate__", null); NativeCall,
__decorate([ __metadata("design:type", Function),
NativeCall, __metadata("design:paramtypes", [String]),
__metadata("design:type", Function), __metadata("design:returntype", void 0)
__metadata("design:paramtypes", []), ], Panel.prototype, "__init__", null);
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__onDestroy__", null); NativeCall,
__decorate([ __metadata("design:type", Function),
NativeCall, __metadata("design:paramtypes", []),
__metadata("design:type", Function), __metadata("design:returntype", void 0)
__metadata("design:paramtypes", []), ], Panel.prototype, "__onCreate__", null);
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__onShow__", null); NativeCall,
__decorate([ __metadata("design:type", Function),
NativeCall, __metadata("design:paramtypes", []),
__metadata("design:type", Function), __metadata("design:returntype", void 0)
__metadata("design:paramtypes", []), ], Panel.prototype, "__onDestroy__", null);
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__onHidden__", null); NativeCall,
__decorate([ __metadata("design:type", Function),
NativeCall, __metadata("design:paramtypes", []),
__metadata("design:type", Function), __metadata("design:returntype", void 0)
__metadata("design:paramtypes", [Object]), ], Panel.prototype, "__onShow__", null);
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__build__", null); NativeCall,
__decorate([ __metadata("design:type", Function),
NativeCall, __metadata("design:paramtypes", []),
__metadata("design:type", Function), __metadata("design:returntype", void 0)
__metadata("design:paramtypes", [Array, String]), ], Panel.prototype, "__onHidden__", null);
__metadata("design:returntype", void 0) __decorate([
], Panel.prototype, "__response__", null); NativeCall,
return Panel; __metadata("design:type", Function),
})(); __metadata("design:paramtypes", [Object]),
export { Panel }; __metadata("design:returntype", void 0)
], Panel.prototype, "__build__", null);
__decorate([
NativeCall,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, String]),
__metadata("design:returntype", void 0)
], Panel.prototype, "__response__", null);

View File

@ -13,279 +13,275 @@ import { loge } from "../util/log";
export function Property(target, propKey) { export function Property(target, propKey) {
Reflect.defineMetadata(propKey, true, target); Reflect.defineMetadata(propKey, true, target);
} }
let View = /** @class */ (() => { export class View {
class View { constructor() {
constructor() { this.width = 0;
this.width = 0; this.height = 0;
this.height = 0; this.x = 0;
this.x = 0; this.y = 0;
this.y = 0; this.viewId = uniqueId('ViewId');
this.viewId = uniqueId('ViewId'); this.callbacks = new Map;
this.callbacks = new Map; /** Anchor end*/
/** Anchor end*/ this.__dirty_props__ = {};
this.__dirty_props__ = {}; this.nativeViewModel = {
this.nativeViewModel = { id: this.viewId,
id: this.viewId, type: this.constructor.name,
type: this.constructor.name, props: this.__dirty_props__,
props: this.__dirty_props__, };
}; return new Proxy(this, {
return new Proxy(this, { get: (target, p, receiver) => {
get: (target, p, receiver) => { return Reflect.get(target, p, receiver);
return Reflect.get(target, p, receiver); },
}, set: (target, p, v, receiver) => {
set: (target, p, v, receiver) => { const oldV = Reflect.get(target, p, receiver);
const oldV = Reflect.get(target, p, receiver); const ret = Reflect.set(target, p, v, receiver);
const ret = Reflect.set(target, p, v, receiver); if (Reflect.getMetadata(p, target) && oldV !== v) {
if (Reflect.getMetadata(p, target) && oldV !== v) { receiver.onPropertyChanged(p.toString(), oldV, v);
receiver.onPropertyChanged(p.toString(), oldV, v);
}
return ret;
} }
}); return ret;
}
callback2Id(f) {
const id = uniqueId('Function');
this.callbacks.set(id, f);
return id;
}
id2Callback(id) {
let f = this.callbacks.get(id);
if (f === undefined) {
f = Reflect.get(this, id);
} }
return f; });
}
callback2Id(f) {
const id = uniqueId('Function');
this.callbacks.set(id, f);
return id;
}
id2Callback(id) {
let f = this.callbacks.get(id);
if (f === undefined) {
f = Reflect.get(this, id);
} }
/** Anchor start*/ return f;
get left() { }
return this.x; /** Anchor start*/
get left() {
return this.x;
}
set left(v) {
this.x = v;
}
get right() {
return this.x + this.width;
}
set right(v) {
this.x = v - this.width;
}
get top() {
return this.y;
}
set top(v) {
this.y = v;
}
get bottom() {
return this.y + this.height;
}
set bottom(v) {
this.y = v - this.height;
}
get centerX() {
return this.x + this.width / 2;
}
get centerY() {
return this.y + this.height / 2;
}
set centerX(v) {
this.x = v - this.width / 2;
}
set centerY(v) {
this.y = v - this.height / 2;
}
get dirtyProps() {
return this.__dirty_props__;
}
onPropertyChanged(propKey, oldV, newV) {
if (newV instanceof Function) {
newV = this.callback2Id(newV);
} }
set left(v) { else {
this.x = v; newV = obj2Model(newV);
} }
get right() { this.__dirty_props__[propKey] = newV;
return this.x + this.width; }
} clean() {
set right(v) { for (const key in this.__dirty_props__) {
this.x = v - this.width; if (Reflect.has(this.__dirty_props__, key)) {
} Reflect.deleteProperty(this.__dirty_props__, key);
get top() {
return this.y;
}
set top(v) {
this.y = v;
}
get bottom() {
return this.y + this.height;
}
set bottom(v) {
this.y = v - this.height;
}
get centerX() {
return this.x + this.width / 2;
}
get centerY() {
return this.y + this.height / 2;
}
set centerX(v) {
this.x = v - this.width / 2;
}
set centerY(v) {
this.y = v - this.height / 2;
}
get dirtyProps() {
return this.__dirty_props__;
}
onPropertyChanged(propKey, oldV, newV) {
if (newV instanceof Function) {
newV = this.callback2Id(newV);
} }
else {
newV = obj2Model(newV);
}
this.__dirty_props__[propKey] = newV;
}
clean() {
for (const key in this.__dirty_props__) {
if (Reflect.has(this.__dirty_props__, key)) {
Reflect.deleteProperty(this.__dirty_props__, key);
}
}
}
isDirty() {
return Reflect.ownKeys(this.__dirty_props__).length !== 0;
}
responseCallback(id, ...args) {
const f = this.id2Callback(id);
if (f instanceof Function) {
const argumentsList = [];
for (let i = 1; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(f, this, argumentsList);
}
else {
loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`);
}
}
toModel() {
return this.nativeViewModel;
}
let(block) {
block(this);
}
also(block) {
block(this);
return this;
}
apply(config) {
for (let key in config) {
Reflect.set(this, key, Reflect.get(config, key, config), this);
}
return this;
}
in(group) {
group.addChild(this);
return this;
}
nativeChannel(context, name) {
let thisView = this;
return function (args = undefined) {
const viewIds = [];
while (thisView != undefined) {
viewIds.push(thisView.viewId);
thisView = thisView.superview;
}
const params = {
viewIds: viewIds.reverse(),
name,
args,
};
return context.callNative('shader', 'command', params);
};
}
getWidth(context) {
return this.nativeChannel(context, 'getWidth')();
}
getHeight(context) {
return this.nativeChannel(context, 'getHeight')();
}
getX(context) {
return this.nativeChannel(context, 'getX')();
}
getY(context) {
return this.nativeChannel(context, 'getY')();
}
getLocationOnScreen(context) {
return this.nativeChannel(context, "getLocationOnScreen")();
}
doAnimation(context, animation) {
return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => {
for (let key in args) {
Reflect.set(this, key, Reflect.get(args, key, args), this);
Reflect.deleteProperty(this.__dirty_props__, key);
}
});
} }
} }
__decorate([ isDirty() {
Property, return Reflect.ownKeys(this.__dirty_props__).length !== 0;
__metadata("design:type", Number) }
], View.prototype, "width", void 0); responseCallback(id, ...args) {
__decorate([ const f = this.id2Callback(id);
Property, if (f instanceof Function) {
__metadata("design:type", Number) const argumentsList = [];
], View.prototype, "height", void 0); for (let i = 1; i < arguments.length; i++) {
__decorate([ argumentsList.push(arguments[i]);
Property, }
__metadata("design:type", Number) return Reflect.apply(f, this, argumentsList);
], View.prototype, "x", void 0); }
__decorate([ else {
Property, loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`);
__metadata("design:type", Number) }
], View.prototype, "y", void 0); }
__decorate([ toModel() {
Property, return this.nativeViewModel;
__metadata("design:type", Object) }
], View.prototype, "backgroundColor", void 0); let(block) {
__decorate([ block(this);
Property, }
__metadata("design:type", Object) also(block) {
], View.prototype, "corners", void 0); block(this);
__decorate([ return this;
Property, }
__metadata("design:type", Object) apply(config) {
], View.prototype, "border", void 0); for (let key in config) {
__decorate([ Reflect.set(this, key, Reflect.get(config, key, config), this);
Property, }
__metadata("design:type", Object) return this;
], View.prototype, "shadow", void 0); }
__decorate([ in(group) {
Property, group.addChild(this);
__metadata("design:type", Number) return this;
], View.prototype, "alpha", void 0); }
__decorate([ nativeChannel(context, name) {
Property, let thisView = this;
__metadata("design:type", Boolean) return function (args = undefined) {
], View.prototype, "hidden", void 0); const viewIds = [];
__decorate([ while (thisView != undefined) {
Property, viewIds.push(thisView.viewId);
__metadata("design:type", Object) thisView = thisView.superview;
], View.prototype, "padding", void 0); }
__decorate([ const params = {
Property, viewIds: viewIds.reverse(),
__metadata("design:type", Object) name,
], View.prototype, "layoutConfig", void 0); args,
__decorate([ };
Property, return context.callNative('shader', 'command', params);
__metadata("design:type", Function) };
], View.prototype, "onClick", void 0); }
__decorate([ getWidth(context) {
Property, return this.nativeChannel(context, 'getWidth')();
__metadata("design:type", Number) }
], View.prototype, "translationX", void 0); getHeight(context) {
__decorate([ return this.nativeChannel(context, 'getHeight')();
Property, }
__metadata("design:type", Number) getX(context) {
], View.prototype, "translationY", void 0); return this.nativeChannel(context, 'getX')();
__decorate([ }
Property, getY(context) {
__metadata("design:type", Number) return this.nativeChannel(context, 'getY')();
], View.prototype, "scaleX", void 0); }
__decorate([ getLocationOnScreen(context) {
Property, return this.nativeChannel(context, "getLocationOnScreen")();
__metadata("design:type", Number) }
], View.prototype, "scaleY", void 0); doAnimation(context, animation) {
__decorate([ return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => {
Property, for (let key in args) {
__metadata("design:type", Number) Reflect.set(this, key, Reflect.get(args, key, args), this);
], View.prototype, "pivotX", void 0); Reflect.deleteProperty(this.__dirty_props__, key);
__decorate([ }
Property, });
__metadata("design:type", Number) }
], View.prototype, "pivotY", void 0); }
__decorate([ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], View.prototype, "rotation", void 0); ], View.prototype, "width", void 0);
__decorate([ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], View.prototype, "rotationX", void 0); ], View.prototype, "height", void 0);
__decorate([ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], View.prototype, "rotationY", void 0); ], View.prototype, "x", void 0);
__decorate([ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], View.prototype, "perspective", void 0); ], View.prototype, "y", void 0);
__decorate([ __decorate([
Property, Property,
__metadata("design:type", Object) __metadata("design:type", Object)
], View.prototype, "flexConfig", void 0); ], View.prototype, "backgroundColor", void 0);
return View; __decorate([
})(); Property,
export { View }; __metadata("design:type", Object)
], View.prototype, "corners", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "border", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "shadow", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "alpha", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], View.prototype, "hidden", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "padding", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "layoutConfig", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], View.prototype, "onClick", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "translationX", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "translationY", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "scaleX", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "scaleY", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "pivotX", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "pivotY", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "rotation", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "rotationX", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "rotationY", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], View.prototype, "perspective", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "flexConfig", void 0);
export class Superview extends View { export class Superview extends View {
subviewById(id) { subviewById(id) {
for (let v of this.allSubviews()) { for (let v of this.allSubviews()) {

View File

@ -1,61 +1,57 @@
/** /**
* Store color as format AARRGGBB or RRGGBB * Store color as format AARRGGBB or RRGGBB
*/ */
let Color = /** @class */ (() => { export class Color {
class Color { constructor(v) {
constructor(v) { this._value = 0;
this._value = 0; this._value = v | 0x0;
this._value = v | 0x0; }
static parse(str) {
if (!str.startsWith("#")) {
throw new Error(`Parse color error with ${str}`);
} }
static parse(str) { const val = parseInt(str.substr(1), 16);
if (!str.startsWith("#")) { if (str.length === 7) {
throw new Error(`Parse color error with ${str}`); return new Color(val | 0xff000000);
}
const val = parseInt(str.substr(1), 16);
if (str.length === 7) {
return new Color(val | 0xff000000);
}
else if (str.length === 9) {
return new Color(val);
}
else {
throw new Error(`Parse color error with ${str}`);
}
} }
static safeParse(str, defVal = Color.TRANSPARENT) { else if (str.length === 9) {
let color = defVal; return new Color(val);
try {
color = Color.parse(str);
}
catch (e) {
}
finally {
return color;
}
} }
alpha(v) { else {
v = v * 255; throw new Error(`Parse color error with ${str}`);
return new Color((this._value & 0xffffff) | ((v & 0xff) << 24));
}
toModel() {
return this._value;
} }
} }
Color.BLACK = new Color(0xFF000000); static safeParse(str, defVal = Color.TRANSPARENT) {
Color.DKGRAY = new Color(0xFF444444); let color = defVal;
Color.GRAY = new Color(0xFF888888); try {
Color.LTGRAY = new Color(0xFFCCCCCC); color = Color.parse(str);
Color.WHITE = new Color(0xFFFFFFFF); }
Color.RED = new Color(0xFFFF0000); catch (e) {
Color.GREEN = new Color(0xFF00FF00); }
Color.BLUE = new Color(0xFF0000FF); finally {
Color.YELLOW = new Color(0xFFFFFF00); return color;
Color.CYAN = new Color(0xFF00FFFF); }
Color.MAGENTA = new Color(0xFFFF00FF); }
Color.TRANSPARENT = new Color(0); alpha(v) {
return Color; v = v * 255;
})(); return new Color((this._value & 0xffffff) | ((v & 0xff) << 24));
export { Color }; }
toModel() {
return this._value;
}
}
Color.BLACK = new Color(0xFF000000);
Color.DKGRAY = new Color(0xFF444444);
Color.GRAY = new Color(0xFF888888);
Color.LTGRAY = new Color(0xFFCCCCCC);
Color.WHITE = new Color(0xFFFFFFFF);
Color.RED = new Color(0xFFFF0000);
Color.GREEN = new Color(0xFF00FF00);
Color.BLUE = new Color(0xFF0000FF);
Color.YELLOW = new Color(0xFFFFFF00);
Color.CYAN = new Color(0xFF00FFFF);
Color.MAGENTA = new Color(0xFFFF00FF);
Color.TRANSPARENT = new Color(0);
export var GradientOrientation; export var GradientOrientation;
(function (GradientOrientation) { (function (GradientOrientation) {
/** draw the gradient from the top to the bottom */ /** draw the gradient from the top to the bottom */

View File

@ -5,33 +5,29 @@ var ValueType;
ValueType[ValueType["Percent"] = 2] = "Percent"; ValueType[ValueType["Percent"] = 2] = "Percent";
ValueType[ValueType["Auto"] = 3] = "Auto"; ValueType[ValueType["Auto"] = 3] = "Auto";
})(ValueType || (ValueType = {})); })(ValueType || (ValueType = {}));
let FlexTypedValue = /** @class */ (() => { export class FlexTypedValue {
class FlexTypedValue { constructor(type) {
constructor(type) { this.value = 0;
this.value = 0; this.type = type;
this.type = type;
}
static percent(v) {
const ret = new FlexTypedValue(ValueType.Percent);
ret.value = v;
return ret;
}
static point(v) {
const ret = new FlexTypedValue(ValueType.Point);
ret.value = v;
return ret;
}
toModel() {
return {
type: this.type,
value: this.value,
};
}
} }
FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); static percent(v) {
return FlexTypedValue; const ret = new FlexTypedValue(ValueType.Percent);
})(); ret.value = v;
export { FlexTypedValue }; return ret;
}
static point(v) {
const ret = new FlexTypedValue(ValueType.Point);
ret.value = v;
return ret;
}
toModel() {
return {
type: this.type,
value: this.value,
};
}
}
FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto);
export var FlexDirection; export var FlexDirection;
(function (FlexDirection) { (function (FlexDirection) {
FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN"; FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN";

View File

@ -10,68 +10,64 @@ export const BOTTOM = (END | SPECIFIED) << SHIFT_Y;
export const CENTER_X = SPECIFIED << SHIFT_X; export const CENTER_X = SPECIFIED << SHIFT_X;
export const CENTER_Y = SPECIFIED << SHIFT_Y; export const CENTER_Y = SPECIFIED << SHIFT_Y;
export const CENTER = CENTER_X | CENTER_Y; export const CENTER = CENTER_X | CENTER_Y;
let Gravity = /** @class */ (() => { export class Gravity {
class Gravity { constructor() {
constructor() { this.val = 0;
this.val = 0;
}
left() {
const val = this.val | LEFT;
const ret = new Gravity;
ret.val = val;
return ret;
}
right() {
const val = this.val | RIGHT;
const ret = new Gravity;
ret.val = val;
return ret;
}
top() {
const val = this.val | TOP;
const ret = new Gravity;
ret.val = val;
return ret;
}
bottom() {
const val = this.val | BOTTOM;
const ret = new Gravity;
ret.val = val;
return ret;
}
center() {
const val = this.val | CENTER;
const ret = new Gravity;
ret.val = val;
return ret;
}
centerX() {
const val = this.val | CENTER_X;
const ret = new Gravity;
ret.val = val;
return ret;
}
centerY() {
const val = this.val | CENTER_Y;
const ret = new Gravity;
ret.val = val;
return ret;
}
toModel() {
return this.val;
}
} }
Gravity.origin = new Gravity; left() {
Gravity.Center = Gravity.origin.center(); const val = this.val | LEFT;
Gravity.CenterX = Gravity.origin.centerX(); const ret = new Gravity;
Gravity.CenterY = Gravity.origin.centerY(); ret.val = val;
Gravity.Left = Gravity.origin.left(); return ret;
Gravity.Right = Gravity.origin.right(); }
Gravity.Top = Gravity.origin.top(); right() {
Gravity.Bottom = Gravity.origin.bottom(); const val = this.val | RIGHT;
return Gravity; const ret = new Gravity;
})(); ret.val = val;
export { Gravity }; return ret;
}
top() {
const val = this.val | TOP;
const ret = new Gravity;
ret.val = val;
return ret;
}
bottom() {
const val = this.val | BOTTOM;
const ret = new Gravity;
ret.val = val;
return ret;
}
center() {
const val = this.val | CENTER;
const ret = new Gravity;
ret.val = val;
return ret;
}
centerX() {
const val = this.val | CENTER_X;
const ret = new Gravity;
ret.val = val;
return ret;
}
centerY() {
const val = this.val | CENTER_Y;
const ret = new Gravity;
ret.val = val;
return ret;
}
toModel() {
return this.val;
}
}
Gravity.origin = new Gravity;
Gravity.Center = Gravity.origin.center();
Gravity.CenterX = Gravity.origin.centerX();
Gravity.CenterY = Gravity.origin.centerY();
Gravity.Left = Gravity.origin.left();
Gravity.Right = Gravity.origin.right();
Gravity.Top = Gravity.origin.top();
Gravity.Bottom = Gravity.origin.bottom();
export function gravity() { export function gravity() {
return new Gravity; return new Gravity;
} }

View File

@ -25,16 +25,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
import { Property, View } from "../ui/view"; import { Property, View } from "../ui/view";
import { Stack } from "../widget/layouts"; import { Stack } from "../widget/layouts";
import { layoutConfig } from "../util/layoutconfig"; import { layoutConfig } from "../util/layoutconfig";
let Draggable = /** @class */ (() => { export class Draggable extends Stack {
class Draggable extends Stack { }
} __decorate([
__decorate([ Property,
Property, __metadata("design:type", Function)
__metadata("design:type", Function) ], Draggable.prototype, "onDrag", void 0);
], Draggable.prototype, "onDrag", void 0);
return Draggable;
})();
export { Draggable };
export function draggable(views, config) { export function draggable(views, config) {
const ret = new Draggable; const ret = new Draggable;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();

View File

@ -25,113 +25,105 @@ var __metadata = (this && this.__metadata) || function (k, v) {
import { Stack } from './layouts'; import { Stack } from './layouts';
import { Property, Superview, View } from '../ui/view'; import { Property, Superview, View } from '../ui/view';
import { layoutConfig } from '../util/index.util'; import { layoutConfig } from '../util/index.util';
let FlowLayoutItem = /** @class */ (() => { export class FlowLayoutItem extends Stack {
class FlowLayoutItem extends Stack { }
__decorate([
Property,
__metadata("design:type", String)
], FlowLayoutItem.prototype, "identifier", void 0);
export class FlowLayout extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2;
this.itemCount = 0;
this.batchCount = 15;
} }
__decorate([ allSubviews() {
Property, if (this.loadMoreView) {
__metadata("design:type", String) return [...this.cachedViews.values(), this.loadMoreView];
], FlowLayoutItem.prototype, "identifier", void 0); }
return FlowLayoutItem; else {
})(); return this.cachedViews.values();
export { FlowLayoutItem }; }
let FlowLayout = /** @class */ (() => { }
class FlowLayout extends Superview { reset() {
constructor() { this.cachedViews.clear();
super(...arguments); this.itemCount = 0;
this.cachedViews = new Map; }
getItem(itemIdx) {
let view = this.renderItem(itemIdx);
view.superview = this;
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false; this.ignoreDirtyCallOnce = false;
this.columnCount = 2; //Ignore the dirty call once.
this.itemCount = 0; return false;
this.batchCount = 15;
}
allSubviews() {
if (this.loadMoreView) {
return [...this.cachedViews.values(), this.loadMoreView];
}
else {
return this.cachedViews.values();
}
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
}
getItem(itemIdx) {
let view = this.renderItem(itemIdx);
view.superview = this;
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();
});
}
toModel() {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
return super.toModel();
} }
return super.isDirty();
} }
__decorate([ renderBunchedItems(start, length) {
Property, this.ignoreDirtyCallOnce = true;
__metadata("design:type", Object) return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
], FlowLayout.prototype, "columnCount", void 0); const listItem = this.getItem(start + idx);
__decorate([ return listItem.toModel();
Property, });
__metadata("design:type", Number) }
], FlowLayout.prototype, "columnSpace", void 0); toModel() {
__decorate([ if (this.loadMoreView) {
Property, this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
__metadata("design:type", Number) }
], FlowLayout.prototype, "rowSpace", void 0); return super.toModel();
__decorate([ }
Property, }
__metadata("design:type", Object) __decorate([
], FlowLayout.prototype, "itemCount", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], FlowLayout.prototype, "columnCount", void 0);
__metadata("design:type", Function) __decorate([
], FlowLayout.prototype, "renderItem", void 0); Property,
__decorate([ __metadata("design:type", Number)
Property, ], FlowLayout.prototype, "columnSpace", void 0);
__metadata("design:type", Object) __decorate([
], FlowLayout.prototype, "batchCount", void 0); Property,
__decorate([ __metadata("design:type", Number)
Property, ], FlowLayout.prototype, "rowSpace", void 0);
__metadata("design:type", Function) __decorate([
], FlowLayout.prototype, "onLoadMore", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], FlowLayout.prototype, "itemCount", void 0);
__metadata("design:type", Boolean) __decorate([
], FlowLayout.prototype, "loadMore", void 0); Property,
__decorate([ __metadata("design:type", Function)
Property, ], FlowLayout.prototype, "renderItem", void 0);
__metadata("design:type", FlowLayoutItem) __decorate([
], FlowLayout.prototype, "loadMoreView", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], FlowLayout.prototype, "batchCount", void 0);
__metadata("design:type", Function) __decorate([
], FlowLayout.prototype, "onScroll", void 0); Property,
__decorate([ __metadata("design:type", Function)
Property, ], FlowLayout.prototype, "onLoadMore", void 0);
__metadata("design:type", Function) __decorate([
], FlowLayout.prototype, "onScrollEnd", void 0); Property,
return FlowLayout; __metadata("design:type", Boolean)
})(); ], FlowLayout.prototype, "loadMore", void 0);
export { FlowLayout }; __decorate([
Property,
__metadata("design:type", FlowLayoutItem)
], FlowLayout.prototype, "loadMoreView", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], FlowLayout.prototype, "onScroll", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], FlowLayout.prototype, "onScrollEnd", void 0);
export function flowlayout(config) { export function flowlayout(config) {
const ret = new FlowLayout; const ret = new FlowLayout;
for (let key in config) { for (let key in config) {

View File

@ -31,77 +31,73 @@ export var ScaleType;
ScaleType[ScaleType["ScaleAspectFit"] = 1] = "ScaleAspectFit"; ScaleType[ScaleType["ScaleAspectFit"] = 1] = "ScaleAspectFit";
ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill";
})(ScaleType || (ScaleType = {})); })(ScaleType || (ScaleType = {}));
let Image = /** @class */ (() => { export class Image extends View {
class Image extends View { }
} __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "imageUrl", void 0);
], Image.prototype, "imageUrl", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "imagePath", void 0);
], Image.prototype, "imagePath", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "imageRes", void 0);
], Image.prototype, "imageRes", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "imageBase64", void 0);
], Image.prototype, "imageBase64", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Image.prototype, "scaleType", void 0);
], Image.prototype, "scaleType", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Boolean)
__metadata("design:type", Boolean) ], Image.prototype, "isBlur", void 0);
], Image.prototype, "isBlur", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "placeHolderImage", void 0);
], Image.prototype, "placeHolderImage", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "placeHolderImageBase64", void 0);
], Image.prototype, "placeHolderImageBase64", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color
__metadata("design:type", Color /**
/** * Display while image is failed to load
* Display while image is failed to load * It can be file name in local path
* It can be file name in local path */
*/ )
) ], Image.prototype, "placeHolderColor", void 0);
], Image.prototype, "placeHolderColor", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "errorImage", void 0);
], Image.prototype, "errorImage", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Image.prototype, "errorImageBase64", void 0);
], Image.prototype, "errorImageBase64", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color)
__metadata("design:type", Color) ], Image.prototype, "errorColor", void 0);
], Image.prototype, "errorColor", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Function)
__metadata("design:type", Function) ], Image.prototype, "loadCallback", void 0);
], Image.prototype, "loadCallback", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Image.prototype, "imageScale", void 0);
], Image.prototype, "imageScale", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Object)
__metadata("design:type", Object) ], Image.prototype, "stretchInset", void 0);
], Image.prototype, "stretchInset", void 0);
return Image;
})();
export { Image };
export function image(config) { export function image(config) {
const ret = new Image; const ret = new Image;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();

View File

@ -26,71 +26,67 @@ import { View, Property } from "../ui/view";
import { Color } from "../util/color"; import { Color } from "../util/color";
import { Gravity } from "../util/gravity"; import { Gravity } from "../util/gravity";
import { layoutConfig } from "../util/index.util"; import { layoutConfig } from "../util/index.util";
let Input = /** @class */ (() => { export class Input extends View {
class Input extends View { getText(context) {
getText(context) { return this.nativeChannel(context, 'getText')();
return this.nativeChannel(context, 'getText')();
}
setSelection(context, start, end = start) {
return this.nativeChannel(context, 'setSelection')({
start,
end,
});
}
requestFocus(context) {
return this.nativeChannel(context, 'requestFocus')();
}
releaseFocus(context) {
return this.nativeChannel(context, 'releaseFocus')();
}
} }
__decorate([ setSelection(context, start, end = start) {
Property, return this.nativeChannel(context, 'setSelection')({
__metadata("design:type", String) start,
], Input.prototype, "text", void 0); end,
__decorate([ });
Property, }
__metadata("design:type", Color) requestFocus(context) {
], Input.prototype, "textColor", void 0); return this.nativeChannel(context, 'requestFocus')();
__decorate([ }
Property, releaseFocus(context) {
__metadata("design:type", Number) return this.nativeChannel(context, 'releaseFocus')();
], Input.prototype, "textSize", void 0); }
__decorate([ }
Property, __decorate([
__metadata("design:type", String) Property,
], Input.prototype, "hintText", void 0); __metadata("design:type", String)
__decorate([ ], Input.prototype, "text", void 0);
Property, __decorate([
__metadata("design:type", Number) Property,
], Input.prototype, "inputType", void 0); __metadata("design:type", Color)
__decorate([ ], Input.prototype, "textColor", void 0);
Property, __decorate([
__metadata("design:type", Color) Property,
], Input.prototype, "hintTextColor", void 0); __metadata("design:type", Number)
__decorate([ ], Input.prototype, "textSize", void 0);
Property, __decorate([
__metadata("design:type", Boolean) Property,
], Input.prototype, "multiline", void 0); __metadata("design:type", String)
__decorate([ ], Input.prototype, "hintText", void 0);
Property, __decorate([
__metadata("design:type", Gravity) Property,
], Input.prototype, "textAlignment", void 0); __metadata("design:type", Number)
__decorate([ ], Input.prototype, "inputType", void 0);
Property, __decorate([
__metadata("design:type", Function) Property,
], Input.prototype, "onTextChange", void 0); __metadata("design:type", Color)
__decorate([ ], Input.prototype, "hintTextColor", void 0);
Property, __decorate([
__metadata("design:type", Function) Property,
], Input.prototype, "onFocusChange", void 0); __metadata("design:type", Boolean)
__decorate([ ], Input.prototype, "multiline", void 0);
Property, __decorate([
__metadata("design:type", Number) Property,
], Input.prototype, "maxLength", void 0); __metadata("design:type", Gravity)
return Input; ], Input.prototype, "textAlignment", void 0);
})(); __decorate([
export { Input }; Property,
__metadata("design:type", Function)
], Input.prototype, "onTextChange", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Input.prototype, "onFocusChange", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], Input.prototype, "maxLength", void 0);
export var InputType; export var InputType;
(function (InputType) { (function (InputType) {
InputType[InputType["Default"] = 0] = "Default"; InputType[InputType["Default"] = 0] = "Default";

View File

@ -29,19 +29,16 @@ export class Stack extends Group {
} }
export class Root extends Stack { export class Root extends Stack {
} }
let LinearLayout = /** @class */ (() => { class LinearLayout extends Group {
class LinearLayout extends Group { }
} __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], LinearLayout.prototype, "space", void 0);
], LinearLayout.prototype, "space", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Gravity)
__metadata("design:type", Gravity) ], LinearLayout.prototype, "gravity", void 0);
], LinearLayout.prototype, "gravity", void 0);
return LinearLayout;
})();
export class VLayout extends LinearLayout { export class VLayout extends LinearLayout {
} }
export class HLayout extends LinearLayout { export class HLayout extends LinearLayout {

View File

@ -25,108 +25,100 @@ var __metadata = (this && this.__metadata) || function (k, v) {
import { View, Property, Superview } from "../ui/view"; import { View, Property, Superview } from "../ui/view";
import { Stack } from "./layouts"; import { Stack } from "./layouts";
import { layoutConfig } from "../util/layoutconfig"; import { layoutConfig } from "../util/layoutconfig";
let ListItem = /** @class */ (() => { export class ListItem extends Stack {
class ListItem extends Stack { }
__decorate([
Property,
__metadata("design:type", String)
], ListItem.prototype, "identifier", void 0);
export class List extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 15;
} }
__decorate([ allSubviews() {
Property, if (this.loadMoreView) {
__metadata("design:type", String) return [...this.cachedViews.values(), this.loadMoreView];
], ListItem.prototype, "identifier", void 0); }
return ListItem; else {
})(); return this.cachedViews.values();
export { ListItem }; }
let List = /** @class */ (() => { }
class List extends Superview { scrollToItem(context, index, config) {
constructor() { const animated = config === null || config === void 0 ? void 0 : config.animated;
super(...arguments); return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
this.cachedViews = new Map; }
reset() {
this.cachedViews.clear();
this.itemCount = 0;
}
getItem(itemIdx) {
let view = this.renderItem(itemIdx);
view.superview = this;
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false; this.ignoreDirtyCallOnce = false;
this.itemCount = 0; //Ignore the dirty call once.
this.batchCount = 15; return false;
}
allSubviews() {
if (this.loadMoreView) {
return [...this.cachedViews.values(), this.loadMoreView];
}
else {
return this.cachedViews.values();
}
}
scrollToItem(context, index, config) {
const animated = config === null || config === void 0 ? void 0 : config.animated;
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
}
reset() {
this.cachedViews.clear();
this.itemCount = 0;
}
getItem(itemIdx) {
let view = this.renderItem(itemIdx);
view.superview = this;
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();
});
}
toModel() {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
}
return super.toModel();
} }
return super.isDirty();
} }
__decorate([ renderBunchedItems(start, length) {
Property, this.ignoreDirtyCallOnce = true;
__metadata("design:type", Object) return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
], List.prototype, "itemCount", void 0); const listItem = this.getItem(start + idx);
__decorate([ return listItem.toModel();
Property, });
__metadata("design:type", Function) }
], List.prototype, "renderItem", void 0); toModel() {
__decorate([ if (this.loadMoreView) {
Property, this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId;
__metadata("design:type", Object) }
], List.prototype, "batchCount", void 0); return super.toModel();
__decorate([ }
Property, }
__metadata("design:type", Function) __decorate([
], List.prototype, "onLoadMore", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], List.prototype, "itemCount", void 0);
__metadata("design:type", Boolean) __decorate([
], List.prototype, "loadMore", void 0); Property,
__decorate([ __metadata("design:type", Function)
Property, ], List.prototype, "renderItem", void 0);
__metadata("design:type", ListItem) __decorate([
], List.prototype, "loadMoreView", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], List.prototype, "batchCount", void 0);
__metadata("design:type", Function) __decorate([
], List.prototype, "onScroll", void 0); Property,
__decorate([ __metadata("design:type", Function)
Property, ], List.prototype, "onLoadMore", void 0);
__metadata("design:type", Function) __decorate([
], List.prototype, "onScrollEnd", void 0); Property,
__decorate([ __metadata("design:type", Boolean)
Property, ], List.prototype, "loadMore", void 0);
__metadata("design:type", Number) __decorate([
], List.prototype, "scrolledPosition", void 0); Property,
return List; __metadata("design:type", ListItem)
})(); ], List.prototype, "loadMoreView", void 0);
export { List }; __decorate([
Property,
__metadata("design:type", Function)
], List.prototype, "onScroll", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], List.prototype, "onScrollEnd", void 0);
__decorate([
Property,
__metadata("design:type", Number)
], List.prototype, "scrolledPosition", void 0);
export function list(config) { export function list(config) {
const ret = new List; const ret = new List;
for (let key in config) { for (let key in config) {

View File

@ -23,22 +23,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
* limitations under the License. * limitations under the License.
*/ */
import { Group, Property } from '../ui/view'; import { Group, Property } from '../ui/view';
let NestedSlider = /** @class */ (() => { export class NestedSlider extends Group {
class NestedSlider extends Group { addSlideItem(view) {
addSlideItem(view) { this.addChild(view);
this.addChild(view);
}
slidePage(context, page, smooth = false) {
return this.nativeChannel(context, "slidePage")({ page, smooth });
}
getSlidedPage(context) {
return this.nativeChannel(context, "getSlidedPage")();
}
} }
__decorate([ slidePage(context, page, smooth = false) {
Property, return this.nativeChannel(context, "slidePage")({ page, smooth });
__metadata("design:type", Function) }
], NestedSlider.prototype, "onPageSlided", void 0); getSlidedPage(context) {
return NestedSlider; return this.nativeChannel(context, "getSlidedPage")();
})(); }
export { NestedSlider }; }
__decorate([
Property,
__metadata("design:type", Function)
], NestedSlider.prototype, "onPageSlided", void 0);

View File

@ -9,40 +9,36 @@ var __metadata = (this && this.__metadata) || function (k, v) {
}; };
import { Property, Superview } from "../ui/view"; import { Property, Superview } from "../ui/view";
import { layoutConfig } from "../util/layoutconfig"; import { layoutConfig } from "../util/layoutconfig";
let Refreshable = /** @class */ (() => { export class Refreshable extends Superview {
class Refreshable extends Superview { allSubviews() {
allSubviews() { const ret = [this.content];
const ret = [this.content]; if (this.header) {
if (this.header) { ret.push(this.header);
ret.push(this.header);
}
return ret;
}
setRefreshable(context, refreshable) {
return this.nativeChannel(context, 'setRefreshable')(refreshable);
}
setRefreshing(context, refreshing) {
return this.nativeChannel(context, 'setRefreshing')(refreshing);
}
isRefreshable(context) {
return this.nativeChannel(context, 'isRefreshable')();
}
isRefreshing(context) {
return this.nativeChannel(context, 'isRefreshing')();
}
toModel() {
this.dirtyProps.content = this.content.viewId;
this.dirtyProps.header = (this.header || {}).viewId;
return super.toModel();
} }
return ret;
} }
__decorate([ setRefreshable(context, refreshable) {
Property, return this.nativeChannel(context, 'setRefreshable')(refreshable);
__metadata("design:type", Function) }
], Refreshable.prototype, "onRefresh", void 0); setRefreshing(context, refreshing) {
return Refreshable; return this.nativeChannel(context, 'setRefreshing')(refreshing);
})(); }
export { Refreshable }; isRefreshable(context) {
return this.nativeChannel(context, 'isRefreshable')();
}
isRefreshing(context) {
return this.nativeChannel(context, 'isRefreshing')();
}
toModel() {
this.dirtyProps.content = this.content.viewId;
this.dirtyProps.header = (this.header || {}).viewId;
return super.toModel();
}
}
__decorate([
Property,
__metadata("design:type", Function)
], Refreshable.prototype, "onRefresh", void 0);
export function refreshable(config) { export function refreshable(config) {
const ret = new Refreshable; const ret = new Refreshable;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();

View File

@ -35,34 +35,30 @@ export function scroller(content, config) {
v.content = content; v.content = content;
}); });
} }
let Scroller = /** @class */ (() => { export class Scroller extends Superview {
class Scroller extends Superview { allSubviews() {
allSubviews() { return [this.content];
return [this.content];
}
toModel() {
this.dirtyProps.content = this.content.viewId;
return super.toModel();
}
scrollTo(context, offset, animated) {
return this.nativeChannel(context, "scrollTo")({ offset, animated });
}
scrollBy(context, offset, animated) {
return this.nativeChannel(context, "scrollBy")({ offset, animated });
}
} }
__decorate([ toModel() {
Property, this.dirtyProps.content = this.content.viewId;
__metadata("design:type", Object) return super.toModel();
], Scroller.prototype, "contentOffset", void 0); }
__decorate([ scrollTo(context, offset, animated) {
Property, return this.nativeChannel(context, "scrollTo")({ offset, animated });
__metadata("design:type", Function) }
], Scroller.prototype, "onScroll", void 0); scrollBy(context, offset, animated) {
__decorate([ return this.nativeChannel(context, "scrollBy")({ offset, animated });
Property, }
__metadata("design:type", Function) }
], Scroller.prototype, "onScrollEnd", void 0); __decorate([
return Scroller; Property,
})(); __metadata("design:type", Object)
export { Scroller }; ], Scroller.prototype, "contentOffset", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Scroller.prototype, "onScroll", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Scroller.prototype, "onScrollEnd", void 0);

View File

@ -25,79 +25,71 @@ var __metadata = (this && this.__metadata) || function (k, v) {
import { Superview, View, Property } from "../ui/view"; import { Superview, View, Property } from "../ui/view";
import { Stack } from "./layouts"; import { Stack } from "./layouts";
import { layoutConfig } from "../util/layoutconfig"; import { layoutConfig } from "../util/layoutconfig";
let SlideItem = /** @class */ (() => { export class SlideItem extends Stack {
class SlideItem extends Stack { }
__decorate([
Property,
__metadata("design:type", String)
], SlideItem.prototype, "identifier", void 0);
export class Slider extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 3;
} }
__decorate([ allSubviews() {
Property, return this.cachedViews.values();
__metadata("design:type", String) }
], SlideItem.prototype, "identifier", void 0); getItem(itemIdx) {
return SlideItem; let view = this.renderPage(itemIdx);
})(); view.superview = this;
export { SlideItem }; this.cachedViews.set(`${itemIdx}`, view);
let Slider = /** @class */ (() => { return view;
class Slider extends Superview { }
constructor() { isDirty() {
super(...arguments); if (this.ignoreDirtyCallOnce) {
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false; this.ignoreDirtyCallOnce = false;
this.itemCount = 0; //Ignore the dirty call once.
this.batchCount = 3; return false;
}
allSubviews() {
return this.cachedViews.values();
}
getItem(itemIdx) {
let view = this.renderPage(itemIdx);
view.superview = this;
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx);
return slideItem.toModel();
});
}
slidePage(context, page, smooth = false) {
return this.nativeChannel(context, "slidePage")({ page, smooth });
}
getSlidedPage(context) {
return this.nativeChannel(context, "getSlidedPage")();
} }
return super.isDirty();
} }
__decorate([ renderBunchedItems(start, length) {
Property, this.ignoreDirtyCallOnce = true;
__metadata("design:type", Object) return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
], Slider.prototype, "itemCount", void 0); const slideItem = this.getItem(start + idx);
__decorate([ return slideItem.toModel();
Property, });
__metadata("design:type", Function) }
], Slider.prototype, "renderPage", void 0); slidePage(context, page, smooth = false) {
__decorate([ return this.nativeChannel(context, "slidePage")({ page, smooth });
Property, }
__metadata("design:type", Object) getSlidedPage(context) {
], Slider.prototype, "batchCount", void 0); return this.nativeChannel(context, "getSlidedPage")();
__decorate([ }
Property, }
__metadata("design:type", Function) __decorate([
], Slider.prototype, "onPageSlided", void 0); Property,
__decorate([ __metadata("design:type", Object)
Property, ], Slider.prototype, "itemCount", void 0);
__metadata("design:type", Boolean) __decorate([
], Slider.prototype, "loop", void 0); Property,
return Slider; __metadata("design:type", Function)
})(); ], Slider.prototype, "renderPage", void 0);
export { Slider }; __decorate([
Property,
__metadata("design:type", Object)
], Slider.prototype, "batchCount", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Slider.prototype, "onPageSlided", void 0);
__decorate([
Property,
__metadata("design:type", Boolean)
], Slider.prototype, "loop", void 0);
export function slider(config) { export function slider(config) {
const ret = new Slider; const ret = new Slider;
for (let key in config) { for (let key in config) {

View File

@ -25,32 +25,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
import { View, Property } from "../ui/view"; import { View, Property } from "../ui/view";
import { Color } from "../util/color"; import { Color } from "../util/color";
import { layoutConfig } from "../util/index.util"; import { layoutConfig } from "../util/index.util";
let Switch = /** @class */ (() => { export class Switch extends View {
class Switch extends View { }
} __decorate([
__decorate([ Property,
Property, __metadata("design:type", Boolean)
__metadata("design:type", Boolean) ], Switch.prototype, "state", void 0);
], Switch.prototype, "state", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Function)
__metadata("design:type", Function) ], Switch.prototype, "onSwitch", void 0);
], Switch.prototype, "onSwitch", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color)
__metadata("design:type", Color) ], Switch.prototype, "offTintColor", void 0);
], Switch.prototype, "offTintColor", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color)
__metadata("design:type", Color) ], Switch.prototype, "onTintColor", void 0);
], Switch.prototype, "onTintColor", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color)
__metadata("design:type", Color) ], Switch.prototype, "thumbTintColor", void 0);
], Switch.prototype, "thumbTintColor", void 0);
return Switch;
})();
export { Switch };
export function switchView(config) { export function switchView(config) {
const ret = new Switch; const ret = new Switch;
ret.layoutConfig = layoutConfig().just(); ret.layoutConfig = layoutConfig().just();

View File

@ -33,68 +33,64 @@ export var TruncateAt;
TruncateAt[TruncateAt["Start"] = 2] = "Start"; TruncateAt[TruncateAt["Start"] = 2] = "Start";
TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip";
})(TruncateAt || (TruncateAt = {})); })(TruncateAt || (TruncateAt = {}));
let Text = /** @class */ (() => { export class Text extends View {
class Text extends View { }
} __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Text.prototype, "text", void 0);
], Text.prototype, "text", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Color)
__metadata("design:type", Color) ], Text.prototype, "textColor", void 0);
], Text.prototype, "textColor", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "textSize", void 0);
], Text.prototype, "textSize", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "maxLines", void 0);
], Text.prototype, "maxLines", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Gravity)
__metadata("design:type", Gravity) ], Text.prototype, "textAlignment", void 0);
], Text.prototype, "textAlignment", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Text.prototype, "fontStyle", void 0);
], Text.prototype, "fontStyle", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Text.prototype, "font", void 0);
], Text.prototype, "font", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "maxWidth", void 0);
], Text.prototype, "maxWidth", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "maxHeight", void 0);
], Text.prototype, "maxHeight", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "lineSpacing", void 0);
], Text.prototype, "lineSpacing", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Boolean)
__metadata("design:type", Boolean) ], Text.prototype, "strikethrough", void 0);
], Text.prototype, "strikethrough", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Boolean)
__metadata("design:type", Boolean) ], Text.prototype, "underline", void 0);
], Text.prototype, "underline", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", String)
__metadata("design:type", String) ], Text.prototype, "htmlText", void 0);
], Text.prototype, "htmlText", void 0); __decorate([
__decorate([ Property,
Property, __metadata("design:type", Number)
__metadata("design:type", Number) ], Text.prototype, "truncateAt", void 0);
], Text.prototype, "truncateAt", void 0);
return Text;
})();
export { Text };
export function text(config) { export function text(config) {
const ret = new Text; const ret = new Text;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();

View File

@ -38,7 +38,6 @@ export abstract class ViewModel<M extends Object, V extends ViewHolder> {
getViewHolder() { getViewHolder() {
return this.viewHolder; return this.viewHolder;
} }
updateState(setter: Setter<M>) { updateState(setter: Setter<M>) {
setter(this.state) setter(this.state)
this.onBind(this.state, this.viewHolder) this.onBind(this.state, this.viewHolder)

2298
doric-web/dist/index.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long