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-toggle

v1.0.3

Published

hide or show react native`s component

Downloads

9

Readme

react-native-root-toggle


A React Native component that allows you to use native property to hide or show children components inside: When the component is hidden, its state will be retained in memory would not be released.

Install

npm install react-native-toggle@latest --save

iOS

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-toggle ➜ ios and add the .xcodeproj file

In XCode, in the project navigator, select your project. Add the lib*.a from the RCTToggle project to your project's Build Phases ➜ Link Binary With Libraries Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../../node_modules/react-native/React and $(SRCROOT)/../../react-native/React - mark both as recursive.

Run your project (Cmd+R)

Android

copy files under ./android to your project root path

edit file [your project's name]/android/app/src/main/java/com/[your package name]/MainActivity.java

add


...
import java.util.List;
import com.horcrux.toggle.*; // <------- import package

public class MainActivity extends ReactActivity {
...
    ...
   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),  // <------- add comma here
        new ToggleViewPackage() // <------- add package
      );
    }
    ...

Props

Prop | Type | Default | Description -------------- | -------- | -------- | -------------------- hidden | bool | false | Show/Hide the Toggle

Usage

The Toggle component is an implementation for visibility style

{
    visibility: hidden // when hidden={true}
}
{
    visibility: visible // when hidden={false}
}
import React, {
    AppRegistry,
    Component,
    StyleSheet,
    Text,
    View,
    TouchableHighlight,
    TextInput
} from 'react-native';

import Toggle from 'react-native-toggle'; // import Toggle

class ToggleExample extends Component {
    constructor() {
        super(...arguments);
        this.state = {
            hidden: false
        };
    }

    toggle = () => {
        this.setState({
            hidden: !this.state.hidden
        });
    };

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.title}>
                    You can click the button below to hide or show the TextInput
                </Text>
                <Toggle hidden={this.state.hidden}>
                    <TextInput
                        style={styles.textInput}
                    />
                </Toggle>
                <TouchableHighlight
                    style={styles.button}
                    onPress={this.toggle}
                    underlayColor="#aaa"
                >
                    <Text style={styles.buttonText}>{this.state.hidden ? 'Show' : 'Hide'} TextInput</Text>
                </TouchableHighlight>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: '#F5FCFF'
    },
    textInput: {
        height: 25,
        width: 160,
        marginBottom: 10,
        backgroundColor: '#ccc',
        alignSelf: 'center',
        borderRadius: 5,
        textAlign: 'center'
    },
    button: {
        borderRadius: 4,
        padding: 10,
        marginLeft: 10,
        marginRight: 10,
        backgroundColor: '#ccc',
        borderColor: '#333',
        borderWidth: 1
    },
    title: {
        textAlign: 'center',
        marginHorizontal: 20,
        marginBottom: 10
    },
    buttonText: {
        color: '#000'
    }
});
AppRegistry.registerComponent('ToggleExample', () => ToggleExample);

Run example

Just cd to ./Example and run npm install