I have nav stack with a fragment and 2 bottomsheetdialogfragment. This is how my nav graph looks like,
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="@id/football_home"
android:id="@+id/home">
<fragment
android:id="@+id/football_home"
android:name="com.football.mib.ui.home.HomeFragment"
android:label="@string/title_home"
tools:layout="@layout/fragment_home">
<action
android:id="@+id/launch_otl_link_prompt"
app:destination="@+id/initial_flow"/>
</fragment>
<dialog android:id="@+id/initial_flow"
android:name="com.football.mib.ui.consent.LinkPromptFragment"
android:label="@string/title_initial_flow"
tools:layout="@layout/fragment_link_prompt">
<action android:id="@+id/activate_game"
app:popUpTo="@id/game_activated"
app:popUpToInclusive="true"
app:destination="@id/game_activated"/>
</dialog>
<dialog android:id="@+id/game_activated"
android:name="com.football.mib.ui.consent.GameActivatedFragment"
android:label="@string/game_activated"
tools:layout="@layout/fragment_game_activated" />
</navigation>
I can easily navigate between the fragments and dialogs, however I need to pop the previous bottomsheet when navigating to the second one. I have tried using app:popUpTo
and app:popUpToInclusive
but the first dialog initial_flow
is still available in the backstack and dismissing the second dialog game_activated
brings it to top again.
I also tried to invoke popUp programmatically via navOptions when navigating to second dialog to no avail e.g
binding.activateOneTap.setOnClickListener {
val navOptions = navOptions {
popUpTo(R.id.game_activated) {
inclusive = true
}
}
findNavController().navigate(R.id.activate_game, null, navOptions)
}
I am using navigation component 2.3.4.
Any hints or alternatives?