Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

PollAnswer.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // @flow
  2. import React from 'react';
  3. import { Switch, Text, View } from 'react-native';
  4. import { Button } from 'react-native-paper';
  5. import BaseTheme from '../../../base/ui/components/BaseTheme.native';
  6. import { BUTTON_MODES } from '../../../chat/constants';
  7. import { isSubmitAnswerDisabled } from '../../functions';
  8. import AbstractPollAnswer from '../AbstractPollAnswer';
  9. import type { 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. return (
  23. <View>
  24. <View>
  25. <Text style = { dialogStyles.question } >{ poll.question }</Text>
  26. </View>
  27. <View style = { chatStyles.answerContent }>
  28. {poll.answers.map((answer, index) => (
  29. <View
  30. key = { index }
  31. style = { chatStyles.switchRow } >
  32. <Switch
  33. /* eslint-disable react/jsx-no-bind */
  34. onValueChange = { state => setCheckbox(index, state) }
  35. value = { checkBoxStates[index] } />
  36. <Text style = { chatStyles.switchLabel }>{answer.name}</Text>
  37. </View>
  38. ))}
  39. </View>
  40. <View style = { chatStyles.buttonRow }>
  41. <Button
  42. color = { BaseTheme.palette.action02 }
  43. mode = { BUTTON_MODES.CONTAINED }
  44. onPress = { changingVote ? skipChangeVote : skipAnswer }
  45. style = { chatStyles.pollCreateButton } >
  46. {t('polls.answer.skip')}
  47. </Button>
  48. <Button
  49. color = { BaseTheme.palette.screen01Header }
  50. disabled = { isSubmitAnswerDisabled(checkBoxStates) }
  51. labelStyle = {
  52. isSubmitAnswerDisabled(checkBoxStates)
  53. ? chatStyles.pollSendDisabledLabel
  54. : chatStyles.pollSendLabel
  55. }
  56. mode = { BUTTON_MODES.CONTAINED }
  57. onPress = { submitAnswer }
  58. style = { chatStyles.pollCreateButton } >
  59. {t('polls.answer.submit')}
  60. </Button>
  61. </View>
  62. </View>
  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);