I would like to begin by outlining my current app setup. It utilizes Jetpack Compose and wraps NavController with AndroidViewBinding, enabling me to employ the traditional method of navigation, which involves numerous navigation graph XML files. The rationale behind this approach is the significant effort required to migrate these navigation graphs to Jetpack Compose Navigation (NavHost, NavHostController). Despite this, the implementation below functions effectively.
@Composable
private fun HfAppContent(
state: MainViewState,
eventHandler: (MainViewEvent) -> Unit
) {
AndroidViewBinding(
factory = FragmentNavHostBinding::inflate,
modifier = Modifier.fillMaxSize(),
onReset = {
}
) {
// Make sure initialising NavController only once.
if (state.navController == null) {
fragmentContainerView.getFragment<NavHostFragment>().navController.let {
// Set the NavController to view model
eventHandler(MainViewEvent.NavControllerInitialized(it))
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- DO NOT enable fitsSystemWindows which causes LoginScreen and FullScreenLoading show blank
status bar on logout somehow. Use Compose Modifier.imePadding instead -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_view"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
But the only issue which I have is that I find defining exitAnim and popExitAnim in navigation action does not work, although enterAnim and popEnterAnime work.
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigation_login"
app:startDestination="@+id/login">
<fragment
android:id="@+id/login"
android:name="com.myapp.features.login.view.LoginFragment">
<action
android:id="@+id/forgot_password_action"
app:destination="@+id/forgotPasswordEmail"
app:enterAnim="@anim/slide_in_from_right"
app:exitAnim="@anim/slide_out_to_left"
app:popEnterAnim="@anim/slide_in_from_left"
app:popExitAnim="@anim/slide_out_to_right" />
</fragment>
</navigation>
I would like to know if anyone has a similar setup and faced the same issue and I would like to know how to fix it?