Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Update to Compose 2023.10.01 (#940)
Browse files Browse the repository at this point in the history
* Update to Compose 2023.10.01

Change-Id: I9e663b9eda4762fbd83b418d33ee4d7a22820a7c

* Update usage of Pages.

Change-Id: I5a9421041d497c83a12585ab429f847e441e4c92
  • Loading branch information
arriolac authored Dec 20, 2023
1 parent cdccad4 commit 937fc80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ enum class SunflowerPage(
fun HomeScreen(
modifier: Modifier = Modifier,
onPlantClick: (Plant) -> Unit = {},
viewModel: PlantListViewModel = hiltViewModel()
viewModel: PlantListViewModel = hiltViewModel(),
pages: Array<SunflowerPage> = SunflowerPage.values()
) {
val pagerState = rememberPagerState()
val pagerState = rememberPagerState(pageCount = { pages.size })
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()

Scaffold(
Expand All @@ -89,6 +90,7 @@ fun HomeScreen(
HomePagerScreen(
onPlantClick = onPlantClick,
pagerState = pagerState,
pages = pages,
Modifier.padding(top = contentPadding.calculateTopPadding())
)
}
Expand All @@ -99,8 +101,8 @@ fun HomeScreen(
fun HomePagerScreen(
onPlantClick: (Plant) -> Unit,
pagerState: PagerState,
pages: Array<SunflowerPage>,
modifier: Modifier = Modifier,
pages: Array<SunflowerPage> = SunflowerPage.values()
) {
Column(modifier) {
val coroutineScope = rememberCoroutineScope()
Expand Down Expand Up @@ -129,7 +131,6 @@ fun HomePagerScreen(
// Pages
HorizontalPager(
modifier = Modifier.background(MaterialTheme.colorScheme.background),
pageCount = pages.size,
state = pagerState,
verticalAlignment = Alignment.Top
) { index ->
Expand Down Expand Up @@ -200,9 +201,11 @@ private fun HomeTopAppBar(
@Composable
private fun HomeScreenPreview() {
SunflowerTheme {
val pages = SunflowerPage.values()
HomePagerScreen(
onPlantClick = {},
pagerState = PagerState(),
pagerState = rememberPagerState(pageCount = { pages.size }),
pages = pages
)
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ androidGradlePlugin = "8.1.2"
benchmark = "1.1.0"
# @keep
compileSdk = "34"
composeLatest = "1.4.0-alpha03"
composeBom = "2023.06.01"
composeLatest = "1.6.0-beta03"
composeBom = "2023.10.01"
compose-compiler = "1.5.3"
constraintLayoutCompose = "1.0.1"
coreTesting = "2.2.0"
Expand Down

0 comments on commit 937fc80

Please sign in to comment.