您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

EnableLobbyModeDialog.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { Text, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { CustomSubmitDialog } from '../../../base/dialog';
  6. import { translate } from '../../../base/i18n';
  7. import { connect } from '../../../base/redux';
  8. import { toggleLobbyMode } from '../../actions';
  9. import styles from './styles';
  10. type Props = {
  11. /**
  12. * The Redux Dispatch function.
  13. */
  14. dispatch: Function,
  15. /**
  16. * Function to be used to translate i18n labels.
  17. */
  18. t: Function
  19. };
  20. /**
  21. * Implements a dialog that lets the user enable the lobby mode.
  22. */
  23. class EnableLobbyModeDialog extends PureComponent<Props> {
  24. /**
  25. * Instantiates a new component.
  26. *
  27. * @inheritdoc
  28. */
  29. constructor(props: Props) {
  30. super(props);
  31. this._onEnableLobbyMode = this._onEnableLobbyMode.bind(this);
  32. }
  33. /**
  34. * Implements {@code PureComponent#render}.
  35. *
  36. * @inheritdoc
  37. */
  38. render() {
  39. return (
  40. <CustomSubmitDialog
  41. okKey = 'lobby.enableDialogSubmit'
  42. onSubmit = { this._onEnableLobbyMode }
  43. titleKey = 'lobby.dialogTitle'>
  44. <View style = { styles.formWrapper }>
  45. <Text>
  46. { this.props.t('lobby.enableDialogText') }
  47. </Text>
  48. </View>
  49. </CustomSubmitDialog>
  50. );
  51. }
  52. _onEnableLobbyMode: () => void;
  53. /**
  54. * Callback to be invoked when the user initiates the lobby mode enable flow.
  55. *
  56. * @returns {void}
  57. */
  58. _onEnableLobbyMode() {
  59. this.props.dispatch(toggleLobbyMode(true));
  60. return true;
  61. }
  62. }
  63. /**
  64. * Maps part of the Redux state to the props of this component.
  65. *
  66. * @param {Object} state - The Redux state.
  67. * @returns {Props}
  68. */
  69. function _mapStateToProps(state: Object): Object {
  70. return {
  71. _dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
  72. };
  73. }
  74. export default translate(connect(_mapStateToProps)(EnableLobbyModeDialog));