Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PollAnswer.tsx 2.9KB

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