Compare commits

...

28 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
陈阳
50b7f288c2 0.3.5 2019-04-11 16:22:47 +08:00
陈阳
27f6c528d3 0.3.4 2019-04-11 16:22:03 +08:00
Horcrux
36a3725f82
Fix auto focus 2019-04-11 16:20:46 +08:00
Bell
cafe32c074
Merge pull request #39 from rozPierog/android-gradle-update
[Gradle] Update to new react native style of android versioning
2018-10-19 16:22:57 +08:00
Leon Omelan
645b4023ab [Gradle] Update to new react native style of android versioning 2018-10-19 10:13:36 +02:00
Bell
65624e69f8
Merge pull request #35 from radreamer/add-keyboard-type-setting-ios
add keyboardType option for ios
2018-10-19 14:59:53 +08:00
Bell
b30c8395f0
Merge pull request #37 from rozPierog/master
Clean & update build.gradle
2018-10-19 14:54:49 +08:00
Marcin Omelan
9354a8e8f8 Clean & update build.gradle 2018-05-04 14:31:26 +02:00
raDreamer
946dd01f87 add keyboardType option for ios 2018-04-05 13:00:11 +03:00
song
9c1ffa4605 chore:横屏依然全屏,但保留actionDone 2018-02-07 14:30:47 +08:00
Bell
a928f1c12e
Merge pull request #28 from shimohq/feat/support-land
feat:横屏时去掉全屏
2018-02-06 16:08:07 +08:00
song
18a79c92d3 feat:横屏时去掉全屏 2018-02-06 16:06:09 +08:00
Horcrux
1af614c921
Merge pull request #22 from krystofcelba/typescript-typings
Add TypeScript type definitions
2017-11-20 12:26:46 +08:00
Krystof Celba
9e40f3a994 chore: add TypeScript type definitions 2017-11-19 00:53:25 +01:00
Bell
8e34686146 chore: Bump Version 2017-08-24 10:56:41 +08:00
Bell
7c5cca5861 Merge pull request #18 from aroth/master
Fix for specifying a callback as third param.
2017-08-24 10:45:33 +08:00
Adam Roth
951ce90ec1 Merge branch 'master' of https://github.com/shimohq/react-native-prompt-android 2017-08-23 10:37:57 -04:00
Adam Roth
b53293aa08 Remove unnecessary noop callback. 2017-08-23 10:29:02 -04:00
Bell
68da243e8c fix: new RNPromptFragment 2017-08-23 11:53:08 +08:00
Horcrux
5be7159c6c Merge pull request #19 from shimohq/fix/ValidFragment
fix: ValidFragment
2017-08-23 11:30:19 +08:00
Adam Roth
8822b42cb2 Fix for specifying a callback as third param.
Resolves https://github.com/shimohq/react-native-prompt-android/issues/4
2017-08-22 16:43:45 -04:00
12 changed files with 105 additions and 115 deletions

View File

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

View File

@ -49,6 +49,7 @@ prompt(
type | Text input type: `'numeric', 'secure-text', 'phone-pad', 'email-address'` | String | 'default'
cancelable | | Boolean |
defaultValue | Default input value | String | ''
keyboardType | The keyboard type of first text field(if exists). One of `'default'`, `'email-address'`, `'numeric'`, `'phone-pad'`, `'ascii-capable'`, `'numbers-and-punctuation'`, `'url'`, `'number-pad'`, `'name-phone-pad'`, `'decimal-pad'`, `'twitter'` or `'web-search'`. | String | 'default'
placeholder | | String | ''

View File

@ -1,24 +1,19 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 27
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
versionName "1.1"
}
lintOptions {
abortOnError false
@ -35,7 +30,8 @@ repositories {
}
dependencies {
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.facebook.react:react-native:+'
compile fileTree( dir: "libs", includes: ['*.jar'] )
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 {
@ -155,7 +156,9 @@ public class RNPromptFragment extends DialogFragment implements DialogInterface.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = this.createDialog(getActivity(), getArguments());
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
if (mInputText.requestFocus()) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
return dialog;
}

View File

@ -183,7 +183,7 @@ public class RNPromptModule extends ReactContextBaseJavaModule implements Lifecy
PromptFragmentListener actionListener =
actionCallback != null ? new PromptFragmentListener(actionCallback) : null;
final RNPromptFragment promptFragment = new RNPromptFragment(actionListener, arguments);
final RNPromptFragment promptFragment = new RNPromptFragment();
promptFragment.setListener(actionListener);
promptFragment.setArguments(arguments);

View File

@ -4,5 +4,5 @@
android:layout_height="match_parent"
android:textCursorDrawable="@drawable/edit_text_cursor"
style="@style/ShimoEditTextStyle"
android:theme="@style/ShimoEditTextStyle">
</EditText>
android:imeOptions="actionDone"
android:theme="@style/ShimoEditTextStyle"/>

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,88 +3,26 @@ 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 default function prompt(title, message, callbackOrButtons, options) {
const defaultButtons = [
{
text: 'Cancel',
},
{
text: 'OK',
onPress: callbackOrButtons
}
];
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 {
let buttons = callbackOrButtons;
let buttons = typeof callbackOrButtons === 'function'
? defaultButtons
: callbackOrButtons;
let config = {
title: title || '',
message: message || '',
};
if (typeof callbackOrButtons === 'function') {
buttons.push({
text: 'OK',
onPress: callbackOrButtons
});
}
if (options) {
config = {
...config,
@ -97,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();

59
index.d.ts vendored Normal file
View File

@ -0,0 +1,59 @@
// Type definitions for react-native-prompt-android 0.3.1
// Project: https://github.com/shimohq/react-native-prompt-android
// Definitions by: Krystof Celba <https://github.com/krystofcelba>
// TypeScript Version: 2.6.1
type PromptButton = {
text?: string;
onPress?: (message: string) => void;
/** @platform ios */
style?: 'default' | 'cancel' | 'destructive';
};
type PromptType = 'default' | 'plain-text' | 'secure-text';
type PromptTypeIOS = 'login-password';
type PromptTypeAndroid = 'numeric' | 'email-address' | 'phone-pad';
type PromptStyleAndroid = 'default' | 'shimo';
export interface PromptOptions {
/**
* * Cross platform:
*
* - `'default'`
* - `'plain-text'`
* - `'secure-text'`
*
* * iOS only:
*
* - `'login-password'`
*
* * Android only:
*
* - `'numeric'`
* - `'email-address'`
* - `'phone-pad'`
*/
type?: PromptType | PromptTypeIOS | PromptTypeAndroid;
defaultValue?: string;
/** @platform android */
placeholder?: string;
/** @platform android */
cancelable?: boolean;
/** @platform android */
style?: PromptStyleAndroid;
}
declare function prompt(
title?: string,
message?: string,
callbackOrButtons?: ((value: string) => void) | Array<PromptButton>,
options?: PromptOptions,
): void;
export default prompt;

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);
};

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.0",
"version": "1.0.0",
"description": "Polyfill for Alert.prompt on Android",
"repository": {
"type": "git",