Skip to content

Commit

Permalink
[Navigation Animation] Allow nullable transition blocks
Browse files Browse the repository at this point in the history
Matches the API of composable()

Fixes #630
  • Loading branch information
chrisbanes committed Aug 9, 2021
1 parent 26a01f9 commit 48f86d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions navigation-animation/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ package com.google.accompanist.navigation.animation {
}

public final class AnimatedNavHostKt {
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedNavHost(androidx.navigation.NavHostController navController, String startDestination, optional androidx.compose.ui.Modifier modifier, optional String? route, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition> enterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition> exitTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition> popEnterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition> popExitTransition, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedNavHost(androidx.navigation.NavHostController navController, androidx.navigation.NavGraph graph, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition> enterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition> exitTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition> popEnterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition> popExitTransition);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedNavHost(androidx.navigation.NavHostController navController, String startDestination, optional androidx.compose.ui.Modifier modifier, optional String? route, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition>? enterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition>? exitTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition>? popEnterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition>? popExitTransition, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedNavHost(androidx.navigation.NavHostController navController, androidx.navigation.NavGraph graph, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition>? enterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition>? exitTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.EnterTransition>? popEnterTransition, optional kotlin.jvm.functions.Function2<? super androidx.navigation.NavBackStackEntry,? super androidx.navigation.NavBackStackEntry,? extends androidx.compose.animation.ExitTransition>? popExitTransition);
}

public final class NavGraphBuilderKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ public fun AnimatedNavHost(
startDestination: String,
modifier: Modifier = Modifier,
route: String? = null,
enterTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition =
enterTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)? =
{ _, _ -> fadeIn(animationSpec = tween(700)) },
exitTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition =
exitTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)? =
{ _, _ -> fadeOut(animationSpec = tween(700)) },
popEnterTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition =
enterTransition,
popExitTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition =
exitTransition,
popEnterTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)? = enterTransition,
popExitTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)? = exitTransition,
builder: NavGraphBuilder.() -> Unit
) {
AnimatedNavHost(
Expand Down Expand Up @@ -117,14 +115,12 @@ public fun AnimatedNavHost(
navController: NavHostController,
graph: NavGraph,
modifier: Modifier = Modifier,
enterTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition =
enterTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)? =
{ _, _ -> fadeIn(animationSpec = tween(700)) },
exitTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition =
exitTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)? =
{ _, _ -> fadeOut(animationSpec = tween(700)) },
popEnterTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition =
enterTransition,
popExitTransition: (initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition =
exitTransition,
popEnterTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)? = enterTransition,
popExitTransition: ((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)? = exitTransition,
) {

enterTransitions[graph.route] = enterTransition
Expand Down Expand Up @@ -252,19 +248,19 @@ public fun AnimatedNavHost(
@ExperimentalAnimationApi
internal val enterTransitions =
mutableMapOf<String?,
(initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition>()
((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)?>()

@ExperimentalAnimationApi
internal val exitTransitions =
mutableMapOf<String?,
(initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition>()
((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)?>()

@ExperimentalAnimationApi
internal val popEnterTransitions =
mutableMapOf<String?,
(initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition>()
((initial: NavBackStackEntry, target: NavBackStackEntry) -> EnterTransition)?>()

@ExperimentalAnimationApi
internal val popExitTransitions =
mutableMapOf<String?,
(initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition>()
((initial: NavBackStackEntry, target: NavBackStackEntry) -> ExitTransition)?>()

0 comments on commit 48f86d5

Please sign in to comment.