Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-native-collapsible-header

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-collapsible-header

A collapsible header component for React Native.

latest
Source
npmnpm
Version
0.0.14
Version published
Maintainers
1
Created
Source

react-native-collapsible-header

npm version

Inspiration. (also this Snack)

Installation

yarn add react-native-collapsible-header

Definition

type collapsible = {
  backgroundColor?: string,
  flatList?: boolean, // default = false
  max?: number, // default = 44
  min?: number, // default = 20 (ios), 24 (android)
  renderContent: any, // <Component />
  renderHeader: any // <Component />
  // ScrollView props can be passed
  // FlatList 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={styles.header}>
    <Text style={styles.headerText}>Header</Text>
  </View>
);

const Content = ({ gray }) => {
  const contentStyle = [
    styles.content,
    { backgroundColor: gray ? '#f7f7f7' : '#fff' }
  ];

  return (
    <View style={contentStyle}>
      <Text style={styles.contentText}>Content</Text>
    </View>
  );
};

const color = '#0f9d58';

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

  render() {
    return (
      <Collapsible
        backgroundColor={color}
        renderHeader={<Header />}
        // renderContent is not needed if using FlatList
        renderContent={
          <View>
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
            <Content />
            <Content gray />
          </View>
        }

        // flatList
        // data={Array(10).fill()}
        // keyExtractor={(item, i) => String(i)}
        // renderItem={({ index }) => <Content gray={index % 2 !== 0} />}
      />
    );
  }
}

const styles = {
  header: { alignItems: 'center', flex: 1, justifyContent: 'center' },
  headerText: { color: '#fff' },
  content: { alignItems: 'center', justifyContent: 'center' },
  contentText: { color: '#444', padding: 40 }
};

FAQs

Package last updated on 17 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts