js:change apis of declarable
This commit is contained in:
2
doric-js/lib/src/widget/draggable.d.ts
vendored
2
doric-js/lib/src/widget/draggable.d.ts
vendored
@@ -6,4 +6,4 @@ export interface IDraggable extends IStack {
|
||||
export declare class Draggable extends Stack implements IDraggable {
|
||||
onDrag?: (x: number, y: number) => void;
|
||||
}
|
||||
export declare function draggable(config: IDraggable, views: View[]): Draggable;
|
||||
export declare function draggable(views: View | View[], config?: IDraggable): Draggable;
|
||||
|
@@ -22,7 +22,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Property } from "../ui/view";
|
||||
import { Property, View } from "../ui/view";
|
||||
import { Stack } from "../widget/layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
export class Draggable extends Stack {
|
||||
@@ -31,14 +31,21 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Function)
|
||||
], Draggable.prototype, "onDrag", void 0);
|
||||
export function draggable(config, views) {
|
||||
export 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;
|
||||
}
|
||||
|
9
doric-js/lib/src/widget/flowlayout.d.ts
vendored
9
doric-js/lib/src/widget/flowlayout.d.ts
vendored
@@ -1,6 +1,9 @@
|
||||
import { Stack } from './layouts';
|
||||
import { Stack, IStack } from './layouts';
|
||||
import { IView, Superview, View, NativeViewModel } from '../ui/view';
|
||||
export declare class FlowLayoutItem extends Stack {
|
||||
export interface IFlowLayoutItem extends IStack {
|
||||
identifier?: string;
|
||||
}
|
||||
export declare class FlowLayoutItem extends Stack implements IFlowLayoutItem {
|
||||
/**
|
||||
* Set to reuse native view
|
||||
*/
|
||||
@@ -34,4 +37,4 @@ export declare class FlowLayout extends Superview implements IFlowLayout {
|
||||
toModel(): NativeViewModel;
|
||||
}
|
||||
export declare function flowlayout(config: IFlowLayout): FlowLayout;
|
||||
export declare function flowItem(item: View): FlowLayoutItem;
|
||||
export declare function flowItem(item: View | View[], config?: IFlowLayoutItem): FlowLayoutItem;
|
||||
|
@@ -23,7 +23,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Stack } from './layouts';
|
||||
import { Property, Superview } from '../ui/view';
|
||||
import { Property, Superview, View } from '../ui/view';
|
||||
import { layoutConfig } from '../util/index.util';
|
||||
export class FlowLayoutItem extends Stack {
|
||||
}
|
||||
@@ -123,9 +123,21 @@ export function flowlayout(config) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
export function flowItem(item) {
|
||||
export 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
6
doric-js/lib/src/widget/layouts.d.ts
vendored
6
doric-js/lib/src/widget/layouts.d.ts
vendored
@@ -22,7 +22,7 @@ export interface IHLayout extends IView {
|
||||
}
|
||||
export declare class HLayout extends LinearLayout implements IHLayout {
|
||||
}
|
||||
export declare function stack(views: View[]): Stack;
|
||||
export declare function hlayout(views: View[]): HLayout;
|
||||
export declare function vlayout(views: View[]): VLayout;
|
||||
export declare function stack(views: View[], config?: IStack): Stack;
|
||||
export declare function hlayout(views: View[], config?: IHLayout): HLayout;
|
||||
export declare function vlayout(views: View[], config?: IVLayout): VLayout;
|
||||
export {};
|
||||
|
@@ -43,27 +43,42 @@ export class VLayout extends LinearLayout {
|
||||
}
|
||||
export class HLayout extends LinearLayout {
|
||||
}
|
||||
export function stack(views) {
|
||||
export 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;
|
||||
}
|
||||
export function hlayout(views) {
|
||||
export 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;
|
||||
}
|
||||
export function vlayout(views) {
|
||||
export 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;
|
||||
}
|
||||
|
9
doric-js/lib/src/widget/list.d.ts
vendored
9
doric-js/lib/src/widget/list.d.ts
vendored
@@ -1,6 +1,9 @@
|
||||
import { View, Superview, IView, NativeViewModel } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
export declare class ListItem extends Stack {
|
||||
import { Stack, IStack } from "./layouts";
|
||||
export interface IListItem extends IStack {
|
||||
identifier?: string;
|
||||
}
|
||||
export declare class ListItem extends Stack implements IListItem {
|
||||
/**
|
||||
* Set to reuse native view
|
||||
*/
|
||||
@@ -28,4 +31,4 @@ export declare class List extends Superview implements IList {
|
||||
toModel(): NativeViewModel;
|
||||
}
|
||||
export declare function list(config: IList): List;
|
||||
export declare function listItem(item: View): ListItem;
|
||||
export declare function listItem(item: View | View[], config?: IListItem): ListItem;
|
||||
|
@@ -22,9 +22,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
import { Property, Superview } from "../ui/view";
|
||||
import { View, Property, Superview } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig, LayoutSpec } from "../util/layoutconfig";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
export class ListItem extends Stack {
|
||||
}
|
||||
__decorate([
|
||||
@@ -113,9 +113,21 @@ export function list(config) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
export function listItem(item) {
|
||||
export function listItem(item, config) {
|
||||
return (new ListItem).also((it) => {
|
||||
it.layoutConfig = layoutConfig().most().configHeight(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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
9
doric-js/lib/src/widget/slider.d.ts
vendored
9
doric-js/lib/src/widget/slider.d.ts
vendored
@@ -1,7 +1,10 @@
|
||||
import { Superview, View, IView } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { Stack, IStack } from "./layouts";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
export declare class SlideItem extends Stack {
|
||||
export interface ISlideItem extends IStack {
|
||||
identifier?: string;
|
||||
}
|
||||
export declare class SlideItem extends Stack implements ISlideItem {
|
||||
/**
|
||||
* Set to reuse native view
|
||||
*/
|
||||
@@ -27,5 +30,5 @@ export declare class Slider extends Superview implements ISlider {
|
||||
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
||||
getSlidedPage(context: BridgeContext): Promise<number>;
|
||||
}
|
||||
export declare function slideItem(item: View): SlideItem;
|
||||
export declare function slider(config: ISlider): Slider;
|
||||
export declare function slideItem(item: View | View[], config?: ISlideItem): SlideItem;
|
||||
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
import { Superview, Property } from "../ui/view";
|
||||
import { Superview, View, Property } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
export class SlideItem extends Stack {
|
||||
@@ -74,12 +74,6 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Function)
|
||||
], Slider.prototype, "onPageSlided", void 0);
|
||||
export function slideItem(item) {
|
||||
return (new SlideItem).also((it) => {
|
||||
it.layoutConfig = layoutConfig().fit();
|
||||
it.addChild(item);
|
||||
});
|
||||
}
|
||||
export function slider(config) {
|
||||
const ret = new Slider;
|
||||
for (let key in config) {
|
||||
@@ -87,3 +81,21 @@ export function slider(config) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
export 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user