Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucasferreira/react-native-simpledialog-android
React Native Android module to use Android's AlertDialog - same idea of AlertIOS
https://github.com/lucasferreira/react-native-simpledialog-android
Last synced: 5 days ago
JSON representation
React Native Android module to use Android's AlertDialog - same idea of AlertIOS
- Host: GitHub
- URL: https://github.com/lucasferreira/react-native-simpledialog-android
- Owner: lucasferreira
- Archived: true
- Created: 2015-11-05T16:35:20.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-09T00:47:08.000Z (about 7 years ago)
- Last Synced: 2024-11-09T18:22:48.330Z (about 1 month ago)
- Language: Java
- Size: 17.6 KB
- Stars: 43
- Watchers: 2
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native - react-native-simpledialog-android ★41 - React Native Android module to use Android's AlertDialog - same idea of AlertIOS (Components / UI)
- awesome-reactnative-ui - react-native-simpledialog-android - same idea of AlertIOS|<ul><li>Last updated : 1 year ago</li><li>Stars : 41</li><li>Open issues : 0</li></ul>|![](http://img.shields.io/npm/v/react-native-simpledialog-android.svg?style=flat-square)| (Others)
- awesome-react-native - react-native-simpledialog-android ★41 - React Native Android module to use Android's AlertDialog - same idea of AlertIOS (Components / UI)
- awesome-reactnative-ui - react-native-simpledialog-android - same idea of AlertIOS|<ul><li>Last updated : 1 year ago</li><li>Stars : 41</li><li>Open issues : 0</li></ul>|![](http://img.shields.io/npm/v/react-native-simpledialog-android.svg?style=flat-square)| (Others)
- awesome-react-native - react-native-simpledialog-android ★41 - React Native Android module to use Android's AlertDialog - same idea of AlertIOS (Components / UI)
- awesome-react-native-ui - react-native-simpledialog-android ★39 - React Native Android module to use Android's AlertDialog - same idea of AlertIOS (Components / UI)
- awesome-react-native - react-native-simpledialog-android ★41 - React Native Android module to use Android's AlertDialog - same idea of AlertIOS (Components / UI)
README
# react-native-simpledialog-android
React Native Android module to use Android's AlertDialog - same idea of AlertIOS[![npm version](http://img.shields.io/npm/v/react-native-simpledialog-android.svg?style=flat-square)](https://npmjs.org/package/react-native-simpledialog-android "View this project on npm")
[![npm downloads](http://img.shields.io/npm/dm/react-native-simpledialog-android.svg?style=flat-square)](https://npmjs.org/package/react-native-simpledialog-android "View this project on npm")
[![npm licence](http://img.shields.io/npm/l/react-native-simpledialog-android.svg?style=flat-square)](https://npmjs.org/package/react-native-simpledialog-android "View this project on npm")### Installation
```bash
npm install react-native-simpledialog-android --save
```### Add it to your android project
* In `android/settings.gradle`
```gradle
...
include ':RNSimpleAlertDialogModule', ':app'
project(':RNSimpleAlertDialogModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-simpledialog-android/android')
```* In `android/app/build.gradle`
```gradle
...
dependencies {
...
compile project(':RNSimpleAlertDialogModule')
}
```* Register Module >= 0.17 && <= 0.29(in ```MainActivity.java```)
* NOTE: >= RN 29 split ```MainActivity.java``` into ```MainActivity.java``` and
```MainApplication.java```. So make modifications below to ```MainApplication.java``````java
import com.burnweb.rnsimplealertdialog.RNSimpleAlertDialogPackage; // <--- importpublic class MainApplication extends Application implements ReactApplication {
......@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNSimpleAlertDialogPackage()); // <------ add this line to your MainApplication class
}......
}
```## Usage
This module are very similar to [AlertIOS](https://facebook.github.io/react-native/docs/alertios.html) native module, and only works with **alert** method *(prompt method aren't implemented yet)*.The main difference are in the way that you declare buttons. In Android you can declare **up to 3 buttons** and in this module you have to declare what **type** the button is.
A button can be **SimpleAlert.POSITIVE_BUTTON**, **SimpleAlert.NEGATIVE_BUTTON** or **SimpleAlert.NEUTRAL_BUTTON**.## Example
```javascript
var SimpleAlert = require('react-native-simpledialog-android');function _onPress(event) {
console.log(event);
};SimpleAlert.alert(
'Please read me!',
'Want a warning alert?', [
{ type: SimpleAlert.POSITIVE_BUTTON, text: 'Yes', onPress: _onPress },
{ type: SimpleAlert.NEGATIVE_BUTTON, text: 'No', onPress: _onPress },
{ type: SimpleAlert.NEUTRAL_BUTTON, text: 'Neutral', onPress: _onPress },
]
);
```## License
MIT