diff --git a/.github/workflows/test_and_release_snapshot.yml b/.github/workflows/test_and_release_snapshot.yml index f937a96..cc65c96 100644 --- a/.github/workflows/test_and_release_snapshot.yml +++ b/.github/workflows/test_and_release_snapshot.yml @@ -2,7 +2,6 @@ name: Run tests and publish snapshot on: push: - branches: [ trunk ] pull_request: jobs: diff --git a/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt b/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt index 5bd0c63..e0c9597 100644 --- a/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt +++ b/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.absoluteOffset import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment @@ -60,14 +59,16 @@ fun SwipeableActionsBox( } } - val backgroundColor: Color by animateColorAsState( - when { - state.swipedAction != null -> state.swipedAction!!.value.background - !state.hasCrossedSwipeThreshold() -> backgroundUntilSwipeThreshold - state.visibleAction != null -> state.visibleAction!!.value.background - else -> Color.Transparent - } - ) + val backgroundColor = when { + state.swipedAction != null -> state.swipedAction!!.value.background + !state.hasCrossedSwipeThreshold() -> backgroundUntilSwipeThreshold + state.visibleAction != null -> state.visibleAction!!.value.background + else -> Color.Transparent + } + val animatedBackgroundColor: Color = when (state.layoutWidth) { + 0 -> backgroundColor + else -> animateColorAsState(backgroundColor).value + } val scope = rememberCoroutineScope() Box( @@ -93,7 +94,7 @@ fun SwipeableActionsBox( modifier = Modifier.matchParentSize(), action = action, offset = state.offset.value, - backgroundColor = backgroundColor, + backgroundColor = animatedBackgroundColor, content = { action.value.icon() } ) }