Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PollAnswer.js 2.9KB

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