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

rn-switch

v0.2.2

Published

react-native 开关组件

Downloads

17

Readme

#rn-switch 开关组件

效果

例子

例子

import React, {Component} from 'react';
import {
    AppRegistry,
    View
} from 'react-native';
import {Switch} from 'rn-switch';
class App extends Component{
    constructor(props) {
        super(props);
        this.state={value:1};
    }
    switchChange(val){
        this.setState({value:val})
    }
    render(){
        return (
        <View style={{marginTop:20}}>
                        <Text>{this.state.value}</Text>
                        <Switch toggleValue={this.state.value}
                                onChange={this.switchChange.bind(this)}
                        ></Switch>
                        <Switch toggleValue="0"
                                width={100}
                                onBackgroundColor="red"
                                onChange={this.switchChange.bind(this)}
                        ></Switch>
                        <Switch toggleValue="1"
                                width={100}
                                toggleLable={true}
                                onChange={this.switchChange.bind(this)}
                        ></Switch>
                        <Switch toggleValue="1"
                                onLable="开"
                                offLable="关"
                                height={30}
                                onLableColor="red"
                                toggleLable={true}
                                onChange={this.switchChange.bind(this)}
                        ></Switch>
                         <Switch toggleValue="1"
                                disabled={true}
                                toggleLable={true}
                                onChange={this.switchChange.bind(this)}
                        ></Switch>
                    </View>
                )
} 
}
AppRegistry.registerComponent('App', () => App);

属性

  • width: number 开关组件宽度
  • height: number 开关组件高度
  • duration: number 动画速率,默认为200
  • disabled: bool 默认 false
  • disabledStyle: object 禁用后的样式
  • onBackgroundColor: string 开启状态下的背景颜色
  • offBackgroundColor: string 关闭状态下的背景颜色
  • onValue: any 开启状态下回调返回的值,默认返回1
  • offValue: any 关闭状态下回调返回的值,默认返回0
  • onLable: string 默认不开启
  • onLableColor: string 开启提示的文字颜色
  • offLable: string 默认不开启
  • offLableColor: string 关闭提示的文字颜色
  • toggleLable: bool 默认为false,即不显示文字提示
  • toggleValue: bool true为开启状态,false为关闭状态,默认为false
  • onChange: function(val) 修改后触发的回调函数,返回切换后的值