Skip to content

Fix #11: Allow to give a view to put the alert in #62

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jerbob92
Copy link

@jerbob92 jerbob92 commented Mar 18, 2020

This functionality allows you to pass a view to put the alert in to try to fix #11 . This is useful when using a Modal. On Android NativeScript uses a DialogFragment to create modals. The DialogFragment is on top of everything which makes the notification not possible.

I was able to get the proper view like this:

    getNotificationOptions() {
        if (isAndroid) {
            const fragments = Application.android.foregroundActivity.getSupportFragmentManager().getFragments();
            let dialogFragment = null;

            for (let i = 0; i < fragments.size(); i++) {
                const fragment = fragments.get(i);
                if (fragment.toString().indexOf("DialogFragment") !== -1) {
                    dialogFragment = fragment;
                    break;
                }
            }

            if (dialogFragment) {
                return {
                    android: {
                        addToView: dialogFragment.getView()
                    }
                };
            }

            return {};
        }

        return {};
    }

Then you can show the feedback like this:

        const feedback = new Feedback();
        const options = this.getNotificationOptions();
        options.title = "test";
        options.message = "message";
        feedback.show(options);

Please note that it has some issues:

  • The animation to make the notification appear does not work.
  • The notification won't be in the status bar.
  • The notification has some extra space that would normally appear in the status bar.

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

Successfully merging this pull request may close these issues.

Feedback not showing on fullscreen MODAL page on Android
1 participant