react-native-dropdownalert
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -56,2 +56,4 @@ | ||
this.dismiss = this.dismiss.bind(this) | ||
this.animate = this.animate.bind(this) | ||
this.validateType = this.validateType.bind(this) | ||
} | ||
@@ -164,10 +166,5 @@ renderTitle() { | ||
alert(type, title, message) { | ||
if (type.length === 0 || type === null ) { | ||
console.warn('Missing DropdownAlert type. Available types: info, warn, error or custom') | ||
if (this.validateType(type) == false) { | ||
return | ||
} | ||
if (type != 'info' && type != 'warn' && type != 'error' && type != 'custom') { | ||
console.warn('Invalid DropdownAlert type. Available types: info, warn, error or custom') | ||
return | ||
} | ||
if (this.state.isOpen) { | ||
@@ -186,8 +183,3 @@ this.dismiss() | ||
} | ||
Animated.timing( | ||
this.state.fadeAnim, { | ||
toValue: 1, | ||
duration: this.state.duration | ||
} | ||
).start() | ||
this.animate(1) | ||
if (this.props.closeInterval > 1) { | ||
@@ -204,8 +196,3 @@ closeTimeoutId = setTimeout(function() { | ||
} | ||
Animated.timing( | ||
this.state.fadeAnim, { | ||
toValue: 0, | ||
duration: this.state.duration | ||
} | ||
).start() | ||
this.animate(0) | ||
setTimeout(function() { | ||
@@ -221,2 +208,21 @@ if (this.state.visible) { | ||
} | ||
animate(toValue) { | ||
Animated.timing( | ||
this.state.fadeAnim, { | ||
toValue: toValue, | ||
duration: this.state.duration | ||
} | ||
).start() | ||
} | ||
validateType(type) { | ||
if (type.length === 0 || type === null) { | ||
console.warn('Missing DropdownAlert type. Available types: info, warn, error or custom') | ||
return false | ||
} | ||
if (type != 'info' && type != 'warn' && type != 'error' && type != 'custom') { | ||
console.warn('Invalid DropdownAlert type. Available types: info, warn, error or custom') | ||
return false | ||
} | ||
return true | ||
} | ||
} | ||
@@ -223,0 +229,0 @@ |
{ | ||
"name": "react-native-dropdownalert", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "A dropdown alert that allows you to display bits of information to your user.", | ||
@@ -5,0 +5,0 @@ "main": "DropdownAlert.js", |
@@ -6,2 +6,3 @@ ### react-native-dropdownalert | ||
[![Build Status](https://travis-ci.org/devBrian/react-native-dropdownalert.svg?branch=master)](https://travis-ci.org/devBrian/react-native-dropdownalert) | ||
[![License](https://img.shields.io/dub/l/vibe-d.svg)](https://raw.github.com/devBrian/react-native-dropdownalert/master/LICENSE) | ||
@@ -25,3 +26,3 @@ A dropdown alert that allows you to display bits of information to your users. Try 1 of 3 pre-defined types or roll your own custom type (see props below). The user can tap the alert to close it or it will close automatically after 4 seconds or you can choose how long (see closeInterval prop). | ||
<View> | ||
<DropdownAlert ref={"dropdownalert"} /> | ||
<DropdownAlert ref={'dropdown'} /> | ||
</View> | ||
@@ -32,3 +33,6 @@ ) | ||
handleServerResponse(err, response) { | ||
this.refs.dropdownalert.alert('error', 'Error', 'Sorry, there was an unexpected problem. Please try again.') | ||
if (err != null) { | ||
// Inform the user of the error. | ||
this.refs.dropdown.alert('error', 'Error', err) | ||
} | ||
} | ||
@@ -40,3 +44,3 @@ // ... | ||
### Types | ||
--- | ||
--- | ||
@@ -64,6 +68,1 @@ ![screenshot](https://raw.github.com/devBrian/react-native-dropdownalert/master/screenshots/info.png) | ||
Inspired by: [RKDropdownAlert](https://github.com/cwRichardKim/RKDropdownAlert) | ||
### License | ||
--- | ||
[MIT](https://raw.github.com/devBrian/react-native-dropdownalert/master/LICENSE) |
19364
266
64