iOS: implement Image Pixel
This commit is contained in:
2
doric-js/lib/src/ui/view.d.ts
vendored
2
doric-js/lib/src/ui/view.d.ts
vendored
@@ -62,7 +62,7 @@ export declare abstract class View implements Modeling {
|
||||
onClick?: Function;
|
||||
superview?: Superview;
|
||||
callbacks: Map<String, Function>;
|
||||
private callback2Id;
|
||||
callback2Id(f: Function): string;
|
||||
private id2Callback;
|
||||
findViewByTag(tag: string): View | undefined;
|
||||
constructor();
|
||||
|
8
doric-js/lib/src/widget/image.d.ts
vendored
8
doric-js/lib/src/widget/image.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { View } from "../ui/view";
|
||||
import { View, NativeViewModel } from "../ui/view";
|
||||
import { Color } from "../util/color";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { Resource } from "../util/resource";
|
||||
@@ -95,5 +95,11 @@ export declare class Image extends View {
|
||||
mimeType: string;
|
||||
}>;
|
||||
getImagePixels(context: BridgeContext): Promise<ArrayBuffer>;
|
||||
setImagePixels(context: BridgeContext, imagePixels: {
|
||||
width: number;
|
||||
height: number;
|
||||
pixels: ArrayBuffer;
|
||||
}): Promise<void>;
|
||||
toModel(): NativeViewModel;
|
||||
}
|
||||
export declare function image(config: Partial<Image>): Image;
|
||||
|
@@ -48,6 +48,25 @@ export class Image extends View {
|
||||
getImagePixels(context) {
|
||||
return this.nativeChannel(context, "getImagePixels")();
|
||||
}
|
||||
setImagePixels(context, imagePixels) {
|
||||
if (Environment.platform === 'iOS') {
|
||||
imagePixels.pixels = context.function2Id(() => {
|
||||
return imagePixels.pixels;
|
||||
});
|
||||
}
|
||||
return this.nativeChannel(context, "setImagePixels")(imagePixels);
|
||||
}
|
||||
toModel() {
|
||||
const ret = super.toModel();
|
||||
if (Environment.platform === 'iOS') {
|
||||
if (Reflect.has(ret.props, "imagePixels")) {
|
||||
const imagePixels = Reflect.get(ret.props, "imagePixels");
|
||||
const pixels = imagePixels.pixels;
|
||||
imagePixels.pixels = this.callback2Id(() => pixels);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
Property,
|
||||
|
Reference in New Issue
Block a user