npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-switch-selector-fix

v2.0.4

Published

Switch Selector to React Native.

Downloads

28

Readme

SwitchSelector

Switch Selector to React Native.

npm version downloads

SwitchSelector

SwitchSelector

SwitchSelector - Custom Example

SwitchSelector

Installing

yarn add react-native-switch-selector

or

npm i react-native-switch-selector --save

Usage

import SwitchSelector from "react-native-switch-selector";
const options = [
  { label: "01:00", value: "1" },
  { label: "01:30", value: "1.5" },
  { label: "02:00", value: "2" }
];
<SwitchSelector
  options={options}
  initial={0}
  onPress={value => console.log(`Call onPress with value: ${value}`)}
/>

Custom Example

<SwitchSelector
  initial={0}
  onPress={value => this.setState({ gender: value })}
  textColor={colors.purple} //'#7a44cf'
  selectedColor={colors.white}
  buttonColor={colors.purple}
  borderColor={colors.purple}
  hasPadding
  options={[
    { label: "Feminino", value: "f", imageIcon: images.feminino }, //images.feminino = require('./path_to/assets/img/feminino.png')
    { label: "Masculino", value: "m", imageIcon: images.masculino } //images.masculino = require('./path_to/assets/img/masculino.png')
  ]}
/>

Props

| Prop | Type | Default | Required | Note | | ------------------------- | ----------------------- | ----------- | -------- | -------------------------------------------------------------------------------- | | options | array | null | true | Items array to render. Each item has a label and a value and optionals icons | | options[].label | string | null | true | Label from each item | | options[].value | string | null | true | Value from each item | | options[].customIcon | Jsx element ou Function | null | false | Optional custom icon from each item | | options[].imageIcon | string | null | false | Source from a image icon form each item. Has the same color then label in render | | options[].activeColor | string | null | false | Color from each item when is selected | | initial | number | -1 | false | Item selected in initial render | | value | number | undefined | false | The switch value (will call onPress) | | onPress | function | console.log | true | Callback function called after change value. | | disableValueChangeOnPress | bool | false | false | Disables the onPress call when the value is manually changed | | fontSize | number | null | false | Font size from labels. If null default fontSize of the app is used. | | selectedColor | string | '#fff' | false | Color text of the item selected | | buttonMargin | number | 0 | false | Margin of the item selected to component | | buttonColor | string | '#BCD635' | false | Color bg of the item selected | | textColor | string | '#000' | false | Color text of the not selecteds items | | backgroundColor | string | '#ffffff' | false | Color bg of the component | | borderColor | string | '#c9c9c9' | false | Border Color of the component | | borderRadius | number | 50 | false | Border Radius of the component | | hasPadding | bool | false | false | Indicate if item has padding | | animationDuration | number | 250 | false | Duration of the animation | | valuePadding | number | 1 | false | Size of padding | | height | number | 40 | false | Height of component | | bold | bool | false | false | Indicate if text has fontWeight bold | | textStyle | object | {} | false | Text style | | selectedTextStyle | object | {} | false | Selected text style | | textContainerStyle | object | {} | false | Style for text (and icon) container (TouchableOpacity) | | selectedTextContainerStyle | object | {} | false | Style for selected text (and icon) container (TouchableOpacity) | | imageStyle | object | {} | false | Image style | | style | object | {} | false | Container style | | returnObject | bool | false | false | Indicate if onPress function return an option instead of option.value | | disabled | bool | false | false | Disables the switch |

Authors

Contribute

Contributions are always welcome! Create a new Pull Request