react-native-scrollable-navigation-bar

repository·master·Indexed 42 days ago

https://github.com/zobeirhamid/react-native-scrollable-navigation-bar

A React Native library for creating highly customizable, high-performance (60 FPS) scrollable navigation bars using the built-in Animated API. Version 3.0.6 provides components like Container, AppleStyle, NavigationBar, and Appearer to implement collapsible and sticky navigation behaviors across all platforms.

Tokens
15.4K
Snippets
52
Records
71
Agent score
54%

What's inside react-native-scrollable-navigation-bar

  1. Features of React Native Scrollable Navigation Bar

    master

    The library offers the following key features:

    • 60 FPS scroll animations: Smooth performance during navigation interactions.
    • Cross-platform support: Works on all supported React Native platforms.
    • Zero extra dependencies: Uses the built-in react-native Animated API.
    • Fully customizable: Allows for deep styling and behavior adjustments.
  2. Use the General Method to add animations to existing UI

    master

    The General Method is intended for scenarios where you have already designed your UI elements and simply want to integrate the scrollable navigation animations. This is achieved by using the Container component and providing your existing UI components as props to the Container API.

    To use this method, you must pass your custom components for the following roles to the Container:

    • NavigationBarComponent: Your custom navigation bar.
    • HeaderNavigationBarComponent: The navigation bar used in the header state.
    • HeaderForegroundComponent: The foreground element of the header.
    • HeaderBackgroundComponent: The background element of the header.
    • BorderComponent: Your custom border component.
    • HeaderBorderComponent: Your custom header border component.
    import {
      Container,
      NavigationBar,
      HeaderTitle,
      StatusBar,
    } from 'react-native-scrollable-navigation-bar';
    
    // ... inside your component
    <Container
      headerHeight={300}
      NavigationBarComponent={NavigationBarComponent}
      HeaderNavigationBarComponent={HeaderNavigationBarComponent}
      HeaderForegroundComponent={HeaderForegroundComponent}
      HeaderBackgroundComponent={HeaderBackgroundComponent}
      BorderComponent={BorderComponent}
      HeaderBorderComponent={HeaderBorderComponent}
    >
      {/* Your scrollable content goes here */}
      <Placeholder />
      <Placeholder />
    </Container>
  3. Get started with React Native Scrollable Navigation Bar

    master

    To begin using react-native-scrollable-navigation-bar, you can access the full documentation at the official website. The library provides high-performance (60 FPS) scroll animations and is designed to work across all platforms using the standard react-native Animated API, meaning no additional heavy dependencies are required.

    https://zobeirhamid.github.io/react-native-scrollable-navigation-bar
  4. Import components and hooks from react-native-scrollable-navigation-bar

    master

    You can import the available components, styles, constants, and hooks from the package root. The package exports a variety of tools for building scrollable navigation interfaces, including layout components like Container and NavigationBar, as well as animation hooks like useAnimatedValue.

    import {
      Container,
      NavigationBar,
      HeaderTitle,
      Border,
      StatusBar,
      AppleStyle,
      constants,
      useAnimatedValue,
      useHasReachedTransitionPoint,
      useMeasurements,
      Transitioner,
      Appearer,
    } from 'react-native-scrollable-navigation-bar';
  5. Implement an Image Background in AppleStyle

    master

    To use an image or custom component as a header background, provide a component to the HeaderBackgroundComponent prop of AppleStyle.

    Crucial Requirement: You must set headerBackgroundColor to 'transparent' to ensure the background component is visible.

    import { AppleStyle } from 'react-native-scrollable-navigation-bar';
    
    function HeaderBackgroundComponent(props) {
      return (
        <Image
          source={{ uri: 'YOUR_IMAGE_URI' }}
          style={{ width: 300, height: 300 }}
        />
      );
    }
    
    // Inside your render function:
    <AppleStyle
      headerHeight={300}
      title={'Hello World'}
      HeaderBackgroundComponent={HeaderBackgroundComponent}
      headerBackgroundColor={'transparent'}
      headerTitleColor={'white'}
    >
      {/* Your scrollable content here */}
    </AppleStyle>