STL Demo: Add EdgeWithPreview in interactive Notifications
A drag down gesture on a notification in LockScreen should expand it,
and if we continue the gesture we should open the shade.
See b/336710600#comment12
Test: No tests
Bug: 336710600
Flag: EXEMPT demo app
Change-Id: Ibfbe400af5237e55489a62f32f3de5da7045d7a8
diff --git a/samples/SceneTransitionLayoutDemo/src/com/android/compose/animation/scene/demo/notification/Notification.kt b/samples/SceneTransitionLayoutDemo/src/com/android/compose/animation/scene/demo/notification/Notification.kt
index 851b3b9..385a342 100644
--- a/samples/SceneTransitionLayoutDemo/src/com/android/compose/animation/scene/demo/notification/Notification.kt
+++ b/samples/SceneTransitionLayoutDemo/src/com/android/compose/animation/scene/demo/notification/Notification.kt
@@ -33,6 +33,7 @@
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.MovableElementKey
import com.android.compose.animation.scene.MutableSceneTransitionLayoutState
+import com.android.compose.animation.scene.NestedScrollBehavior
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.SceneTransitionLayout
@@ -105,16 +106,20 @@
Modifier.fillMaxWidth()
.notificationClip(remember { Path() }, { topRadius }, { bottomRadius })
.thenIf(isInteractive) {
- Modifier.clickable {
- viewModel.state.setTargetScene(
- when (viewModel.state.transitionState.currentScene) {
- Notification.Scenes.Expanded ->
- Notification.Scenes.Collapsed
- else -> Notification.Scenes.Expanded
- },
- coroutineScope,
+ Modifier.verticalNestedScrollToScene(
+ topBehavior = NestedScrollBehavior.EdgeWithPreview,
+ bottomBehavior = NestedScrollBehavior.EdgeWithPreview,
)
- }
+ .clickable {
+ viewModel.state.setTargetScene(
+ when (viewModel.state.transitionState.currentScene) {
+ Notification.Scenes.Expanded ->
+ Notification.Scenes.Collapsed
+ else -> Notification.Scenes.Expanded
+ },
+ coroutineScope,
+ )
+ }
}
.background(backgroundColor)
) {