CheckBoxText.js 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. import { View, Text, StyleSheet } from 'react-native';
  3. import CheckBox from '../components/CheckBox';
  4. const CheckBoxText = (
  5. {
  6. value=false,
  7. text='',
  8. disabled=false,
  9. onValueChange,
  10. flexText=false,
  11. style=styles.checkboxItem,
  12. textStyle=styles.checkboxText
  13. }
  14. ) => (
  15. <View style={style}>
  16. <CheckBox
  17. value={value}
  18. disabled={disabled}
  19. onValueChange={onValueChange}/>
  20. <Text
  21. style={[textStyle, flexText ? {flex: 1} : {}]}
  22. onPress={() => {
  23. if (onValueChange) onValueChange(!value)
  24. }}>{text}</Text>
  25. </View>
  26. )
  27. export default CheckBoxText;
  28. const styles = StyleSheet.create({
  29. checkboxItem: {
  30. flex: 1,
  31. minWidth: 100,
  32. paddingTop: 2,
  33. paddingBottom: 4,
  34. alignItems: 'center',
  35. flexDirection: 'row'
  36. },
  37. checkboxText: {
  38. color: '#222',
  39. fontSize: 16,
  40. padding: 4
  41. }
  42. })