1.1.0 • Published 2 years ago

react-native-duo-toggle-switch v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

Battle Tested ✅

Fully customizable animated duo toggle switch for React Native

npm version npm Platform - Android and iOS License: MIT styled with prettier

Version 1 🥰

Version 1 is released with typescript and some breaking changes

  • Code Cleaning
  • Typescript
  • Better props
  • Fully customizable
  • Better animations
  • Better GIFs on documentation

Installation

Add the dependency:

npm i react-native-duo-toggle-switch

Peer Dependencies

IMPORTANT! You need install them

Zero Dependency

Usage

Import

import DuoToggleSwitch from "react-native-duo-toggle-switch";

Basic Usage

<DuoToggleSwitch
  primaryText="Map"
  secondaryText="List"
  onPrimaryPress={() => {}}
  onSecondaryPress={() => {}}
/>

Custom Usage

<DuoToggleSwitch
  primaryText="Map"
  secondaryText="List"
  onPrimaryPress={() => {}}
  onSecondaryPress={() => {}}
  TouchableComponent={Ripple}
  rippleColor="#fff"
  rippleContainerBorderRadius={50}
/>

Configuration - Props

TouchableComponent?: any;

PropertyTypeDefaultDescription
primaryTextstringundefinedset the primary button's (left one) text
secondyTextstringundefinedset the secondy button's (right one) text
activeColorstring#FBA928change the button's background color when it is active or pressed
inactiveColorstring#fffchange the button's background color when it is inactive or pressed
activeTextColorstring#f1f1f1change the button's text color when it is active or pressed
inactiveTextColorstring#757575change the button's text color when it is active or pressed
onPrimaryPressfunctionnullset your own onPress logic for first(primary) button
onSecondaryPressfunctionnullset your own onPress logic for second(secondary) button
styleViewStyledefaultset or override style for the main container
primaryTextStyleTextViewdefaultset or override style for primary text style
secondaryTextStyleTextViewdefaultset or override style for secondary text style
TouchableComponentcomponentTouchableOpacityset your own Pressable functionality instead of TouchableOpacity

Future Plans

  • LICENSE
  • Typescript
  • Color Change Animation
  • Write an article about the lib on Medium

Author

FreakyCoder, kurayogun@gmail.com

License

React Native Duo Toggle Switch is available under the MIT license. See the LICENSE file for more info.