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-segmented-pager

v0.1.18

Published

Pure React Native segmented pager component

Downloads

57

Readme

React Native Segmented Pager

npm GitHub license

Pure React Native cross-platform segmented pager component

Requirements

  • React version >= 16.3.0
  • React Native - any version with Animated lib supported (but tested with >= 0.55.4 only)
  • Babel preset - react-native

Features

  • Tabs scrolling independently
  • Header height animated
  • No extra libs or components, just segmented pager component
  • Easy to implement parallax for the header and tab bar with underline animated (see Demo)

Demo

Please see example folder

Installation

npm install react-native-segmented-pager --save

or

yarn add react-native-segmented-pager

Example

Please see example folder for full code

import React, { PureComponent } from 'react';

import ReactNativeSegmentedPager from 'react-native-segmented-pager';

export default class ReactNativeSegmentedPagerDemo extends PureComponent {
  constructor(props, context) {
    super(props, context);

    this.renderHeader = this.renderHeader.bind(this);

    this.state = {
      currentPage: 0,
      pages: getPages(),
    };
  }

  render() {
    const { currentPage, pages, } = this.state;

    return (
      <ReactNativeSegmentedPager
        currentPage={currentPage}
        header={this.renderHeader}
        headerMaxHeight={150}
        headerMinHeight={70}
        headerStyle={styles.header}
        onCurrentPageChange={(pageIndex) => {
          this.setState(() => ({
            currentPage: pageIndex,
          }));
        }}
        pages={pages}
        style={styles.segmented}
      />
    );
  }

  renderHeader(state, props) {
    return (
      ...
    );
  }
}


function getPages() {
  return [{
    content: (
      ...
    ),
    title: 'PAGE 1',
  }, {
    content: (
      ...
    ),
    title: 'PAGE 2',
  }, {
    content: (
      ...
    ),
    title: 'PAGE 3',
  }];
}

Props

  • currentPage - index of the currently visible page (number, default is 0)
  • header - header to render at the top of the component (element, array of elements or a function)
  • headerMaxHeight - max possible height of the header (number, auto-calculated if not set)
  • headerMinHeight - min possible height of the header (number, default is 0)
  • headerStyle - custom style for the header (style object)
  • horScrollProps - ScrollView props for horizontal ScrollView component
  • onCurrentPageChange - a callback function called when current page changes (takes index of the new visible page as an argument)
  • style - custom style for the component
  • pages - array of objects of the following view:
{
  content: ...,
  scrollViewProps: ...,
  title: ...,
}

Here

  • content - a React Native element
  • scrollViewProps - ScrollView props for vertical ScrollView component of the page

Header as a render prop

If header prop is a function it takes two arguments:

  • state - state of the ReactNativeSegmentedPager (to access it's Animated vars)
  • props - props of the ReactNativeSegmentedPager

Please see example folder for an example