update js defination,use Partical insted of IView

This commit is contained in:
pengfei.zhou
2020-04-16 19:21:24 +08:00
committed by osborn
parent b2241fe343
commit 2598d0f266
57 changed files with 633 additions and 972 deletions

View File

@@ -5,64 +5,6 @@ import { LayoutConfig } from '../util/layoutconfig';
import { IAnimation } from "./animation";
import { FlexConfig } from "../util/flexbox";
export declare function Property(target: Object, propKey: string): void;
export interface IView {
width?: number;
height?: number;
backgroundColor?: Color | GradientColor;
corners?: number | {
leftTop?: number;
rightTop?: number;
leftBottom?: number;
rightBottom?: number;
};
border?: {
width: number;
color: Color;
};
shadow?: {
color: Color;
opacity: number;
radius: number;
offsetX: number;
offsetY: number;
};
/**
* float [0,..1]
*/
alpha?: number;
hidden?: boolean;
padding?: {
left?: number;
right?: number;
top?: number;
bottom?: number;
};
layoutConfig?: LayoutConfig;
onClick?: Function;
identifier?: string;
/**++++++++++transform++++++++++*/
translationX?: number;
translationY?: number;
scaleX?: number;
scaleY?: number;
/**
* float [0,..1]
*/
pivotX?: number;
/**
* float [0,..1]
*/
pivotY?: number;
/**
* rotation*PI
*/
rotation?: number;
/**----------transform----------*/
/**
* Only affected when its superview or itself is FlexLayout.
*/
flexConfig?: FlexConfig;
}
export declare type NativeViewModel = {
id: string;
type: string;
@@ -70,7 +12,7 @@ export declare type NativeViewModel = {
[index: string]: Model;
};
};
export declare abstract class View implements Modeling, IView {
export declare abstract class View implements Modeling {
width: number;
height: number;
x: number;
@@ -93,6 +35,9 @@ export declare abstract class View implements Modeling, IView {
offsetX: number;
offsetY: number;
};
/**
* float [0,..1]
*/
alpha?: number;
hidden?: boolean;
viewId: string;
@@ -135,7 +80,7 @@ export declare abstract class View implements Modeling, IView {
toModel(): NativeViewModel;
let(block: (it: this) => void): void;
also(block: (it: this) => void): this;
apply(config: IView): this;
apply(config: Partial<this>): this;
in(group: Group): this;
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
getWidth(context: BridgeContext): Promise<number>;
@@ -149,12 +94,21 @@ export declare abstract class View implements Modeling, IView {
/**++++++++++transform++++++++++*/
translationX?: number;
translationY?: number;
/**
* float [0,..1]
*/
scaleX?: number;
scaleY?: number;
pivotX?: number;
pivotY?: number;
/**
* rotation*PI
*/
rotation?: number;
/**----------transform----------*/
/**
* Only affected when its superview or itself is FlexLayout.
*/
flexConfig?: FlexConfig;
doAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
}

View File

@@ -4,3 +4,4 @@ export * from './layoutconfig';
export * from './log';
export * from './types';
export * from './uniqueId';
export * from './flexbox';

View File

@@ -19,3 +19,4 @@ export * from './layoutconfig';
export * from './log';
export * from './types';
export * from './uniqueId';
export * from './flexbox';

View File

@@ -1,9 +1,6 @@
import { View } from "../ui/view";
import { IStack, Stack } from "../widget/layouts";
export interface IDraggable extends IStack {
import { Stack } from "../widget/layouts";
export declare class Draggable extends Stack {
onDrag?: (x: number, y: number) => void;
}
export declare class Draggable extends Stack implements IDraggable {
onDrag?: (x: number, y: number) => void;
}
export declare function draggable(views: View | View[], config?: IDraggable): Draggable;
export declare function draggable(views: View | View[], config?: Partial<Draggable>): Draggable;

View File

@@ -1,34 +1,12 @@
import { Stack, IStack } from './layouts';
import { IView, Superview, View, NativeViewModel } from '../ui/view';
export interface IFlowLayoutItem extends IStack {
identifier?: string;
}
export declare class FlowLayoutItem extends Stack implements IFlowLayoutItem {
import { Stack } from './layouts';
import { Superview, View, NativeViewModel } from '../ui/view';
export declare class FlowLayoutItem extends Stack {
/**
* Set to reuse native view
*/
identifier?: string;
}
export interface IFlowLayout extends IView {
renderItem: (index: number) => FlowLayoutItem;
itemCount: number;
batchCount?: number;
columnCount?: number;
columnSpace?: number;
rowSpace?: number;
loadMore?: boolean;
onLoadMore?: () => void;
loadMoreView?: FlowLayoutItem;
onScroll?: (offset: {
x: number;
y: number;
}) => void;
onScrollEnd?: (offset: {
x: number;
y: number;
}) => void;
}
export declare class FlowLayout extends Superview implements IFlowLayout {
export declare class FlowLayout extends Superview {
private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];
@@ -55,5 +33,5 @@ export declare class FlowLayout extends Superview implements IFlowLayout {
private renderBunchedItems;
toModel(): NativeViewModel;
}
export declare function flowlayout(config: IFlowLayout): FlowLayout;
export declare function flowItem(item: View | View[], config?: IFlowLayoutItem): FlowLayoutItem;
export declare function flowlayout(config: Partial<FlowLayout>): FlowLayout;
export declare function flowItem(item: View | View[], config?: Partial<FlowLayoutItem>): FlowLayoutItem;

View File

@@ -1,11 +1,11 @@
import { IView, View } from "../ui/view";
import { View } from "../ui/view";
import { Color } from "../util/color";
export declare enum ScaleType {
ScaleToFill = 0,
ScaleAspectFit = 1,
ScaleAspectFill = 2
}
export interface IImage extends IView {
export declare class Image extends View {
imageUrl?: string;
/**
* Read image from local path
@@ -49,20 +49,4 @@ export interface IImage extends IView {
height: number;
} | undefined) => void;
}
export declare class Image extends View implements IImage {
imageUrl?: string;
imagePath?: string;
imageRes?: string;
imageBase64?: string;
scaleType?: ScaleType;
isBlur?: boolean;
placeHolderImage?: string;
placeHolderColor?: Color;
errorImage?: string;
errorColor?: Color;
loadCallback?: (image: {
width: number;
height: number;
} | undefined) => void;
}
export declare function image(config: IImage): Image;
export declare function image(config: Partial<Image>): Image;

View File

@@ -63,7 +63,12 @@ __decorate([
], Image.prototype, "placeHolderImage", void 0);
__decorate([
Property,
__metadata("design:type", Color)
__metadata("design:type", Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
)
], Image.prototype, "placeHolderColor", void 0);
__decorate([
Property,

View File

@@ -1,19 +1,8 @@
import { View, IView } from "../ui/view";
import { View } from "../ui/view";
import { Color } from "../util/color";
import { Gravity } from "../util/gravity";
import { BridgeContext } from "../runtime/global";
export interface IInput extends IView {
text?: string;
textColor?: Color;
textSize?: number;
hintText?: string;
hintTextColor?: Color;
multilines?: boolean;
textAlignment?: Gravity;
onTextChange?: (text: string) => void;
onFocusChange?: (focused: boolean) => void;
}
export declare class Input extends View implements IInput {
export declare class Input extends View {
text?: string;
textColor?: Color;
textSize?: number;
@@ -28,4 +17,4 @@ export declare class Input extends View implements IInput {
requestFocus(context: BridgeContext): Promise<any>;
releaseFocus(context: BridgeContext): Promise<any>;
}
export declare function input(config: IInput): Input;
export declare function input(config: Partial<Input>): Input;

View File

@@ -1,8 +1,6 @@
import { Group, IView, View } from "../ui/view";
import { Group, View } from "../ui/view";
import { Gravity } from "../util/gravity";
export interface IStack extends IView {
}
export declare class Stack extends Group implements IStack {
export declare class Stack extends Group {
}
export declare class Root extends Stack {
}
@@ -10,22 +8,14 @@ declare class LinearLayout extends Group {
space?: number;
gravity?: Gravity;
}
export interface IVLayout extends IView {
space?: number;
gravity?: Gravity;
export declare class VLayout extends LinearLayout {
}
export declare class VLayout extends LinearLayout implements IVLayout {
export declare class HLayout extends LinearLayout {
}
export interface IHLayout extends IView {
space?: number;
gravity?: Gravity;
}
export declare class HLayout extends LinearLayout implements IHLayout {
}
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 declare function stack(views: View[], config?: Partial<Stack>): Stack;
export declare function hlayout(views: View[], config?: Partial<HLayout>): HLayout;
export declare function vlayout(views: View[], config?: Partial<VLayout>): VLayout;
export declare class FlexLayout extends Group {
}
export declare function flexlayout(views: View[], config?: IView): FlexLayout;
export declare function flexlayout(views: View[], config?: Partial<FlexLayout>): FlexLayout;
export {};

View File

@@ -1,31 +1,12 @@
import { View, Superview, IView, NativeViewModel } from "../ui/view";
import { Stack, IStack } from "./layouts";
export interface IListItem extends IStack {
identifier?: string;
}
export declare class ListItem extends Stack implements IListItem {
import { View, Superview, NativeViewModel } from "../ui/view";
import { Stack } from "./layouts";
export declare class ListItem extends Stack {
/**
* Set to reuse native view
*/
identifier?: string;
}
export interface IList extends IView {
renderItem: (index: number) => ListItem;
itemCount: number;
batchCount?: number;
onLoadMore?: () => void;
loadMore?: boolean;
loadMoreView?: ListItem;
onScroll?: (offset: {
x: number;
y: number;
}) => void;
onScrollEnd?: (offset: {
x: number;
y: number;
}) => void;
}
export declare class List extends Superview implements IList {
export declare class List extends Superview {
private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<ListItem> | ListItem[];
@@ -49,5 +30,5 @@ export declare class List extends Superview implements IList {
private renderBunchedItems;
toModel(): NativeViewModel;
}
export declare function list(config: IList): List;
export declare function listItem(item: View | View[], config?: IListItem): ListItem;
export declare function list(config: Partial<List>): List;
export declare function listItem(item: View | View[], config?: Partial<ListItem>): ListItem;

View File

@@ -1,16 +1,9 @@
import { View, Superview, IView, NativeViewModel } from "../ui/view";
import { List } from "./list";
import { Scroller } from "./scroller";
import { View, Superview, NativeViewModel } from "../ui/view";
import { BridgeContext } from "../runtime/global";
export interface IRefreshable extends IView {
export declare class Refreshable extends Superview {
content: View;
header?: View;
onRefresh?: () => void;
}
export declare class Refreshable extends Superview implements IRefreshable {
content: List | Scroller;
header?: View;
onRefresh?: () => void;
allSubviews(): View[];
setRefreshable(context: BridgeContext, refreshable: boolean): Promise<any>;
setRefreshing(context: BridgeContext, refreshing: boolean): Promise<any>;
@@ -18,7 +11,7 @@ export declare class Refreshable extends Superview implements IRefreshable {
isRefreshing(context: BridgeContext): Promise<boolean>;
toModel(): NativeViewModel;
}
export declare function refreshable(config: IRefreshable): Refreshable;
export declare function refreshable(config: Partial<Refreshable>): Refreshable;
export interface IPullable {
startAnimation(): void;
stopAnimation(): void;

View File

@@ -1,14 +1,7 @@
import { Superview, View, IView, NativeViewModel } from '../ui/view';
import { Superview, View, NativeViewModel } from '../ui/view';
import { BridgeContext } from '../runtime/global';
export declare function scroller(content: View, config?: IScroller): Scroller;
export interface IScroller extends IView {
content?: View;
contentOffset?: {
x: number;
y: number;
};
}
export declare class Scroller extends Superview implements IScroller {
export declare function scroller(content: View, config?: Partial<Scroller>): Scroller;
export declare class Scroller extends Superview {
content: View;
contentOffset?: {
x: number;

View File

@@ -1,23 +1,13 @@
import { Superview, View, IView } from "../ui/view";
import { Stack, IStack } from "./layouts";
import { Superview, View } from "../ui/view";
import { Stack } from "./layouts";
import { BridgeContext } from "../runtime/global";
export interface ISlideItem extends IStack {
identifier?: string;
}
export declare class SlideItem extends Stack implements ISlideItem {
export declare class SlideItem extends Stack {
/**
* Set to reuse native view
*/
identifier?: string;
}
export interface ISlider extends IView {
renderPage: (index: number) => SlideItem;
itemCount: number;
batchCount?: number;
onPageSlided?: (index: number) => void;
loop?: boolean;
}
export declare class Slider extends Superview implements ISlider {
export declare class Slider extends Superview {
private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<SlideItem>;
@@ -32,5 +22,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 slider(config: ISlider): Slider;
export declare function slideItem(item: View | View[], config?: ISlideItem): SlideItem;
export declare function slider(config: Partial<Slider>): Slider;
export declare function slideItem(item: View | View[], config?: Partial<SlideItem>): SlideItem;

View File

@@ -1,6 +1,6 @@
import { View, IView } from "../ui/view";
import { View } from "../ui/view";
import { Color } from "../util/color";
export interface ISwitch extends IView {
export declare class Switch extends View {
/**
* True is on ,false is off,defalut is off.
*/
@@ -9,18 +9,8 @@ export interface ISwitch extends IView {
* Switch change callback
*/
onSwitch?: (state: boolean) => void;
onTintColor?: Color;
offTintColor?: Color;
thumbTintColor?: Color;
}
export declare class Switch extends View {
/**
* True is on ,false is off,defalut is off.
*/
state?: boolean;
onSwitch?: (state: boolean) => void;
offTintColor?: Color;
onTintColor?: Color;
thumbTintColor?: Color;
}
export declare function switchView(config: ISwitch): Switch;
export declare function switchView(config: Partial<Switch>): Switch;

View File

@@ -1,7 +1,7 @@
import { IView, View } from "../ui/view";
import { View } from "../ui/view";
import { Color } from "../util/color";
import { Gravity } from "../util/gravity";
export interface IText extends IView {
export declare class Text extends View {
text?: string;
textColor?: Color;
textSize?: number;
@@ -16,19 +16,4 @@ export interface IText extends IView {
underline?: boolean;
htmlText?: string;
}
export declare class Text extends View implements IText {
text?: string;
textColor?: Color;
textSize?: number;
maxLines?: number;
textAlignment?: Gravity;
fontStyle?: "normal" | "bold" | "italic" | "bold_italic";
font?: string;
maxWidth?: number;
maxHeight?: number;
lineSpacing?: number;
strikethrough?: boolean;
underline?: boolean;
htmlText?: string;
}
export declare function text(config: IText): Text;
export declare function text(config: Partial<Text>): Text;