1.0.3 • Published 2 years ago

switchin-react-native v1.0.3

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

Swith in React-Native

Battle Tested ✅

npm version

Platform - Android and iOS License: MIT styled with prettier

Installation

Add the dependency:

npm i switchin-react-native

Peer Dependencies

IMPORTANT! You need install them

Zero Dependency

Usage

Import

import DuoToggleSwitch from "switchin-react-native";

Basic Usage

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

OR (Also you can add icon like this)

<DuoToggleSwitch
  primaryText={<Feather name="grid" size={24} color={'black'} />}
  secondaryText={<Feather name="menu" size={24} color={'black'} />}
  onPrimaryPress={() => {}}
  onSecondaryPress={() => {}}
/>

Custom Usage

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

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
primaryButtonStyleViewStyledefaultset or override style for the primary button
secondaryButtonStyleViewStyledefaultset or override style for the secondary button
primaryTextStyleTextViewdefaultset or override style for primary text style
secondaryTextStyleTextViewdefaultset or override style for secondary text style
TouchableComponentcomponentTouchableOpacityset your own Pressable functionality instead of TouchableOpacity

Author

Ravindra Nakrani, 0330.ravindra@gmail.com

License

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