CheckBoxText.js 949 B

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