2020-01-03 14:44:51 +08:00
|
|
|
import { Color, GradientColor } from "../util/color";
|
2021-05-14 19:24:07 +08:00
|
|
|
import { Modeling, Model, ClassType } from "../util/types";
|
2020-01-03 14:44:51 +08:00
|
|
|
import { BridgeContext } from "../runtime/global";
|
|
|
|
import { LayoutConfig } from '../util/layoutconfig';
|
|
|
|
import { IAnimation } from "./animation";
|
2020-04-09 20:01:22 +08:00
|
|
|
import { FlexConfig } from "../util/flexbox";
|
2020-01-03 14:44:51 +08:00
|
|
|
export declare function Property(target: Object, propKey: string): void;
|
2021-03-03 10:08:48 +08:00
|
|
|
export declare function InconsistProperty(target: Object, propKey: string): void;
|
2021-05-14 19:24:07 +08:00
|
|
|
export declare function ViewComponent(constructor: ClassType<any>): void;
|
2020-01-03 16:35:04 +08:00
|
|
|
export declare type NativeViewModel = {
|
|
|
|
id: string;
|
|
|
|
type: string;
|
|
|
|
props: {
|
|
|
|
[index: string]: Model;
|
|
|
|
};
|
|
|
|
};
|
2021-12-03 15:37:42 +08:00
|
|
|
declare type RefType<T> = T extends Ref<infer R> ? R : never;
|
2021-09-02 11:39:51 +08:00
|
|
|
export declare class Ref<T extends View> {
|
|
|
|
private view?;
|
|
|
|
set current(v: T);
|
|
|
|
get current(): T;
|
2021-12-03 15:37:42 +08:00
|
|
|
apply(config: Partial<RefType<this>>): void;
|
2021-09-02 11:39:51 +08:00
|
|
|
}
|
2021-09-03 16:48:24 +08:00
|
|
|
export declare function createRef<T extends View>(): Ref<T>;
|
2020-04-16 19:21:24 +08:00
|
|
|
export declare abstract class View implements Modeling {
|
2020-01-03 14:44:51 +08:00
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
x: number;
|
|
|
|
y: 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;
|
|
|
|
};
|
2020-04-16 19:21:24 +08:00
|
|
|
/**
|
|
|
|
* float [0,..1]
|
|
|
|
*/
|
2020-01-03 14:44:51 +08:00
|
|
|
alpha?: number;
|
|
|
|
hidden?: boolean;
|
|
|
|
viewId: string;
|
2020-07-04 10:04:40 +08:00
|
|
|
tag?: string;
|
2020-01-03 14:44:51 +08:00
|
|
|
padding?: {
|
|
|
|
left?: number;
|
|
|
|
right?: number;
|
|
|
|
top?: number;
|
|
|
|
bottom?: number;
|
|
|
|
};
|
|
|
|
layoutConfig?: LayoutConfig;
|
|
|
|
onClick?: Function;
|
|
|
|
superview?: Superview;
|
|
|
|
callbacks: Map<String, Function>;
|
2021-11-22 11:54:47 +08:00
|
|
|
callback2Id(f: Function): string;
|
2020-01-03 14:44:51 +08:00
|
|
|
private id2Callback;
|
2020-07-04 10:04:40 +08:00
|
|
|
findViewByTag(tag: string): View | undefined;
|
2020-01-03 14:44:51 +08:00
|
|
|
constructor();
|
|
|
|
/** Anchor start*/
|
2020-01-17 14:55:39 +08:00
|
|
|
get left(): number;
|
|
|
|
set left(v: number);
|
|
|
|
get right(): number;
|
|
|
|
set right(v: number);
|
|
|
|
get top(): number;
|
|
|
|
set top(v: number);
|
|
|
|
get bottom(): number;
|
|
|
|
set bottom(v: number);
|
|
|
|
get centerX(): number;
|
|
|
|
get centerY(): number;
|
|
|
|
set centerX(v: number);
|
|
|
|
set centerY(v: number);
|
2020-01-03 14:44:51 +08:00
|
|
|
/** Anchor end*/
|
|
|
|
private __dirty_props__;
|
2020-01-17 14:55:39 +08:00
|
|
|
get dirtyProps(): {
|
2020-01-03 14:44:51 +08:00
|
|
|
[index: string]: Model;
|
|
|
|
};
|
2020-01-03 16:35:04 +08:00
|
|
|
nativeViewModel: NativeViewModel;
|
2021-05-14 19:24:07 +08:00
|
|
|
viewType(): any;
|
2020-01-03 14:44:51 +08:00
|
|
|
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void;
|
|
|
|
clean(): void;
|
|
|
|
isDirty(): boolean;
|
|
|
|
responseCallback(id: string, ...args: any): any;
|
2020-01-03 16:35:04 +08:00
|
|
|
toModel(): NativeViewModel;
|
2020-01-03 14:44:51 +08:00
|
|
|
let(block: (it: this) => void): void;
|
|
|
|
also(block: (it: this) => void): this;
|
2020-04-16 19:21:24 +08:00
|
|
|
apply(config: Partial<this>): this;
|
2020-01-03 14:44:51 +08:00
|
|
|
in(group: Group): this;
|
2020-01-17 16:51:17 +08:00
|
|
|
nativeChannel(context: BridgeContext, name: string): (args?: any) => Promise<any>;
|
2020-01-03 14:44:51 +08:00
|
|
|
getWidth(context: BridgeContext): Promise<number>;
|
|
|
|
getHeight(context: BridgeContext): Promise<number>;
|
2020-03-03 14:43:49 +08:00
|
|
|
getX(context: BridgeContext): Promise<number>;
|
|
|
|
getY(context: BridgeContext): Promise<number>;
|
2020-01-03 14:44:51 +08:00
|
|
|
getLocationOnScreen(context: BridgeContext): Promise<{
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
}>;
|
|
|
|
/**++++++++++transform++++++++++*/
|
|
|
|
translationX?: number;
|
|
|
|
translationY?: number;
|
2020-04-16 19:21:24 +08:00
|
|
|
/**
|
|
|
|
* float [0,..1]
|
|
|
|
*/
|
2020-01-03 14:44:51 +08:00
|
|
|
scaleX?: number;
|
|
|
|
scaleY?: number;
|
|
|
|
pivotX?: number;
|
|
|
|
pivotY?: number;
|
2020-04-16 19:21:24 +08:00
|
|
|
/**
|
|
|
|
* rotation*PI
|
2020-06-02 20:43:27 +08:00
|
|
|
* In Z
|
2020-04-16 19:21:24 +08:00
|
|
|
*/
|
2020-01-03 14:44:51 +08:00
|
|
|
rotation?: number;
|
2020-06-02 20:43:27 +08:00
|
|
|
/**
|
|
|
|
* rotation*PI
|
|
|
|
* In X
|
|
|
|
*/
|
|
|
|
rotationX?: number;
|
|
|
|
/**
|
|
|
|
* rotation*PI
|
|
|
|
* In Y
|
|
|
|
*/
|
|
|
|
rotationY?: number;
|
2020-06-03 14:53:32 +08:00
|
|
|
/**
|
|
|
|
* Determines the distance between the z=0 plane and the user in order to give a 3D-positioned element some perspective.
|
|
|
|
* Default is 200
|
|
|
|
*/
|
|
|
|
perspective?: number;
|
2020-01-03 14:44:51 +08:00
|
|
|
/**----------transform----------*/
|
2020-04-16 19:21:24 +08:00
|
|
|
/**
|
|
|
|
* Only affected when its superview or itself is FlexLayout.
|
|
|
|
*/
|
2020-04-09 20:01:22 +08:00
|
|
|
flexConfig?: FlexConfig;
|
2021-08-31 12:49:47 +08:00
|
|
|
set props(props: Partial<this>);
|
2021-09-02 11:39:51 +08:00
|
|
|
set parent(v: Group);
|
|
|
|
set ref(ref: Ref<this>);
|
2020-01-03 14:44:51 +08:00
|
|
|
doAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
|
2021-04-22 11:46:24 +08:00
|
|
|
clearAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
|
2021-04-22 14:54:25 +08:00
|
|
|
cancelAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
|
2022-07-04 14:13:41 +08:00
|
|
|
static isViewClass(): boolean;
|
2020-01-03 14:44:51 +08:00
|
|
|
}
|
|
|
|
export declare abstract class Superview extends View {
|
|
|
|
subviewById(id: string): View | undefined;
|
2020-07-04 10:04:40 +08:00
|
|
|
findViewByTag(tag: string): View | undefined;
|
|
|
|
private findViewTraversal;
|
2020-01-03 14:44:51 +08:00
|
|
|
abstract allSubviews(): Iterable<View>;
|
|
|
|
isDirty(): boolean;
|
|
|
|
clean(): void;
|
2020-01-03 16:35:04 +08:00
|
|
|
toModel(): NativeViewModel;
|
2020-01-03 14:44:51 +08:00
|
|
|
}
|
2021-09-03 13:42:25 +08:00
|
|
|
export declare type ViewArray = View[];
|
2022-07-20 20:58:43 +08:00
|
|
|
export declare type ViewFragment = View | ViewArray | undefined | null;
|
2021-09-03 13:42:25 +08:00
|
|
|
export declare abstract class Group extends Superview implements JSX.ElementChildrenAttribute {
|
2020-01-03 14:44:51 +08:00
|
|
|
readonly children: View[];
|
|
|
|
allSubviews(): View[];
|
|
|
|
addChild(view: View): void;
|
2020-05-15 17:58:25 +08:00
|
|
|
removeChild(view: View): void;
|
|
|
|
removeAllChildren(): void;
|
2021-09-03 13:42:25 +08:00
|
|
|
private addInnerElement;
|
|
|
|
set innerElement(e: View | ViewFragment | ViewFragment[] | undefined | null);
|
2020-01-03 14:44:51 +08:00
|
|
|
}
|
2021-12-03 15:37:42 +08:00
|
|
|
export {};
|