diff --git a/buildSrc/src/main/kotlin/Projects.kt b/buildSrc/src/main/kotlin/Projects.kt index 831baa4662..6f93ae1feb 100644 --- a/buildSrc/src/main/kotlin/Projects.kt +++ b/buildSrc/src/main/kotlin/Projects.kt @@ -82,11 +82,9 @@ private inline fun Project.setupBaseModule( "-Xno-call-assertions", "-Xno-param-assertions", "-Xno-receiver-assertions", - // https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-requires-opt-in/#requiresoptin - "-Xopt-in=kotlin.RequiresOptIn" ) if (project.name != "coil-test") { - arguments += "-Xopt-in=coil.annotation.ExperimentalCoilApi" + arguments += "-opt-in=coil.annotation.ExperimentalCoilApi" } // https://youtrack.jetbrains.com/issue/KT-41985 freeCompilerArgs += arguments diff --git a/coil-base/api/coil-base.api b/coil-base/api/coil-base.api index da8807691a..dcf8a922ca 100644 --- a/coil-base/api/coil-base.api +++ b/coil-base/api/coil-base.api @@ -426,6 +426,14 @@ public final class coil/memory/MemoryCache$Key : android/os/Parcelable { public fun writeToParcel (Landroid/os/Parcel;I)V } +public final class coil/memory/MemoryCache$Key$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcoil/memory/MemoryCache$Key; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcoil/memory/MemoryCache$Key; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + public final class coil/memory/MemoryCache$Value { public fun (Landroid/graphics/Bitmap;Ljava/util/Map;)V public synthetic fun (Landroid/graphics/Bitmap;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V diff --git a/coil-compose-base/build.gradle.kts b/coil-compose-base/build.gradle.kts index c5f09a8ac2..22f748df17 100644 --- a/coil-compose-base/build.gradle.kts +++ b/coil-compose-base/build.gradle.kts @@ -10,7 +10,7 @@ setupLibraryModule(publish = true) { compose = true } composeOptions { - kotlinCompilerExtensionVersion = libs.versions.compose.get() + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } } diff --git a/coil-compose-singleton/build.gradle.kts b/coil-compose-singleton/build.gradle.kts index a97e06e29e..4fa3a56e58 100644 --- a/coil-compose-singleton/build.gradle.kts +++ b/coil-compose-singleton/build.gradle.kts @@ -10,7 +10,7 @@ setupLibraryModule(publish = true) { compose = true } composeOptions { - kotlinCompilerExtensionVersion = libs.versions.compose.get() + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } } diff --git a/coil-sample-compose/build.gradle.kts b/coil-sample-compose/build.gradle.kts index b4521b4fd4..1c1bbf3677 100644 --- a/coil-sample-compose/build.gradle.kts +++ b/coil-sample-compose/build.gradle.kts @@ -21,7 +21,7 @@ setupAppModule { compose = true } composeOptions { - kotlinCompilerExtensionVersion = libs.versions.compose.get() + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } } @@ -34,6 +34,5 @@ dependencies { implementation(libs.androidx.activity.compose) implementation(libs.androidx.lifecycle.viewmodel.compose) - implementation(libs.accompanist.insets) implementation(libs.compose.material) } diff --git a/coil-sample-compose/src/main/java/coil/sample/LazyStaggeredGrid.kt b/coil-sample-compose/src/main/java/coil/sample/LazyStaggeredGrid.kt index f41c51803e..bd1c8c6d9c 100644 --- a/coil-sample-compose/src/main/java/coil/sample/LazyStaggeredGrid.kt +++ b/coil-sample-compose/src/main/java/coil/sample/LazyStaggeredGrid.kt @@ -14,22 +14,18 @@ */ package coil.sample -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.gestures.LocalOverScrollConfiguration +import androidx.compose.foundation.gestures.Orientation +import androidx.compose.foundation.gestures.rememberScrollableState import androidx.compose.foundation.gestures.scrollBy +import androidx.compose.foundation.gestures.scrollable import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.input.nestedscroll.NestedScrollConnection -import androidx.compose.ui.input.nestedscroll.NestedScrollSource -import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.unit.dp import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -47,38 +43,22 @@ fun LazyStaggeredGrid( } val scope = rememberCoroutineScope { Dispatchers.Main.immediate } - val scrollConnections = List(columnCount) { index -> - object : NestedScrollConnection { - override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { - val delta = available.y - scope.launch { - states.forEachIndexed { stateIndex, state -> - if (stateIndex != index) { - state.scrollBy(-delta) - } - } - } - return Offset.Zero - } - } + val scrollableState = rememberScrollableState { delta -> + scope.launch { states.forEach { it.scrollBy(-delta) } } + delta } val gridScope = RealLazyStaggeredGridScope(columnCount).apply(content) - // Disable overscroll otherwise it'll only overscroll one column. - @OptIn(ExperimentalFoundationApi::class) - CompositionLocalProvider(LocalOverScrollConfiguration provides null) { - Row { - for (index in 0 until columnCount) { - LazyColumn( - contentPadding = contentPadding, - state = states[index], - modifier = Modifier - .nestedScroll(scrollConnections[index]) - .weight(1f) - ) { - for ((key, itemContent) in gridScope.items(index)) { - item(key) { itemContent() } - } + Row(Modifier.scrollable(scrollableState, Orientation.Vertical)) { + for (index in 0 until columnCount) { + LazyColumn( + contentPadding = contentPadding, + state = states[index], + userScrollEnabled = false, + modifier = Modifier.weight(1f) + ) { + for ((key, itemContent) in gridScope.items(index)) { + item(key) { itemContent() } } } } diff --git a/coil-sample-compose/src/main/java/coil/sample/MainActivity.kt b/coil-sample-compose/src/main/java/coil/sample/MainActivity.kt index 80808090c4..7d9b7ce6e2 100644 --- a/coil-sample-compose/src/main/java/coil/sample/MainActivity.kt +++ b/coil-sample-compose/src/main/java/coil/sample/MainActivity.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.LazyListState import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme @@ -33,8 +34,6 @@ import androidx.lifecycle.viewmodel.compose.viewModel import coil.compose.AsyncImage import coil.memory.MemoryCache import coil.request.ImageRequest -import com.google.accompanist.insets.LocalWindowInsets -import com.google.accompanist.insets.ProvideWindowInsets class MainActivity : ComponentActivity() { @@ -53,26 +52,24 @@ private fun Content(viewModel: MainViewModel = viewModel()) { onPrimary = Color.Black ) ) { - ProvideWindowInsets { - Scaffold( - topBar = { - Toolbar( - assetType = viewModel.assetType.collectAsState().value, - onAssetTypeChange = { viewModel.assetType.value = it } + Scaffold( + topBar = { + Toolbar( + assetType = viewModel.assetType.collectAsState().value, + onAssetTypeChange = { viewModel.assetType.value = it } + ) + }, + content = { padding -> + Box(Modifier.padding(padding)) { + ScaffoldContent( + screen = viewModel.screen.collectAsState().value, + onScreenChange = { viewModel.screen.value = it }, + images = viewModel.images.collectAsState().value ) - }, - content = { padding -> - Box(Modifier.padding(padding)) { - ScaffoldContent( - screen = viewModel.screen.collectAsState().value, - onScreenChange = { viewModel.screen.value = it }, - images = viewModel.images.collectAsState().value - ) - } } - ) - BackHandler { viewModel.onBackPressed() } - } + } + ) + BackHandler { viewModel.onBackPressed() } } } @@ -81,13 +78,10 @@ private fun Toolbar( assetType: AssetType, onAssetTypeChange: (AssetType) -> Unit, ) { - val topPadding = with(LocalDensity.current) { - LocalWindowInsets.current.systemBars.top.toDp() - } TopAppBar( title = { Text(stringResource(R.string.app_name)) }, actions = { AssetTypeButton(assetType, onAssetTypeChange) }, - modifier = Modifier.padding(top = topPadding) + modifier = Modifier.statusBarsPadding() ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5da6dc62af..140432395b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] -accompanist = "0.23.1" androidx-activity = "1.4.0" androidx-lifecycle = "2.4.1" androidx-test = "1.4.0" -compose = "1.1.1" +compose = "1.2.0-rc03" +composeCompiler = "1.2.0" coroutines = "1.6.4" ktlint = "0.44.0" okhttp = "4.10.0" @@ -16,11 +16,10 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "10.3.0" } [libraries] gradlePlugin-android = "com.android.tools.build:gradle:7.2.1" -gradlePlugin-kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" +gradlePlugin-kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0" gradlePlugin-mavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.21.0" -accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" } -accompanist-insets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" } +accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version = "0.24.13-rc" } androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }