shiv19 / nativescript-cfalert-dialog

CFAlertDialog Wrapper for NativeScript
Apache License 2.0
42 stars 21 forks source link

ReferenceError: CFAlertStyle is not defined #21

Closed it3r4-pineda closed 5 years ago

it3r4-pineda commented 5 years ago

Make sure to check the demo app(s) for sample usage

Checked

Make sure to check the existing issues in this repository

Checked

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Which platform(s) does your issue occur on?

Error - Using Vanilla Js

An uncaught Exception occurred on "main" thread. com.tns.NativeScriptException: Calling js method onTouch failed

ReferenceError: CFAlertStyle is not defined File: "file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js, line: 228, column: 40

StackTrace: Frame: function:'ChangeColor', file:'file:///data/data/org.nativescript.E4/files/app/choose/choose-page.js', line: 40, column: 22 Frame: function:'_executeCallback', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 282, column: 27 Frame: function:'TapAndDoubleTapGestureListenerImpl.onSingleTapUp', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 25, column: 17 Frame: function:'GesturesObserver.androidOnTouchEvent', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 228, column: 41 Frame: function:'', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 252, column: 25 Frame: function:'View.handleGestureTouch', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 251, column: 18 Frame: function:'TouchListenerImpl.onTouch', file:'file:///data/data/org.nativescript.E4/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 30, column: 19

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
at com.tns.Runtime.callJSMethod(Runtime.java:987)
at com.tns.Runtime.callJSMethod(Runtime.java:967)
at com.tns.Runtime.callJSMethod(Runtime.java:959)
at com.tns.gen.java.lang.Object_view_24_32_TouchListenerImpl.onTouch(Object_view_24_32_TouchListenerImpl.java:18)
at android.view.View.dispatchTouchEvent(View.java:11717)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
at android.app.Activity.dispatchTouchEvent(Activity.java:3292)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
at android.view.View.dispatchPointerEvent(View.java:11960)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
shiv19 commented 5 years ago

Did you do tns platform clean android (or ios), after installing the plugin?

it3r4-pineda commented 5 years ago

error still persists.

shiv19 commented 5 years ago

Try passing one of these values directly

export declare enum CFAlertStyle { NOTIFICATION = 0, ALERT = 1, BOTTOM_SHEET = 2 }

Ex: If you wanted to use CFAlertStyle.NOTIFICATION

try passing 0 directly.

(just to check if rest of it is working for you),

And if that does work, this could be an import error.

it3r4-pineda commented 5 years ago

Will this work with vanila JavaScript?

On Mon, Feb 11, 2019, 1:25 AM Shiva Prasad notifications@github.com wrote:

Try passing one of these values directly

export declare enum CFAlertStyle { NOTIFICATION = 0, ALERT = 1, BOTTOM_SHEET = 2 }

Ex: If you wanted to use CFAlertStyle.NOTIFICATION

try passing 0 directly.

(just to check if rest of it is working for you),

And if that does work, this could be an import error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shiv19/nativescript-cfalert-dialog/issues/21#issuecomment-462153264, or mute the thread https://github.com/notifications/unsubscribe-auth/Ak0UH2xGAsHgG8-Y0_ST1xc8Xx8lLBlZks5vMFX4gaJpZM4azI8E .

it3r4-pineda commented 5 years ago

Heres my code :

var Dialog = require("nativescript-cfalert-dialog");
var cfalertDialog = new Dialog.CFAlertDialog();

//made a functions based on given comment
function CFAlertStyle() {
NOTIFICATION = 0,
ALERT = 1,
BOTTOM_SHEET = 2
}

function CFAlertActionStyle() {
DEFAULT = 0,
NEGATIVE = 1,
POSITIVE = 2
}

function CFAlertActionAlignment() {
START = 0,
END = 1,
CENTER = 2,
JUSTIFIED = 3
}

//show Dialog
cfalertDialog.show({
        dialogStyle: CFAlertStyle.BOTTOM_SHEET,
        title: "This is a bottom sheet!",
        message: "It is shown at the bottom of the screen",
        buttons: [{
                text: "Okay",
                buttonStyle: CFAlertActionStyle.POSITIVE,
                buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
                onClick: function (response) {
                    console.log("Inside OK Response");
                    console.log(response); // Prints Okay
                }
            },
            {
                text: "Nope",
                buttonStyle: CFAlertActionStyle.NEGATIVE,
                buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
                onClick: function (response) {
                    console.log("Inside Nope Response");
                    console.log(response); // Prints Nope
                }
            }
        ]
    });

the following does not return an error but doesnt show the dialog either

shiv19 commented 5 years ago

Umm, you didn't do what I asked you to do.

I want you to directly pass the enum values and see if it works.

Or import it this way const CFAlertActionStyle = require("nativescript-cfalert-dialog").CFAlertActionStyle;

shiv19 commented 5 years ago

Closing due to inactivity