npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expo-header

v1.0.0

Published

A full functional Header for React Native

Downloads

122

Readme

AppHeader Component for React Native

The AppHeader component is a customizable and animated header component designed for React Native applications. It supports dynamic titles, interactive buttons, and integrations with React Navigation.

Features

  • Customizable left and right components/icons.
  • Dynamic header title based on the current route or a custom title.
  • Animated button press effects using react-native-reanimated.
  • Integrates seamlessly with React Navigation's Drawer and other navigators.
  • Flexible styling options for the header and its elements.

Installation

To use the AppHeader component in your project, ensure you have the following dependencies installed:

npm i expo-header

Please ensure that those packages are installed.

react-navigation @react-navigation/native react-native-reanimated

AppHeader Component

Usage

Here's an example of how to use the AppHeader component in your project:

import React from "react";
import { View, Text } from "react-native";
import AppHeader from "expo-header";

const ExampleScreen = () => {
  return (
    <View style={{ flex: 1 }}>
      <AppHeader
        headerTitle="Home"
        onLeftPress={() => console.log("Left button pressed!")}
        onRightPress={() => console.log("Right button pressed!")}
        leftIcon="menu"
        rightIcon="notifications"
      />
      <Text style={{ flex: 1, textAlign: "center", marginTop: 20 }}>
        Welcome to the example screen!
      </Text>
    </View>
  );
};

export default ExampleScreen;

Props

AppHeader

| Prop Name | Type | Default Value | Description | | ------------------- | ----------------- | ----------------- | --------------------------------------------------------------------- | | headerTitle | string | Current route | Title of the header. If not provided, the current route name is used. | | onLeftPress | () => void | Opens drawer | Function to execute when the left button is pressed. | | onRightPress | () => void | Alerts a message | Function to execute when the right button is pressed. | | leftIcon | string | "menu" | Icon name for the left button. | | rightIcon | string | undefined | Icon name for the right button. | | leftIconFamily | string | "MaterialIcons" | Icon family for the left button. | | rightIconFamily | string | "MaterialIcons" | Icon family for the right button. | | leftIconSize | number | 28 | Size of the left button icon. | | rightIconSize | number | 28 | Size of the right button icon. | | leftIconColor | string | "#007AFF" | Color of the left button icon. | | rightIconColor | string | "#007AFF" | Color of the right button icon. | | LeftComponent | React.Component | undefined | Custom component for the left side. Overrides leftIcon props. | | RightComponent | React.Component | undefined | Custom component for the right side. Overrides rightIcon props. | | headerStyle | ViewStyle | {} | Style for the header container. | | leftPressDisable | boolean | false | Disables the left button interaction. | | rightPressDisable | boolean | false | Disables the right button interaction. |

Customization

You can override any default styles by providing your own styles through the headerStyle, leftIconStyle, rightIconStyle, or titleStyle props.

Example:

<AppHeader
  headerTitle="Profile"
  headerStyle={{ backgroundColor: "#f8f8f8", elevation: 5 }}
  titleStyle={{ color: "#333", fontWeight: "bold" }}
/>

Animations

The AppHeader uses react-native-reanimated to provide smooth press animations for its buttons. Customize these animations in the AnimatedTouchable component if needed.

License

This package is open-sourced under the MIT License. Feel free to use and modify it as per your needs.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to enhance the functionality of this package.

Acknowledgements

  • Built with ❤️ and react-native-reanimated.
  • Icon rendering powered by the react-native-vector-icons package.