8000 GitHub - csuermann/react-native-collapsible-header: A collapsible header/navbar component for React Native.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

csuermann/react-native-collapsible-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-collapsible-header

Can also be utilized to create a parallax scrolling effect.

Inspiration. (also this Snack)

Installation

yarn add react-native-collapsible-header

Definition

type collapsible = {
  backgroundColor?: string,
  bounce?: boolean,         // default = true
  max?: number,             // default = 44
  min?: boolean,            // default = true
  renderContent: any        // <Component />
  renderHeader: any,        // <Component />
                            // ScrollView props can be passed
 };

Example

import React, { Component } from 'react';
import { Platform, StatusBar, Text, View } from 'react-native';

import Collapsible from 'react-native-collapsible-header';

const Header = () => (
  <View
    style={{
      alignItems: 'center',
      flex: 1,
      justifyContent: 'center'
    }}>
    <Text style={{ color: '#fff' }}>
      Header
    </Text>
  </View>
);

const Content = ({ gray }) => (
  <View
    style={{
      alignItems: 'center',
      backgroundColor: gray ? '#f7f7f7' : null,
      justifyContent: 'center'
    }}>
    <Text style={{ color: '#444', padding: 40 }}>Content</Text>
  </View>
);

export default class Example extends Component {
  componentWillMount() {
    StatusBar.setBarStyle('light-content', true);

    if (Platform.OS === 'android')
      StatusBar.setBackgroundColor('#0f9d58', true);
  }

  render() {
    return (
      <Collapsible
        backgroundColor="#0f9d58"
        renderHeader={<Header />}
        renderContent={
          <View>
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
          </View>
        }
      />
    );
  }
}

About

A collapsible header/navbar component for React Native.

Resources

Stars

Watchers

Forks

Packages

No packages published
0