FEDUSS
01/03/2024, 2:17 PMFEDUSS
01/03/2024, 2:20 PMFEDUSS
01/03/2024, 2:27 PMCurrent backstack entry is empty. Please ensure:
1. The current WearNavigator navigation backstack is not empty (e.g. by using androidx.wear.compose.navigation.composable to build your nav graph).
2. The last entry is not popped prior to navigation (instead, use navigate with popUpTo).
3. If the activity uses FLAG_ACTIVITY_NEW_TASK you should also set FLAG_ACTIVITY_CLEAR_TASK to maintain the backstack consistency.
If i wrap the navhost in a BasicSwipeToDismissBox (even if it is already in the SwipeDismissableNavHost), sharing the swipe state of the navhost, and i implement a custom LaunchedEffect, i can come back to the watchface, but a black screen appears for just a second.FEDUSS
01/03/2024, 3:26 PMyschimke
01/04/2024, 6:43 AMShubham
01/04/2024, 6:48 AMFEDUSS
01/04/2024, 9:24 AMFEDUSS
01/04/2024, 10:08 AMstevebower
01/04/2024, 12:13 PMFEDUSS
01/04/2024, 12:14 PMFEDUSS
01/04/2024, 12:15 PMFEDUSS
01/04/2024, 12:23 PMstevebower
01/18/2024, 4:54 PMFEDUSS
01/18/2024, 5:31 PMstevebower
01/29/2024, 3:23 PM@Composable
internal fun CustomTouchSlopProvider(
newTouchSlop: Float,
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalViewConfiguration provides CustomTouchSlop(
newTouchSlop,
LocalViewConfiguration.current
)
) {
content()
}
}
class CustomTouchSlop(
private val customTouchSlop: Float,
currentConfiguration: ViewConfiguration
) : ViewConfiguration by currentConfiguration {
override val touchSlop: Float
get() = customTouchSlop
}
and then wrap the current content like this:
val originalTouchSlop = LocalViewConfiguration.current.touchSlop
CustomTouchSlopProvider(newTouchSlop = originalTouchSlop * 2) {
// content goes here
}
FEDUSS
01/29/2024, 9:32 PMstevebower
01/30/2024, 11:33 AMFEDUSS
01/30/2024, 1:42 PMstevebower
02/01/2024, 11:59 AMtween(150, 0)
in the library) - just to confirm if the problem you see is that the pager is not settling before the tap on the screen.FEDUSS
02/01/2024, 12:12 PMFEDUSS
02/02/2024, 10:17 AMstevebower
02/06/2024, 2:46 PMclass MainActivity : ComponentActivity() {
@OptIn(ExperimentalFoundationApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent(parent = null) {
MaterialTheme {
val navController = rememberSwipeDismissableNavController()
SwipeDismissableNavHost(
navController = navController,
startDestination = PAGER_SCREEN
) {
composable(PAGER_SCREEN) {
val originalTouchSlop = LocalViewConfiguration.current.touchSlop
CustomTouchSlopProvider(newTouchSlop = originalTouchSlop * 2) {
val pagesCount = 3
val pagerState = rememberPagerState { pagesCount }
val screenWidth = with(LocalDensity.current) {
LocalConfiguration.current.screenWidthDp.dp.toPx()
}
var allowPaging by remember { mutableStateOf(true) }
HorizontalPager(
modifier = Modifier
.fillMaxSize()
.pointerInput(screenWidth) {
coroutineScope {
awaitEachGesture {
allowPaging = true
val firstDown =
awaitFirstDown(false, PointerEventPass.Initial)
val xPosition = firstDown.position.x
// Define edge zone of 15%
allowPaging = xPosition > screenWidth * 0.15f
}
}
}
.semantics {
horizontalScrollAxisRange = if (allowPaging) {
ScrollAxisRange(value = { pagerState.currentPage.toFloat() },
maxValue = { 3f })
} else {
// signals system swipe to dismiss that they can take over
ScrollAxisRange(value = { 0f },
maxValue = { 0f })
}
},
state = pagerState,
flingBehavior =
PagerDefaults.flingBehavior(
pagerState,
snapAnimationSpec = tween(150, 0),
),
userScrollEnabled = allowPaging
) {
Centralize {
ListHeader { Text("Page $it") }
}
}
}
}
}
}
}
}
}
@Composable
fun Centralize(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) {
Column(
modifier = modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
content = content
)
}
@Composable
private fun CustomTouchSlopProvider(
newTouchSlop: Float,
content: @Composable () -> Unit
) {
CompositionLocalProvider(
LocalViewConfiguration provides CustomTouchSlop(
newTouchSlop,
LocalViewConfiguration.current
)
) {
content()
}
}
private class CustomTouchSlop(
private val customTouchSlop: Float,
currentConfiguration: ViewConfiguration
) : ViewConfiguration by currentConfiguration {
override val touchSlop: Float
get() = customTouchSlop
}
private const val PAGER_SCREEN = "pager_screen"
FEDUSS
02/09/2024, 3:53 PMstevebower
02/23/2024, 10:06 AMbod
03/31/2024, 1:02 AMFEDUSS
04/01/2024, 9:32 AMbod
04/01/2024, 12:36 PMSwipeDismissableNavHost
and trying to dismiss from the edge.FEDUSS
04/01/2024, 12:45 PMbod
04/01/2024, 12:47 PMFEDUSS
04/01/2024, 12:50 PMbod
04/01/2024, 12:51 PMbod
04/01/2024, 6:26 PM