Compare commits

...

7 Commits

Author SHA1 Message Date
Marcos Rodriguez Vélez
ed168d66fe
Rename index.ios.js to index.js 2021-05-29 02:21:18 -04:00
Horcrux
2073b07f64 fix iOS prompt 2019-09-18 19:02:34 +08:00
Horcrux
957e99cd4e fix conflict 2019-09-18 18:58:48 +08:00
钟加仁
7eae9e24cd chore: bump version to 1.0.0 2019-09-17 11:34:37 +08:00
Bell
12ec414163
feature: adaptive react-native 0.60 (#52) 2019-09-17 11:31:38 +08:00
Horcrux
b9b9b93acf 0.3.6 2019-09-06 10:56:22 +08:00
Horcrux
83d23015c9 fix some crash 2019-09-06 10:56:12 +08:00
8 changed files with 13 additions and 87 deletions

View File

@ -1,2 +1 @@
node_modules/
Example/

View File

@ -30,7 +30,7 @@ repositories {
}
dependencies {
implementation "com.android.support:appcompat-v7:27.1.1"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.facebook.react:react-native:+'
implementation fileTree( dir: "libs", includes: ['*.jar'] )
}

View File

@ -5,12 +5,13 @@ import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.widget.EditText;
import androidx.appcompat.app.AlertDialog;
import javax.annotation.Nullable;
public class RNPromptFragment extends DialogFragment implements DialogInterface.OnClickListener {

View File

@ -4,7 +4,8 @@
<item name="colorAccent">@color/prompt_color</item>
</style>
<style name="ShimoEditTextStyle" parent="Widget.AppCompat.EditText">
<style name="ShimoEditTextStyle">
<item name="android:textColor">@color/prompt_color</item>
<item name="colorControlNormal">@color/prompt_color</item>
<item name="colorControlActivated">@color/prompt_color</item>
<item name="colorControlHighlight">@color/prompt_color</item>

View File

@ -3,75 +3,7 @@ import {
} from 'react-native';
const PromptAndroid = NativeModules.PromptAndroid;
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 = [
{
text: 'Cancel',
@ -103,7 +35,7 @@ export default function prompt(
}
// At most three buttons (neutral, negative, positive). Ignore rest.
// 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();
const buttonNegative = validButtons.pop();
const buttonNeutral = validButtons.pop();

View File

@ -1,12 +0,0 @@
import {
AlertIOS
} 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);
};

5
index.js Normal file
View File

@ -0,0 +1,5 @@
import { Alert } from 'react-native';
export default function prompt(title, message, callbackOrButtons, options) {
Alert.prompt(title, message, callbackOrButtons, options.type, options.defaultValue, options.keyboardType);
}

View File

@ -1,6 +1,6 @@
{
"name": "react-native-prompt-android",
"version": "0.3.5",
"version": "1.0.0",
"description": "Polyfill for Alert.prompt on Android",
"repository": {
"type": "git",