5.0.0-alpha3 • Published 6 years ago

react-navigation-collapsible v5.0.0-alpha3

Weekly downloads
2,740
License
MIT
Repository
github
Last release
6 years ago

react-navigation-collapsible

npm npm code style: prettier

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

Try out on Expo Snack

Compatibility 🚧

react-navigationreact-navigation-collapsibleDocumentation
^5.0.0 (next)^5.0.0 (next)current
^4.0.0 (latest)^3.0.0 (latest)v3-4 branch
^2.0.0^2.0.0v2 branch

The navigation tab 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

2. Sub Header (e.g Search Bar)

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@next

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
6.3.0

4 years ago

6.3.0-rc0

4 years ago

6.3.0-rc3

4 years ago

6.3.0-rc2

4 years ago

6.3.0-rc1

4 years ago

6.2.0-beta1

4 years ago

6.2.0-beta2

4 years ago

6.2.0

4 years ago

6.2.0-beta0

4 years ago

6.1.0

4 years ago

6.0.0

5 years ago

5.10.2

5 years ago

5.10.1

5 years ago

5.10.0

5 years ago

5.9.1

5 years ago

5.8.1

5 years ago

5.8.0

5 years ago

5.7.5

5 years ago

5.7.4

5 years ago

5.7.3

5 years ago

5.7.2

5 years ago

5.7.1

5 years ago

5.7.0

5 years ago

5.6.4

6 years ago

5.6.3

6 years ago

5.6.2

6 years ago

3.0.4

6 years ago

5.6.1

6 years ago

5.6.0

6 years ago

5.5.0

6 years ago

5.4.0

6 years ago

5.3.0

6 years ago

5.2.0

6 years ago

5.1.0

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

5.0.0-alpha4

6 years ago

5.0.0-alpha3

6 years ago

5.0.0-alpha2

6 years ago

5.0.0-alpha0

6 years ago

5.0.0-alpha1

6 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

3.0.0-beta2

7 years ago

3.0.0-beta1

7 years ago

3.0.0-bera1

7 years ago

2.0.0

7 years ago

3.0.0-alpha1

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.18

7 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

8 years ago

0.2.14

8 years ago

0.2.13

8 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago