Skip to content

Commit

Permalink
Initail commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nysamnang committed Jan 25, 2019
1 parent be5ba52 commit bf2375e
Show file tree
Hide file tree
Showing 7 changed files with 469 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OSX
.DS_Store

# Node Module
node_modules/
171 changes: 170 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,171 @@
# react-native-alert-pro
The Pro Version of React Native Alert (Android & iOS)

[![npm version](https://badge.fury.io/js/react-native-alert-pro.svg)](//npmjs.com/package/react-native-alert-pro) [![npm downloads](https://img.shields.io/npm/dm/react-native-alert-pro.svg)
](//npmjs.com/package/react-native-alert-pro)

- Super lightweight component (50 KB)
- Smooth animation
- Beautiful
- Use method instead of state
- Work like a Pro
- Customize whatever you like
- Support all orientations
- Support both Android and iOS

| iOS | Android |
| :-------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------: |
| ![](https://raw.githubusercontent.com/NYSamnang/stock-images/master/react-native-alert-pro/RNALP-IOS.gif) | ![](https://raw.githubusercontent.com/NYSamnang/stock-images/master/react-native-alert-pro/RNALP-AOS.gif) |

## Installation

```
npm i react-native-alert-pro --save
```

### or

```
yarn add react-native-alert-pro
```

## Example

```jsx
import React, { Component } from "react";
import { StyleSheet, View, TouchableOpacity, Text } from "react-native";
import AlertPro from "react-native-alert-pro";

class Example extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.title}>REACT NATIVE ALERT PRO</Text>
<View style={styles.buttonContainer}>
<TouchableOpacity
onPress={() => this.AlertPro.open()}
style={styles.button}
>
<Text style={styles.text}>CUSTOM</Text>
</TouchableOpacity>
</View>

<AlertPro
ref={ref => {
this.AlertPro = ref;
}}
onConfirm={() => this.AlertPro.close()}
title="Delete confirmation"
message="Are you sure to delete the entry?"
textCancel="Cancel"
textConfirm="Delete"
customStyles={{
mask: {
backgroundColor: "transparent"
},
container: {
borderWidth: 1,
borderColor: "#9900cc",
shadowColor: "#000000",
shadowOpacity: 0.1,
shadowRadius: 10
},
buttonCancel: {
backgroundColor: "#4da6ff"
},
buttonConfirm: {
backgroundColor: "#ffa31a"
}
}}
/>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
backgroundColor: "#fff"
},
title: {
fontSize: 20,
marginTop: 120
},
buttonContainer: {
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: "#FFFFFF"
},
button: {
backgroundColor: "#4EB151",
paddingVertical: 11,
paddingHorizontal: 17,
borderRadius: 3,
marginBottom: 15
},
text: {
color: "#FFFFFF",
fontSize: 16,
fontWeight: "600"
}
});

export default Example;
```

## Props

| Prop | Type | Description | Default |
| ---------------- | -------- | -------------------------------------------------------- | -------------------------- |
| title | string | AlertPro's title | "Do you want to continue?" |
| message | string | AlertPro's message | "" |
| showCancel | boolean | Show a Cancel button | true |
| showConfirm | boolean | Show a Confirm button | true |
| textCancel | string | Text display on Cancel button | "No" |
| textConfirm | string | Text display on Confirm button | "Yes" |
| closeOnPressMask | boolean | Close AlertPro when press on mask (The empty space area) | true |
| customStyles | object | Custom style to AlertPro | {} |
| onCancel | function | Event on Cancel button | |
| onConfirm | function | Event on Confirm button | |

### Available Custom Style

```jsx
customStyles: {
title: {...}, // AlertPro's title
message: {...}, // AlertPro's message
mask: {...}, // The empty space area
container: {...}, // AlertPro container
content: {...}, // AlertPro content
buttonCancel: {...}, // Cancel button
buttonConfirm: {...}, // Confirm button
textCancel: {...}, // Cancel button's Text
textConfirm: {...} // Confirm button's Text

}
```

## Methods

| Method Name | Description |
| ----------- | -------------- |
| open | Open AlertPro |
| close | Close AlertPro |

### Note

Always set `ref` to `AlertPro` and call each method by using `this.AlertPro.methodName()` like example above.

### Give me a Star

If you think this project is helpful just give me a ⭐️ Star is enough because i don't drink coffee :D

## License

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/NYSamnang/react-native-alert-pro/blob/master/LICENSE) file for details

## Author

Made with ❤️ by [NY Samnang](https://github.com/NYSamnang).
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AlertPro from "./src";

export default AlertPro;
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "react-native-alert-pro",
"version": "1.0.0",
"description": "The Pro Version of React Native Alert (Android & iOS)",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NYSamnang/react-native-alert-pro.git"
},
"keywords": [
"react-native",
"alert",
"alert-pro",
"dialog",
"popup",
"confirm",
"modal",
"box"
],
"author": "NY Samnang",
"license": "MIT",
"bugs": {
"url": "https://github.com/NYSamnang/react-native-alert-pro/issues"
},
"homepage": "https://github.com/NYSamnang/react-native-alert-pro#readme",
"dependencies": {
"prop-types": "^15.6.2"
}
}
Loading

0 comments on commit bf2375e

Please sign in to comment.