Skip to content

Commit a3e9ea3

Browse files
fix(navigation): use proper transition direction
1 parent 2a8527f commit a3e9ea3

File tree

1 file changed

+20
-5
lines changed
  • app/src/main/kotlin/io/github/tommygeenexus/usbdonglecontrol/navigation

1 file changed

+20
-5
lines changed

app/src/main/kotlin/io/github/tommygeenexus/usbdonglecontrol/navigation/NavGraph.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ fun NavGraph(
5252
) {
5353
composable<NavDestinations.Setup>(
5454
enterTransition = {
55-
materialSharedAxisXIn(forward = true, slideDistance = slideDistance)
55+
materialSharedAxisXIn(forward = false, slideDistance = slideDistance)
5656
},
5757
exitTransition = {
58-
materialSharedAxisXOut(forward = false, slideDistance = slideDistance)
58+
materialSharedAxisXOut(forward = true, slideDistance = slideDistance)
5959
}
6060
) {
6161
SetupScreen(
@@ -82,11 +82,19 @@ fun NavGraph(
8282
) {
8383
materialSharedAxisXIn(forward = true, slideDistance = slideDistance)
8484
} else {
85-
materialSharedAxisZIn(forward = true)
85+
materialSharedAxisZIn(forward = false)
8686
}
8787
},
8888
exitTransition = {
89-
materialSharedAxisZOut(forward = false)
89+
if (initialState
90+
.destination
91+
.route
92+
?.endsWith(NavDestinations.Setup.toString()) == true
93+
) {
94+
materialSharedAxisXOut(forward = false, slideDistance = slideDistance)
95+
} else {
96+
materialSharedAxisZOut(forward = true)
97+
}
9098
}
9199
) {
92100
ControlScreen(
@@ -97,7 +105,14 @@ fun NavGraph(
97105
navController.navigate(NavDestinations.Settings)
98106
},
99107
onNavigateToSetup = {
100-
navController.navigate(NavDestinations.Setup)
108+
navController.navigate(
109+
route = NavDestinations.Setup,
110+
navOptions = navOptions {
111+
popUpTo(route = NavDestinations.Control) {
112+
inclusive = true
113+
}
114+
}
115+
)
101116
}
102117
)
103118
}

0 commit comments

Comments
 (0)