Skip to content

Commit ce80175

Browse files
committed
fix: remove extra dismiss animation
1 parent 3a05d47 commit ce80175

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

app/src/main/java/to/bitkit/ui/components/ToastView.kt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.compose.animation.SizeTransform
55
import androidx.compose.animation.core.Animatable
66
import androidx.compose.animation.core.Spring
77
import androidx.compose.animation.core.spring
8-
import androidx.compose.animation.core.tween
98
import androidx.compose.animation.fadeIn
109
import androidx.compose.animation.fadeOut
1110
import androidx.compose.animation.slideInVertically
@@ -58,13 +57,10 @@ import to.bitkit.ui.theme.AppThemeSurface
5857
import to.bitkit.ui.theme.Colors
5958
import kotlin.math.roundToInt
6059

61-
private const val DISMISS_THRESHOLD_DP = 50
62-
private const val DISMISS_ANIMATION_TARGET_PX = -200f
63-
private const val DISMISS_ANIMATION_DURATION_MS = 300
60+
private const val DISMISS_THRESHOLD_DP = 40
6461
private const val SNAP_BACK_DAMPING_RATIO = 0.7f
6562
private const val DRAG_RESISTANCE_FACTOR = 0.08f
6663
private const val DRAG_START_THRESHOLD_PX = 5
67-
private const val HORIZONTAL_DISMISS_ANIMATION_TARGET_PX = 500f
6864
private const val TINT_ALPHA = 0.32f
6965
private const val SHADOW_ALPHA = 0.4f
7066
private const val ELEVATION_DP = 10
@@ -95,7 +91,6 @@ fun ToastView(
9591
.padding(horizontal = 16.dp)
9692
.then(toast.testTag?.let { Modifier.testTag(it) } ?: Modifier),
9793
) {
98-
9994
Box(
10095
modifier = Modifier
10196
.fillMaxWidth()
@@ -131,23 +126,10 @@ fun ToastView(
131126
val isHorizontalSwipe = horizontalSwipeDistance > verticalSwipeDistance
132127

133128
if (isHorizontalSwipe && horizontalSwipeDistance > dismissThreshold.toPx()) {
134-
// Horizontal swipe dismiss - animate out in swipe direction
135-
val targetX = if (dragOffsetX.value > 0) {
136-
HORIZONTAL_DISMISS_ANIMATION_TARGET_PX
137-
} else {
138-
-HORIZONTAL_DISMISS_ANIMATION_TARGET_PX
139-
}
140-
dragOffsetX.animateTo(
141-
targetValue = targetX,
142-
animationSpec = tween(durationMillis = DISMISS_ANIMATION_DURATION_MS)
143-
)
129+
// Horizontal swipe dismiss
144130
onDismiss()
145131
} else if (!isHorizontalSwipe && dragOffsetY.value < -dismissThreshold.toPx()) {
146-
// Vertical swipe up dismiss - animate out upward
147-
dragOffsetY.animateTo(
148-
targetValue = DISMISS_ANIMATION_TARGET_PX,
149-
animationSpec = tween(durationMillis = DISMISS_ANIMATION_DURATION_MS)
150-
)
132+
// Vertical swipe up dismiss
151133
onDismiss()
152134
} else {
153135
// Snap back to original position
@@ -214,7 +196,7 @@ fun ToastView(
214196
// Pause auto-hide when drag starts (only once)
215197
val totalDragDistance = kotlin.math.sqrt(
216198
dragOffsetX.value * dragOffsetX.value +
217-
dragOffsetY.value * dragOffsetY.value
199+
dragOffsetY.value * dragOffsetY.value
218200
)
219201
if (totalDragDistance > DRAG_START_THRESHOLD_PX && !hasPausedAutoHide) {
220202
hasPausedAutoHide = true

0 commit comments

Comments
 (0)