fernando-silva-dev / react-native-switch-with-icons

A simple switch component with icons in the thumb.
MIT License
15 stars 5 forks source link

How to change icons? #1

Closed medmo7 closed 3 years ago

medmo7 commented 3 years ago

Thanks for this lib.

I don't see how to add custom, icons to the switch.

it seems that the path of icons is hardcoded in the lib, I'm right?

import ic_switch_on from '../../img/SwitchOn.png';
import ic_switch_off from '../../img/SwitchOff.png';
Hadenaut commented 3 years ago

Hello. Those you see hardcoded are the defaults, to add your own icons you need to pass them as the icon prop.

Ex:

<SwitchWithIcons icon={{
  true: icon1, //This is the icon that is displayed in the thumb when the value is true
  false: icon2 //This is the icon that is displayed in the thumb when the value is false
}}/>

Hope that helps.