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.

EnableLobbyModeDialog.js 2.3KB

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