feat: Add animated alpha transition for tab content in keepAliveTab function

This commit is contained in:
tapframe 2026-03-28 22:12:30 +05:30
parent d075a62f54
commit 12eded17a7

View file

@ -1,6 +1,7 @@
package com.nuvio.app
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
@ -586,10 +587,16 @@ private fun BoxScope.keepAliveTab(
selected: Boolean,
content: @Composable () -> Unit,
) {
val contentAlpha by animateFloatAsState(
targetValue = if (selected) 1f else 0f,
animationSpec = tween(durationMillis = 220),
label = "tab_content_alpha",
)
Box(
modifier = Modifier
.fillMaxSize()
.alpha(if (selected) 1f else 0f)
.alpha(contentAlpha)
.zIndex(if (selected) 1f else 0f),
) {
content()