Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. export const RadioButtons = enhance(({
  2. lastMessage: { options }, visibleModal, toggleModal,
  3. }) => {
  4. const len = options.length
  5. const buttonStyle = {
  6. justifyContent: 'center',
  7. margin: 1,
  8. backgroundColor: colors.disable,
  9. elevation: 0,
  10. width: '100%',
  11. }
  12.  
  13.  
  14. if (len <= 3) {
  15. const { width, flexDirection } = widthMap[len]
  16.  
  17. return (
  18. <View
  19. style={[
  20. styles.containerForTwoElement,
  21. { flexDirection },
  22. ]}
  23. >
  24. {options.map((item) => (
  25. <Button
  26. text={item}
  27. full={false}
  28. style={{ ...buttonStyle, width }}
  29. />
  30. ))}
  31. </View>
  32. )
  33. }
  34.  
  35. return (
  36. <React.Fragment>
  37. <Button
  38. text="Выбрать значение"
  39. full={false}
  40. style={buttonStyle}
  41. onPress={() => toggleModal(true)}
  42. />
  43.  
  44. <Modal
  45. visible={visibleModal}
  46. onRequestClose={() => toggleModal(false)}
  47. >
  48. <Container>
  49. <Header>
  50. <Left style={{ flex: 0.2 }}>
  51. <TouchableOpacity
  52. onPress={() => toggleModal(false)}
  53. >
  54. <Icon
  55. name="close"
  56. style={styles.close}
  57. />
  58. </TouchableOpacity>
  59. </Left>
  60. <Body style={{ flex: 0.8 }}>
  61. <Title style={styles.title}>Выберите значение</Title>
  62. </Body>
  63. </Header>
  64. <Content>
  65. <List
  66. dataArray={options}
  67. renderRow={(text) => (
  68. <ListItem>
  69. <TouchableOpacity>
  70. <Text>{text}</Text>
  71. </TouchableOpacity>
  72. </ListItem>
  73. )}
  74. />
  75. </Content>
  76. </Container>
  77. </Modal>
  78. </React.Fragment>
  79. )
  80. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement