react-native-prompt-android
Advanced tools
Comparing version
@@ -6,71 +6,3 @@ import { | ||
export type PromptType = $Enum<{ | ||
/** | ||
* Default alert with no inputs | ||
*/ | ||
'default': string, | ||
/** | ||
* Plain text input alert | ||
*/ | ||
'plain-text': string, | ||
/** | ||
* Secure text input alert | ||
*/ | ||
'secure-text': string, | ||
/** | ||
* Numeric input alert | ||
*/ | ||
'numeric': string, | ||
/** | ||
* Email address input alert | ||
*/ | ||
'email-address': string, | ||
/** | ||
* Phone pad input alert | ||
*/ | ||
'phone-pad': string, | ||
}>; | ||
export type PromptStyle = $Enum<{ | ||
/** | ||
* Default alert dialog style | ||
*/ | ||
'default': string, | ||
/** | ||
* Shimo alert dialog style | ||
*/ | ||
'shimo': string, | ||
}>; | ||
type Options = { | ||
cancelable?: ?boolean; | ||
type?: ?PromptType; | ||
defaultValue?: ?String; | ||
placeholder?: ?String; | ||
style?: ?PromptStyle; | ||
}; | ||
/** | ||
* Array or buttons | ||
* @typedef {Array} ButtonsArray | ||
* @property {string=} text Button label | ||
* @property {Function=} onPress Callback function when button pressed | ||
*/ | ||
type ButtonsArray = Array<{ | ||
/** | ||
* Button label | ||
*/ | ||
text?: string, | ||
/** | ||
* Callback function when button pressed | ||
*/ | ||
onPress?: ?Function, | ||
}>; | ||
export default function prompt( | ||
title: ?string, | ||
message?: ?string, | ||
callbackOrButtons?: ?((text: string) => void) | ButtonsArray, | ||
options?: Options | ||
): void { | ||
export default function prompt(title, message, callbackOrButtons, options) { | ||
const defaultButtons = [ | ||
@@ -107,3 +39,3 @@ { | ||
// The text 'OK' should be probably localized. iOS Alert does that in native. | ||
const validButtons: Buttons = buttons ? buttons.slice(0, 3) : [{text: 'OK'}]; | ||
const validButtons = buttons ? buttons.slice(0, 3) : [{text: 'OK'}]; | ||
const buttonPositive = validButtons.pop(); | ||
@@ -110,0 +42,0 @@ const buttonNegative = validButtons.pop(); |
@@ -1,12 +0,5 @@ | ||
import { | ||
AlertIOS | ||
} from 'react-native'; | ||
import { Alert } from 'react-native'; | ||
export default function prompt( | ||
title: ?string, | ||
message?: ?string, | ||
callbackOrButtons?: ?((text: string) => void) | Object, | ||
options?: Object | ||
): void { | ||
AlertIOS.prompt(title, message, callbackOrButtons, options.type, options.defaultValue, options.keyboardType); | ||
}; | ||
export default function prompt(title, message, callbackOrButtons, options) { | ||
Alert.prompt(title, message, callbackOrButtons, options.type, options.defaultValue, options.keyboardType); | ||
} |
{ | ||
"name": "react-native-prompt-android", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Polyfill for Alert.prompt on Android", | ||
@@ -5,0 +5,0 @@ "repository": { |
50045
-2.7%506
-12.31%