From 3f2b05b8dc463b460d628796899172bb79614d85 Mon Sep 17 00:00:00 2001 From: Felipe Vieira <> Date: Wed, 30 May 2018 19:21:34 -0300 Subject: [PATCH 1/5] checkbox prompt support for picker --- android/build.gradle | 2 +- .../modules/DialogAndroid.java | 35 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index ae9e302..df6cfc2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -31,5 +31,5 @@ dependencies { compile 'com.facebook.react:react-native:+' compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile 'com.afollestad.material-dialogs:commons:0.8.6.2' + compile 'com.afollestad.material-dialogs:commons:0.9.0.1' } diff --git a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java index 329c19f..69a9c1c 100644 --- a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java +++ b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java @@ -163,6 +163,12 @@ public class DialogAndroid extends ReactContextBaseJavaModule { builder.btnStackedGravity(GravityEnum.START); } break; + case "checkBoxPrompt": + ReadableMap checkBoxPrompt = options.getMap("checkBoxPrompt"); + boolean initiallyChecked = checkBoxPrompt.hasKey("initiallyChecked") && + checkBoxPrompt.getBoolean("initiallyChecked"); + builder.checkBoxPrompt(checkBoxPrompt.getString("text"), initiallyChecked, null); + break; case "progress": ReadableMap progress = options.getMap("progress"); boolean indeterminate = progress.hasKey("indeterminate") && @@ -275,7 +281,8 @@ public class DialogAndroid extends ReactContextBaseJavaModule { if (!mCallbackConsumed) { mCallbackConsumed = true; charSequence = charSequence == null ? "" : charSequence; - callback.invoke("itemsCallbackSingleChoice", i, charSequence.toString()); + boolean isPromptCheckBoxChecked = materialDialog.isPromptCheckBoxChecked(); + callback.invoke("itemsCallbackSingleChoice", i, charSequence.toString(), isPromptCheckBoxChecked); } return true; } @@ -407,7 +414,18 @@ public class DialogAndroid extends ReactContextBaseJavaModule { MaterialDialog simple; @ReactMethod public void list(ReadableMap options, final Callback callback) { - final MaterialSimpleListAdapter simpleListAdapter = new MaterialSimpleListAdapter(getCurrentActivity()); + final MaterialSimpleListAdapter simpleListAdapter = new MaterialSimpleListAdapter(new MaterialSimpleListAdapter.Callback() { + @Override + public void onMaterialListItemSelected(int index, MaterialSimpleListItem item) { + if (!mCallbackConsumed) { + mCallbackConsumed = true; + callback.invoke(index, item.getContent()); + } + if (simple != null) { + simple.dismiss(); + } + } + }); ReadableArray arr = options.getArray("items"); for(int i = 0; i < arr.size(); i++){ @@ -418,18 +436,7 @@ public class DialogAndroid extends ReactContextBaseJavaModule { final MaterialDialog.Builder adapter = new MaterialDialog.Builder(getCurrentActivity()) .title(options.hasKey("title") ? options.getString("title") : "") - .adapter(simpleListAdapter, new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { - if (!mCallbackConsumed) { - mCallbackConsumed = true; - callback.invoke(which, text); - } - if (simple != null) { - simple.dismiss(); - } - } - }) + .adapter(simpleListAdapter, null) .autoDismiss(true); UiThreadUtil.runOnUiThread(new Runnable() { From d8c3700e195d3e2bc1ba796274a671c859f92aea Mon Sep 17 00:00:00 2001 From: Noitidart Date: Wed, 30 May 2018 22:09:12 -0700 Subject: [PATCH 2/5] Udpate DialogAndroid.java - adjust for js api --- .../modules/DialogAndroid.java | 109 ++++++++---------- 1 file changed, 46 insertions(+), 63 deletions(-) diff --git a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java index 69a9c1c..ed2d14b 100644 --- a/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java +++ b/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java @@ -29,16 +29,12 @@ public class DialogAndroid extends ReactContextBaseJavaModule { return "DialogAndroid"; } - public DialogAndroid(ReactApplicationContext reactContext) { super(reactContext); } /* Apply the options to the provided builder */ - private MaterialDialog.Builder applyOptions( - MaterialDialog.Builder builder, - ReadableMap options - ) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { + private MaterialDialog.Builder applyOptions(MaterialDialog.Builder builder, ReadableMap options) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { ReadableMapKeySetIterator iterator = options.keySetIterator(); while(iterator.hasNextKey()) { String key = iterator.nextKey(); @@ -103,6 +99,7 @@ public class DialogAndroid extends ReactContextBaseJavaModule { builder.autoDismiss(options.getBoolean("autoDismiss")); break; case "forceStacking": + // should change to StackingBehavior? forceStacking is deprecated? builder.forceStacking(options.getBoolean("forceStacking")); break; case "alwaysCallSingleChoiceCallback": @@ -124,8 +121,7 @@ public class DialogAndroid extends ReactContextBaseJavaModule { builder.cancelable(options.getBoolean("cancelable")); break; case "progressIndeterminateStyle": // true for horizontal, DO NOT USE - builder.progressIndeterminateStyle( - options.getBoolean("progressIndeterminateStyle")); + builder.progressIndeterminateStyle(options.getBoolean("progressIndeterminateStyle")); break; case "buttonsGravity": String bg = options.getString("buttonsGravity"); @@ -163,21 +159,17 @@ public class DialogAndroid extends ReactContextBaseJavaModule { builder.btnStackedGravity(GravityEnum.START); } break; - case "checkBoxPrompt": - ReadableMap checkBoxPrompt = options.getMap("checkBoxPrompt"); - boolean initiallyChecked = checkBoxPrompt.hasKey("initiallyChecked") && - checkBoxPrompt.getBoolean("initiallyChecked"); - builder.checkBoxPrompt(checkBoxPrompt.getString("text"), initiallyChecked, null); + case "checkboxLabel": + boolean defaultValue = options.hasKey("checkboxDefaultValue") && options.getBoolean("checkboxDefaultValue"); + builder.checkBoxPrompt(options.getString("checkboxLabel"), defaultValue, null); break; case "progress": ReadableMap progress = options.getMap("progress"); - boolean indeterminate = progress.hasKey("indeterminate") && - progress.getBoolean("indeterminate"); + boolean indeterminate = progress.hasKey("indeterminate") && progress.getBoolean("indeterminate"); if (indeterminate) { builder.progress(true, 0); - boolean horizontal = progress.hasKey("style") && - progress.getString("style").equals("horizontal"); + boolean horizontal = progress.hasKey("style") && progress.getString("style").equals("horizontal"); if (horizontal) builder.progressIndeterminateStyle(horizontal); } else { // Determinate progress bar not supported currently @@ -245,11 +237,11 @@ public class DialogAndroid extends ReactContextBaseJavaModule { if (!mCallbackConsumed) { mCallbackConsumed = true; if (dialogAction == DialogAction.POSITIVE) { - callback.invoke("onAny", 0); + callback.invoke("onAny", 0, materialDialog.isPromptCheckBoxChecked()); } else if (dialogAction == DialogAction.NEUTRAL) { - callback.invoke("onAny", 1); + callback.invoke("onAny", 1, materialDialog.isPromptCheckBoxChecked()); } else { - callback.invoke("onAny", 2); + callback.invoke("onAny", 2, materialDialog.isPromptCheckBoxChecked()); } } } @@ -259,11 +251,10 @@ public class DialogAndroid extends ReactContextBaseJavaModule { if (options.hasKey("itemsCallback")) { mBuilder.itemsCallback(new MaterialDialog.ListCallback() { @Override - public void onSelection(MaterialDialog materialDialog, View view, int i, - CharSequence charSequence) { + public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { if (!mCallbackConsumed) { mCallbackConsumed = true; - callback.invoke("itemsCallback", i, charSequence == null ? null : charSequence.toString()); + callback.invoke("itemsCallback", i, materialDialog.isPromptCheckBoxChecked()); } } }); @@ -271,22 +262,18 @@ public class DialogAndroid extends ReactContextBaseJavaModule { if (options.hasKey("itemsCallbackSingleChoice")) { // Check if there is a preselected index - int selectedIndex = options.hasKey("selectedIndex") ? - options.getInt("selectedIndex") : -1; - mBuilder.itemsCallbackSingleChoice(selectedIndex, - new MaterialDialog.ListCallbackSingleChoice() { - @Override - public boolean onSelection(MaterialDialog materialDialog, View view, int i, - CharSequence charSequence) { - if (!mCallbackConsumed) { - mCallbackConsumed = true; - charSequence = charSequence == null ? "" : charSequence; - boolean isPromptCheckBoxChecked = materialDialog.isPromptCheckBoxChecked(); - callback.invoke("itemsCallbackSingleChoice", i, charSequence.toString(), isPromptCheckBoxChecked); - } - return true; - } - }); + int selectedIndex = options.hasKey("selectedIndex") ? options.getInt("selectedIndex") : -1; + mBuilder.itemsCallbackSingleChoice(selectedIndex, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { + if (!mCallbackConsumed) { + mCallbackConsumed = true; + charSequence = charSequence == null ? "" : charSequence; + callback.invoke("itemsCallbackSingleChoice", i, materialDialog.isPromptCheckBoxChecked()); + } + return true; + } + }); } if (options.hasKey("itemsCallbackMultiChoice")) { @@ -300,32 +287,29 @@ public class DialogAndroid extends ReactContextBaseJavaModule { } } - mBuilder.itemsCallbackMultiChoice(selectedIndices, - new MaterialDialog.ListCallbackMultiChoice() { - @Override - public boolean onSelection(MaterialDialog materialDialog, - Integer[] integers, CharSequence[] charSequences) { + mBuilder.itemsCallbackMultiChoice(selectedIndices, new MaterialDialog.ListCallbackMultiChoice() { + @Override + public boolean onSelection(MaterialDialog materialDialog, Integer[] integers, CharSequence[] charSequences) { - // Concatenate selected IDs into a string - StringBuilder selected = new StringBuilder(""); - for (int i = 0; i < integers.length - 1; i++) { - selected.append(integers[i]).append(","); - } - if (integers.length > 0) { - selected.append(integers[integers.length - 1]); - } + // Concatenate selected IDs into a string + StringBuilder selected = new StringBuilder(""); + for (int i = 0; i < integers.length - 1; i++) { + selected.append(integers[i]).append(","); + } + if (integers.length > 0) { + selected.append(integers[integers.length - 1]); + } - if (!mCallbackConsumed) { - mCallbackConsumed = true; - callback.invoke("itemsCallbackMultiChoice", selected.toString()); - } - return true; - } - }); + if (!mCallbackConsumed) { + mCallbackConsumed = true; + callback.invoke("itemsCallbackMultiChoice", selected.toString(), materialDialog.isPromptCheckBoxChecked()); + } + return true; + } + }); // Provide a 'Clear' button to unselect all choices - if (options.hasKey("multiChoiceClearButton") && - options.getBoolean("multiChoiceClearButton")) { + if (options.hasKey("multiChoiceClearButton") && options.getBoolean("multiChoiceClearButton")) { mBuilder.onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) { @@ -378,8 +362,7 @@ public class DialogAndroid extends ReactContextBaseJavaModule { String prefill = input.hasKey("prefill") ? input.getString("prefill") : null; // Check if empty input is allowed - boolean allowEmptyInput = !input.hasKey("allowEmptyInput") || - input.getBoolean("allowEmptyInput"); + boolean allowEmptyInput = !input.hasKey("allowEmptyInput") || input.getBoolean("allowEmptyInput"); // TODO : Provide pre-selected input types in Javascript if (input.hasKey("type")) { @@ -396,7 +379,7 @@ public class DialogAndroid extends ReactContextBaseJavaModule { public void onInput(MaterialDialog materialDialog, CharSequence charSequence) { if (!mCallbackConsumed) { mCallbackConsumed = true; - callback.invoke("input", charSequence.toString()); + callback.invoke("input", charSequence.toString(), materialDialog.isPromptCheckBoxChecked()); } } }); From cc1eed32f6d0acfb996c7e92fc9b22d257c86908 Mon Sep 17 00:00:00 2001 From: Noitidart Date: Wed, 30 May 2018 22:10:29 -0700 Subject: [PATCH 3/5] Update DialogAndroid.js - adjust for js api --- DialogAndroid.js | 84 +++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/DialogAndroid.js b/DialogAndroid.js index 4e8370a..fb84788 100644 --- a/DialogAndroid.js +++ b/DialogAndroid.js @@ -8,6 +8,16 @@ type IdKey = string | 'id'; type LabelKey = string | 'label'; type ListItem = { label:string, id?:any }; +type OptionsAlert = {| + ...OptionsCheckbox, + ...OptionsCommon +|} + +type OptionsCheckbox = {| + checkboxLabel?: string, + checkboxDefaultValue?: boolean +|} + type OptionsCommon = {| title?: null | string, titleColor?: ColorValue, @@ -222,10 +232,9 @@ class DialogAndroid { Object.assign(DialogAndroid.defaults, defaults); } - static alert(title: Title, content: Content, options?: OptionsCommon = {}): Promise< - {| - action: typeof DialogAndroid.actionPositive | typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss - |} + static alert(title: Title, content: Content, options?: OptionsAlert = {}): Promise< + {| action: typeof DialogAndroid.actionPositive | typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss |} | + {| action: typeof DialogAndroid.actionPositive | typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral, checked: boolean |} > { return new Promise((resolve, reject) => { const nativeConfig: NativeConfig = { @@ -249,11 +258,11 @@ class DialogAndroid { return resolve({ action:DialogAndroid.actionDismiss }); } case 'onAny': { - const [ dialogAction ] = rest; + const [ dialogAction, checked ] = rest; switch (dialogAction) { - case 0: return resolve({ action:DialogAndroid.actionPositive }); - case 1: return resolve({ action:DialogAndroid.actionNeutral }); - case 2: return resolve({ action:DialogAndroid.actionNegative }); + case 0: return resolve({ action:DialogAndroid.actionPositive, ...getChecked(nativeConfig, checked) }); + case 1: return resolve({ action:DialogAndroid.actionNeutral, ...getChecked(nativeConfig, checked) }); + case 2: return resolve({ action:DialogAndroid.actionNegative, ...getChecked(nativeConfig, checked) }); } } default: { @@ -265,15 +274,12 @@ class DialogAndroid { } static showPicker(title: Title, content: Content, options: OptionsPicker): Promise< - {| - action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss - |} | {| - action: typeof DialogAndroid.actionSelect, - selectedItem: ListItem - |} | {| - action: typeof DialogAndroid.actionSelect, - selectedItems: ListItem[] - |} + {| action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss |} | + {| action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral, checked: boolean |} | + {| action: typeof DialogAndroid.actionSelect, selectedItem: ListItem |} | + {| action: typeof DialogAndroid.actionSelect, selectedItem: ListItem, checked: boolean |} | + {| action: typeof DialogAndroid.actionSelect, selectedItems: ListItem[] |} | + {| action: typeof DialogAndroid.actionSelect, selectedItems: ListItem[], checked: boolean |} > { // options is required, must defined items @@ -332,27 +338,23 @@ class DialogAndroid { return reject(`DialogAndroid ${error}. nativeConfig: ${nativeConfig}`); } case 'itemsCallbackMultiChoice': { - const selectedIndicesString = rest[0]; // blank string when nothing selected + const [selectedIndicesString, checked] = rest; // blank string when nothing selected const selectedItems = selectedIndicesString === '' ? [] : selectedIndicesString.split(',').map(index => items[index]); - return resolve({ action:DialogAndroid.actionPositive, selectedItems }); + return resolve({ action:DialogAndroid.actionPositive, selectedItems, ...getChecked(nativeConfig, checked) }); } case 'itemsCallback': case 'itemsCallbackSingleChoice': { - const [ selectedIndex, selectedLabel, isPromptCheckBoxChecked ] = rest; + const [ selectedIndex, checked ] = rest; const selectedItem = items[selectedIndex]; - return resolve({ - action: DialogAndroid.actionSelect, - selectedItem, - isPromptCheckBoxChecked - }); + return resolve({ action:DialogAndroid.actionSelect, selectedItem, ...getChecked(nativeConfig, checked) }); } case 'onAny': { - const [ dialogAction ] = rest; + const [ dialogAction, checked ] = rest; switch (dialogAction) { - case 0: return resolve({ action:DialogAndroid.actionPositive }); - case 1: return resolve({ action:DialogAndroid.actionNeutral }); - case 2: return resolve({ action:DialogAndroid.actionNegative }); + case 0: return resolve({ action:DialogAndroid.actionPositive, ...getChecked(nativeConfig, checked) }); + case 1: return resolve({ action:DialogAndroid.actionNeutral, ...getChecked(nativeConfig, checked) }); + case 2: return resolve({ action:DialogAndroid.actionNegative, ...getChecked(nativeConfig, checked) }); } } case 'dismissListener': { @@ -416,12 +418,10 @@ class DialogAndroid { } static prompt(title: Title, content: Content, options?: OptionsPrompt = {}): Promise< - {| - action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss - |} | {| - action: typeof DialogAndroid.actionPositive, - text: string - |} + {| action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral | typeof DialogAndroid.actionDismiss |} | + {| action: typeof DialogAndroid.actionNegative | typeof DialogAndroid.actionNeutral, checked: boolean |} | + {| action: typeof DialogAndroid.actionPositive, text: string |} | + {| action: typeof DialogAndroid.actionPositive, text: string, checked: boolean |} > { return new Promise((resolve, reject) => { @@ -462,15 +462,15 @@ class DialogAndroid { return reject(`DialogAndroid ${error}. nativeConfig: ${nativeConfig}`); } case 'onAny': { - const [ dialogAction ] = rest; + const [ dialogAction, checked ] = rest; switch (dialogAction) { - case 1: return resolve({ action:DialogAndroid.actionNeutral }); - case 2: return resolve({ action:DialogAndroid.actionNegative }); + case 1: return resolve({ action:DialogAndroid.actionNeutral, ...getChecked(nativeConfig, checked) }); + case 2: return resolve({ action:DialogAndroid.actionNegative, ...getChecked(nativeConfig, checked) }); } } case 'input': { - const [ text ] = rest; - return resolve({ action:DialogAndroid.actionPositive, text }); + const [ text, checked ] = rest; + return resolve({ action:DialogAndroid.actionPositive, text, ...getChecked(nativeConfig, checked) }); } case 'dismissListener': { return resolve({ action:DialogAndroid.actionDismiss }); @@ -489,4 +489,8 @@ class DialogAndroid { } } +function getChecked(nativeConfig, checked) { + return nativeConfig.checkboxLabel ? { checked } : {}; +} + export default DialogAndroid From b6e0b41890b9df68cf4461363fd23bd2a6e2efd2 Mon Sep 17 00:00:00 2001 From: Noitidart Date: Wed, 30 May 2018 22:10:53 -0700 Subject: [PATCH 4/5] Update README.md - adjust for js api --- README.md | 128 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index c9c7c06..99f2d67 100644 --- a/README.md +++ b/README.md @@ -216,16 +216,19 @@ The default options to be used by all methods. To modify this, either directly m > static alert( > title: Title, > content: Content, -> options: Options -> ): Promise<{| action: "actionDismiss" | "actionNegative" | "actionNeutral" | "actionPositive" |}> +> options: OptionsAlert +> ): Promise< +> {| action: "actionDismiss" | "actionNegative" | "actionNeutral" | "actionPositive" |} | +> {| action: "actionDismiss" | "actionNegative" | "actionNeutral" | "actionPositive", checked: boolean |} +> > Shows a dialog. -| Parameter | Type | Default | Required | Description | -|-----------|----------------------------------------|---------|----------|--------------------------------------------| -| title | `string, null, void` | | | Title of dialog | -| content | `string, null, void` | | | Message of dialog | -| options | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | +| Parameter | Type | Default | Required | Description | +|-----------|--------------------------------------|---------|----------|------------------------------------------| +| title | `string, null, void` | | | Title of dialog | +| content | `string, null, void` | | | Message of dialog | +| options | [`OptionsAlert`](#type-optionsalert) | | | See [`OptionsAlert`](#type-optionsalert) | ##### `assignDefaults` @@ -254,7 +257,9 @@ Hides the currently showing dialog. > options: OptionsPrompt > ): Promise< > {| action: "actionNegative" | "actionNeutral" | "actionDismiss" |} | -> {| action: "actionPositive", text: string |} +> {| action: "actionNegative" | "actionNeutral", checked: boolean |} | +> {| action: "actionPositive", text: string |} | +> {| action: "actionPositive", text: string, checked: boolean |} > > Shows a dialog with a text input field. @@ -273,8 +278,11 @@ Shows a dialog with a text input field. > options: OptionsPicker > ): Promise< > {| action: "actionNegative" | "actionNeutral" | "actionDismiss" |} | +> {| action: "actionNegative" | "actionNeutral" | "actionDismiss", checked: boolean |} | > {| action: "actionSelect", selectedItem: ListItem |} | -> {| action: "actionSelect", selectedItems: ListItem[] |} +> {| action: "actionSelect", selectedItem: ListItem, checked: boolean |} | +> {| action: "actionSelect", selectedItems: ListItem[] |} | +> {| action: "actionSelect", selectedItems: ListItem[], checked: boolean |} > > Shows a regular alert, but also with items that can be selected. @@ -323,6 +331,30 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt > "listCheckbox" | "listPlain" | "listRadio" +##### `type OptionsAlert` + +> { +> ...OptionsCommon, +> ...OptionsAlert +> } + +| Key | Type | Default | Required | Description | +|--------------------|--------------------------------------------|---------|----------|------------------------------------------------| +| ...OptionsCheckbox | [`OptionsCheckbox`](#type-optionscheckbox) | | | See [`OptionsCheckbox`](#type-optionscheckbox) | +| ...OptionsCommon | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | + +##### `type OptionsCheckbox` + +> { +> checkboxLabel?: string, +> checkboxDefaultValue?: boolean +> } + +| Key | Type | Default | Required | Description | +|----------------------|-----------|---------|----------|------------------------------------------------------------------------------------| +| checkboxLabel | `string` | | | If set, then there is a checkbox shown at the bottom of the dialog with this label | +| checkboxDefaultValue | `boolean` | `false` | | The initial state of the checkbox. Does nothing if `checkboxLabel` is not set | + ##### `type OptionsCommon` > { @@ -342,21 +374,21 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt > titleColor?: ColorValue, > } -| Key | Type | Default | Required | Description | -|---------------|----------------------------------------------------------------------------|---------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------| -| cancelable | `boolean` | | | If tapping outside of dialog area, or hardware back button, should dismiss dialog. | -| content | `string` | | | Dialog message | +| Key | Type | Default | Required | Description | +|---------------|--------------------------------------------------------------------------|---------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------| +| cancelable | `boolean` | | | If tapping outside of dialog area, or hardware back button, should dismiss dialog. | +| content | `string` | | | Dialog message | | contentColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of dialog message | -| contentIsHtml | `boolean` | | | If dialog message should be parsed as html. (supported tags include: ``, ``, etc) | -| forceStacking | `boolean` | | | If you have multiple action buttons that together are too wide to fit on one line, the dialog will stack the buttons to be vertically oriented. | +| contentIsHtml | `boolean` | | | If dialog message should be parsed as html. (supported tags include: ``, ``, etc) | +| forceStacking | `boolean` | | | If you have multiple action buttons that together are too wide to fit on one line, the dialog will stack the buttons to be vertically oriented. | | linkColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | If `contentIsHtml` is true, and `content` contains `` tags, these are colored with this color | | negativeColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | | -| negativeText | `string` | | | If falsy, button is not shown. | +| negativeText | `string` | | | If falsy, button is not shown. | | neutralColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | | -| neutralText | `string` | | | Shows button in far left with this string as label. If falsy, button is not shown. | +| neutralText | `string` | | | Shows button in far left with this string as label. If falsy, button is not shown. | | positiveColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | | -| positiveText | `string` | | | If falsy, button is not shown. | -| title | `string` | | | Title of dialog | +| positiveText | `string` | | | If falsy, button is not shown. | +| title | `string` | | | Title of dialog | | titleColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of title | ##### `type OptionsProgress` @@ -371,14 +403,14 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt > widgetColor: $PropertyType > } -| Key | Type | Default | Required | Description | -|---------------|----------------------------------------------------------------------------|---------|----------|----------------------------------------------------------| -| contentColor | [`OptionsCommon#contentColor`](#type-optionscommon) | | | See [`OptionsCommon#contentColor`](#type-optionscommon) | -| contentIsHtml | [`OptionsCommon#contentIsHtml`](#type-optionscommon) | | | See [`OptionsCommon#contentIsHtml`](#type-optionscommon) | -| linkColor | [`OptionsCommon#linkColor`](#type-optionscommon) | | | See [`OptionsCommon#linkColor`](#type-optionscommon) | -| style | [`ProgressStyle`](#type-ProgressStyle) | | | See [`ProgressStyle`](#type-progressstyle) | -| title | [`OptionsCommon#title`](#type-optionscommon) | | | See [`OptionsCommon#title`](#type-optionscommon) | -| titleColor | [`OptionsCommon#titleColor`](#type-optionscommon) | | | See [`OptionsCommon#titleColor`](#type-optionscommon) | +| Key | Type | Default | Required | Description | +|---------------|--------------------------------------------------------------------------|---------|----------|----------------------------------------------------------| +| contentColor | [`OptionsCommon#contentColor`](#type-optionscommon) | | | See [`OptionsCommon#contentColor`](#type-optionscommon) | +| contentIsHtml | [`OptionsCommon#contentIsHtml`](#type-optionscommon) | | | See [`OptionsCommon#contentIsHtml`](#type-optionscommon) | +| linkColor | [`OptionsCommon#linkColor`](#type-optionscommon) | | | See [`OptionsCommon#linkColor`](#type-optionscommon) | +| style | [`ProgressStyle`](#type-ProgressStyle) | | | See [`ProgressStyle`](#type-progressstyle) | +| title | [`OptionsCommon#title`](#type-optionscommon) | | | See [`OptionsCommon#title`](#type-optionscommon) | +| titleColor | [`OptionsCommon#titleColor`](#type-optionscommon) | | | See [`OptionsCommon#titleColor`](#type-optionscommon) | | widgetColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of progress indicator | ##### `type OptionsPicker` @@ -395,17 +427,18 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt > widgetColor?: ColorValue > } -| Key | Type | Default | Required | Description | -|----------------|----------------------------------------------------------------------------|---------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| OptionsCommon | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | -| idKey | `string` | "id" | | | -| items | [`ListItem`](#type-listitem)[] | | Yes | See [`ListItem`](#type-listitem) | -| labelKey | `string` | "label" | | | -| neutralIsClear | `boolean` | | | Pressing the neutral button causes the dialog to be closed and `selectedItems` to be an empty array. Only works if `neutralText` is also supplied. | -| selectedId | `any` | | | The respective radio will be selected on dialog show. If no such id is found, then nothing is selected. Only applicable if `type` is `DialogAndroid.listRadio`. Requires that `items[]` contain key described by `idKey`. | -| selectedIds | `any[]` | | | The respective checkbox will be selected on dialog show. If no such id is found, nothing is selected for that id. Only applicable if `type` is `DialogAndroid.listCheckbox`. Requires that `items[]` contain key described by `idKey`. | -| type | [`ListType`](#type-listtype) | `DialogAndroid.listPlain` | | See [`ListType`](#type-listtype) | -| widgetColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of radio or checkbox | +| Key | Type | Default | Required | Description | +|-----------------|--------------------------------------------------------------------------|---------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| OptionsCheckbox | [`OptionsCheckbox`](#type-optionscheckbox) | | | See [`OptionsCheckbox`](#type-optionscheckbox) | +| OptionsCommon | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | +| idKey | `string` | "id" | | | +| items | [`ListItem`](#type-listitem)[] | | Yes | See [`ListItem`](#type-listitem) | +| labelKey | `string` | "label" | | | +| neutralIsClear | `boolean` | | | Pressing the neutral button causes the dialog to be closed and `selectedItems` to be an empty array. Only works if `neutralText` is also supplied. | +| selectedId | `any` | | | The respective radio will be selected on dialog show. If no such id is found, then nothing is selected. Only applicable if `type` is `DialogAndroid.listRadio`. Requires that `items[]` contain key described by `idKey`. | +| selectedIds | `any[]` | | | The respective checkbox will be selected on dialog show. If no such id is found, nothing is selected for that id. Only applicable if `type` is `DialogAndroid.listCheckbox`. Requires that `items[]` contain key described by `idKey`. | +| type | [`ListType`](#type-listtype) | `DialogAndroid.listPlain` | | See [`ListType`](#type-listtype) | +| widgetColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of radio or checkbox | ##### `type OptionsPrompt` @@ -414,10 +447,11 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt > widgetColor?: ColorValue > } -| Key | Type | Default | Required | Description | -|---------------|----------------------------------------------------------------------------|---------|----------|--------------------------------------------| -| OptionsCommon | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | -| widgetColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of field underline and cursor | +| Key | Type | Default | Required | Description | +|-----------------|--------------------------------------------------------------------------|---------|----------|------------------------------------------------| +| OptionsCheckbox | [`OptionsCheckbox`](#type-optionscheckbox) | | | See [`OptionsCheckbox`](#type-optionscheckbox) | +| OptionsCommon | [`OptionsCommon`](#type-optionscommon) | | | See [`OptionsCommon`](#type-optionscommon) | +| widgetColor | [`ColorValue`](https://facebook.github.io/react-native/docs/colors.html) | | | Color of field underline and cursor | ##### `type ProgressStyle` @@ -602,11 +636,11 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds -| [
Vojtech Novak](https://github.com/vonovak)
[💬](#question-vonovak "Answering Questions") [💻](https://github.com/aakashns/react-native-dialogs/commits?author=vonovak "Code") [🤔](#ideas-vonovak "Ideas, Planning, & Feedback") [👀](#review-vonovak "Reviewed Pull Requests") | [
Noitidart](http://noitidart.github.io/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Noitidart "Code") [📖](https://github.com/aakashns/react-native-dialogs/commits?author=Noitidart "Documentation") [💡](#example-Noitidart "Examples") [🤔](#ideas-Noitidart "Ideas, Planning, & Feedback") | [
Alisson Carvalho](http://alissoncs.com)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=alissoncs "Code") | [
Anthony Ou](https://github.com/Anthonyzou)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Anthonyzou "Code") | [
Ashley White](http://ashleyd.ws)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=ashleydw "Code") | [
Bee](https://github.com/1ne8ight7even)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=1ne8ight7even "Code") | [
BrianSo](https://github.com/BrianSo)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=BrianSo "Code") | -| :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Byron Wang](https://github.com/byronpc)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=byronpc "Code") | [
Farzad Abdolhosseini](https://github.com/farzadab)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=farzadab "Code") | [
Geoffrey Goh](https://github.com/geof90)
[🐛](https://github.com/aakashns/react-native-dialogs/issues?q=author%3Ageof90 "Bug reports") [💻](https://github.com/aakashns/react-native-dialogs/commits?author=geof90 "Code") | [
Gustavo FĂŁo Valvassori](http://gustavofao.com/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=faogustavo "Code") [🤔](#ideas-faogustavo "Ideas, Planning, & Feedback") | [
Henrik](https://github.com/Henreich)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=Henreich "Documentation") | [
heydabop](https://github.com/heydabop)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=heydabop "Code") | [
Huang Yu](https://github.com/hyugit)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=hyugit "Code") | -| [
Iragne](http://pcdn.jairagne.ovh)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Iragne "Code") | [
Janic Duplessis](https://medium.com/@janicduplessis)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=janicduplessis "Code") | [
jeffchienzabinet](https://github.com/jeffchienzabinet)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=jeffchienzabinet "Code") | [
Jeremy Dagorn](http://www.jeremydagorn.com)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=jrm2k6 "Documentation") | [
jykun](https://github.com/jykun)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=jykun "Code") | [
Mattias Pfeiffer](http://pfeiffer.dk)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=pfeiffer "Documentation") | [
pureday](https://github.com/lakeoffaith)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=lakeoffaith "Documentation") | -| [
Radek Czemerys](https://twitter.com/radko93)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=radko93 "Code") | [
Ricardo Fuhrmann](https://github.com/Fuhrmann)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=Fuhrmann "Documentation") | [
Ross](https://thebhwgroup.com/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=rdixonbhw "Code") | [
Vinicius Zaramella](http://programei.com)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=vzaramel "Code") | +| [
Vojtech Novak](https://github.com/vonovak)
[💬](#question-vonovak "Answering Questions") [💻](https://github.com/aakashns/react-native-dialogs/commits?author=vonovak "Code") [🤔](#ideas-vonovak "Ideas, Planning, & Feedback") [👀](#review-vonovak "Reviewed Pull Requests") | [
Noitidart](http://noitidart.github.io/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Noitidart "Code") [📖](https://github.com/aakashns/react-native-dialogs/commits?author=Noitidart "Documentation") [💡](#example-Noitidart "Examples") [🤔](#ideas-Noitidart "Ideas, Planning, & Feedback") | [
Alisson Carvalho](http://alissoncs.com)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=alissoncs "Code") | [
Anthony Ou](https://github.com/Anthonyzou)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Anthonyzou "Code") | [
Ashley White](http://ashleyd.ws)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=ashleydw "Code") | [
Bee](https://github.com/1ne8ight7even)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=1ne8ight7even "Code") | [
BrianSo](https://github.com/BrianSo)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=BrianSo "Code") | +|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| [
Byron Wang](https://github.com/byronpc)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=byronpc "Code") | [
Farzad Abdolhosseini](https://github.com/farzadab)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=farzadab "Code") | [
Geoffrey Goh](https://github.com/geof90)
[🐛](https://github.com/aakashns/react-native-dialogs/issues?q=author%3Ageof90 "Bug reports") [💻](https://github.com/aakashns/react-native-dialogs/commits?author=geof90 "Code") | [
Gustavo FĂŁo Valvassori](http://gustavofao.com/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=faogustavo "Code") [🤔](#ideas-faogustavo "Ideas, Planning, & Feedback") | [
Henrik](https://github.com/Henreich)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=Henreich "Documentation") | [
heydabop](https://github.com/heydabop)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=heydabop "Code") | [
Huang Yu](https://github.com/hyugit)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=hyugit "Code") | +| [
Iragne](http://pcdn.jairagne.ovh)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=Iragne "Code") | [
Janic Duplessis](https://medium.com/@janicduplessis)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=janicduplessis "Code") | [
jeffchienzabinet](https://github.com/jeffchienzabinet)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=jeffchienzabinet "Code") | [
Jeremy Dagorn](http://www.jeremydagorn.com)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=jrm2k6 "Documentation") | [
jykun](https://github.com/jykun)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=jykun "Code") | [
Mattias Pfeiffer](http://pfeiffer.dk)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=pfeiffer "Documentation") | [
pureday](https://github.com/lakeoffaith)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=lakeoffaith "Documentation") | +| [
Radek Czemerys](https://twitter.com/radko93)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=radko93 "Code") | [
Ricardo Fuhrmann](https://github.com/Fuhrmann)
[📖](https://github.com/aakashns/react-native-dialogs/commits?author=Fuhrmann "Documentation") | [
Ross](https://thebhwgroup.com/)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=rdixonbhw "Code") | [
Vinicius Zaramella](http://programei.com)
[💻](https://github.com/aakashns/react-native-dialogs/commits?author=vzaramel "Code") | | | | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From ee616a5b944b5dfe7f0c4121ec2c5868741f8071 Mon Sep 17 00:00:00 2001 From: Noitidart Date: Wed, 30 May 2018 22:32:55 -0700 Subject: [PATCH 5/5] update table of contents and note about where to so examples with checkboxes --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 99f2d67..9eebec8 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ An Android only module for Material Design dialogs. This is a wrapper over [afol - [`type ActionType`](#type-actiontype) - [`type ListItem`](#type-listitem) - [`type ListType`](#type-listtype) + - [`type OptionsAlert`](#type-optionsalert) + - [`type OptionsCheckbox`](#type-optionscheckbox) - [`type OptionsCommon`](#type-optionscommon) - [`type OptionsProgress`](#type-optionsprogress) - [`type OptionsPicker`](#type-optionspicker) @@ -459,6 +461,8 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt ### Examples +To see the examples redone with `checkboxLabel` see this PR - [Github :: aakashns/react-native-dialogs - #86](https://github.com/aakashns/react-native-dialogs/pull/86#issuecomment-393408317) + #### Progress Dialog ![](https://github.com/aakashns/react-native-dialogs/blob/master/screenshots/progress-bar.png)