1.0.8 • Published 2 years ago

rn-animated-switch v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

rn-animated-switch

A simple Switch component with animations and icons or whatever you want, reducing your development time for great apps to enjoy your coffee <( ͡° ͜ʖ ͡°)☕️

preview

Install

from yarn

yarn add rn-animated-switch

from npm

npm i rn-animated-switch

Usage

import RNAnimatedSwitch from 'rn-animated-switch'

...

const circleContent = () => {
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center'
        }}
      >
        <Text>Hi!</Text>
      </View>
    )
  }

 const renderActiveComponent = () => {
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
        }}>
        <Image source={Images.smile} style={{width: 30, height: 30}} />
      </View>
    );
  };

const renderInactiveComponent = () => {
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
        }}>
        <Image source={Images.sadBoyzSiTinh} style={{width: 30, height: 30}} />
      </View>
    );
  };

...

 <RNAnimatedSwitch
          width={100}
          height={40}
          value={value}
          onValueChange={setValue}
          activeColor={'#282E38'}
          inactiveColor={'#D8F3FF'}
          circleContent={circleContent}
          activeComponent={renderActiveComponent}
          inactiveComponent={renderInactiveComponent}
/>

...

Properties

PropDefaultTypeDescription
widthnonenumberWidth of Switch
heightnonenumberHeight of Switch
valuenonebooleanValue of Switch
onValueChangenonefunctionThe callback function for when the value is changed in Switch, providing the updated value in params
activeColornonestringActive color
inactiveColornonestringInactive color
activeCircleColornonestringActive color of circle
inactiveCircleColornonestringInactive color of circle
isDisablenonebooleanDisable switch
disableColornonestringSwitch color when disabled
circleContentnoneelementContent of Switch's circle
activeComponentnoneelementComponent show when switch inactive
inactiveComponentnoneelementComponent show when switch inactive

License

MIT License.

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago