Skip to content

Commit 5dbef5a

Browse files
Resolved the GIT comment in the Nav3Snippets
1 parent dfb6511 commit 5dbef5a

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

  • compose/snippets/src/main/java/com/example/compose/snippets/predictiveback

compose/snippets/src/main/java/com/example/compose/snippets/predictiveback/Nav3Snippets.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
package com.example.compose.snippets.predictiveback
2020

21+
import android.annotation.SuppressLint
2122
import android.os.Bundle
2223
import android.util.Log
2324
import android.view.MotionEvent.EDGE_LEFT
2425
import android.view.MotionEvent.EDGE_RIGHT
2526
import androidx.activity.ComponentActivity
2627
import androidx.activity.compose.setContent
27-
import androidx.compose.animation.core.animateDpAsState
2828
import androidx.compose.animation.core.animateFloatAsState
2929
import androidx.compose.runtime.Composable
3030
import androidx.compose.runtime.getValue
@@ -74,6 +74,7 @@ class MainActivity : ComponentActivity() {
7474
}
7575
}
7676

77+
@SuppressLint("ConfigurationScreenWidthHeight")
7778
@Composable
7879
fun ScreenB(
7980
backEventState: NavigationEventState<NavigationEventInfo>,
@@ -99,16 +100,16 @@ fun ScreenB(
99100
label = "ScaleAnimation"
100101
)
101102

102-
val maxShift = (LocalConfiguration.current.screenWidthDp / 20f) - 8
103+
val configuration = LocalConfiguration.current
104+
val maxShift = remember(configuration) {
105+
(configuration.screenWidthDp / 20f) - 8
106+
}
103107

104-
val animatedOffsetX by animateDpAsState(
105-
targetValue = when (swipeEdge) {
106-
EDGE_LEFT -> (backProgress * maxShift).dp
107-
EDGE_RIGHT -> (-backProgress * maxShift).dp
108-
else -> 0.dp
109-
},
110-
label = "OffsetXAnimation"
111-
)
108+
val offsetX = when (swipeEdge) {
109+
EDGE_LEFT -> (backProgress * maxShift).dp
110+
EDGE_RIGHT -> (-backProgress * maxShift).dp
111+
else -> 0.dp
112+
}
112113

113114
NavigationBackHandler(
114115
state = backEventState,

0 commit comments

Comments
 (0)