Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toasty ios: ReferenceError: ToastStyle is not defined #2

Closed
felixkrautschuk opened this issue Dec 6, 2020 · 7 comments
Closed

Toasty ios: ReferenceError: ToastStyle is not defined #2

felixkrautschuk opened this issue Dec 6, 2020 · 7 comments
Labels

Comments

@felixkrautschuk
Copy link

First, thank you for keeping that bunch of plugins up-to-date and to support NS 7!

I tried @triniwiz/[email protected] and it works very well on Android (except Android 11, see triniwiz/nativescript-toasty#45), but on iOS I do not see the Toast and I get the following error:

ReferenceError: ToastStyle is not defined

@triniwiz
Copy link
Owner

triniwiz commented Dec 6, 2020

Interesting did you try cleaning/nuking after installing? If yes can you try logging ToastPosition or ToastStyle you will need to declare it since the typings may not be available oob

@triniwiz triniwiz added the Toasty label Dec 6, 2020
@felixkrautschuk
Copy link
Author

After installing the plugin, I cleaned the platforms folder and built the app again, but I get the same result.

Not sure what you mean, but this is what I do:

const toastModule = require("@triniwiz/nativescript-toasty");

exports.showToast = function(text, showLong) {
        try {
            console.log(toastModule.ToastDuration);
            console.log(toastModule.ToastPosition);

            const toasty = new toastModule.Toasty({
                text: text,
                duration: showLong === true ? toastModule.ToastDuration.LONG : toastModule.ToastDuration.SHORT,
                position: toastModule.ToastPosition.BOTTOM,
                textColor: "#FFFFFF",
                backgroundColor: "#656565",
                yAxisOffset: 20
            });

            toasty.show();
        } catch(e) {
            console.log(e);
        }
};

So I logged toastModule.ToastDuration and toastModule.ToastPosition, and I got:
CONSOLE LOG: {
"SHORT": "short",
"LONG": "long"
}
CONSOLE LOG: {
"BOTTOM": "bottom",
"BOTTOM_LEFT": "bottomLeft",
"BOTTOM_RIGHT": "bottomRight",
...
}

@triniwiz
Copy link
Owner

triniwiz commented Dec 7, 2020

Sorry I meant doing something like the following

console.dir(ToastStyle);

Usually if you were using something like typescript you would of need to add declare const ToastStyle: any;

@felixkrautschuk
Copy link
Author

@triniwiz I gave it another try in a NS typescript project:

import {ToastDuration, ToastPosition, Toasty} from "@triniwiz/nativescript-toasty";

declare const ToastStyle: any;

export function showToast(text: string) {
    try {
        console.dir(ToastStyle);

        /*new Toasty({ text : text })
            .setToastDuration(ToastDuration.SHORT)
            .setToastPosition(ToastPosition.BOTTOM)
            .setTextColor("#FFFFFF")
            .setBackgroundColor("#656565")
            .show();*/
    } catch (e) {
        console.log("Error showToast:");
        console.log(e);
    }
}

So I tried to log the ToastStyle element and I got the same error

ReferenceError: ToastStyle is not defined

@triniwiz
Copy link
Owner

triniwiz commented Dec 8, 2020

Yeah seems to be a silly mistake 😂 with the project structure will publish soon

@triniwiz
Copy link
Owner

Update to the latest to enjoy 😄

@felixkrautschuk
Copy link
Author

felixkrautschuk commented Dec 28, 2020

@triniwiz thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants