6
6
[ ![ Build Status] ( https://travis-ci.org/testshallpass/react-native-dropdownalert.svg?branch=master )] ( https://travis-ci.org/testshallpass/react-native-dropdownalert )
7
7
[ ![ License] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/LICENSE )
8
8
9
- A simple alert to notify users about new chat messages, something went wrong or everything is ok. It can be dismissed by onPress, cancel onPress, automatically with ` closeInterval ` prop, pan responder up gesture or programmatically.
9
+ ![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/info.png ) ![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/warning.png ) ![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/error.png ) ![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/success.png )
10
+
11
+ ### Table of contents
12
+ 1 . [ News] ( #news )
13
+ 2 . [ Installation] ( #installation )
14
+ 3 . [ Demo] ( #demo )
15
+ 4 . [ Usage] ( #usage )
16
+ 5 . [ Props] ( #props )
17
+
18
+ A simple alert to notify users about new chat messages, something went wrong or everything is ok. It can be closed by tap, cancel button, automatically with ` closeInterval ` , pan responder up gesture or programmatically.
10
19
11
20
### News
12
21
> v2.13.0 supports ViewPropTypes introduced in react-native ** 0.44.0** . If you support an earlier react-native version, please use v2.12.0 or earlier.
@@ -21,39 +30,31 @@ npm i react-native-dropdownalert --save
21
30
22
31
### Usage
23
32
``` javascript
24
-
25
- import DropdownAlert from ' react-native-dropdownalert'
26
- // ...
27
- render () {
28
- return (
29
- < View>
30
- // !!! Make sure it's the last component in your document tree.
31
- < DropdownAlert
32
- ref= {(ref ) => this .dropdown = ref}
33
- onClose= {(data ) => this .onClose (data)} / >
34
- < / View>
35
- )
36
- }
37
- // ...
38
- handleRequestCallback (err , response ) {
39
- if (err != null ) {
40
- this .dropdown .alertWithType (' error' , ' Error' , err)
33
+ import DropdownAlert from ' react-native-dropdownalert' ;
34
+ export default class Example extends Component {
35
+ // ...
36
+ onError = error => {
37
+ if (error) {
38
+ this .dropdown .alertWithType (' error' , ' Error' , error);
39
+ }
40
+ };
41
+ // ...
42
+ onClose (data ) {
43
+ // data = {type, title, message, action}
44
+ // action means how the alert was closed.
45
+ // returns: automatic, programmatic, tap, pan or cancel
46
+ }
47
+ render () {
48
+ return (
49
+ < View>
50
+ // !!! Make sure it's the last component in your document tree.
51
+ < DropdownAlert ref= {ref => this .dropdown = ref} onClose= {data => this .onClose (data)} / >
52
+ < / View>
53
+ );
41
54
}
42
55
}
43
- // ...
44
- onClose (data ) {
45
- // data = {type, title, message, action}
46
- // action means how the alert was dismissed. returns: automatic, programmatic, tap, pan or cancel
47
- }
48
- // ...
49
56
```
50
57
51
- ### Predefined Types
52
-
53
- | info | warn | error | success |
54
- | :---: | :---: | :---: | :---: |
55
- |![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/info.png ) |![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/warning.png ) |![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/error.png ) |![ screenshot] ( https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/success.png )
56
-
57
58
### Props
58
59
| Name | Type | Description | Default |
59
60
| ---- | :---: | --- | --- |
@@ -76,7 +77,7 @@ onClose(data) {
76
77
| ``` activeStatusBarBackgroundColor ``` | String | StatusBar backgroundColor when alert is open | It takes on the backgroundColor of alert if predefined else default or provided prop
77
78
| ``` inactiveStatusBarStyle ``` | String | StatusBar barStyle when alert dismisses | ` StatusBar._defaultProps.barStyle.value `
78
79
| ``` inactiveStatusBarBackgroundColor ``` | String | StatusBar backgroundColor when alert dismisses | ` StatusBar._defaultProps.backgroundColor.value `
79
- | ``` containerStyle ``` | View.propTypes .style | styles for container for custom type only | ``` { padding: 16, flexDirection: 'row' } ```
80
+ | ``` containerStyle ``` | ViewPropTypes .style | styles for container for custom type only | ``` { padding: 16, flexDirection: 'row' } ```
80
81
| ``` titleStyle ``` | Text.propTypes.style | styles for title for all types | ``` { fontSize: 16, textAlign: 'left', fontWeight: 'bold', color: 'white', backgroundColor: 'transparent' } ```
81
82
| ``` messageStyle ``` | Text.propTypes.style | styles for message for all types | ``` { fontSize: 14, textAlign: 'left', fontWeight: 'bold', color: 'white', backgroundColor: 'transparent' } ```
82
83
| ``` imageStyle ``` | Image.propTypes.style | styles for image for all types | ``` { padding: 8, width: 36, height: 36, alignSelf: 'center' } ```
@@ -87,5 +88,7 @@ onClose(data) {
87
88
| ``` errorColor ``` | String | Default background color of error message | #cc3232
88
89
| ``` elevation ``` | Number | Animated.View elevation | 1
89
90
| ``` sensitivity ``` | Number | Sensitivity for the pan responder up gesture | 20
91
+ | ``` defaultContainer ``` | ViewPropTypes.style | Style for inner view container (** override paddingTop with this** ) | ``` { padding: 8, paddingTop: IS_ANDROID ? 0 : 20, flexDirection: 'row' } ```
92
+ | ``` defaultTextContainer ``` | ViewPropTypes.style | Style for inner text container (holds title and message) | ``` { flex: 1, padding: 8 } ```
90
93
91
94
> Inspired by: [ RKDropdownAlert] ( https://github.com/cwRichardKim/RKDropdownAlert )
0 commit comments