Skip to content

Commit

Permalink
Only animate text items on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Jul 23, 2023
1 parent 9714436 commit e1101b1
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -63,6 +67,9 @@ fun TextServiceUi(
) {
val state = rememberLazyListState()
ScrollToTopHandler(state)

// Only animate items in on first load
var animatePlacement by remember { mutableStateOf(true) }
LazyColumn(
modifier = modifier,
state = state,
Expand All @@ -84,8 +91,15 @@ fun TextServiceUi(
} else {
null
}
val itemModifier =
if (animatePlacement) {
LaunchedEffect(Unit) { animatePlacement = false }
Modifier.animateItemPlacement()
} else {
Modifier
}
ClickableItem(
modifier = Modifier.animateItemPlacement(),
modifier = itemModifier,
onClick = { eventSink(ServiceScreen.Event.ItemClicked(item)) },
onLongClick = onLongClick
) {
Expand Down

0 comments on commit e1101b1

Please sign in to comment.