1+ /*
2+ * Copyright 2024 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117package com.example.compose.snippets.predictiveback
218
3- import androidx.compose.runtime.Composable
4- import androidx.compose.ui.Modifier
5- import androidx.navigation.compose.NavHost
6- import androidx.navigation.compose.rememberNavController
7- import androidx.navigation.NavHostController
8- import androidx.compose.animation.scaleOut
9- import androidx.compose.ui.graphics.TransformOrigin
10- import androidx.compose.animation.EnterTransition
1119import android.os.SystemClock
1220import androidx.activity.compose.PredictiveBackHandler
13- import androidx.compose.ui.unit.dp
21+ import androidx.compose.animation.EnterTransition
1422import androidx.compose.animation.core.Animatable
15- import androidx.navigation. compose.composable
23+ import androidx.compose.animation.scaleOut
1624import androidx.compose.foundation.layout.fillMaxSize
1725import androidx.compose.material3.Surface
26+ import androidx.compose.runtime.Composable
1827import androidx.compose.runtime.getValue
1928import androidx.compose.runtime.mutableStateOf
2029import androidx.compose.runtime.remember
2130import androidx.compose.runtime.rememberCoroutineScope
2231import androidx.compose.runtime.setValue
32+ import androidx.compose.ui.Modifier
2333import androidx.compose.ui.geometry.Offset
34+ import androidx.compose.ui.graphics.TransformOrigin
2435import androidx.compose.ui.input.pointer.util.VelocityTracker
2536import androidx.compose.ui.platform.LocalDensity
37+ import androidx.compose.ui.unit.dp
38+ import androidx.navigation.NavHostController
39+ import androidx.navigation.compose.NavHost
40+ import androidx.navigation.compose.composable
41+ import androidx.navigation.compose.rememberNavController
2642import kotlin.coroutines.cancellation.CancellationException
2743
28-
2944@Composable
3045private fun PredictiveBackOverrideExit (
3146 modifier : Modifier ,
@@ -39,7 +54,7 @@ private fun PredictiveBackOverrideExit(
3954 popExitTransition = {
4055 scaleOut(
4156 targetScale = 0.9f ,
42- transformOrigin = TransformOrigin (pivotFractionX = 0.5f , pivotFractionY = 0.5f )
57+ transformOrigin = TransformOrigin (pivotFractionX = 0.5f , pivotFractionY = 0.5f )
4358 )
4459 },
4560 popEnterTransition = {
@@ -66,16 +81,16 @@ private fun PredictiveBackOverrideExit(
6681
6782@Composable
6883private fun HomeScreen (
69- modifier : Modifier = Modifier , navController : NavHostController
84+ modifier : Modifier = Modifier ,
85+ navController : NavHostController
7086) {
71-
7287}
7388
7489@Composable
7590private fun SettingsScreen (
76- modifier : Modifier = Modifier , navController : NavHostController
91+ modifier : Modifier = Modifier ,
92+ navController : NavHostController
7793) {
78-
7994}
8095
8196@Composable
@@ -130,7 +145,6 @@ private fun PredictiveBackHandlerManualProgress() {
130145 velocityTracker.resetTracking()
131146 }
132147 // [END android_compose_predictivebackhandler]
133-
134148 }
135149}
136150
@@ -139,4 +153,4 @@ private enum class DrawerState {
139153 Closed
140154}
141155
142- private val DrawerWidth = 300 .dp
156+ private val DrawerWidth = 300 .dp
0 commit comments