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

DialogFragment support? #106

Closed
Spellbit opened this issue Aug 20, 2019 · 5 comments
Closed

DialogFragment support? #106

Spellbit opened this issue Aug 20, 2019 · 5 comments

Comments

@Spellbit
Copy link

Greteengs! It would be great to have DialogFragment support out of the box. Its a pretty much common case and for now we have to subclass Navigator and implement it manually.

@mathemandy
Copy link

@Spellbit do you have a workaround, i currently have a need for it ?

@Spellbit
Copy link
Author

Spellbit commented Aug 28, 2019

@Spellbit do you have a workaround, i currently have a need for it ?

For the moment i have a very quick and crude solution. For example here is my fragmentForward of Navigator:

    protected fun fragmentForward(command: Forward) {
        val screen = command.screen as SupportAppScreen
        val fragment = createFragment(screen)

        val fragmentTransaction = fragmentManager.beginTransaction()
        setupFragmentTransaction(
                command,
                fragmentManager.findFragmentById(containerId),
                fragment,
                fragmentTransaction
        )

        fragmentTransaction.addToBackStack(screen.screenKey)

        if (fragment is android.support.v4.app.DialogFragment) {
            fragment.show(fragmentTransaction, screen.screenKey)
        } else {
            fragmentTransaction
                    .replace(containerId, fragment)
                    .commit()
        }
        localStackCopy!!.add(screen.screenKey)
    }

As you can see, there is a check if our fragment is an instance of DialogFragment and if it is - call of the show function. fragmentReplace is similar. Unfortunately its a very crude solution cause you have to call dismiss to close DialogFragment and as a consequence you cant navigate back with router. To solve this we need to deal with stack in DialogFragment case somehow. When i got some time for it - maybe i will make a more decent implementation but for now i just call dismiss from view.

@terrakok
Copy link
Owner

Hello! My opinion is Dialogs are not navigation screens! Because android puts dialogs not in container but in system window. What happens if you want replace dialog to fragment? Or set dialog as root screen? There are a lot of corner cases with dialogs. I don't know good common solution for managing dialogs at the moment :)

@nikialeksey
Copy link

Jetpack navigation has this feature since 2.1.0

@terrakok
Copy link
Owner

  1. google navigation library is not analog cicerone. (Cicerone helps with lifecycle and navigation commands)
  2. you can implement it via overriding navigator
  3. see comments above

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

No branches or pull requests

4 participants