react-native-navigation的迁移库

NativeCommandsSender.ts 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { NativeModules } from 'react-native';
  2. export class NativeCommandsSender {
  3. private nativeCommandsModule;
  4. constructor() {
  5. this.nativeCommandsModule = NativeModules.RNNBridgeModule;
  6. }
  7. setRoot(layoutTree: object) {
  8. return this.nativeCommandsModule.setRoot(layoutTree);
  9. }
  10. setDefaultOptions(options: object) {
  11. this.nativeCommandsModule.setDefaultOptions(options);
  12. }
  13. setOptions(componentId: string, options: object) {
  14. this.nativeCommandsModule.setOptions(componentId, options);
  15. }
  16. async push(onComponentId: string, layout: object) {
  17. const pushedComponentId = await this.nativeCommandsModule.push(onComponentId, layout);
  18. return pushedComponentId;
  19. }
  20. pop(componentId: string, options: object) {
  21. return this.nativeCommandsModule.pop(componentId, options);
  22. }
  23. popTo(componentId: string) {
  24. return this.nativeCommandsModule.popTo(componentId);
  25. }
  26. popToRoot(componentId: string) {
  27. return this.nativeCommandsModule.popToRoot(componentId);
  28. }
  29. async showModal(layout: object) {
  30. const completed = await this.nativeCommandsModule.showModal(layout);
  31. return completed;
  32. }
  33. dismissModal(componentId: string) {
  34. return this.nativeCommandsModule.dismissModal(componentId);
  35. }
  36. dismissAllModals() {
  37. return this.nativeCommandsModule.dismissAllModals();
  38. }
  39. showOverlay(type: any, options: object) {
  40. return this.nativeCommandsModule.showOverlay(type, options);
  41. }
  42. dismissOverlay() {
  43. this.nativeCommandsModule.dismissOverlay();
  44. return Promise.resolve(true);
  45. }
  46. }