File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
androidTest/java/com/example/compose/snippets/semantics
main/java/com/example/compose/snippets Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1616
1717package com.example.compose.snippets.semantics
1818
19+ import androidx.compose.material3.Text
1920import androidx.compose.runtime.Composable
2021import androidx.compose.ui.semantics.Role
2122import androidx.compose.ui.semantics.SemanticsProperties
Original file line number Diff line number Diff line change @@ -659,7 +659,7 @@ fun CustomPredictiveBackHandle() {
659659 // For each backEvent that comes in, we manually seekTo the reported back progress
660660 try {
661661 seekableTransitionState.seekTo(backEvent.progress, targetState = Screen .Home )
662- } catch (e : CancellationException ) {
662+ } catch (_ : CancellationException ) {
663663 // seekTo may be cancelled as expected, if animateTo or subsequent seekTo calls
664664 // before the current seekTo finishes, in this case, we ignore the cancellation.
665665 }
@@ -671,6 +671,7 @@ fun CustomPredictiveBackHandle() {
671671 // When the predictive back gesture is cancelled, we snap to the end state to ensure
672672 // it completes its seeking animation back to the currentState
673673 seekableTransitionState.snapTo(seekableTransitionState.currentState)
674+ throw e
674675 }
675676 }
676677 val coroutineScope = rememberCoroutineScope()
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import androidx.compose.ui.Modifier
3737import androidx.compose.ui.geometry.Offset
3838import androidx.compose.ui.graphics.Color
3939import androidx.compose.ui.graphics.TransformOrigin
40+ import androidx.compose.ui.graphics.graphicsLayer
4041import androidx.compose.ui.input.pointer.util.VelocityTracker
4142import androidx.compose.ui.platform.LocalDensity
4243import androidx.compose.ui.unit.dp
@@ -110,7 +111,10 @@ private fun PredictiveBackHandlerBasicExample() {
110111
111112 Box (
112113 modifier = Modifier
113- .fillMaxSize(boxScale)
114+ .graphicsLayer {
115+ scaleX = boxScale
116+ scaleY = scaleX
117+ }
114118 .background(Color .Blue )
115119 )
116120
@@ -127,6 +131,7 @@ private fun PredictiveBackHandlerBasicExample() {
127131 } catch (e: CancellationException ) {
128132 // code for cancellation
129133 boxScale = 1F
134+ throw e
130135 }
131136 }
132137 // [END android_compose_predictivebackhandler_basic]
@@ -180,8 +185,10 @@ private fun PredictiveBackHandlerManualProgress() {
180185 closeDrawer(velocityTracker.calculateVelocity().x)
181186 } catch (e: CancellationException ) {
182187 openDrawer(velocityTracker.calculateVelocity().x)
188+ throw e
189+ } finally {
190+ velocityTracker.resetTracking()
183191 }
184- velocityTracker.resetTracking()
185192 }
186193 // [END android_compose_predictivebackhandler_manualprogress]
187194 }
You can’t perform that action at this time.
0 commit comments