feat:add Pullable and view's setRotation function
This commit is contained in:
parent
208c635b8b
commit
3dfa6c9770
@ -269,4 +269,9 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
}
|
||||
doricLayer.setRotation(rotation * 360);
|
||||
}
|
||||
|
||||
@DoricMethod
|
||||
public float getRotation() {
|
||||
return doricLayer.getRotation() / 360;
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ public class DoricUtils {
|
||||
return new JavaValue((Integer) arg);
|
||||
} else if (arg instanceof Long) {
|
||||
return new JavaValue((Long) arg);
|
||||
} else if (arg instanceof Float) {
|
||||
return new JavaValue((Float) arg);
|
||||
} else if (arg instanceof Double) {
|
||||
return new JavaValue((Double) arg);
|
||||
} else if (arg instanceof Boolean) {
|
||||
|
@ -1,16 +1,30 @@
|
||||
import { refreshable, Group, Panel, navbar, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network, navigator } from "doric";
|
||||
import { title, label, colors } from "./utils";
|
||||
import { refreshable, Group, Panel, pullable, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network, navigator, stack, Image } from "doric";
|
||||
import { title, label, colors, icon_refresh } from "./utils";
|
||||
|
||||
@Entry
|
||||
class RefreshableDemo extends Panel {
|
||||
build(rootView: Group): void {
|
||||
let refreshImage: Image
|
||||
let refreshView = refreshable({
|
||||
layoutConfig: layoutConfig().atmost(),
|
||||
header: text({
|
||||
text: "This is Header",
|
||||
width: 100,
|
||||
height: 100,
|
||||
layoutConfig: layoutConfig().exactly(),
|
||||
header: pullable(context,
|
||||
stack([
|
||||
image({
|
||||
layoutConfig: layoutConfig().exactly().m({ top: 50, bottom: 10, }),
|
||||
width: 30,
|
||||
height: 30,
|
||||
imageBase64: icon_refresh,
|
||||
}).also(v => refreshImage = v),
|
||||
]), {
|
||||
startAnimation: () => {
|
||||
log('startAnimation')
|
||||
},
|
||||
stopAnimation: () => {
|
||||
log('stopAnimation')
|
||||
},
|
||||
setProgressRotation: (rotation: number) => {
|
||||
refreshImage.setRotation(context, rotation)
|
||||
},
|
||||
}),
|
||||
content: scroller(vlayout([
|
||||
title("Refreshable Demo"),
|
||||
|
@ -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
|
||||
}
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user