diff --git a/app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt b/app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt index 299c21467..9deaba6a8 100644 --- a/app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt +++ b/app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt @@ -71,9 +71,10 @@ enum class SunflowerPage( fun HomeScreen( modifier: Modifier = Modifier, onPlantClick: (Plant) -> Unit = {}, - viewModel: PlantListViewModel = hiltViewModel() + viewModel: PlantListViewModel = hiltViewModel(), + pages: Array = SunflowerPage.values() ) { - val pagerState = rememberPagerState() + val pagerState = rememberPagerState(pageCount = { pages.size }) val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() Scaffold( @@ -89,6 +90,7 @@ fun HomeScreen( HomePagerScreen( onPlantClick = onPlantClick, pagerState = pagerState, + pages = pages, Modifier.padding(top = contentPadding.calculateTopPadding()) ) } @@ -99,8 +101,8 @@ fun HomeScreen( fun HomePagerScreen( onPlantClick: (Plant) -> Unit, pagerState: PagerState, + pages: Array, modifier: Modifier = Modifier, - pages: Array = SunflowerPage.values() ) { Column(modifier) { val coroutineScope = rememberCoroutineScope() @@ -129,7 +131,6 @@ fun HomePagerScreen( // Pages HorizontalPager( modifier = Modifier.background(MaterialTheme.colorScheme.background), - pageCount = pages.size, state = pagerState, verticalAlignment = Alignment.Top ) { index -> @@ -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 ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0c27a9ccb..fb9ecac4e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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"