Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kwaak/react-native-android-blurryoverlay
A react native android package to show a blurry overlay.
https://github.com/kwaak/react-native-android-blurryoverlay
Last synced: 6 days ago
JSON representation
A react native android package to show a blurry overlay.
- Host: GitHub
- URL: https://github.com/kwaak/react-native-android-blurryoverlay
- Owner: kwaak
- License: mit
- Created: 2015-11-26T22:40:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-24T14:43:15.000Z (almost 9 years ago)
- Last Synced: 2024-11-17T07:22:14.158Z (26 days ago)
- Language: Java
- Size: 2 MB
- Stars: 75
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-android-blurryoverlay ★75 - A react native android package to show a blurry overlay. (Components / UI)
- awesome-reactnative-ui - react-native-android-blurryoverlay - native-android-blurryoverlay/master/Example/Example.gif?raw=true "Example")| (Others)
- awesome-react-native - react-native-android-blurryoverlay ★75 - A react native android package to show a blurry overlay. (Components / UI)
- awesome-reactnative-ui - react-native-android-blurryoverlay - native-android-blurryoverlay/master/Example/Example.gif?raw=true "Example")| (Others)
- awesome-react-native - react-native-android-blurryoverlay ★75 - A react native android package to show a blurry overlay. (Components / UI)
- awesome-react-native-ui - react-native-android-blurryoverlay ★48 - A react native android package to show a blurry overlay. (Components / UI)
- awesome-react-native - react-native-android-blurryoverlay ★75 - A react native android package to show a blurry overlay. (Components / UI)
README
# Blurry overlay for react-native android
[![npm](https://img.shields.io/npm/v/react-native-android-blurryoverlay.svg)](https://www.npmjs.com/package/react-native-android-blurryoverlay)
# This is very experimental
A react native android module to add a blurry overlay.
![Example](Example/Example.gif?raw=true "Example")
## Setup
* install module
```bash
npm i --save react-native-android-blurryoverlay
```* `android/settings.gradle`
```gradle
...
include ':react-native-android-blurryoverlay'
project(':react-native-android-blurryoverlay').projectDir = new File(settingsDir, '../node_modules/react-native-android-blurryoverlay')
```* `android/app/build.gradle`
```gradle
...
android {
...
defaultConfig {
...
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
...
}
...
dependencies {
...
compile project(':react-native-android-blurryoverlay')
}
```* register module (in MainActivity.java)
```java
import com.kwaak.react.BlurryOverlayPackage; // <--- importpublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......
private static Activity mActivity = null;@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);mActivity = this;
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new BlurryOverlayPackage(this)) // <------- add package, the 'this' is super important
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
setContentView(mReactRootView);
}......
}
```## Usage
The Android root view will be 'screenshotted' and rendered blurry in the view.
```js
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
Image
} from 'react-native';var BlurryOverlay = require('react-native-android-blurryoverlay');
class BlurryTest extends Component {
constructor() {
super();
this.state = {
renderBlurry: false
}
}
componentDidMount() {
setTimeout(() => {
this.setState({ renderBlurry: true })
});
}
render() {
var overlay = (this.state.renderBlurry) ? : ;
return (
Welcome to React Native!
To get started, edit index.android.js
Shake or press menu button for dev menu
{overlay}
);
}
}const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});AppRegistry.registerComponent('BlurryTest', () => BlurryTest);
```