1.0.2 • Published 7 months ago

react-native-navigation-bar-customizer v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

React Native Navigation Bar Customizer

A React Native module for Android that allows you to customize and interact with the navigation bar. Features include setting the color, theme, visibility, button state, retrieving properties, and synchronizing with the status bar.

Installation

To install the package, use one of the following commands:

npm install react-native-navigation-bar-customizer

Features

Available Methods

import NavigationBar from 'react-native-navigation-bar-customizer';

// Changes the navigation bar's color.
NavigationBar.setColor('#FF5733');

//Sets the theme of the navigation bar to either light or dark.
NavigationBar.setBarTheme('dark');

// Shows or hides the navigation bar.
NavigationBar.setVisible(false);

// Enables or disables the navigation bar buttons.
NavigationBar.setButtonEnabled(false);

// Retrieves the current color of the navigation bar as a hex string.
NavigationBar.getColor().then((color) => console.log(color));

// Retrieves the height of the navigation bar in pixels.
NavigationBar.getHeight().then((height) => console.log(height));

// Animates the navigation bar color over the specified duration (in milliseconds).
NavigationBar.setColorWithAnimation("#00FF00", 1000);

// Synchronizes the navigation bar's color with the status bar.
NavigationBar.syncWithStatusBar();

// Sets the navigation bar's color and theme in one call.
NavigationBar.setColorAndTheme("#123456", "light");

Example Usage

Here’s a full example of how to use the module:

import React from "react";
import { View, Button } from "react-native";
import NavigationBar from "react-native-navigation-bar-customizer";

const App = () => {
  const changeColor = () => NavigationBar.setColor("#FF0000");
  const toggleTheme = () => NavigationBar.setBarTheme("dark");
  const toggleVisibility = () => NavigationBar.setVisible(false);
  const disableButtons = () => NavigationBar.setButtonEnabled(false);
  const syncWithStatusBar = () => NavigationBar.syncWithStatusBar();
  const getNavigationBarColor = async () => {
    const color = await NavigationBar.getColor();
    console.log("Current Color:", color);
  };
  const getNavigationBarHeight = async () => {
    const height = await NavigationBar.getHeight();
    console.log("Navigation Bar Height:", height);
  };

  return (
    <View>
      <Button title="Change Color" onPress={changeColor} />
      <Button title="Set Dark Theme" onPress={toggleTheme} />
      <Button title="Hide Navigation Bar" onPress={toggleVisibility} />
      <Button title="Disable Buttons" onPress={disableButtons} />
      <Button title="Sync with Status Bar" onPress={syncWithStatusBar} />
      <Button title="Get Color" onPress={getNavigationBarColor} />
      <Button title="Get Height" onPress={getNavigationBarHeight} />
    </View>
  );
};
export default App;