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-scrollable-tabstring

v0.0.8

Published

a scrollable list with animated horizontal tab when scrolling

Downloads

66

Readme

Build Status

A ScrollView-like component with animated horizontal tab when scrolling

Get started

Installation

Install the dependency.

$ npm install react-native-scrollable-tabstring
$ yarn add react-native-scrollable-tabstring

Usage

Start using the components or try it on Snack here.

import ScrollableTabString from 'react-native-scrollable-tabstring';
//Standard scrollable tab
<ScrollableTabString
    onPressTab={() => yourCustomOnPressIfNeeded}
    dataTabs={yourTabNamesList}
    dataSections={yourDataSectionList}
    renderSection={(item) => yourCustomSectionItemRender} 
    renderTabName={(item) => yourCustomSectionTabName}
    selectedTabStyle={{
        ...your custom styles when a Tab is scrolled to or tapped
    }}
    unselectedTabStyle={{
        ...your custom styles when a Tab is normal
    }}
/>

Component Detail

This component currently support tab list for horizontal side and vertical section list. Both of which are Flatlist

| Property | Type | Required | Default | Description | | -------- | ---- | -------- | ------- | ----------- | | dataTabs | Array | Yes | [] | A tab list to represent | | dataSections | Array | Yes | [] | A Section list to represent | | isParent | Boolean | No | false | Switch to true if you want to support more sections following by a parent tab, see detail here | | headerTransitionWhenScroll | Boolean | No | true | Animation at tab header when section scrolling | | tabPosition | String | No | top | Tab list position arrangement, top and bottom | | renderSectionItem | Func | Yes | | Function to render Section Item | | renderTabNameItem | Func | Yes | | Function to render Tab Item, equal to renderItem in Flatlist | | customTabNamesProps | Object | No | | Flatlist Props, avoid props like renderItem, data, ref, onScroll as may result some issues | | customSectionProps | Object | No | | ScrollView Props | | onPressTab | Func | No | | Custom function when pressing on a tab | | onScrollSection | Func | No | | Custom function when section scrolling | | selectedTabStyle | Object | No | { borderBottomColor: 'black', borderBottomWidth: 1, } | Custom style when a tab is selected | | unselectedTabStyle | Object | No | { backgroundColor: 'white', alignItems: 'center', justifyContent: 'center', } | Custom style when a tab is unselected |

Example

Scrollable tab

Display a basic scrollable tab

Note: Length of `dataTabs` and `dataSections` must equal, otherwise may result in incorrect scrolling order
   const tabNames = [{
    title: 'Tab 1',
},
...................
{
    title: 'Tab 6',
}];

const dataSections = [
    {
        name: 'Section 1',
        data: [..........]
    },
    ...............
    {
        name: 'Section 6',
        data: [..........]

    },
];

render () {
    return (
        <ScrollableTabString
            dataTabs={tabNames}
            dataSections={dataSections}
            renderSection={(item) => (
                <View>
                    <Text>{item.name}</Text>
                    {
                        item.data.map((i) => (
                            <Text key={i.id} style={{ padding: 20 }}>{i.name}</Text>
                        ))
                    }
                </View>
            )}
            renderTabName={(item) => (
                <TouchableOpacity>
                    <Text style={{ padding: 10 }}>
                        {item.title}
                    </Text>
                </TouchableOpacity>
            )}
            selectedTabStyle={{
                borderColor: Colors.brown_grey,
                borderRadius: 10,
                borderWidth: 1,
                margin: 10
            }}
            unselectedTabStyle={{
                backgroundColor: Colors.white,
                alignItems: 'center',
                justifyContent: 'center',
            }}
        />
    )
};

Scrollable tab with parent tab

Scrollable tab with parent tab and children section follow

Use this if you want to support more sections following on a tab.

Add index key to parent tab and sections (start from 0). For example Tab 1 has 2 children section follow. They are Section 1 and Section 2 -> index of Tab 1, Section 1 and 2 are 0

Note: Index of both parent and children section must equivalent and those sections must be adjacent.
const tabNames = [{
    title: 'Tab 1',
    index: 0
}
.....
, {
    title: 'Tab 6',
    index: 5
}];

const dataSections = [
    {
        name: 'Section 1',
        index: 0,
        data: [..........]
    },
    {
        name: 'Section 2',
        index: 0,
        data: [..........]
    },
    {
        name: 'Section 3',
        index: 1,
        data: [..........]
    },
    {
        name: 'Section 4',
        index: 1,
        data: [..........]
    },
    {
        name: 'Section 5',
        index: 2,
        data: [..........]
    },
    {
        name: 'Section 6',
        index: 2,
        data: [..........]
    },
    {
        name: 'Section 7',
        index: 3,
        data: [..........]
    },
    {
        name: 'Section 8',
        index: 4,
        data: [..........]
    },
];

const ScrollableTabStringDemo = () => (
    <ScrollableTabString
        isParent //remember to add this
        dataTabs={tabNames}
        dataSections={dataSections}
        renderSection={(item) => (
            <View>
                <Text>{item.name}</Text>
                {
                    item.data.map((i) => (
                        <Text key={i.id} style={{ padding: 20 }}>{i.name}</Text>
                    ))
                }
            </View>
        )}
        renderTabName={(item) => (
            <TouchableOpacity>
                <Text style={{ padding: 10 }}>
                    {item.title}
                </Text>
            </TouchableOpacity>
        )}
        selectedTabStyle={{
            borderColor: Colors.brown_grey,
            borderRadius: 10,
            borderWidth: 1,
            margin: 10
        }}
        unselectedTabStyle={{
            backgroundColor: Colors.white,
            alignItems: 'center',
            justifyContent: 'center',
        }}
    />
);

Limitation

This component allows you to customize some Flatlist props on Tab Name and ScrollView props as well. However, you should avoid some of properties like onScroll, renderItem, CellRendererComponent, horizontal as may result some issues.

Furthermore, this component doesn't support on load more yet due to heavily calculated, still working on this :p

Contributing

All contributions are welcome! Please open an issue if you get stuck and bugs, or a PR if you have any feature idea, improvements and bug fixing. I'm very appreciate !

License

MIT