diff --git a/src/main/kotlin/com/looker/droidify/ui/compose/utils/Animations.kt b/src/main/kotlin/com/looker/droidify/ui/compose/utils/Animations.kt new file mode 100644 index 00000000..329580b8 --- /dev/null +++ b/src/main/kotlin/com/looker/droidify/ui/compose/utils/Animations.kt @@ -0,0 +1,30 @@ +package com.looker.droidify.ui.compose.utils + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.AnimatedVisibilityScope +import androidx.compose.animation.expandHorizontally +import androidx.compose.animation.shrinkHorizontally +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment + +@Composable +fun HorizontalExpandingVisibility( + expanded: Boolean = false, + from: Alignment.Horizontal = Alignment.Start, + towards: Alignment.Horizontal = Alignment.End, + expandedView: @Composable (AnimatedVisibilityScope.() -> Unit), + collapsedView: @Composable (AnimatedVisibilityScope.() -> Unit) +) { + AnimatedVisibility( + visible = expanded, + enter = expandHorizontally(expandFrom = from), + exit = shrinkHorizontally(shrinkTowards = from), + content = expandedView + ) + AnimatedVisibility( + visible = !expanded, + enter = expandHorizontally(expandFrom = towards), + exit = shrinkHorizontally(shrinkTowards = towards), + content = collapsedView + ) +} \ No newline at end of file