Giter Club home page Giter Club logo

react-native-dialogs's Introduction

react-native-dialogs

All Contributors

An Android only module for Material Design dialogs. This is a wrapper over afollestad/material-dialogs. This module is designed for Android only with no plans to support iOS.

Table of Contents

Installation

  1. Install:

    • Using npm: npm install react-native-dialogs --save
    • Using Yarn: yarn add react-native-dialogs
  2. Link:

    • react-native link react-native-dialogs
    • Or if this fails, link manually using these steps
  3. Compile application using react-native run-android

Manual Linking

Follow these steps if automatic linking (react-native link) failed.

  1. In android/app/build.gradle, add the dependency to your app build:

    dependencies {
        ...
        compile project(':react-native-dialogs') // Add this
    }
    
  2. In android/build.gradle, it should already be there, but in case it is not, add Jitpack maven repository to download the library afollestad/material-dialogs:

    allprojects {
        repositories {
            ...
            jcenter() // Add this if it is not already here
            ...
        }
    }
    
  3. In android/settings.gradle:

    rootProject.name = ...
    ...
    include ':react-native-dialogs' // Add this
    project(':react-native-dialogs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dialogs/android') // Add this
    
    ...
    include ':app'
    
  4. Import and add package, in android/app/src/main/.../MainApplication.java:

    ...
    import android.app.Application;
    ...
    
    import com.aakashns.reactnativedialogs.ReactNativeDialogsPackage; // Add new import
    
    ...
    
    public class MainApplication extends Application implements ReactApplication {
      ...
      @Override
      protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          ...
          new ReactNativeDialogsPackage() // Add the package here
        );
      }
    }

Usage

  1. Import it in your JS:

    import DialogAndroid from 'react-native-dialogs';
  2. Call API:

    class Blah extends Component {
        render() {
            return <Button title="Show DialogAndroid" onPress={this.showDialogAndroid} />
        }
    
        showDialogAndroid = async () => {
            const { action } = await DialogAndroid.alert('Title', 'Message');
            switch (action) {
                case DialogAndroid.actionPositive:
                    console.log('positive!')
                    break;
                case DialogAndroid.actionNegative:
                    console.log('negative!')
                    break;
                case DialogAndroid.actionNeutral:
                    console.log('neutral!')
                    break;
                case DialogAndroid.actionDismiss:
                    console.log('dismissed!')
                    break;
            }
        }
    }

API

Properties

defaults

{ positiveText: 'OK' }

The default options to be used by all methods. To modify this, either directly manipulate with DialogAndroid.defaults = { ... } or use assignDefaults

actionDismiss

static actionDismiss = "actionDismiss"

actionNegative

static actionNegative = "actionNegative"

actionNeutral

static actionNeutral = "actionNeutral"

actionPositive

static actionPositive = "actionPositive"

listPlain

static listPlain = "listPlain"

listRadio

static listRadio = "listRadio"

listCheckbox

static listCheckbox = "listCheckbox"

progressHorizontal

static progressHorizontal = "progressHorizontal"

Methods

alert
static alert(
    title: Title,
    content: Content,
    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 OptionsAlert See OptionsAlert
assignDefaults
static assignDefaults({
    [string]: value
): void

Set default colors for example, so you don't have to provide it on every method call.

{ positiveText: 'OK' }

dismiss
static dismiss(): void

Hides the currently showing dialog.

prompt
static prompt(
    title?: null | string,
    content?: null | string,
    options: OptionsPrompt
): Promise<
    {| action: "actionNegative" | "actionNeutral" | "actionDismiss" |} |
    {| action: "actionNegative" | "actionNeutral", checked: boolean |} |
    {| action: "actionPositive", text: string |} |
    {| action: "actionPositive", text: string, checked: boolean |}
>

Shows a dialog with a text input field.

Parameter Type Default Required Description
title string, null, void Title of dialog
content string, null, void Message of dialog
options OptionsPrompt See OptionsPrompt
showPicker
static showPicker(
    title?: null | string,
    content?: null | string,
    options: OptionsPicker
): Promise<
    {| action: "actionNegative" | "actionNeutral" | "actionDismiss" |} |
    {| action: "actionNegative" | "actionNeutral" | "actionDismiss", checked: boolean |} |
    {| action: "actionSelect", selectedItem: 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.

Parameter Type Default Required Description
title string, null, void Title of dialog
content string, null, void Message of dialog
options OptionsPicker See OptionsPrompt
showProgress
static showProgress(
    content?: null | string,
    options: OptionsProgress
): Promise<{| action:"actionDismiss" |}>

Shows a progress dialog. By default no buttons are shown, and hardware back button does not close it. You must close it with DialogAndroid.dismiss().

Parameter Type Default Required Description
content string, null, void Message of dialog
options OptionsProgress See OptionsPrompt

Types

Flow is used as the typing system.

Internal Types

type ActionType
"actionDismiss" | "actionNegative" | "actionNeutral" | "actionPositive" | "actionSelect"
type ListItem
{ label:string } | { label:string, id:any } | {}

Notes

  • If label key does not exist, specify which key should be used as the label with labelKey property of OptionsPicker.
  • id is only required if selectedId/selectedIds needs to be used.
    • If id key does not exist, specify which key should be used as the id with idKey property of OptionsPicker.
type ListType
"listCheckbox" | "listPlain" | "listRadio"
type OptionsAlert
{
    ...OptionsCommon
}
Key Type Default Required Description
...OptionsCommon OptionsCommon See OptionsCommon
type OptionsCommon
{
    cancelable?: boolean,
    checkboxDefaultValue?: boolean
    checkboxLabel?: string,
    content?: string,
    contentColor?: string,
    contentIsHtml?: boolean,
    forceStacking?: boolean,
    linkColor?: ColorValue,
    negativeColor?: ColorValue,
    negativeText?: string,
    neutralColor?: ColorValue,
    neutralText?: string,
    positiveColor?: ColorValue,
    positiveText?: string, // default "OK"
    backgroundColor?: ColorValue,
    title?: string,
    titleColor?: ColorValue,
}
Key Type Default Required Description
cancelable boolean If tapping outside of dialog area, or hardware back button, should dismiss dialog.
checkboxDefaultValue boolean false The initial state of the checkbox. Does nothing if checkboxLabel is not set.
checkboxLabel string If set, then there is a checkbox shown at the bottom of the dialog with this label
content string Dialog message
contentColor ColorValue Color of dialog message
contentIsHtml boolean If dialog message should be parsed as html. (supported tags include: <a>, <img>, 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 If contentIsHtml is true, and content contains <a> tags, these are colored with this color
negativeColor ColorValue
negativeText string If falsy, button is not shown.
neutralColor ColorValue
neutralText string Shows button in far left with this string as label. If falsy, button is not shown.
positiveColor ColorValue
positiveText string If falsy, button is not shown.
backgroundColor ColorValue
title string Title of dialog
titleColor ColorValue Color of title
type OptionsProgress
{
    contentColor: $PropertyType<OptionsCommon, 'contentColor'>,
    contentIsHtml: $PropertyType<OptionsCommon, 'contentIsHtml'>,
    linkColor: $PropertyType<OptionsCommon, 'linkColor'>,
    style?: ProgressStyle,
    title: $PropertyType<OptionsCommon, 'title'>,
    titleColor: $PropertyType<OptionsCommon, 'titleColor'>',
    widgetColor: $PropertyType<OptionsCommon, 'widgetColor'>
}
Key Type Default Required Description
contentColor OptionsCommon#contentColor See OptionsCommon#contentColor
contentIsHtml OptionsCommon#contentIsHtml See OptionsCommon#contentIsHtml
linkColor OptionsCommon#linkColor See OptionsCommon#linkColor
style ProgressStyle See ProgressStyle
title OptionsCommon#title See OptionsCommon#title
titleColor OptionsCommon#titleColor See OptionsCommon#titleColor
widgetColor ColorValue Color of progress indicator
type OptionsPicker

{| ...OptionsCommon, type?: typeof ListType.listPlain, maxNumberOfItems?: number, items: ListItemJustLabel[], |} | {| ...OptionsCommon, type?: typeof ListType.listPlain, maxNumberOfItems?: number, items: ListItemBare[], labelKey: string |} | {| // radio - no preselected ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemJustLabel[], |} | {| // radio - no preselected ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemBare[], labelKey: string |} | {| // radio - preselected - ListItemFull ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemFull[], selectedId: any |} | {| // radio - preselected - ListItemJustlabel ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemJustLabel[], idKey: string, selectedId: any |} | {| // radio - preselected - ListItemJustId ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemJustId[], labelKey: string, selectedId: any |} | {| // radio - preselected - ListItemBare ...OptionsCommon, type: typeof ListType.listRadio, widgetColor?: ColorValue // radio color items: ListItemBare[], idKey: string, labelKey: string, selectedId: any |} | {| // checklist - no preselected - ListItemJustLabel ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemJustLabel[] |} | {| // checklist - no preselected - ListItemBare ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemBare[], labelKey: string |} | {| // checklist - preselected - ListItemFull ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemFull[], selectedIds: any[] |} | {| // checklist - preselected - ListItemJustlabel ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemJustLabel[], idKey: string, selectedIds: any |} | {| // checklist - preselected - ListItemJustId ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemJustId[], labelKey: string, selectedIds: any |} | {| // checklist - preselected - ListItemBare ...OptionsCommon, type: typeof ListType.listCheckbox, neutralIsClear?: boolean, widgetColor?: ColorValue, // checkbox color items: ListItemBare[], idKey: string, labelKey: string, selectedIds: any |}

Key Type Default Required Description
OptionsCommon OptionsCommon See OptionsCommon
idKey string "id"
items ListItem[] Yes See ListItem
labelKey string "label"
maxNumberOfItems number If you want to set a max amount of visible items in a list
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 DialogAndroid.listPlain See ListType
widgetColor ColorValue Color of radio or checkbox
type OptionsPrompt
{
    ...OptionsCommon,
    keyboardType?:
      | 'numeric'
      | 'number-pad'
      | 'numeric-password'
      | 'decimal-pad'
      | 'email-address'
      | 'password'
      | 'phone-pad'
      | 'url',
    defaultValue?: string,
    placeholder?: string,
    allowEmptyInput?: boolean,
    minLength?: number,
    maxLength?: number,
    widgetColor?: ColorValue
}
Key Type Default Required Description
OptionsCommon OptionsCommon See OptionsCommon
widgetColor ColorValue Color of field underline and cursor
type ProgressStyle
"progressHorizontal"

Examples

To see the examples redone with checkboxLabel see this PR - Github :: aakashns/react-native-dialogs - #86

Progress Dialog

DialogAndroid.showProgress('Downloading...', {
    style: DialogAndroid.progressHorizontal // omit this to get circular
});
setTimeout(DialogAndroid.dismiss, 5000);

Basic List

const { selectedItem } = await DialogAndroid.showPicker('Pick a fruit', null, {
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});
if (selectedItem) {
    // when negative button is clicked, selectedItem is not present, so it doesn't get here
    console.log('You selected item:', selectedItem);
}

Radio List

Set positiveText to null for auto-dismiss behavior on press of a radio button item.

const { selectedItem } = await DialogAndroid.showPicker('Pick a fruit', null, {
    // positiveText: null, // if positiveText is null, then on select of item, it dismisses dialog
    negativeText: 'Cancel',
    type: DialogAndroid.listRadio,
    selectedId: 'apple',
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});
if (selectedItem) {
    // when negative button is clicked, selectedItem is not present, so it doesn't get here
    console.log('You picked:', selectedItem);
}
Without auto-dismiss

Here we pass in a string to positiveText, this prevents the auto-dismiss on select of a radio item.

const { selectedItem } = await DialogAndroid.showPicker('Pick a fruit', null, {
    positiveText: 'OK', // this is what makes disables auto dismiss
    negativeText: 'Cancel',
    type: DialogAndroid.listRadio,
    selectedId: 'apple',
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});
if (selectedItem) {
    // when negative button is clicked, selectedItem is not present, so it doesn't get here
    console.log('You picked:', selectedItem);
}

Checklist

const { selectedItems } = await DialogAndroid.showPicker('Select multiple fruits', null, {
    type: DialogAndroid.listCheckbox,
    selectedIds: ['apple', 'orange'],
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});
if (selectedItems) {
    if (!selectedItems.length) {
        console.log('You selected no items.');
    } else {
        console.log('You selected items:', selectedItems);
    }
}
With clear list button

We can make the neutral button be a special button. Pressing it will clear the list and close the dialog. If you want this behavior, set neutralIsClear to true and also set neutralText to a string. Both of these properties must be set.

const { selectedItems } = await DialogAndroid.showPicker('Select multiple fruits', null, {
    type: DialogAndroid.listCheckbox,
    selectedIds: ['apple', 'orange'],
    neutralIsClear: true, /////// added this
    neutralText: 'Clear', /////// added this
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});
if (selectedItems) {
    if (!selectedItems.length) {
        console.log('You selected no items.');
    } else {
        console.log('You selected items:', selectedItems);
    }
}

Prompt

const { action, text } = await DialogAndroid.prompt('Title - optional', 'Message - optional');
if (action === DialogAndroid.actionPositive) {
    console.log(`You submitted: "${text}"`);
}

HTML

DialogAndroid.alert('Title', `This is a link <a href="https://www.duckduckgo.com/">DuckDuckGo</a>`, {
    contentIsHtml: true
});

assignDefaults

You can set some defaults so you don't have to change it everytime.

DialogAndroid.assignDefaults({
    title: 'Default Title',
    positiveText: null,
    contentColor: 'rgba(0, 0, 0, 0.2)',
    widgetColor: 'blue'
})

Now any time you omit or pass undefined to contentColor, widgetColor, or title, it will use the defaults we assigned here.

DialogAndroid.alert(undefined, 'message here')

This will show title "Default Title", with no positive button, and the color of the message will be 20% black. If you did Dialog.showProgress, the progress indicator would be blue. etc.

Contributors

Thanks goes to these wonderful people (emoji key):


Vojtech Novak

💬 💻 🤔 👀

Noitidart

💻 📖 💡 🤔

Alisson Carvalho

💻

Anthony Ou

💻

Ashley White

💻

Bee

💻

BrianSo

💻

Byron Wang

💻

Farzad Abdolhosseini

💻

Geoffrey Goh

🐛 💻

Gustavo Fão Valvassori

💻 🤔

Henrik

📖

heydabop

💻

Huang Yu

💻

Iragne

💻

Janic Duplessis

💻

jeffchienzabinet

💻

Jeremy Dagorn

📖

jykun

💻

Mattias Pfeiffer

📖

pureday

📖

Radek Czemerys

💻

Ricardo Fuhrmann

📖

Ross

💻

Vinicius Zaramella

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

react-native-dialogs's People

Contributors

aakashns avatar anthonyzou avatar blaues0cke avatar brianso avatar byronpc avatar dependabot[bot] avatar faogustavo avatar farzadab avatar frozenpear42 avatar fuhrmann avatar geof90 avatar hsjoberg avatar iggyfisk avatar iragne avatar jamiesanerd avatar janczer avatar janicduplessis avatar jbazant avatar jeffchienzabinet avatar jrm2k6 avatar lewnelson avatar noitidart avatar pfeiffer avatar phecda avatar radko93 avatar rdixonbhw avatar svbutko avatar vonovak avatar vzaramel avatar white-ubuntu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-dialogs's Issues

IncompatibleClassChangeError during compilation after adding the package

I added this package to my app and when I run command react-native run-android to compile and run the app for Android, it ends with the below exception

java.lang.IncompatibleClassChangeError: The method 
     'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' 
     was expected to be of type virtual but instead was found to be of type direct 

This error is showing up for a different package react-native-push-notification but it is happening due to a mismatch between the com.android.support libraries. The default one included in react-native project is v23.0.1 but the one included in the underlying material-dialogs package is v24.2.0. This is causing the problem while compiling the app. There are multiple questions on stackoverflow regarding similar error which seem to suggest to downgrade the version to v23 but I am not sure how to do it as the material-dialogs package is downloaded during build and is present in some gradle repository location.

Is it possible to downgrade the com.android.support used material-dialogs or if someone has come across this problem and were able to solve it, please share.

React-native 0.14 support

Hello, and thanks for your amazing work.
Is there any plan for supporting react-native 0.14? The package itself fails to install due to peerDependencies not satisfied.

HTML in dialog content

How to use HTML in dialog content? Android dialogs support HTML by using Html.fromHtml - https://stackoverflow.com/a/14652941/1828637 - and it seems afollestad/material-dialogs does use Html.fromHtml - https://github.com/afollestad/material-dialogs/search?utf8=%E2%9C%93&q=fromHtml&type=

However doing this is not working:

const dialog = new DialogAndroid();
dialog.set({
    title: 'Testing HTML',
    content: 'html <br/><a href="#">link me</a>?',
    positiveText: 'OK',
    negativeText: 'Cancel'
})
dialog.show();

My goal is to create dialog like this with a drop down, which expands to second image:

Failed to generate resource table for split ''

Hi,

I'm having a strange issue coming of nowhere when compiling the project. It has been working well so far until today where this error came up:

Unknown source file : Failed to generate resource table for split ''
/home/cloud/Escritorio/mobile_android/node_modules/react-native-dialogs/android/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.0/res/values-v11/values-v11.xml:17:54-92 : No resource found that matches the given name (at 'android:actionModeCloseDrawable' with value '@drawable/abc_ic_ab_back_mtrl_am_alpha').

EDIT: It comes from the afollestad library

It has been solved here: issue

Could you fix the issue on the lib please?

That would be great, thanks :)

Changes needed for gradle 3.0.1 compatibility

Some minor changes are needed for gradle 3.0.1 compatibility: in android/build.gradle:

We are currently hacking these changes with a script in status.im, and would rather it is fixed upstream. Thanks!

Parent issue: status-im/status-mobile#3037

Build error on react-native 0.14.2

ReadableMapKeySeyIterator is changed to ReadableMapKeySetIterator on react-native 0.14.2
facebook/react-native#3540

So I got this error below.
After changed the class name on DialogAndroid.java file, it worked.

/Users/james/Dropbox/Development/react/Builder/node_modules/react-native-dialogs/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java:15: error: cannot find symbol
import com.facebook.react.bridge.ReadableMapKeySeyIterator;
^
symbol: class ReadableMapKeySeyIterator
location: package com.facebook.react.bridge
/Users/james/Dropbox/Development/react/Builder/node_modules/react-native-dialogs/android/src/main/java/com/aakashns/reactnativedialogs/modules/DialogAndroid.java:40: error: cannot find symbol
ReadableMapKeySeyIterator iterator = options.keySetIterator();
^
symbol: class ReadableMapKeySeyIterator
location: class DialogAndroid
2 errors

facebook/react-native#3540

readme no match the react-native-dialogs version

The readme prepares for the 1.0.0. but the result is 0.0.21 when i yarn add react-native-dialogs.
It works when i replace the DialogsAndroid.js && DialogsAndroid.java && build.gradle in the node_modules

Getting build error with RN version 0.27

Hi, I m getting the following build error in a project having multiple dependencies,
MainActivity.java:42: error: method does not override or implement a method from a supertype @Override ^1 error :app:compileDebugJavaWithJavac FAILED

I suspect this is due to - this. This should be related to RN 0.29 breaking changes regarding android template - here. Since the plugin downloads latest version of RN jar to compile against, it forces the app to compile with it, which breaks due to changes (third party plugins now no longer added in Activity, but new App file which extend android.app.Application and implement ReactApplication)

Going on, if any user decides to use RN 0.29 , I don't see any problem in using this, but in case he decides to use lesser version, the build would fail. Can you check please ? Thanks.

prefill radio

I am trying to set a default selection for a single choice list. I am trying this with no luck

  var options = {
            items: ['Data Entry', 'Notes', 'Take Picture'],
            positiveText: "Select",
            negativeText: "Cancel",
            title: this.state.selectedSubdivision.subdivisionName,
            input: { prefill: '0'},
            itemsCallbackSingleChoice: _menuSelect
        };

Crash on app load

After installing this package the app builds, but crashes on load with the following error:

09-18 12:19:00.442 7174-7211/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
                                                 Process: com.app, PID: 7174
                                                 java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/com.app-1/base.apk)
                                                     at com.google.android.gms.iid.zzd.zzdo(Unknown Source)
                                                     at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                     at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                     at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
                                                     at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
                                                     at com.learnium.RNDeviceInfo.RNDeviceModule.getConstants(RNDeviceModule.java:112)
                                                     at com.facebook.react.bridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:140)
                                                     at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                     at android.os.Handler.handleCallback(Handler.java:751)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
                                                     at android.os.Looper.loop(Looper.java:154)
                                                     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
                                                     at java.lang.Thread.run(Thread.java:761)

Using react-native 0.48.1 and react-native-dialogs 0.0.19

Can get the app to run properly by removing the react-native link generated code, but then obviously, I can't use the package.

Any idea what is wrong? I know nothing about developing for Android.

undefined is not an object

By calling
dialog.show({});

In DialogAndroid.js line 67
NativeModules.DialogAndroid.show(finalOptions, callbackFunc);

says undefined is not an object.

seems NativeModules.DialogAndroid is deprecated?

App crashes: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.getColor(int)' on a null object reference

I have used this module in an app and some times it gives me following error:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.getColor(int)' on a null object reference
at com.afollestad.materialdialogs.util.DialogUtils.getColor(DialogUtils.java:115)
at com.afollestad.materialdialogs.MaterialDialog$Builder.(MaterialDialog.java:477)
at com.aakashns.reactnativedialogs.modules.DialogAndroid.show(DialogAndroid.java:119)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:271)
at com.facebook.react.bridge.NativeModuleRegistry$ModuleDefinition.call(NativeModuleRegistry.java:183)
at com.facebook.react.bridge.NativeModuleRegistry.call(NativeModuleRegistry.java:62)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeModulesReactCallback.call(CatalystInstanceImpl.java:421)
at com.facebook.react.bridge.queue.NativeRunnableDeprecated.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:187)
at java.lang.Thread.run(Thread.java:818)

I have found following link which may be helpful:
domoticz/domoticz-android#267

Superb!

This is absolute superb, I just wanted to post saying thank you for this!!! I was always looking for something like this. Way looking forward to one day being able to one-to-one what afollestad/material-dialogs package can do.

How to uninstall

Im trying to uninstall this library by the following command:
npm uninstall react-native-dialogs

but after uninstalling when I'm trying to run the project it giving me the it following error:

err

Unable to show plain list using showPicker API

I am using the showPicker API to show a list of things. I want to show them in a plain list without checkboxes or radio buttons but showPicker show the list with checkboxes when I don't specify a type or specify the type as DialogAndroid.listPlain. I used the example in the README also

const { selectedItem } = await DialogAndroid.showPicker('Pick a fruit', null, {
    items: [
        { label:'Apple', id:'apple' },
        { label:'Orange', id:'orange' },
        { label:'Pear', id:'pear' }
    ]
});

and it rendered the below dialog box:
screen shot 2018-07-24 at 11 57 35 pm

RNPM install doesn't work

I don't know if it's a problem of rnpm or react-native-dialogs but NativeModules.DialogAndroid is not present after rnpm-link

react-native 0.56 compatibility

Сan't build release app without manually changing compileSdkVersion and targetSdkVersion to 26 and buildToolsVersion to "26.0.2"

'The callback show() exists in module DialogAndroid...'

'...but only one callback may be registered to a function in a native module'

I keep getting this error. My configuration looks like this

const dialog = new DialogAndroid();
let newColumnName = this.state[columnName];
dialog.set({
  negativeText: 'Cancel',
  positiveText: 'Ok',
  onPositive: () => {
    if (this.state[columnName] !== newColumnName) {
      this.patchInvoice({ [columnName]: newColumnName });
    }
  },
  title,
  input: {
    prefill: newColumnName,
    allowEmptyInput: false,
    callback: (nextValue) => {
      newColumnName = nextValue;
    },
  },
  alwaysCallInputCallback: true,
});
dialog.show();

Build Failed, Could not find :react-native-dialogs:

* What went wrong:          
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find :react-native-dialogs:.
     Searched in the following locations:
         file:/C:/Users/gamat/.m2/repository//react-native-dialogs//react-native-dialogs-.pom
         file:/C:/Users/gamat/.m2/repository//react-native-dialogs//react-native-dialogs-.jar
         https://jcenter.bintray.com//react-native-dialogs//react-native-dialogs-.pom
         https://jcenter.bintray.com//react-native-dialogs//react-native-dialogs-.jar
         https://jitpack.io//react-native-dialogs//react-native-dialogs-.pom
         https://jitpack.io//react-native-dialogs//react-native-dialogs-.jar
         file:/S:/Development/dinpromobile/node_modules/react-native/android//react-native-dialogs//react-native-dialogs-.pom
         file:/S:/Development/dinpromobile/node_modules/react-native/android//react-native-dialogs//react-native-dialogs-.jar
         file:/S:/Program Files (x86)/Android/android-sdk/extras/android/m2repository//react-native-dialogs//react-native-dialogs-.pom
         file:/S:/Program Files (x86)/Android/android-sdk/extras/android/m2repository//react-native-dialogs//react-native-dialogs-.jar
         file:/S:/Program Files (x86)/Android/android-sdk/extras/google/m2repository//react-native-dialogs//react-native-dialogs-.pom
         file:/S:/Program Files (x86)/Android/android-sdk/extras/google/m2repository//react-native-dialogs//react-native-dialogs-.jar
     Required by:

Can´t build my Android project

I receive following error output:

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.github.afollestad.material-dialogs:commons:8f8ab21.

Illegal callback invocation from native module error

I am observing the below error which leads to a crash in the app.

screen shot 2017-03-17 at 12 05 44 pm

Below is the excerpt from code where the error is happening

if (options.hasKey("cancelListener")) {
            mBuilder.cancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    callback.invoke("cancelListener");
                }
            });
        }

This error is occurring when a dialog box is shown on the app and the user presses the home screen and then go back into the app after some time and try to click on any of the options in the dialog box.

InputDialog with type password?

From the documentation I've read, I can set input type with other like TYPE_TEXT_VARIATION_PASSWORD. But I can't figure out how to do this on JS because type just accept integer value.

new MaterialDialog.Builder(this)
        .title(R.string.input)
        .content(R.string.input_content)
        .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
        .input(R.string.input_hint, R.string.input_prefill, new MaterialDialog.InputCallback() {
            @Override
            public void onInput(MaterialDialog dialog, CharSequence input) {
                // Do something
            }
        }).show();

Below is my JS:

const options = {
      input: {
        hint: 'foobar',
        prefill: category.name,
        type: ?? // How to set type as password?
        callback: (value) => {
          this.password= value
        }
      },
      positiveText: 'Update',
      onPositive: () => {
        const newState= React.addons.update(this.state.users, {
          [userIndex]: { name: { $set: this.password } }
        })
        this.setState({ newState })
      }
    }

Require at least 1 or X for single/multi?

Is it possible to require a selection, or X selections for single and multi? Similar to not allowing empty input, which even has added bonus of making the "ok" button disable or not.

Build failed with an exception

I got the following error if i build my app:

android/app/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/8f8ab21/res/values-v11/values-v11.xml:17:54-92 : No resource found that matches the given name (at 'android:actionModeCloseDrawable' with value '@drawable/abc_ic_ab_back_mtrl_am_alpha').

:app:processDebugResources FAILED

FAILURE: Build failed with an exception.

[Feature Request] Multiple Inputs

I think there is only one thing missing from this, either in the implementation or in the docs, a Dialog with Multiple inputs.

Many TextInputs or Text + Checkbox, etc

image

Getting input:{ type(int):*} values

I have checked out the android api for inputTypes .
I checked out the constant value of TYPE_TEXT_VARIATION_PASSWORD which is 128, that worked well but I also need to have an input type of TYPE_NUMBER_VARIATION_PASSWORD. In the api it has a constant value of 16 but so is TYPE_DATETIME_VARIATION_DATE and TYPE_TEXT_VARIATION_URI. 16 does not work. how do I get TYPE_NUMBER_VARIATION_PASSWORD value.

Error resolving dependencies in react native 0.20

I'm not sure if I'm putting things in the right places but since the new releases of react native project structure and files changed a little bit and I get the following error:

A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-dialogs'.
   > Could not resolve all dependencies for configuration ':react-native-dialogs:_debugCompile'.
      > Could not find com.android.support:appcompat-v7:23.1.
        Searched in the following locations:
            https://jitpack.io/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.pom
            https://jitpack.io/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.jar
            file:/home/gabriel/.m2/repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.pom
            file:/home/gabriel/.m2/repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.jar
            https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.pom
            https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.jar
            file:/home/gabriel/Development/android-sdk-linux/extras/android/m2repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.pom
            file:/home/gabriel/Development/android-sdk-linux/extras/android/m2repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.jar
            file:/home/gabriel/Development/android-sdk-linux/extras/google/m2repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.pom
            file:/home/gabriel/Development/android-sdk-linux/extras/google/m2repository/com/android/support/appcompat-v7/23.1/appcompat-v7-23.1.jar
        Required by:
            SistarjsMobile:react-native-dialogs:unspecified



Build fail when installing

Hi,

Just trying to add this package to my app. gradle fails with the following:

Project with path ':react-native-dialogs' could not be found in project ':app'.

build.gradle

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile project(':react-native-dialogs')
    compile project(':ReactNativeBarcodescanner')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile(project(":react-native-google-signin")) {
        exclude group: "com.google.android.gms"
    }
    compile 'com.google.android.gms:play-services-auth:9.2.1'
}

Any idea what I am doing wrong? I remove my gradle caches, restarted the packager.

Thanks

is this repo dead?

There have been no commits in a while, last release on npm a year ago. @aakashns are you still active in this repo or are you looking for maintainers? I'd volunteer, we use this in production.

Change color theme

Changing the color of buttons and input as following

var dialog = new DialogAndroid();
let options = {
  color: '#1E90FF',
  title: 'Title',
  input: {
    hint: 'Placeholder',
    prefill: 'Prefill',
    type: 1,
    callback: (value) => {
      console.log(value);
    }
  },
  positiveText: 'Update',
  negativeText: 'Cancel'
};
dialog.set(options);
dialog.show();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.