diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/data/Navigation.kt b/app/src/main/java/ua/acclorite/book_story/presentation/data/Navigation.kt index 68c6ae8f..b1d1a639 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/data/Navigation.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/data/Navigation.kt @@ -269,11 +269,16 @@ class Navigator @AssistedInject constructor( backExitAnim: ExitTransition = Transitions.BackSlidingTransitionOut, noinline content: @Composable (screen: S) -> Unit ) { - val currentRoute by currentScreen.collectAsState() + val currentRoute = currentScreen.collectAsState() val useBackAnimation by useBackAnimation.collectAsState() + val shouldShow by remember { + derivedStateOf { + currentRoute.value == getRoute() + } + } CustomAnimatedVisibility( - visible = currentRoute == getRoute(), + visible = shouldShow, enter = if (!useBackAnimation) enterAnim else backEnterAnim, exit = if (!useBackAnimation) exitAnim else backExitAnim ) { @@ -309,11 +314,11 @@ class Navigator @AssistedInject constructor( content: @Composable () -> Unit ) { val activity = LocalContext.current as ComponentActivity - val currentScreen by currentScreen.collectAsState() + val currentScreen = currentScreen.collectAsState() val useBackAnimation by useBackAnimation.collectAsState() - val shouldShow by remember(currentScreen) { + val shouldShow by remember { derivedStateOf { - screens.any { it == currentScreen } + screens.any { it == currentScreen.value } } }