Switch.js 994 B

123456789101112131415161718192021222324252627282930
  1. import React from 'react';
  2. import { Switch, SwitchProps, Text, View } from 'react-native';
  3. import Animated from 'react-native-reanimated';
  4. import utils from '../utils/utils';
  5. //const switchStyle = { false: "#B2B2B2", true: colorAccent };
  6. export default SwitchBase = (props, {...SwitchProps}) => {
  7. const colors = utils.hexColorToRgb(colorAccent);
  8. var thumbColor = null;
  9. var trackColor = { false: "#B2B2B2", true: colorAccent }
  10. if (!isIOS) {
  11. thumbColor = (props.value ? utils.getRgbaColor(colors, 0.9) : "#EBEDEC")
  12. trackColor = {false: "#B2B2B2", true: utils.getRgbaColor(colors, 0.3)}
  13. }
  14. return (
  15. <Animated.View style={ui.flexc}>
  16. <Switch
  17. {...props}
  18. trackColor={trackColor}
  19. thumbColor={thumbColor}
  20. />
  21. {/* <Switch
  22. {...props}
  23. />
  24. <Text style={{color: utils.getRgbaColor(colors, 0.9)}}>■■■</Text>
  25. <Text style={{color: utils.getRgbaColor(colors, 0.3)}}>■■■</Text> */}
  26. </Animated.View>
  27. );
  28. }