react-native-navigation-bar-color-fix-behavior-status-bar
Version:
React Native component to change bottom bar/navigation bar color on Android
209 lines (160 loc) • 6.37 kB
Markdown
//app.fossa.io/api/projects/git%2Bgithub.com%2Fthebylito%2Freact-native-navigation-bar-color.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fthebylito%2Freact-native-navigation-bar-color?ref=badge_shield)
Original component is [react-native-navigation-bar-color](https://github.com/thebylito/react-native-navigation-bar-color).
React Native Navigation Bar Color Change is a [React Native](http://facebook.github.io/react-native/) library for change color of navigation/Bottom bar on Android.
<div>
<img src="https://github.com/s-mikulich/react-native-navigation-bar-color-fix-behavior-status-bar/raw/master/screenshots/screenShot1.jpg" height="600">
<img src="https://github.com/s-mikulich/react-native-navigation-bar-color-fix-behavior-status-bar/raw/master/screenshots/screenShot2.jpg" height="600">
<img src="https://github.com/s-mikulich/react-native-navigation-bar-color-fix-behavior-status-bar/raw/master/screenshots/screenShot3.jpg" height="600">
<img src="https://user-images.s-mikulich.com/29806253/46919604-96247c00-cfaf-11e8-996a-81330dad6562.png" height="600">
</div>
- [Installation](
- [Example](
- [API](
- [License](
<a href="https://www.buymeacoffee.com/thebylito"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" target="_blank"></a>
<details>
<summary>react-native >= 0.60.0</summary>
`$ yarn add react-native-navigation-bar-color-fix-behavior-status-bar`
or
`$ npm install react-native-navigation-bar-color-fix-behavior-status-bar --save`
</details>
<details>
<summary>react-native <= 0.59.0</summary>
`$ yarn add react-native-navigation-bar-color-fix-behavior-status-bar`
or
`$ npm install react-native-navigation-bar-color-fix-behavior-status-bar --save`
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add `import com.thebylito.navigationbarcolor.NavigationBarColorPackage;` to the imports at the top of the file
- Add `new NavigationBarColorPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-navigation-bar-color-fix-behavior-status-bar'
project(':react-native-navigation-bar-color-fix-behavior-status-bar').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation-bar-color-fix-behavior-status-bar/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
implementation project(':react-native-navigation-bar-color-fix-behavior-status-bar')
```
</details>
## Example
<details>
<summary>**Android Implementation**</summary>
```javascript
import React from 'react';
import {View, Text, Button} from 'react-native';
import changeNavigationBarColor, {
hideNavigationBar,
showNavigationBar,
} from 'react-native-navigation-bar-color-fix-behavior-status-bar';
export default function App() {
const setNavigationColor = color => {
changeNavigationBarColor(color);
};
const hideNavigation = () => {
hideNavigationBar();
};
const showNavigation = () => {
showNavigationBar();
};
const testSetTranslucent = () => {
changeNavigationBarColor('translucent', false);
};
const testSetTransparent = () => {
changeNavigationBarColor('transparent', true);
};
return (
<View
style={{
flex: 1,
justifyContent: 'space-around',
alignContent: 'center',
alignItems: 'center',
backgroundColor: 'cyan',
}}>
<Button title="Set transparent" onPress={testSetTransparent} />
<Button title="Set translucent" onPress={testSetTranslucent} />
<Button
title="Set color red"
onPress={() => {
setNavigationColor('red');
}}
/>
<Button
title="Set color blue"
onPress={() => {
setNavigationColor('blue');
}}
/>
<Button
title="Set color ligth"
onPress={() => {
changeNavigationBarColor('#ffffff', true);
}}
/>
<Button title="Hide bar" onPress={hideNavigation} />
<Button title="Show bar" onPress={showNavigation} />
<Text>Hello Word!</Text>
</View>
);
}
```
</details>
Change color of Navigation/Bottom bar.
color can be a "translucent" | "transparent" | HEX color, or name.
ex: green, blue,
Light is true? icons will be dark.
- Returns a `Promise`
```javascript
example = async () => {
try{
const response = await changeNavigationBarColor('#80b3ff');
console.log(response)// {success: true}
}catch(e){
console.log(e)// {success: false}
}
};
```
```javascript
example = async () => {
try{
const response = await changeNavigationBarColor('#80b3ff', true);
console.log(response)// {success: true}
}catch(e){
console.log(e)// {success: false}
}
};
```
Hide Navigation Bar
```javascript
import { hideNavigationBar } from 'react-native-navigation-bar-color-fix-behavior-status-bar';
...
hide = () => {
hideNavigationBar();
};
```
Show Navigation Bar
```javascript
import { showNavigationBar } from 'react-native-navigation-bar-color-fix-behavior-status-bar';
...
show = () => {
showNavigationBar();
};
```
MIT
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fthebylito%2Freact-native-navigation-bar-color?ref=badge_large)
[![FOSSA Status](https: