From 7ad0f3483d1d0b6a5709fb01088519298e8aa34f Mon Sep 17 00:00:00 2001
From: Kizito Nwose <kizitonwose@gmail.com>
Date: Sat, 3 Aug 2024 10:37:34 +0200
Subject: [PATCH] Prepare version 2.5.4

---
 .../kizitonwose/calendar/buildsrc/Build.kt    |  4 +--
 .../calendar/compose/CalendarDefaults.kt      | 10 ++++---
 .../src/androidMain/AndroidManifest.xml       |  2 +-
 .../src/commonMain/kotlin/Example10Page.kt    |  5 ++--
 .../calendar/compose/CalendarDefaults.kt      | 10 ++++---
 gradle/libs.versions.toml                     | 10 +++----
 .../calendar/sample/compose/Example10Page.kt  |  7 +++--
 .../calendar/sample/compose/Example3Page.kt   | 27 +++++++++----------
 .../calendar/sample/compose/Example8Page.kt   |  2 ++
 .../calendar/sample/compose/Utils.kt          |  2 +-
 10 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt
index a360d6e5..1bbd3664 100644
--- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt
+++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt
@@ -12,8 +12,8 @@ object Config {
 }
 
 object Version {
-    val android = "2.6.0-SNAPSHOT"
-    val multiplatfrom = "2.6.0-SNAPSHOT"
+    val android = "2.5.4"
+    val multiplatfrom = "2.5.4"
 
     fun String.isNoPublish() = this == VERSION_NO_PUBLISH
 }
diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarDefaults.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarDefaults.kt
index 5bb39f4e..3856d891 100644
--- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarDefaults.kt
+++ b/compose-multiplatform/library/src/commonMain/kotlin/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.SnapPosition
+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
@@ -22,7 +22,7 @@ internal object CalendarDefaults {
     @Composable
     private fun pagedFlingBehavior(state: LazyListState): FlingBehavior {
         val snappingLayout = remember(state) {
-            val provider = SnapLayoutInfoProvider(state, SnapPosition.Start)
+            val provider = SnapLayoutInfoProvider(state, CalendarSnapPositionInLayout())
             CalendarSnapLayoutInfoProvider(provider)
         }
         return rememberSnapFlingBehavior(snappingLayout)
@@ -46,5 +46,9 @@ 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(velocity: Float, decayOffset: Float): Float = 0f
+    override fun calculateApproachOffset(initialVelocity: Float): Float = 0f
 }
+
+@OptIn(ExperimentalFoundationApi::class)
+@Suppress("FunctionName")
+private fun CalendarSnapPositionInLayout() = SnapPositionInLayout { _, _, _, _, _ -> 0 }
diff --git a/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml b/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml
index b87d9441..868a067b 100644
--- a/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml
+++ b/compose-multiplatform/sample/src/androidMain/AndroidManifest.xml
@@ -11,7 +11,7 @@
         <activity
             android:exported="true"
             android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
-            android:name=".MainActivity">
+            android:name="com.kizitonwose.calendar.compose.multiplatform.MainActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
diff --git a/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt b/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt
index 9322c986..b39c25fa 100644
--- a/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt
+++ b/compose-multiplatform/sample/src/commonMain/kotlin/Example10Page.kt
@@ -1,7 +1,8 @@
 
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.background
-import androidx.compose.foundation.gestures.snapping.SnapPosition
+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.layout.Arrangement
 import androidx.compose.foundation.layout.Box
@@ -166,7 +167,7 @@ private fun YearHeader(
             .wrapContentHeight()
             .background(headerBackground),
         state = headerState,
-        flingBehavior = rememberSnapFlingBehavior(lazyListState = headerState, SnapPosition.Center),
+        flingBehavior = rememberSnapFlingBehavior(SnapLayoutInfoProvider(headerState, SnapPositionInLayout.CenterToCenter)),
         contentPadding = PaddingValues(horizontal = if (isTablet) 40.dp else 10.dp),
     ) {
         items(count = startYear.yearsUntil(endYear)) { index ->
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 5bb39f4e..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,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.SnapPosition
+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
@@ -22,7 +22,7 @@ internal object CalendarDefaults {
     @Composable
     private fun pagedFlingBehavior(state: LazyListState): FlingBehavior {
         val snappingLayout = remember(state) {
-            val provider = SnapLayoutInfoProvider(state, SnapPosition.Start)
+            val provider = SnapLayoutInfoProvider(state, CalendarSnapPositionInLayout())
             CalendarSnapLayoutInfoProvider(provider)
         }
         return rememberSnapFlingBehavior(snappingLayout)
@@ -46,5 +46,9 @@ 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(velocity: Float, decayOffset: Float): Float = 0f
+    override fun calculateApproachOffset(initialVelocity: Float): Float = 0f
 }
+
+@OptIn(ExperimentalFoundationApi::class)
+@Suppress("FunctionName")
+private fun CalendarSnapPositionInLayout() = SnapPositionInLayout { _, _, _, _, _ -> 0 }
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 8831358e..936ade43 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,8 +1,8 @@
 [versions]
 agp = "8.5.1"
 kotlin = "2.0.0"
-composeAndroid = "1.7.0-beta06"
-composeMultiplatform = "1.7.0-alpha01"
+composeAndroid = "1.6.8"
+composeMultiplatform = "1.6.11"
 espresso = "3.6.1"
 junit5 = "5.10.3"
 kotlinxSerialization = "1.7.1"
@@ -35,14 +35,14 @@ compose-ui-ui = { module = "androidx.compose.ui:ui", version.ref = "composeAndro
 compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "composeAndroid" }
 compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "composeAndroid" }
 compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "composeAndroid" }
-compose-material3 = { module = "androidx.compose.material3:material3", version = "1.3.0-beta05" }
+compose-material3 = { module = "androidx.compose.material3:material3", version = "1.2.1" }
 compose-activity = { module = "androidx.activity:activity-compose", version = "1.9.1" }
-compose-navigation = { module = "androidx.navigation:navigation-compose", version = "2.8.0-beta06" }
+compose-navigation = { module = "androidx.navigation:navigation-compose", version = "2.7.7" }
 
 compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "composeAndroid" }
 compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "composeAndroid" }
 
-jetbrains-compose-navigation = { module = "org.jetbrains.androidx.navigation:navigation-compose", version = "2.8.0-alpha08" }
+jetbrains-compose-navigation = { module = "org.jetbrains.androidx.navigation:navigation-compose", version = "2.7.0-alpha07" }
 
 [plugins]
 androidApplication = { id = "com.android.application", version.ref = "agp" }
diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example10Page.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example10Page.kt
index dbedbb7a..3e741e80 100644
--- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example10Page.kt
+++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example10Page.kt
@@ -1,7 +1,9 @@
 package com.kizitonwose.calendar.sample.compose
 
+import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.background
-import androidx.compose.foundation.gestures.snapping.SnapPosition
+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.layout.Arrangement
 import androidx.compose.foundation.layout.Box
@@ -147,6 +149,7 @@ fun Example10Page(adjacentYears: Long = 50) {
     }
 }
 
+@OptIn(ExperimentalFoundationApi::class)
 @Composable
 private fun YearHeader(
     startYear: Year,
@@ -163,7 +166,7 @@ private fun YearHeader(
             .wrapContentHeight()
             .background(headerBackground),
         state = headerState,
-        flingBehavior = rememberSnapFlingBehavior(lazyListState = headerState, SnapPosition.Center),
+        flingBehavior = rememberSnapFlingBehavior(SnapLayoutInfoProvider(headerState, SnapPositionInLayout.CenterToCenter)),
         contentPadding = PaddingValues(horizontal = if (isTablet) 40.dp else 10.dp),
     ) {
         items(count = startYear.yearsUntil(endYear).toInt()) { index ->
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 27fcccb1..b5363187 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
@@ -19,12 +19,9 @@ import androidx.compose.foundation.layout.wrapContentWidth
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.LazyItemScope
 import androidx.compose.foundation.lazy.items
-import androidx.compose.material.ripple.RippleAlpha
 import androidx.compose.material3.ExperimentalMaterial3Api
 import androidx.compose.material3.HorizontalDivider
 import androidx.compose.material3.LocalContentColor
-import androidx.compose.material3.LocalRippleConfiguration
-import androidx.compose.material3.RippleConfiguration
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.CompositionLocalProvider
@@ -128,7 +125,7 @@ fun Example3Page() {
                 state = state,
                 dayContent = { day ->
                     @OptIn(ExperimentalMaterial3Api::class)
-                    CompositionLocalProvider(LocalRippleConfiguration provides Example3RippleConfiguration) {
+//                    CompositionLocalProvider(LocalRippleConfiguration provides Example3RippleConfiguration) {
                         val colors = if (day.position == DayPosition.MonthDate) {
                             flights[day.date].orEmpty().map { colorResource(it.color) }
                         } else {
@@ -141,7 +138,7 @@ fun Example3Page() {
                         ) { clicked ->
                             selection = clicked
                         }
-                    }
+//                    }
                 },
                 monthHeader = {
                     MonthHeader(
@@ -322,16 +319,16 @@ private fun AirportInformation(airport: Airport, isDeparture: Boolean) {
 
 // The default dark them ripple is too bright so we tone it down.
 @OptIn(ExperimentalMaterial3Api::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,
-    ),
-)
+//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
diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt
index 880c70d8..16888f83 100644
--- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt
+++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Example8Page.kt
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.ExperimentalMaterial3Api
 import androidx.compose.material3.LocalContentColor
 import androidx.compose.material3.SegmentedButton
 import androidx.compose.material3.SegmentedButtonDefaults
@@ -176,6 +177,7 @@ private fun FullScreenCalendar(
     }
 }
 
+@OptIn(ExperimentalMaterial3Api::class)
 @Composable
 private fun PageOptions(selectedIndex: Int, onSelect: (Int) -> Unit) {
     val options = listOf("Horizontal", "Vertical")
diff --git a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt
index 1535fd4b..7a027057 100644
--- a/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt
+++ b/sample/src/main/java/com/kizitonwose/calendar/sample/compose/Utils.kt
@@ -26,9 +26,9 @@ import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.toArgb
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.platform.LocalInspectionMode
+import androidx.compose.ui.platform.LocalLifecycleOwner
 import androidx.compose.ui.semantics.Role
 import androidx.compose.ui.unit.dp
-import androidx.lifecycle.compose.LocalLifecycleOwner
 import com.kizitonwose.calendar.compose.CalendarLayoutInfo
 import com.kizitonwose.calendar.compose.CalendarState
 import com.kizitonwose.calendar.compose.weekcalendar.WeekCalendarState