Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React from 'react';
  2. import { Text, View } from 'react-native';
  3. import { useSelector } from 'react-redux';
  4. import { getLocalParticipant } from '../../../base/participants/functions';
  5. import Button from '../../../base/ui/components/native/Button';
  6. import Switch from '../../../base/ui/components/native/Switch';
  7. import { BUTTON_TYPES } from '../../../base/ui/constants.native';
  8. import { isSubmitAnswerDisabled } from '../../functions';
  9. import AbstractPollAnswer, { AbstractProps } from '../AbstractPollAnswer';
  10. // @ts-ignore
  11. import { chatStyles, dialogStyles } from './styles';
  12. const PollAnswer = (props: AbstractProps) => {
  13. const {
  14. checkBoxStates,
  15. poll,
  16. setCheckbox,
  17. skipAnswer,
  18. skipChangeVote,
  19. submitAnswer,
  20. t
  21. } = props;
  22. const { changingVote } = poll;
  23. const localParticipant = useSelector(getLocalParticipant);
  24. const { PRIMARY, SECONDARY } = BUTTON_TYPES;
  25. return (
  26. <>
  27. <Text style = { dialogStyles.questionText } >{ poll.question }</Text>
  28. <Text style = { dialogStyles.questionOwnerText } >{
  29. t('polls.by', { name: localParticipant?.name })
  30. }
  31. </Text>
  32. <View style = { chatStyles.answerContent }>
  33. {poll.answers.map((answer, index) => (
  34. <View
  35. key = { index }
  36. style = { chatStyles.switchRow } >
  37. <Switch
  38. checked = { checkBoxStates[index] }
  39. /* eslint-disable-next-line react/jsx-no-bind */
  40. onChange = { state => setCheckbox(index, state) } />
  41. <Text style = { chatStyles.switchLabel }>{answer.name}</Text>
  42. </View>
  43. ))}
  44. </View>
  45. <View style = { chatStyles.buttonRow }>
  46. <Button
  47. accessibilityLabel = 'polls.answer.skip'
  48. labelKey = 'polls.answer.skip'
  49. onClick = { changingVote ? skipChangeVote : skipAnswer }
  50. style = { chatStyles.pollCreateButton }
  51. type = { SECONDARY } />
  52. <Button
  53. accessibilityLabel = 'polls.answer.submit'
  54. disabled = { isSubmitAnswerDisabled(checkBoxStates) }
  55. labelKey = 'polls.answer.submit'
  56. onClick = { submitAnswer }
  57. style = { chatStyles.pollCreateButton }
  58. type = { PRIMARY } />
  59. </View>
  60. </>
  61. );
  62. };
  63. /*
  64. * We apply AbstractPollAnswer to fill in the AbstractProps common
  65. * to both the web and native implementations.
  66. */
  67. // eslint-disable-next-line new-cap
  68. export default AbstractPollAnswer(PollAnswer);