Skip to content

Commit

Permalink
pass contentAlignment & contentKey params
Browse files Browse the repository at this point in the history
  • Loading branch information
qdsfdhvh committed Jun 16, 2024
1 parent 818ad86 commit 37e4c5d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.Navigator

@Composable
Expand All @@ -33,13 +35,17 @@ public fun FadeTransition(
navigator: Navigator,
modifier: Modifier = Modifier,
animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow),
contentAlignment: Alignment = Alignment.TopStart,
disposeScreenAfterTransitionEnd: Boolean = false,
contentKey: (Screen) -> Any = { it.key },
content: ScreenTransitionContent = { it.Content() }
) {
ScreenTransition(
navigator = navigator,
modifier = modifier,
contentAlignment = contentAlignment,
disposeScreenAfterTransitionEnd = disposeScreenAfterTransitionEnd,
contentKey = contentKey,
content = content,
transition = { fadeIn(animationSpec = animationSpec) togetherWith fadeOut(animationSpec = animationSpec) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.core.stack.StackEvent
import cafe.adriel.voyager.navigator.Navigator

Expand Down Expand Up @@ -37,13 +39,17 @@ public fun ScaleTransition(
navigator: Navigator,
modifier: Modifier = Modifier,
animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow),
contentAlignment: Alignment = Alignment.TopStart,
disposeScreenAfterTransitionEnd: Boolean = false,
contentKey: (Screen) -> Any = { it.key },
content: ScreenTransitionContent = { it.Content() }
) {
ScreenTransition(
navigator = navigator,
modifier = modifier,
contentAlignment = contentAlignment,
disposeScreenAfterTransitionEnd = disposeScreenAfterTransitionEnd,
contentKey = contentKey,
content = content,
transition = {
val (initialScale, targetScale) = when (navigator.lastEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ public fun ScreenTransition(
enterTransition: AnimatedContentTransitionScope<Screen>.() -> ContentTransform,
exitTransition: AnimatedContentTransitionScope<Screen>.() -> ContentTransform,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
disposeScreenAfterTransitionEnd: Boolean = false,
contentKey: (Screen) -> Any = { it.key },
content: ScreenTransitionContent = { it.Content() }
) {
ScreenTransition(
navigator = navigator,
modifier = modifier,
contentAlignment = contentAlignment,
disposeScreenAfterTransitionEnd = disposeScreenAfterTransitionEnd,
contentKey = contentKey,
content = content,
transition = {
when (navigator.lastEvent) {
Expand All @@ -83,7 +87,9 @@ public fun ScreenTransition(
defaultTransition: ScreenTransition,
modifier: Modifier = Modifier,
contentZIndex: Float = 0f,
contentAlignment: Alignment = Alignment.TopStart,
disposeScreenAfterTransitionEnd: Boolean = false,
contentKey: (Screen) -> Any = { it.key },
content: ScreenTransitionContent = { it.Content() }
) {
ScreenTransition(
Expand All @@ -98,7 +104,9 @@ public fun ScreenTransition(
)
},
modifier = modifier,
contentAlignment = contentAlignment,
disposeScreenAfterTransitionEnd = disposeScreenAfterTransitionEnd,
contentKey = contentKey,
content = content
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.IntOffset
import cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.core.stack.StackEvent
import cafe.adriel.voyager.navigator.Navigator

Expand Down Expand Up @@ -47,13 +49,17 @@ public fun SlideTransition(
stiffness = Spring.StiffnessMediumLow,
visibilityThreshold = IntOffset.VisibilityThreshold
),
contentAlignment: Alignment = Alignment.TopStart,
disposeScreenAfterTransitionEnd: Boolean = false,
contentKey: (Screen) -> Any = { it.key },
content: ScreenTransitionContent = { it.Content() }
) {
ScreenTransition(
navigator = navigator,
modifier = modifier,
contentAlignment = contentAlignment,
disposeScreenAfterTransitionEnd = disposeScreenAfterTransitionEnd,
contentKey = contentKey,
content = content,
transition = {
val (initialOffset, targetOffset) = when (navigator.lastEvent) {
Expand Down

0 comments on commit 37e4c5d

Please sign in to comment.