js: implement keyboard related api

This commit is contained in:
王劲鹏
2021-03-18 18:47:49 +08:00
committed by osborn
parent eba0261082
commit a21cdcd874
11 changed files with 206 additions and 1 deletions

View File

@@ -9,3 +9,4 @@ export * from './notification';
export * from './statusbar';
export * from './coordinator';
export * from './notch';
export * from './keyboard';

View File

@@ -24,3 +24,4 @@ export * from './notification';
export * from './statusbar';
export * from './coordinator';
export * from './notch';
export * from './keyboard';

7
doric-js/lib/src/native/keyboard.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
import { BridgeContext } from "../runtime/global";
export declare function keyboard(context: BridgeContext): {
subscribe: (callback: (data: {
height: number;
}) => void) => Promise<string>;
unsubscribe: (subscribeId: string) => Promise<any>;
};

View File

@@ -0,0 +1,11 @@
export function keyboard(context) {
return {
subscribe: (callback) => {
return context.callNative('keyboard', 'subscribe', context.function2Id(callback));
},
unsubscribe: (subscribeId) => {
context.removeFuncById(subscribeId);
return context.callNative('keyboard', 'unsubscribe', subscribeId);
}
};
}