CheckBox.js 808 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from 'react';
  2. import { StyleSheet } from 'react-native';
  3. import CheckBoxBase from '@react-native-community/checkbox';
  4. const CheckBox = ({
  5. value=false,
  6. disabled=false,
  7. onValueChange,
  8. iosSize=24
  9. }) => {
  10. if (isIOS) {
  11. return (
  12. <MaterialIcons
  13. name={value ? "check-box" : "check-box-outline-blank"}
  14. size={iosSize}
  15. color={value ? colorAccent : '#777'}
  16. style={styles.checkBoxView}
  17. onPress={() => {
  18. if (onValueChange)
  19. onValueChange(!value)
  20. }}
  21. />
  22. );
  23. } else {
  24. return (
  25. <CheckBoxBase
  26. value={value}
  27. disabled={disabled}
  28. onValueChange={onValueChange}
  29. />
  30. )
  31. }
  32. }
  33. const styles = StyleSheet.create({
  34. checkBoxView: {
  35. padding: 4
  36. }
  37. })
  38. export default CheckBox;