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.

PollAnswer.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import React from 'react';
  3. import { Switch, Text, View } from 'react-native';
  4. import { Button } from 'react-native-paper';
  5. import { BUTTON_MODES } from '../../../chat/constants';
  6. import AbstractPollAnswer from '../AbstractPollAnswer';
  7. import type { AbstractProps } from '../AbstractPollAnswer';
  8. import { chatStyles, dialogStyles } from './styles';
  9. const PollAnswer = (props: AbstractProps) => {
  10. const {
  11. checkBoxStates,
  12. poll,
  13. setCheckbox,
  14. skipAnswer,
  15. submitAnswer,
  16. t
  17. } = props;
  18. return (
  19. <View>
  20. <View>
  21. <Text style = { dialogStyles.question } >{ poll.question }</Text>
  22. </View>
  23. <View style = { chatStyles.answerContent }>
  24. {poll.answers.map((answer, index) => (
  25. <View
  26. key = { index }
  27. style = { chatStyles.switchRow } >
  28. <Switch
  29. /* eslint-disable react/jsx-no-bind */
  30. onValueChange = { state => setCheckbox(index, state) }
  31. value = { checkBoxStates[index] } />
  32. <Text>{answer.name}</Text>
  33. </View>
  34. ))}
  35. </View>
  36. <View style = { chatStyles.buttonRow }>
  37. <Button
  38. color = '#3D3D3D'
  39. mode = { BUTTON_MODES.CONTAINED }
  40. onPress = { skipAnswer }
  41. style = { chatStyles.pollCreateButton } >
  42. {t('polls.answer.skip')}
  43. </Button>
  44. <Button
  45. color = '#17a0db'
  46. mode = { BUTTON_MODES.CONTAINED }
  47. onPress = { submitAnswer }
  48. style = { chatStyles.pollCreateButton } >
  49. {t('polls.answer.submit')}
  50. </Button>
  51. </View>
  52. </View>
  53. );
  54. };
  55. /*
  56. * We apply AbstractPollAnswer to fill in the AbstractProps common
  57. * to both the web and native implementations.
  58. */
  59. // eslint-disable-next-line new-cap
  60. export default AbstractPollAnswer(PollAnswer);