react-navigation-collapsible

React Navigation Extension for Collapsible Header. Make your header of react-navigation collapsible.

  • 所有者: benevbright/react-navigation-collapsible
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

react-navigation-collapsible

npm npm code style: prettier ci: github runs with expo

An extension of react-navigation that makes your header collapsible.

Try out on Expo Snack

Compatibility ?, react-navigation, react-navigation-collapsible, Documentation, ------------------, ------------------------------, ------------------------------------------------------------------------------------, ^5.0.0 (next), ^5.0.0 (latest), current, ^4.0.0 (latest), ^3.0.0, v3-4 branch, ^2.0.0, ^2.0.0, v2 branch, ? The Callapsible Tab-navigator is no longer supported due to the Android bug from react-native.

Usage

1. Default Header

import { createCollapsibleStack } from 'react-navigation-collapsible';

function App() {
  return (
    <NavigationNativeContainer>
      <Stack.Navigator>
        /* Wrap your Stack.Screen */
        {createCollapsibleStack(
          <Stack.Screen
            name="HomeScreen"
            component={MyScreen}
            options={{
              headerStyle: { backgroundColor: 'green' },
              title: 'Home',
            }}
          />,
          {
            collapsedColor: 'red' /* Optional */,
          }
        )}
      </Stack.Navigator>
    </NavigationNativeContainer>
  );
}
import { Animated } from 'react-native';
import { useCollapsibleStack } from 'react-navigation-collapsible';

const MyScreen = ({ navigation, route }) => {
  const {
    onScroll /* Event handler */,
    containerPaddingTop /* number */,
    scrollIndicatorInsetTop /* number */,
    /* Animated.AnimatedInterpolation by scrolling */
    translateY /* 0.0 ~ -headerHeight */,
    progress /* 0.0 ~ 1.0 */,
    opacity /* 1.0 ~ 0.0 */,
  } = useCollapsibleStack();

  return (
    <Animated.FlatList
      onScroll={onScroll}
      contentContainerStyle={{ paddingTop: containerPaddingTop }}
      scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }}
      /* rest of your stuff */
    />
  );
};

See /example/App.tsx and /example/src/DefaultHeaderScreen.tsx

import { createCollapsibleStackSub } from 'react-navigation-collapsible';
/* use 'createCollapsibleStackSub' instead of 'createCollapsibleStack' */

/* The rest are the same with the default header. */
import { Animated } from 'react-native';
import {
  useCollapsibleStack,
  CollapsibleStackSub,
} from 'react-navigation-collapsible';

const MySearchBar = () => (
  <View style={{ padding: 15, width: '100%', height: 60 }}>
    <TextInput placeholder="search here" />
  </View>
);

const MyScreen = ({ navigation, route }) => {
  const {
    onScroll /* Event handler */,
    containerPaddingTop /* number */,
    scrollIndicatorInsetTop /* number */,
  } = useCollapsibleStack();

  return (
    <>
      <Animated.FlatList
        onScroll={onScroll}
        contentContainerStyle={{ paddingTop: containerPaddingTop }}
        scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }}
        /* rest of your stuff */
      />
      /* Wrap your component with `CollapsibleStackSub` */
      <CollapsibleStackSub>
        <MySearchBar />
      </CollapsibleStackSub>
    </>
  );
};

See /example/App.tsx and /example/src/SubHeaderScreen.tsx

Install

# install module
yarn add react-navigation-collapsible

Contribution

PR is welcome!

Testing your library code with the example

/example imports the library directly from the root folder, configured with babel-plugin-module-resolver.
So, just turn the watch option on at the root folder while you're making changes on the library, and check them on the example.

yarn tsc -w

主要指標

概覽
名稱與所有者benevbright/react-navigation-collapsible
主編程語言TypeScript
編程語言Java (語言數: 8)
平台
許可證MIT License
所有者活动
創建於2018-08-02 21:51:28
推送於2021-11-07 09:09:32
最后一次提交
發布數42
最新版本名稱v6.3.0 (發布於 2021-11-07 09:09:30)
第一版名稱2.0.0 (發布於 2018-11-20 00:53:56)
用户参与
星數1.2k
關注者數12
派生數94
提交數268
已啟用問題?
問題數109
打開的問題數13
拉請求數52
打開的拉請求數3
關閉的拉請求數42
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?