You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dialog.native.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import Prompt from 'react-native-prompt';
  4. import { translate } from '../../i18n';
  5. import AbstractDialog from './AbstractDialog';
  6. /**
  7. * Native dialog using Prompt.
  8. */
  9. class Dialog extends AbstractDialog {
  10. /**
  11. * Native sialog component's property types.
  12. *
  13. * @static
  14. */
  15. static propTypes = {
  16. /**
  17. * I18n key to put as body title.
  18. */
  19. bodyKey: React.PropTypes.string
  20. };
  21. /**
  22. * Implements React's {@link Component#render()}.
  23. *
  24. * @inheritdoc
  25. * @returns {ReactElement}
  26. */
  27. render() {
  28. const {
  29. cancelDisabled,
  30. cancelTitleKey,
  31. bodyKey,
  32. okDisabled,
  33. okTitleKey,
  34. t,
  35. titleKey
  36. } = this.props;
  37. return (
  38. <Prompt
  39. cancelText = { cancelDisabled
  40. ? undefined : t(cancelTitleKey || 'dialog.Cancel') }
  41. onCancel = { this._onCancel }
  42. onSubmit = { this._onSubmit }
  43. placeholder = { t(bodyKey) }
  44. submitText = { okDisabled
  45. ? undefined : t(okTitleKey || 'dialog.Ok') }
  46. title = { t(titleKey) }
  47. visible = { true } />
  48. );
  49. }
  50. }
  51. export default translate(connect()(Dialog));