Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.compose.snippets.semantics

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ fun CustomPredictiveBackHandle() {
// For each backEvent that comes in, we manually seekTo the reported back progress
try {
seekableTransitionState.seekTo(backEvent.progress, targetState = Screen.Home)
} catch (e: CancellationException) {
} catch (_: CancellationException) {
// seekTo may be cancelled as expected, if animateTo or subsequent seekTo calls
// before the current seekTo finishes, in this case, we ignore the cancellation.
}
Expand All @@ -671,6 +671,7 @@ fun CustomPredictiveBackHandle() {
// When the predictive back gesture is cancelled, we snap to the end state to ensure
// it completes its seeking animation back to the currentState
seekableTransitionState.snapTo(seekableTransitionState.currentState)
throw e
}
}
val coroutineScope = rememberCoroutineScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.util.VelocityTracker
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -110,7 +111,10 @@ private fun PredictiveBackHandlerBasicExample() {

Box(
modifier = Modifier
.fillMaxSize(boxScale)
.graphicsLayer {
scaleX = boxScale
scaleY = scaleX
}
.background(Color.Blue)
)

Expand All @@ -127,6 +131,7 @@ private fun PredictiveBackHandlerBasicExample() {
} catch (e: CancellationException) {
// code for cancellation
boxScale = 1F
throw e
}
}
// [END android_compose_predictivebackhandler_basic]
Expand Down Expand Up @@ -180,8 +185,10 @@ private fun PredictiveBackHandlerManualProgress() {
closeDrawer(velocityTracker.calculateVelocity().x)
} catch (e: CancellationException) {
openDrawer(velocityTracker.calculateVelocity().x)
throw e
} finally {
velocityTracker.resetTracking()
}
velocityTracker.resetTracking()
}
// [END android_compose_predictivebackhandler_manualprogress]
}
Expand Down