diff --git a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt index 1fce3562..7f322833 100644 --- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt +++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt @@ -64,7 +64,7 @@ object Libs { } object Compose { - private const val composeVersion = "1.5.4" + private const val composeVersion = "1.6.0-beta02" const val ui = "androidx.compose.ui:ui:$composeVersion" const val foundation = "androidx.compose.foundation:foundation:$composeVersion" const val tooling = "androidx.compose.ui:ui-tooling:$composeVersion" diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt index df380a56..3856d891 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt @@ -4,14 +4,13 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.gestures.FlingBehavior import androidx.compose.foundation.gestures.ScrollableDefaults import androidx.compose.foundation.gestures.snapping.SnapLayoutInfoProvider +import androidx.compose.foundation.gestures.snapping.SnapPositionInLayout import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior import androidx.compose.foundation.lazy.LazyListState import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.compose.ui.unit.Density internal object CalendarDefaults { - /** * The default implementation in [rememberSnapFlingBehavior] snaps to the center of the layout * but we want to snap to the start. For example, in a vertical calendar, when the layout size @@ -23,7 +22,7 @@ internal object CalendarDefaults { @Composable private fun pagedFlingBehavior(state: LazyListState): FlingBehavior { val snappingLayout = remember(state) { - val provider = SnapLayoutInfoProvider(state) { _, _, _ -> 0 } + val provider = SnapLayoutInfoProvider(state, CalendarSnapPositionInLayout()) CalendarSnapLayoutInfoProvider(provider) } return rememberSnapFlingBehavior(snappingLayout) @@ -43,10 +42,13 @@ internal object CalendarDefaults { private fun CalendarSnapLayoutInfoProvider( snapLayoutInfoProvider: SnapLayoutInfoProvider, ): SnapLayoutInfoProvider = object : SnapLayoutInfoProvider by snapLayoutInfoProvider { - /** * In compose 1.3, the default was single page snapping (zero), but this changed * in compose 1.4 to decayed page snapping which is not great for calendar usage. */ - override fun Density.calculateApproachOffset(initialVelocity: Float): Float = 0f + override fun calculateApproachOffset(initialVelocity: Float): Float = 0f } + +@OptIn(ExperimentalFoundationApi::class) +@Suppress("FunctionName") +private fun CalendarSnapPositionInLayout() = SnapPositionInLayout { _, _, _, _, _ -> 0 } diff --git a/gradle.properties b/gradle.properties index b23111f1..d4ac1ede 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ SONATYPE_HOST=S01 RELEASE_SIGNING_ENABLED=true GROUP=com.kizitonwose.calendar -VERSION_NAME=2.4.1 +VERSION_NAME=2.5.0-beta01 POM_NAME=Calendar