feat:add Pullable and view's setRotation function

This commit is contained in:
pengfei.zhou
2019-11-26 13:33:03 +08:00
parent 208c635b8b
commit 3dfa6c9770
5 changed files with 57 additions and 8 deletions

View File

@@ -66,6 +66,10 @@ export interface IPullable {
setProgressRotation(rotation: number): void
}
export class PullableView extends Image {
export function pullable(context: BridgeContext, v: View, config: IPullable) {
Reflect.set(v, 'startAnimation', config.startAnimation)
Reflect.set(v, 'stopAnimation', config.stopAnimation)
Reflect.set(v, 'setProgressRotation', config.setProgressRotation)
return v
}

View File

@@ -18,6 +18,7 @@ import { Modeling, Model, obj2Model } from "../util/types";
import { uniqueId } from "../util/uniqueId";
import { Gravity } from "../util/gravity";
import { loge } from "../util/log";
import { BridgeContext } from "../runtime/global";
export enum LayoutSpec {
EXACTLY = 0,
@@ -281,6 +282,29 @@ export abstract class View implements Modeling, IView {
return Reflect.apply(func, undefined, [params]) as Promise<any>
}
}
getWidth(context: BridgeContext) {
return this.nativeChannel(context, 'getWidth')() as Promise<number>
}
getHeight(context: BridgeContext) {
return this.nativeChannel(context, 'getHeight')() as Promise<number>
}
/**
*
* @param rotation [0..1]
*/
setRotation(context: BridgeContext, rotation: number) {
return this.nativeChannel(context, 'setRotation')(rotation)
}
/**
*
* @return rotation [0..1]
*/
getRotation(context: BridgeContext) {
return this.nativeChannel(context, 'getRotation')() as Promise<number>
}
}
export abstract class Superview extends View {