Skip to content

Commit

Permalink
fix pager snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
riggaroo committed Oct 23, 2023
1 parent de41aa6 commit 5896134
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PageSize
Expand Down Expand Up @@ -361,40 +362,36 @@ fun PagerWithTabs() {
@Preview
@Composable
fun PagerIndicator() {
Box {
Box(modifier = Modifier.fillMaxSize()) {
// [START android_compose_pager_indicator]
val pageCount = 4
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
state = pagerState
state = pagerState,
modifier = Modifier.fillMaxSize()
) { page ->
// Our page content
Box(
modifier = Modifier.background(Color.Cyan).size(400.dp)
){
Text(
text = "Page: $page",
)
}
Text(
text = "Page: $page",
)
}
Row(
Modifier
.height(50.dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.Bottom
.wrapContentHeight()
.fillMaxWidth()
.align(Alignment.BottomCenter)
.padding(bottom = 8.dp),
horizontalArrangement = Arrangement.Center
) {
repeat(pageCount) { iteration ->
repeat(pagerState.pageCount) { iteration ->
val color = if (pagerState.currentPage == iteration) Color.DarkGray else Color.LightGray
Box(
modifier = Modifier
.padding(2.dp)
.clip(CircleShape)
.background(color)
.size(20.dp)

.size(16.dp)
)
}
}
Expand Down

0 comments on commit 5896134

Please sign in to comment.