11package com.getcode.ui.components
22
33import androidx.compose.animation.AnimatedVisibility
4+ import androidx.compose.animation.EnterTransition
5+ import androidx.compose.animation.ExitTransition
6+ import androidx.compose.animation.expandVertically
7+ import androidx.compose.animation.fadeIn
8+ import androidx.compose.animation.fadeOut
9+ import androidx.compose.animation.shrinkVertically
410import androidx.compose.foundation.layout.Column
511import androidx.compose.runtime.Composable
612import androidx.compose.runtime.LaunchedEffect
@@ -80,6 +86,12 @@ fun rememberPullToRevealState(initiallyRevealed: Boolean = false): PullToRevealS
8086object PullToRevealDefaults {
8187 /* * Default pull distance required before the reveal slot is shown. */
8288 val Threshold : Dp = 56 .dp
89+
90+ /* * Default transition used to animate the reveal slot in (expand + fade). */
91+ val Enter : EnterTransition = fadeIn() + expandVertically()
92+
93+ /* * Default transition used to animate the reveal slot out (shrink + fade). */
94+ val Exit : ExitTransition = fadeOut() + shrinkVertically()
8395}
8496
8597/* *
@@ -98,6 +110,9 @@ object PullToRevealDefaults {
98110 * sheet's drag-to-dismiss) should be disabled so the pull reveals instead of
99111 * dismissing; the value stays `true` for the whole reveal gesture — not just while
100112 * hidden — so a single hard pull cannot reveal and then dismiss in one motion.
113+ * @param enter transition applied when [revealContent] animates in. Override (e.g.
114+ * with a spring-backed `expandVertically`) to tune the reveal motion.
115+ * @param exit transition applied when [revealContent] animates out.
101116 */
102117@Composable
103118fun PullToReveal (
@@ -107,6 +122,8 @@ fun PullToReveal(
107122 threshold : Dp = PullToRevealDefaults .Threshold ,
108123 enabled : Boolean = true,
109124 onSuppressDismissChange : ((Boolean ) -> Unit )? = null,
125+ enter : EnterTransition = PullToRevealDefaults .Enter ,
126+ exit : ExitTransition = PullToRevealDefaults .Exit ,
110127 content : @Composable () -> Unit ,
111128) {
112129 val thresholdPx = with (LocalDensity .current) { threshold.toPx() }
@@ -167,7 +184,7 @@ fun PullToReveal(
167184 }
168185
169186 Column (modifier = modifier.nestedScroll(connection)) {
170- AnimatedVisibility (visible = state.isRevealed) {
187+ AnimatedVisibility (visible = state.isRevealed, enter = enter, exit = exit ) {
171188 revealContent()
172189 }
173190 content()
0 commit comments