Skip to content

Commit

Permalink
Bump androidx.compose:compose-bom from 2023.10.01 to 2024.02.02 (#1862)
Browse files Browse the repository at this point in the history
* Bump androidx.compose:compose-bom from 2023.10.01 to 2024.01.00

Bumps androidx.compose:compose-bom from 2023.10.01 to 2024.01.00.

---
updated-dependencies:
- dependency-name: androidx.compose:compose-bom
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Resolve compilation errors and crashes

* Fix lint errors

* Fix endless scrolling of BpkCarousel after bump compose foundation to 1.6

* Bump compose compiler version to 1.5.9

* Revert "Fix lint errors"

This reverts commit 4be9715.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maria Neumayer <[email protected]>
Co-authored-by: Alejandro Rosas <[email protected]>
  • Loading branch information
3 people authored Mar 7, 2024
1 parent 83ee0c0 commit 5c5f720
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun rememberBpkCarouselState(
totalImages: Int,
initialImage: Int = 0,
): BpkCarouselState {
val initialPage = (Int.MAX_VALUE / 2) + initialImage
val initialPage = (getModdedPageCount(totalImages) / 2) + initialImage

val pagerState = rememberSaveable(saver = InfinitePagerState.Saver) {
InfinitePagerState(
Expand All @@ -78,7 +78,7 @@ fun BpkCarouselState(
totalImages: Int,
initialImage: Int = 0,
): BpkCarouselState {
val initialPage = (Int.MAX_VALUE / 2) + initialImage
val initialPage = (getModdedPageCount(totalImages) / 2) + initialImage
return BpkCarouselInternalState(
delegate = InfinitePagerState(initialPage = initialPage, totalPages = totalImages),
totalImages = totalImages,
Expand Down Expand Up @@ -118,7 +118,7 @@ internal class BpkCarouselInternalState(
return delegate.currentPage - (currentPage - page)
}

fun getModdedPageNumber(index: Int, count: Int) = (index - (Int.MAX_VALUE / 2)).floorMod(count)
fun getModdedPageNumber(index: Int, count: Int) = (index - (getModdedPageCount(totalImages) / 2)).floorMod(count)

private fun Int.floorMod(other: Int): Int = when (other) {
0 -> this
Expand All @@ -130,11 +130,10 @@ internal class BpkCarouselInternalState(
private class InfinitePagerState(
initialPage: Int,
private val totalPages: Int,
) : PagerState(initialPage, initialPageOffsetFraction = 0f) {
) : PagerState(initialPage, currentPageOffsetFraction = 0f) {

override val pageCount: Int
// if count > 1, set to Int.MAX_VALUE for infinite looping
get() = if (totalPages > 1) Int.MAX_VALUE else 1
get() = getModdedPageCount(totalPages)

companion object {
val Saver: Saver<InfinitePagerState, *> = listSaver(
Expand All @@ -153,3 +152,7 @@ private class InfinitePagerState(
)
}
}

// if count > 1, set to (totalPages * 1000) for "infinite" looping
// revert this change and use Int.MAX_VALUE when https://issuetracker.google.com/issues/311414925 fix is released
private fun getModdedPageCount(count: Int) = if (count > 1) count * 100 else 1
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private fun TopAppBarLayout(

val layoutHeight = heightPx.roundToInt()

layout(constraints.maxWidth, layoutHeight) {
layout(constraints.maxWidth, max(0, layoutHeight)) {
navigationIconPlaceable.placeRelative(
x = 0,
y = (layoutHeight - navigationIconPlaceable.height) / 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal fun BpkRangeSliderImpl(
track = {
SliderDefaults.Track(
colors = sliderColors(),
sliderPositions = it,
rangeSliderState = it,
)
},
colors = sliderColors(),
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "1.9.22"
ksp = "1.9.22-1.0.17" # depends on Kotlin version
composeCompiler = "1.5.8" # depends on Kotlin version
composeCompiler = "1.5.9" # depends on Kotlin version
compilerTesting = "1.5.0"
destinations = "1.9.55" # update this alongside with compiler version

Expand Down Expand Up @@ -80,7 +80,7 @@ kotlin-compilerTestingKsp = { module = "com.github.tschuchortdev:kotlin-compile-
lint-lint = { module = "com.android.tools.lint:lint", version.ref = "lint" }
lint-api = { module = "com.android.tools.lint:lint-api", version.ref = "lint" }

compose-bom = { group = "androidx.compose", name = "compose-bom", version = "2023.10.01" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version = "2024.02.00" }
compose-ui = { group = "androidx.compose.ui", name = "ui" }
compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
Expand Down

0 comments on commit 5c5f720

Please sign in to comment.