NativeDialogManagerAndroid.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow strict-local
  8. * @format
  9. */
  10. 'use strict';
  11. import type {TurboModule} from '../../TurboModule/RCTExport';
  12. import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';
  13. /* 'buttonClicked' | 'dismissed' */
  14. type DialogAction = string;
  15. /*
  16. buttonPositive = -1,
  17. buttonNegative = -2,
  18. buttonNeutral = -3
  19. */
  20. type DialogButtonKey = number;
  21. export type DialogOptions = {|
  22. title?: string,
  23. message?: string,
  24. buttonPositive?: string,
  25. buttonNegative?: string,
  26. buttonNeutral?: string,
  27. items?: Array<string>,
  28. cancelable?: boolean,
  29. |};
  30. export interface Spec extends TurboModule {
  31. +getConstants: () => {|
  32. +buttonClicked: DialogAction,
  33. +dismissed: DialogAction,
  34. +buttonPositive: DialogButtonKey,
  35. +buttonNegative: DialogButtonKey,
  36. +buttonNeutral: DialogButtonKey,
  37. |};
  38. +showAlert: (
  39. config: DialogOptions,
  40. onError: (error: string) => void,
  41. onAction: (action: DialogAction, buttonKey?: DialogButtonKey) => void,
  42. ) => void;
  43. }
  44. export default (TurboModuleRegistry.get<Spec>('DialogManagerAndroid'): ?Spec);