Based on pure JS scripts, without relying on native, no need for react-native link, Title / Header / Tabs / Sticky / Screen components can be flexibly configured, among which Tabs / Sticky can slide When it reaches the top, it will be topped.

Overview

react-native-scrollable-tabview

NPM Version

English | 简体中文

Based on pure JS scripts, without relying on native, no need for react-native link,Title / Header / Tabs / Sticky / Screen components can be flexibly configured, among which Tabs / Sticky can slide When it reaches the top, it will be topped; what we support is to independently manage its own Sticky / Screen / Badge / tabLabel configuration in the form of a stack, and inject the Screen lifecycle onRefresh / onEndReached They will be triggered when the pull-down refresh and the scroll bar hit the bottom, and finally inject more into Screen / Sticky props

Table of Contents

Features

  • Support to individually set pull-down refresh and up-slide load for each screen (life cycle injection form)
  • Flex Tabs and multiple Tabs horizontal scrolling support configuration method
  • Allow to set up each Screen’s own Sticky component
  • Custom badges can be configured for each Tab
  • Support pull down to refresh and slide up to load more pre-functions onBeforeRefresh / onBeforeEndReached
  • Support animation title, can support animation as interpolate.opacity and interpolate.height

Installation

npm i @itenl/react-native-scrollable-tabview

or

yarn add @itenl/react-native-scrollable-tabview

Usage

import React from 'react';
import ScrollableTabView from '@itenl/react-native-scrollable-tabview';

function App() {
  return (
      <ScrollableTabView
        ref={rf => (this.scrollableTabView = rf)}
        mappingProps={{
          fromRootEst: this.state.est,
        }}
        badges={[
          null,
          [
            <View
              style={{
                position: 'absolute',
                zIndex: 100,
                top: 10,
                right: 0,
              }}
            >
              <Text>new</Text>
            </View>,
            <View
              style={{
                position: 'absolute',
                width: 150,
                height: 50,
                zIndex: 100,
                marginTop: 35,
                right: 0,
                opacity: 0.6,
                backgroundColor: 'pink',
                justifyContent: 'center',
                alignItems: 'center',
              }}
            >
              <Text>Three Tips</Text>
            </View>,
          ],
        ]}
        stacks={[
          {
            screen: One,
            sticky: Sticky,
            tabLabel: 'OneTab',
            tabLabelRender: tabLabel => {
              return `--- ${tabLabel} ---`;
            },
            badge: [<Text>one</Text>, <Text>two</Text>],
            toProps: {
              xx: 123,
            },
          },
        ]}
        tabsStyle={{}}
        tabWrapStyle={{}}
        tabInnerStyle={{}}
        tabActiveOpacity={0.6}
        tabStyle={{}}
        textStyle={{}}
        textActiveStyle={{}}
        tabUnderlineStyle={{}}
        firstIndex={0}
        syncToSticky={true}
        onEndReachedThreshold={0.1}
        onBeforeRefresh={(next, toggled) => {
          toggled();
          next();
        }}
        onBeforeEndReached={next => {
          next();
        }}
        onTabviewChanged={index => {
          alert(index);
        }}
        header={() => {
          return <View style={{ backgroundColor: 'pink', height: 120 }}></View>;
        }}
        oneTabHidden={true}
        enableCachePage={true}
        carouselProps={{}}
        sectionListProps={{}}
        toHeaderOnTab={true}
        toTabsOnTab={true}
        tabsShown={false}
        fixedTabs={false}
        fixedHeader={false}
        useScroll={false}
        fillScreen={true}
      ></ScrollableTabView>
  );
}

Props

All props are optional

Prop Type Default Description
stacks Array [] Page Stack < Read Stack Property >
mappingProps Object {} Associate mapping data to Stack / Sticky
badges Array [] Badges for each Tab < Read Badge Property >
tabsStyle Object {} The entire Tabs style
tabWrapStyle Object / Function {} Single Tab wrap style (The function parameters provide item, index, and need to return the style object, eg. return index == 1 && {zIndex: 10})
tabInnerStyle Object {} Single Tab inner style
tabActiveOpacity Number 0.6 Transparency after Tab button click
tabStyle Object {} Single Tab style
textStyle Object {} Text style in Tab
textActiveStyle Object {} Select the active text style
tabUnderlineStyle Object {} Select the active underline style
firstIndex Number / Null null Set the stack of firstIndex to active (make sure that the number of stacks is greater than to firstIndex when setting the firstIndex value)
syncToSticky Boolean true Whether it is synchronized (render triggered in the Screen componentDidUpdate will update Sticky)
onEndReachedThreshold Number 0.2 Bottom callback threshold
onBeforeRefresh Function null Pull down to refresh the pre-functions, execute next to execute onRefresh function in Screen, execute toggled to switch system loading, you can pass true / false to specify (callback contains next, toggled two formal parameters)
onBeforeEndReached Function null Slide up to load more pre-functions, execute next will execute the onEndReached function in the Screen (callback contains next formal parameters)
onTabviewChanged Function null Tab switch completion callback (callback contains index, tabLabel two formal parameters)
screenScrollThrottle Number 60 Screen Throttle parameters during lateral sliding, Unit (ms)
header Function / JSX Element / Class Component null Top component (if the function needs to return Element)
oneTabHidden Boolean false Hide itself when there is only one Tab
enableCachePage Boolean true Whether the persistent page will not be destroyed after switching
carouselProps Object {} The remaining attributes passed to Carousel < Read Carousel >
sectionListProps Object {} Remaining attributes passed to SectionList < Read SectionList >
toHeaderOnTab Boolean false Click to trigger the activated Tab will scroll to Header (high priority)
toTabsOnTab Boolean false Click to trigger the activated Tab will scroll to Tabs
tabsShown Boolean true Configure Tabs display and hide
fixedTabs Boolean false When enableCachePage is true, slide to switch Screen to set the minimum height to ensure that the Header and Tabs will not bounce
fixedHeader Boolean false Render together with Tabs, fix the top Header, do not follow the scroll
useScroll Boolean false Does Tabs support horizontal scrolling (it needs to be enabled when there are multiple category Tabs, it is recommended that tabStyle pass in a fixed width)
useScrollStyle Object {} Set contentContainerStyle for scrolling Tabs, usually add margins to the left and right sides paddingLeft paddingHorizontal
fillScreen Boolean true Fill the entire Screen
title Function / JSX Element / Class Component null Animation title
titleArgs Object { style: {}, interpolateOpacity: {}, interpolateHeight: {} } Title parameter configuration < Read interpolate >
onScroll Function null Scroll event monitoring
tabsEnableAnimated Boolean false Enable sliding effect for Tabs, Need to specify width for tabStyle

Method

  <ScrollableTabView
    ref={rf => (this.scrollableTabView = rf)}
  >
  </ScrollableTabView> 
  this.scrollableTabView.getCurrentRef();
  this.scrollableTabView.toTabView(1);
  this.scrollableTabView.scrollTo(0);
  this.scrollableTabView.clearStacks(()=>alert('done'));
Name Type Description
getCurrentRef(index: number.optional) Function Get the instance of the currently active view, you can pass index to get the specified instance
toTabView(index: number.required / label: string.required) Function Jump to the specified Screen
scrollTo(index: number.required) Function Swipe up and down to the specified position (passing in 0 is the default positioning to tabs / passing in a negative number is set to the top)
clearStacks(callback: function.optional) Function Clear the Stacks and related state (Tabs / Badge / Stacks))

Stack Property

Name Type Description
screen Class Component Screen class components
sticky Class Component Sticky component, The context of this type of component will be returned in the instance
tabLabel String Tab display name
tabLabelRender Function Custom Tab rendering function, priority is higher than tabLabel
badge Array For the current Tab badge, it is mutually exclusive with the badges attribute, and has a higher priority than the outermost attribute badges < Read Badge Property >
toProps Object toProps Only pass to Screen without data association

Badge Property

Type Description
JSX Element Badges/Hovering Tips, etc. rendered based on the current Tab

Injection lifecycle to Screen

Name Type Description
onRefresh Function Triggered when pull-down refresh, the formal parameter toggled function is used to switch the display of the native loading state, if the user switches the tab during loading, it will be forced to hide and reset the state
onEndReached Function Swipe up to load more triggers

Injection props to Screen

Name Type Description
refresh() Function Manually trigger refresh and synchronize Screen status to Sticky
scrollTo(index: number.required) Function Swipe up and down to the specified position (passing in 0 is the default positioning to tabs / passing in a negative number is set to the top)
toTabView(index: number.required / label: string.required) Function Jump to the specified Screen
layoutHeight.container Number Total height of the Container
layoutHeight.header Number Total height of the Header
layoutHeight.tabs Number Total height of the Tabs
layoutHeight.screen Number Total height of the Screen

Injection props to Sticky

Name Type Description
screenContext Object Get Screen context

Known Issues

Snapshot



MIT Licensed

Comments
  • Question stacks

    Question stacks

    hi, is possible create stacks statics? without reload or onEndReached?

    Is possible disable this option?

    my stack

    const first = () => {
      return (
        <View style={{flex:1}}>
          <Text>Hola</Text>
          ...
        </View>
      );
    }
    
    opened by AlexCernik 4
  • scrollableTabV.scrollTo is not function

    scrollableTabV.scrollTo is not function

    I use scrollTo for change tab, but error as the message 'TypeError._this3$scrollableTabV.scrollTo is not function.(In "_this3$scrollableTabV.scrollTo(_this3.state.firstIndex)"

    it the package.json for scrollable info:

    "react": "16.11.0",
    "react-native": "^0.62.2",
    "react-native-scrollable-tab-view": "^0.8.0",
    

    image

    opened by daizhenhong 3
  • cannot run in web

    cannot run in web

    cannot run in web, /node_modules/@itenl/react-native-scrollable-tabview/src/index.js 27:19 Module parse failed: Unexpected token (27:19) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. Se

    opened by edward1986 1
  • 即将删除生命周期警告修复

    即将删除生命周期警告修复

    Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details. image

    opened by imshier 1
  • Dev 1.1.3

    Dev 1.1.3

    • feat: Added props tabsEnableAnimatedUnderlineWidth to support bounce tabs
    • feat: Added props onScroll2Horizontal
    • feat: Added isFirst args in callback(onTabviewChanged)
    • oooptimized code
    opened by itenl 0
Releases(v1.1.7)
Owner
Oops, there's nothing in here :-)
null
React Native's Global Alert Component that can be fully customized and without the need of a state.

?? React Native Easy Alert React Native Easy Alert Component. Watch on youtube Easy Alert example app. React Native's Global Alert Component that can

null 9 Feb 21, 2022
A react component available on npm to easily link to your project on github and is made using React, TypeScript and styled-components.

fork-me-corner fork-me-corner is a react component available on npm to easily link to your project on github and is made using React, TypeScript and s

Victor Dantas 9 Jun 30, 2022
A reusable react hook that preserves a components semantic accessibility to create a visual block link.

useAccessibleBlockLink is a reusable react hook that preserves a components semantic accessibility to create a visual block link. This hook supports multiple links within the same block.

Wayfair Tech – Incubator 4 Nov 28, 2022
Hello, world! :) Welcome to this project. This is a free web repository that you can use as a blog for your website. This project is dedicated to "Sina Sattari" as an honorary title.

QURNO News/Technology Web Application Greetings and courtesy to all of you dear colleagues and friends of the DarkDragons team. We came back with anot

DarkDragons Team 12 Sep 8, 2022
This is a starter file with base SvelteKit skeleton configurations with Open Props, Jit Props, and PostCSS configured.

create-svelte Everything you need to build a Svelte project, powered by create-svelte; Creating a project If you're seeing this, you've probably alrea

Brittney Postma 4 Jul 22, 2022
🎉 toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense!

toastify-react-native ?? toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense! De

Zahid Ali 29 Oct 11, 2022
A simple react js onscroll sticky Nav bar library

react-js-stickynav A simple react js nav bar onscroll Intro Install npm install --save react-js-stickynav Usage length = navigation length , which is

Abod Micheal 29 Dec 19, 2022
Web App to store a list of books (Title and Author) made as a single page app.

Awesome Books This project its an interactive list of books, you can add and remove items to the list. Built With HTML JS Getting Started In this proj

Alex Puente 7 Nov 9, 2022
nivo provides a rich set of dataviz components, built on top of the awesome d3 and Reactjs libraries

nivo provides supercharged React components to easily build dataviz apps, it's built on top of d3. Several libraries already exist for React d3 integr

Raphaël Benitte 10.9k Dec 31, 2022
A React utility belt for function components and higher-order components.

A Note from the Author (acdlite, Oct 25 2018): Hi! I created Recompose about three years ago. About a year after that, I joined the React team. Today,

Andrew Clark 14.8k Jan 4, 2023
Nextjs-components: A collection of React components

nextjs-components A collection of React components, transcribed from https://vercel.com/design. 1 Motivation Blog post from 01/09/2022 Todo's Unit tes

null 94 Nov 30, 2022
Common React Native components used by "Roqay" packed in library for usage in future projects.

Roqay Common React Native Components Common React Native components used by Roqay packed in library for usage in future projects. Installation yarn ad

RoQay 3 Feb 10, 2022
A web application to search all the different countries in the world and get details about them which can include languages, currencies, population, domain e.t.c This application is built with CSS, React, Redux-Toolkit and React-Router.

A web application to search all the different countries in the world and get details about them which can include languages, currencies, population, domain e.t.c This application is built with CSS, React, Redux-Toolkit and React-Router. It also includes a theme switcher from light to dark mode.

Franklin Okolie 4 Jun 5, 2022
we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

고스락 6 Aug 12, 2022
This is a minimal Next.js app where you can create birthday wishes and share the link to anyone :)

Happy Birthday Wisher Check out the Live Website This is a simple Next.js project where you can generate a birthday wish for someone. Just enter their

Gourav Khunger 21 Dec 22, 2022
Finished code and notes from EFA bonus class on building a React project without create-react-app

React From Scratch Completed Code This is the completed code for the EFA bonus class on building a React project from scratch. Included are also markd

Conor Broaders 3 Oct 11, 2021
Expo Demo: Screen Capture with Managed Workflow

Expo Demo: Screen Capture with Managed Workflow This code demonstrates how to setup screen capture on an Expo app, without having to eject from the ma

Luis Taniça 12 Dec 30, 2022
Provide solutions to make your app flexible for different screen sizes, different devices.

react-native-size-scaling Provide solutions to make your app flexible for different screen sizes, different devices, based on your device's pixel rati

Hoà Phan 33 Dec 23, 2022
A frontend Framework for building B2B applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Material Design

react-admin A frontend Framework for building data-driven applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Materi

marmelab 21.2k Dec 30, 2022