From 5ae9acba642b35c6958d43f3de12be273a88d07c Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Sun, 26 May 2024 12:01:13 +0200 Subject: [PATCH] Prepare version 2.6.0-beta01 --- .../calendar/buildsrc/Dependencies.kt | 2 +- .../calendar/compose/CalendarDefaults.kt | 10 +++---- gradle.properties | 3 +-- .../calendar/sample/compose/Example3Page.kt | 27 ++++++++++++------- 4 files changed, 22 insertions(+), 20 deletions(-) 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 b09791b5..a2ffc7e2 100644 --- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt +++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt @@ -66,7 +66,7 @@ object Libs { } object Compose { - private const val composeVersion = "1.6.1" + private const val composeVersion = "1.7.0-beta01" 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 3856d891..5bb39f4e 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarDefaults.kt @@ -4,7 +4,7 @@ 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.SnapPosition import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior import androidx.compose.foundation.lazy.LazyListState import androidx.compose.runtime.Composable @@ -22,7 +22,7 @@ internal object CalendarDefaults { @Composable private fun pagedFlingBehavior(state: LazyListState): FlingBehavior { val snappingLayout = remember(state) { - val provider = SnapLayoutInfoProvider(state, CalendarSnapPositionInLayout()) + val provider = SnapLayoutInfoProvider(state, SnapPosition.Start) CalendarSnapLayoutInfoProvider(provider) } return rememberSnapFlingBehavior(snappingLayout) @@ -46,9 +46,5 @@ private fun CalendarSnapLayoutInfoProvider( * 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 calculateApproachOffset(initialVelocity: Float): Float = 0f + override fun calculateApproachOffset(velocity: Float, decayOffset: Float): Float = 0f } - -@OptIn(ExperimentalFoundationApi::class) -@Suppress("FunctionName") -private fun CalendarSnapPositionInLayout() = SnapPositionInLayout { _, _, _, _, _ -> 0 } diff --git a/gradle.properties b/gradle.properties index 82024a69..7dea3d64 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,8 +6,7 @@ SONATYPE_HOST=S01 RELEASE_SIGNING_ENABLED=true GROUP=com.kizitonwose.calendar -VERSION_NAME=2.5.2-SNAPSHOT - +VERSION_NAME=2.6.0-beta01 POM_NAME=Calendar POM_INCEPTION_YEAR=2019 diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example3Page.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example3Page.kt index f494f6b6..225307de 100644 --- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example3Page.kt +++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example3Page.kt @@ -20,11 +20,13 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.foundation.lazy.items import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.LocalContentColor +import androidx.compose.material.LocalRippleConfiguration +import androidx.compose.material.RippleConfiguration import androidx.compose.material.Text import androidx.compose.material.darkColors -import androidx.compose.material.ripple.LocalRippleTheme -import androidx.compose.material.ripple.RippleTheme +import androidx.compose.material.ripple.RippleAlpha import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect @@ -126,7 +128,8 @@ fun Example3Page() { modifier = Modifier.wrapContentWidth(), state = state, dayContent = { day -> - CompositionLocalProvider(LocalRippleTheme provides Example3RippleTheme) { + @OptIn(ExperimentalMaterialApi::class) + CompositionLocalProvider(LocalRippleConfiguration provides Example3RippleConfiguration) { val colors = if (day.position == DayPosition.MonthDate) { flights[day.date].orEmpty().map { colorResource(it.color) } } else { @@ -319,13 +322,17 @@ private fun AirportInformation(airport: Airport, isDeparture: Boolean) { } // The default dark them ripple is too bright so we tone it down. -private object Example3RippleTheme : RippleTheme { - @Composable - override fun defaultColor() = RippleTheme.defaultRippleColor(Color.Gray, lightTheme = false) - - @Composable - override fun rippleAlpha() = RippleTheme.defaultRippleAlpha(Color.Gray, lightTheme = false) -} +@OptIn(ExperimentalMaterialApi::class) +private val Example3RippleConfiguration = RippleConfiguration( + color = Color.Gray, + // Copied from RippleTheme#DarkThemeRippleAlpha + rippleAlpha = RippleAlpha( + pressedAlpha = 0.10f, + focusedAlpha = 0.12f, + draggedAlpha = 0.08f, + hoveredAlpha = 0.04f, + ), +) @Preview(heightDp = 600) @Composable