Gabriel Gircenko
11/04/2021, 11:21 AM@Composable
private fun ListOfHomePages(rows: List<PageItemUIData>) {
val listState = rememberLazyListState()
val listScope = rememberCoroutineScope()
val scrollState = rememberScrollState()
var index by remember { mutableStateOf(0) }
LazyRow(
modifier = Modifier
.fillMaxSize()
.background(color = colorResource(id = R.color.black)),
state = listState
) {
items(rows) { item: PageItemUIData ->
if (!listState.isScrollInProgress) {
listScope.launch {
listState.animateScrollToItem(index)
}
/*if (listState.isScrollingUp()) {
listScope.launch {
listState.animateScrollToItem(listState.firstVisibleItemIndex + 1)
}
} else if (listState.isScrollingDown()) {
listScope.launch {
listState.animateScrollToItem(listState.firstVisibleItemIndex - 1)
}
}*/
}
PageItem(
painter = item.painter,
iconContentDescription = item.iconContentDescription,
title = item.title,
backgroundGradientStart = item.backgroundGradientStart,
backgroundGradientEnd = item.backgroundGradientEnd,
backgroundGradientOffset = item.backgroundGradientOffset,
modifier = Modifier.onGloballyPositioned { coordinates ->
index = coordinates.positionInParent().x.roundToInt()
}
)
}
}
}
I'm pretty new to Compose too and don't understand how to run a coroutine just once instead of every composition...yschimke
11/04/2021, 2:18 PMAlex Vanyo
11/04/2021, 5:25 PMGabriel Gircenko
11/04/2021, 5:34 PMAlex Vanyo
11/04/2021, 5:37 PMaccompanist/pager
should work out of the box with Wear Compose, since it is only making use of the lower architectural layers of Compose that are shared between the platforms.yschimke
11/04/2021, 9:21 PMJohn Nichol
11/05/2021, 6:20 AMaccompanist/pager
and it does what is needed. We have also tested that it works well with Compose for Wear OS Swipe to Dismiss. We expect accompanist/pager
to migrate to Core Compose in the future. @Michail Kulaga do you have a code snippit you can share for the pager-swipe to dismiss integration?John Nichol
11/05/2021, 6:21 AMPaginationIndicator
which will provide a Wear Material Design indicator in the Scaffold
to show progression through a series of pages that will look good on both round and rectangular watch faces.