react-native-alert
Advanced tools
Comparing version 1.0.2 to 1.0.3
41
Alert.js
@@ -7,12 +7,2 @@ var React = require('react-native') | ||
/* | ||
AlertIOS.alert( | ||
'Foo Title', | ||
'My Alert Msg', | ||
[ | ||
{text: 'Foo', onPress: () => console.log('Foo Pressed!')}, | ||
{text: 'Bar', onPress: () => console.log('Bar Pressed!')}, | ||
] | ||
)} | ||
*/ | ||
module.exports = function () { | ||
@@ -25,9 +15,8 @@ var title = '' | ||
if(len == 1) { | ||
message = args[0] + '' | ||
} | ||
message = args[0] + '' | ||
if(len == 2) { | ||
if(args[1] + '' === args[1]) title = args[1] | ||
if(Array.isArray(args[1])) buttons = args[1] | ||
Array.isArray(args[1]) | ||
? buttons = args[1] | ||
: title = args[1] + '' | ||
} | ||
@@ -41,11 +30,13 @@ | ||
if(buttons.length) buttons = buttons.map(function (li) { | ||
if(li + '' === li) return { | ||
text: li | ||
} | ||
}) | ||
return buttons.length | ||
? AlertIOS.alert(title, message, buttons) | ||
: AlertIOS.alert(title, message) | ||
} | ||
if(buttons.length) { | ||
buttons = buttons.map(function (li) { | ||
return li + '' === li | ||
? { | ||
text: li | ||
} | ||
: li | ||
}) | ||
return AlertIOS.alert(title, message, buttons) | ||
} | ||
return AlertIOS.alert(title, message) | ||
} |
{ | ||
"name": "react-native-alert", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Use AlertIOS as a simple way just like native javascript.", | ||
@@ -5,0 +5,0 @@ "main": "Alert.js", |
@@ -25,2 +25,6 @@ # react-native-alert | ||
// With buttons | ||
alert('123', ['button']) | ||
alert('123', ['button', {text: 'alertButton', onPress: () => alert('ok')}]) | ||
// Complete usage | ||
@@ -27,0 +31,0 @@ alert('title', '123', [ |
38
2186
33