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

@wezyy1/rn-animated-tab-nav

v1.0.9

Published

A cross-platform Tab Navigation component for React Native.

Downloads

9

Readme

@wezyy1/rn-animated-tab-nav

Generic badge

The tag bar component is mainly used for bottom navigation, which is convenient for users to switch between different pages quickly. And it is suggested that the number of tags should be controlled within 3-5.

Installation

Installation can be done by using the npm install command:

$ npm install @wezyy1/rn-animated-tab-nav

Demo (Default Style)

demo

Quick Start


import React from 'react';
import { View, SafeAreaView, Text } from 'react-native';
import TabNav from '@wezyy1/rn-animated-tab-nav'

export default class App extends React.Component{

  state = {
    currentPageIndex: 0,
    tabInfo:[{
      id: 1,
      label: 'Home',
      icon: 'home',
      color:'#10A8F6',
      backgroundColor:'#E9F8FF'
  },{
      id: 2,
      label: 'Dairy',
      icon: 'book',
      color:'#F65E10',
      backgroundColor:'#FFF1E9'

  },{
      id: 3,
      label: 'Search',
      icon: 'search',
      color:'#A79507',
      backgroundColor:'#FFFBDC'
  },{
      id: 4,
      label: 'Me',
      icon: 'user',
      color:'#7B14DA',
      backgroundColor:'#EBDAFA'
  }]
  }

  handlePressTab = (pageValue) => {
    this.setState({currentPageIndex: pageValue})
  }

  render(){
    const { currentPageIndex } = this.state

    let mainPage = <View><Text>Home</Text></View>
    if(currentPageIndex === 1){
      mainPage = <View><Text>Book</Text></View>
    } else if (currentPageIndex === 2){
      mainPage = <View><Text>Search</Text></View>
    } else if (currentPageIndex === 3){
      mainPage = <View><Text>Me</Text></View>
    }

    return(
      <SafeAreaView style={{flex:1}}>
        <View style={{flex:1}}>
          {mainPage}
          <TabNav handlePressTab={this.handlePressTab} tabInfo={this.state.tabInfo} currentPageIndex={this.state.currentPageIndex}/>
        </View>
      </SafeAreaView>
    )
  }
}

Try this example on Snack

Use Tab Navigation with Stack Navigation

You can use this tab Navigation with react native stack navigation as well. Documentation of React Navigation

Example:


import React from 'react';
import { View, SafeAreaView, Text } from 'react-native';
import TabNav from '@wezyy1/rn-animated-tab-nav'
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';

const Home = ({navigation}) => <View><Text onPress={() => navigation.navigate('HomeDetail')}>Home</Text></View>
const HomeDetail = () => <View><Text>HomeDetail</Text></View>

const HomeStack = createStackNavigator();

function HomeStackScreen() {
  return (
    <HomeStack.Navigator>
      <HomeStack.Screen name="Home" component={Home}/>
      <HomeStack.Screen name="HomeDetail" component={HomeDetail}/>
    </HomeStack.Navigator>
  );
}

export default class App extends React.Component{

  state = {
    currentPageIndex: 0,
    tabInfo:[{
      id: 1,
      label: 'Home',
      icon: 'home',
      color:'#10A8F6',
      backgroundColor:'#E9F8FF'
  },{
      id: 2,
      label: 'Dairy',
      icon: 'book',
      color:'#F65E10',
      backgroundColor:'#FFF1E9'

  },{
      id: 3,
      label: 'Search',
      icon: 'search',
      color:'#A79507',
      backgroundColor:'#FFFBDC'
  },{
      id: 4,
      label: 'Me',
      icon: 'user',
      color:'#7B14DA',
      backgroundColor:'#EBDAFA'
  }]
  }

  handlePressTab = (pageValue) => {
    this.setState({currentPageIndex: pageValue})
  }

  render(){
    const { currentPageIndex } = this.state

    let mainPage = <HomeStackScreen/>
    if(currentPageIndex === 1){
      mainPage = <View><Text>Book</Text></View>
    } else if (currentPageIndex === 2){
      mainPage = <View><Text>Search</Text></View>
    } else if (currentPageIndex === 3){
      mainPage = <View><Text>Me</Text></View>
    }

    return(
      <SafeAreaView style={{flex:1}}>
        <View style={{flex:1}}>
          <NavigationContainer>
            {mainPage}
          </NavigationContainer>
          <TabNav handlePressTab={this.handlePressTab} tabInfo={this.state.tabInfo} currentPageIndex={this.state.currentPageIndex}/>
        </View>
      </SafeAreaView>
    )
  }
}

Try this example on Snack

API

Props

|Property|Description|Type|Required| |-|:-:|:-:|-:| |tabInfo|This is an array of the information of the tab navigation. (See more detail in the next table.)|Array|ture| |tabStyle|The style of the tab bar contener.|Style Object|false| |itemStyle|The style of the tab item.|Style Object|false| |currentPageIndex|This is the index of the active item.|Number|true| |handlePressTab|Callback Function when press tab item. This function will get the index of the pressed tab item.|Function|true|

tabInfo Properties

|Property|Description|Type|Required| |-|:-:|:-:|-:| |label|The label displayed in the tab item.|String|true| |icon|The name of the icon you want to use. Feather Icon is suported. You can find the icon and name here.|String|true| |color|The color of the icon and label when the item is active. |Color String|true| |backgroundColor|The color of background when the item is active. |Color String|true|