CheckBox.js 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. tintColor=colorPrimary,
  9. iosSize=24
  10. }) => {
  11. if (isIOS) {
  12. return (
  13. <MaterialIcons
  14. name={value ? "check-box" : "check-box-outline-blank"}
  15. size={iosSize}
  16. color={value ? tintColor : '#777'}
  17. style={styles.checkBoxView}
  18. onPress={() => {
  19. if (onValueChange)
  20. onValueChange(!value)
  21. }}
  22. />
  23. );
  24. } else {
  25. return (
  26. <CheckBoxBase
  27. value={value}
  28. disabled={disabled}
  29. tintColors={{true: tintColor, false: '#777'}}
  30. onValueChange={onValueChange}
  31. />
  32. )
  33. }
  34. }
  35. const styles = StyleSheet.create({
  36. checkBoxView: {
  37. padding: 4
  38. }
  39. })
  40. export default CheckBox;