Fixed
Status Update
Comments
jn...@google.com <jn...@google.com>
mk...@google.com <mk...@google.com>
mk...@google.com <mk...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 899ca7123479a4f5de52a1f37e78535345696f24
Author: stevebower <stevebower@google.com>
Date: Tue Apr 12 12:10:32 2022
Extend SwipeDismissableNavHost to support edge-swiping.
SwipeToDismissBox supports edge-swiping, by adding Modifier.edgeSwipeToDismiss to composables that support horizontal scrolling. In order to allow such usage within SwipeDismissableNavHost, SwipeToDismissBoxState can now be passed into SwipeDismissableNavHostState (previously, it was created internally).
Test: Run androidx.wear.compose.navigation.test
Bug: 228336555
Relnote: "We have added a SwipeDismissableNavHostState parameter to SwipeDismissableNavHost. This supports use of edge-swiping on screens used as navigation destinations, because SwipeToDismissBoxState can now be hoisted and used to initialise both SwipeDismissableNavHostState and Modifier.edgeSwipeToDismiss on screens that require edge-swiping."
Change-Id: I819f5f6daa7084f7c7b536652937d4d1dbdb7ff8
M wear/compose/compose-navigation/api/current.txt
M wear/compose/compose-navigation/api/restricted_current.txt
M wear/compose/integration-tests/navigation/src/main/java/androidx/wear/compose/integration/navigation/MainActivity.kt
M wear/compose/compose-navigation/src/androidTest/kotlin/androidx/wear/compose/navigation/SwipeDismissableNavHostTest.kt
M wear/compose/compose-navigation/src/main/java/androidx/wear/compose/navigation/SwipeDismissableNavHost.kt
M wear/compose/compose-navigation/api/public_plus_experimental_current.txt
https://android-review.googlesource.com/2062231
Branch: androidx-main
commit 899ca7123479a4f5de52a1f37e78535345696f24
Author: stevebower <stevebower@google.com>
Date: Tue Apr 12 12:10:32 2022
Extend SwipeDismissableNavHost to support edge-swiping.
SwipeToDismissBox supports edge-swiping, by adding Modifier.edgeSwipeToDismiss to composables that support horizontal scrolling. In order to allow such usage within SwipeDismissableNavHost, SwipeToDismissBoxState can now be passed into SwipeDismissableNavHostState (previously, it was created internally).
Test: Run androidx.wear.compose.navigation.test
Bug: 228336555
Relnote: "We have added a SwipeDismissableNavHostState parameter to SwipeDismissableNavHost. This supports use of edge-swiping on screens used as navigation destinations, because SwipeToDismissBoxState can now be hoisted and used to initialise both SwipeDismissableNavHostState and Modifier.edgeSwipeToDismiss on screens that require edge-swiping."
Change-Id: I819f5f6daa7084f7c7b536652937d4d1dbdb7ff8
M wear/compose/compose-navigation/api/current.txt
M wear/compose/compose-navigation/api/restricted_current.txt
M wear/compose/integration-tests/navigation/src/main/java/androidx/wear/compose/integration/navigation/MainActivity.kt
M wear/compose/compose-navigation/src/androidTest/kotlin/androidx/wear/compose/navigation/SwipeDismissableNavHostTest.kt
M wear/compose/compose-navigation/src/main/java/androidx/wear/compose/navigation/SwipeDismissableNavHost.kt
M wear/compose/compose-navigation/api/public_plus_experimental_current.txt
st...@google.com <st...@google.com>
ty...@gmail.com <ty...@gmail.com> #3
A crash occurs if dismissing would result in closing the app.
This error does not occur if dismissing would not result in closing the app.
java.lang.IllegalArgumentException: The WearNavigator backstack is empty, there is no navigation destination to display.
Description
Version used: Alpha20
`modifier.edgeSwipeToDismiss(state)` doesn't help as I don't have the state, it's internal in SwipeDismissableNavHost.
```
@Composable
fun WearApp() {
val navController = rememberSwipeDismissableNavController()
Scaffold(
modifier = Modifier.fillMaxSize(),
) {
SwipeDismissableNavHost(
navController = navController,
startDestination = "start",
) {
composable(route = "start") {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Button(onClick = { navController.navigate("second") }) {
Text("Pager")
}
}
}
composable(route = "second") {
val state = rememberPagerState()
val shape = if (LocalConfiguration.current.isScreenRound) CircleShape else null
Box(
modifier = Modifier.fillMaxSize()
) {
HorizontalPager(
modifier = Modifier.fillMaxSize(),
count = 10,
state = state
) { page ->
Box(
modifier = Modifier.fillMaxSize().run {
if (shape != null) {
clip(shape)
} else {
this
}
}
) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(text = "Screen $page")
}
}
}
val pagerScreenState = remember { PageScreenIndicatorState(state = state) }
if (pagerScreenState.pageCount > 0) {
HorizontalPageIndicator(pageIndicatorState = pagerScreenState)
}
}
}
}
}
```