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 16
16
17
17
package com.example.compose.snippets.semantics
18
18
19
+ import androidx.compose.material3.Text
19
20
import androidx.compose.runtime.Composable
20
21
import androidx.compose.ui.semantics.Role
21
22
import androidx.compose.ui.semantics.SemanticsProperties
Original file line number Diff line number Diff line change @@ -659,7 +659,7 @@ fun CustomPredictiveBackHandle() {
659
659
// For each backEvent that comes in, we manually seekTo the reported back progress
660
660
try {
661
661
seekableTransitionState.seekTo(backEvent.progress, targetState = Screen .Home )
662
- } catch (e : CancellationException ) {
662
+ } catch (_ : CancellationException ) {
663
663
// seekTo may be cancelled as expected, if animateTo or subsequent seekTo calls
664
664
// before the current seekTo finishes, in this case, we ignore the cancellation.
665
665
}
@@ -671,6 +671,7 @@ fun CustomPredictiveBackHandle() {
671
671
// When the predictive back gesture is cancelled, we snap to the end state to ensure
672
672
// it completes its seeking animation back to the currentState
673
673
seekableTransitionState.snapTo(seekableTransitionState.currentState)
674
+ throw e
674
675
}
675
676
}
676
677
val coroutineScope = rememberCoroutineScope()
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import androidx.compose.ui.Modifier
37
37
import androidx.compose.ui.geometry.Offset
38
38
import androidx.compose.ui.graphics.Color
39
39
import androidx.compose.ui.graphics.TransformOrigin
40
+ import androidx.compose.ui.graphics.graphicsLayer
40
41
import androidx.compose.ui.input.pointer.util.VelocityTracker
41
42
import androidx.compose.ui.platform.LocalDensity
42
43
import androidx.compose.ui.unit.dp
@@ -110,7 +111,10 @@ private fun PredictiveBackHandlerBasicExample() {
110
111
111
112
Box (
112
113
modifier = Modifier
113
- .fillMaxSize(boxScale)
114
+ .graphicsLayer {
115
+ scaleX = boxScale
116
+ scaleY = scaleX
117
+ }
114
118
.background(Color .Blue )
115
119
)
116
120
@@ -127,6 +131,7 @@ private fun PredictiveBackHandlerBasicExample() {
127
131
} catch (e: CancellationException ) {
128
132
// code for cancellation
129
133
boxScale = 1F
134
+ throw e
130
135
}
131
136
}
132
137
// [END android_compose_predictivebackhandler_basic]
@@ -180,8 +185,10 @@ private fun PredictiveBackHandlerManualProgress() {
180
185
closeDrawer(velocityTracker.calculateVelocity().x)
181
186
} catch (e: CancellationException ) {
182
187
openDrawer(velocityTracker.calculateVelocity().x)
188
+ throw e
189
+ } finally {
190
+ velocityTracker.resetTracking()
183
191
}
184
- velocityTracker.resetTracking()
185
192
}
186
193
// [END android_compose_predictivebackhandler_manualprogress]
187
194
}
You can’t perform that action at this time.
0 commit comments