Skip to content

Commit

Permalink
Prepare version 2.5.0-beta01
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Dec 13, 2023
1 parent 50cba61 commit 273564a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 }
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 273564a

Please sign in to comment.