diff --git a/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt b/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt index abbf12a4..ad2988b6 100644 --- a/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt +++ b/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt @@ -104,7 +104,14 @@ fun DisneyPosters( PosterItem(poster, vm) } } - SelectedPoster(poster) + + var palette by rememberPaletteState() + + SelectedPoster(poster = poster, onPaletteUpdated = { palette = it }) + + palette?.let { + PosterInformation(poster = poster, it) + } } } @@ -131,9 +138,8 @@ private fun PosterItem( @Composable private fun SelectedPoster( poster: Poster, + onPaletteUpdated: (Palette) -> Unit, ) { - var palette by rememberPaletteState(null) - CoilImage( imageModel = { poster.image }, modifier = Modifier.aspectRatio(0.8f), @@ -149,11 +155,17 @@ private fun SelectedPoster( ), ) +CircularRevealPlugin() - +PalettePlugin { palette = it } + +PalettePlugin { onPaletteUpdated.invoke(it) } }, previewPlaceholder = painterResource(id = R.drawable.poster), ) +} +@Composable +private fun PosterInformation( + poster: Poster, + palette: Palette, +) { ColorPalettes(palette) Text( @@ -190,7 +202,7 @@ private fun SelectedPoster( } @Composable -private fun ColorPalettes(palette: Palette?) { +private fun ColorPalettes(palette: Palette) { val colorList: List = palette.paletteColorList() LazyRow( @@ -224,7 +236,7 @@ private fun SelectedPosterPreview() { .fillMaxSize() .verticalScroll(rememberScrollState()), ) { - SelectedPoster(poster = MockUtil.getMockPoster()) + SelectedPoster(poster = MockUtil.getMockPoster()) {} } } } diff --git a/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/AndroidCompose.kt index 23741a4e..83de72c7 100644 --- a/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/AndroidCompose.kt @@ -40,10 +40,6 @@ internal fun Project.configureAndroidCompose( compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.14" - } - packaging { resources { excludes.add("/META-INF/{AL2.0,LGPL2.1}") diff --git a/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt b/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt index 07307b6c..6051de93 100644 --- a/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt +++ b/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt @@ -214,11 +214,14 @@ public fun CoilImage( imageOptions = imageOptions, modifier = modifier, ) ImageRequest@{ imageState -> - when ( - val coilImageState = imageState.toCoilImageState().apply { + + val coilImageState: CoilImageState = remember(imageState) { + imageState.toCoilImageState().apply { onImageStateChanged.invoke(this) } - ) { + } + + when (coilImageState) { is CoilImageState.None -> Unit is CoilImageState.Loading -> { diff --git a/coil3/build.gradle.kts b/coil3/build.gradle.kts index ae3b260c..a7961815 100644 --- a/coil3/build.gradle.kts +++ b/coil3/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ import com.github.skydoves.landscapist.Configuration +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("landscapist.library.compose.multiplatformWasm") @@ -115,14 +117,10 @@ baselineProfile { } } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += listOf( - "-Xexplicit-api=strict", - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-opt-in=com.skydoves.landscapist.InternalLandscapistApi", +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + freeCompilerArgs.addAll( "-opt-in=coil3.annotation.ExperimentalCoilApi", ) } diff --git a/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt b/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt index 5180131a..88dcb730 100644 --- a/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt +++ b/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt @@ -192,11 +192,14 @@ public fun CoilImage( imageOptions = imageOptions, modifier = modifier, ) ImageRequest@{ imageState -> - when ( - val coilImageState = imageState.toCoilImageState().apply { + + val coilImageState: CoilImageState = remember(imageState) { + imageState.toCoilImageState().apply { onImageStateChanged.invoke(this) } - ) { + } + + when (coilImageState) { is CoilImageState.None -> Unit is CoilImageState.Loading -> { diff --git a/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt b/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt index 81083b00..a69ab7f9 100644 --- a/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt +++ b/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt @@ -121,11 +121,15 @@ public fun FrescoImage( imageRequest = StableHolder(imageRequest.invoke()), modifier = modifier, ) ImageRequest@{ imageState -> - when ( - val frescoImageState = imageState.toFrescoImageState().apply { + + val state: FrescoImageState = imageState.toFrescoImageState() + val frescoImageState = remember(state) { + state.apply { onImageStateChanged.invoke(this) } - ) { + } + + when (frescoImageState) { is FrescoImageState.None -> Unit is FrescoImageState.Loading -> { diff --git a/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt b/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt index 55e91c46..d78814cd 100644 --- a/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt +++ b/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt @@ -25,6 +25,8 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.BoxWithConstraintsScope import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalInspectionMode @@ -149,11 +151,14 @@ public fun GlideImage( clearTarget = clearTarget, modifier = modifier, ) ImageRequest@{ imageState -> - when ( - val glideImageState = imageState.toGlideImageState( + + val glideImageState: GlideImageState = remember(imageState) { + imageState.toGlideImageState( glideRequestType = glideRequestType, ).apply { onImageStateChanged.invoke(this) } - ) { + } + + when (glideImageState) { is GlideImageState.None -> Unit is GlideImageState.Loading -> { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 35fc902e..3a2f7e39 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ dokka = "2.0.0" jvmTarget = "11" nexusPlugin = "0.30.0" kotlinxCoroutines = "1.9.0" -kotlinBinaryCompatibility = "0.16.3" +kotlinBinaryCompatibility = "0.17.0" androidGradlePlugin = "8.7.3" androidxActivity = "1.9.3" androidxMaterial = "1.12.0" diff --git a/landscapist-animation/build.gradle.kts b/landscapist-animation/build.gradle.kts index e90255d8..0876330a 100644 --- a/landscapist-animation/build.gradle.kts +++ b/landscapist-animation/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ import com.github.skydoves.landscapist.Configuration +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("landscapist.library.compose.multiplatformWasm") @@ -86,10 +88,10 @@ baselineProfile { } } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += listOf( +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + freeCompilerArgs.addAll( "-Xexplicit-api=strict", "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", diff --git a/landscapist-palette/build.gradle.kts b/landscapist-palette/build.gradle.kts index f178f2bc..48e2ac63 100644 --- a/landscapist-palette/build.gradle.kts +++ b/landscapist-palette/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ import com.github.skydoves.landscapist.Configuration +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("landscapist.library.compose.multiplatform") @@ -81,10 +83,10 @@ baselineProfile { } } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += listOf( +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + freeCompilerArgs.addAll( "-Xexplicit-api=strict", "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", diff --git a/landscapist-palette/src/commonMain/kotlin/com/skydoves/landscapist/palette/RememberPaletteState.kt b/landscapist-palette/src/commonMain/kotlin/com/skydoves/landscapist/palette/RememberPaletteState.kt index 37612ee1..6e5138cc 100644 --- a/landscapist-palette/src/commonMain/kotlin/com/skydoves/landscapist/palette/RememberPaletteState.kt +++ b/landscapist-palette/src/commonMain/kotlin/com/skydoves/landscapist/palette/RememberPaletteState.kt @@ -32,6 +32,8 @@ import com.kmpalette.palette.graphics.Palette */ @Composable public fun rememberPaletteState( - value: Palette?, + value: Palette? = null, policy: SnapshotMutationPolicy = structuralEqualityPolicy(), -): MutableState = remember { mutableStateOf(value = value, policy = policy) } +): MutableState = remember(key1 = value) { + mutableStateOf(value = value, policy = policy) +} diff --git a/landscapist-placeholder/build.gradle.kts b/landscapist-placeholder/build.gradle.kts index 6cdd694b..1e49a356 100644 --- a/landscapist-placeholder/build.gradle.kts +++ b/landscapist-placeholder/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ import com.github.skydoves.landscapist.Configuration +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("landscapist.library.compose.multiplatformWasm") @@ -86,10 +88,10 @@ baselineProfile { } } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += listOf( +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + freeCompilerArgs.addAll( "-Xexplicit-api=strict", "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", diff --git a/landscapist/build.gradle.kts b/landscapist/build.gradle.kts index 20809763..20cfe7d8 100644 --- a/landscapist/build.gradle.kts +++ b/landscapist/build.gradle.kts @@ -15,6 +15,8 @@ */ import com.github.skydoves.landscapist.Configuration +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("landscapist.library.compose.multiplatformWasm") @@ -83,14 +85,9 @@ baselineProfile { } } -tasks.withType { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += listOf( - "-Xexplicit-api=strict", - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-opt-in=com.skydoves.landscapist.InternalLandscapistApi", - ) +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } } diff --git a/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt index 07eb2a68..3bf404ab 100644 --- a/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt +++ b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt @@ -55,13 +55,13 @@ public fun ImageLoad( var state by remember(recomposeKey, imageOptions) { mutableStateOf(ImageLoadState.None) } - LaunchedEffect(recomposeKey, imageOptions) { - executeImageLoading( - executeImageRequest, - ).collect { + + LaunchedEffect(key1 = recomposeKey, key2 = imageOptions) { + executeImageLoading(executeImageRequest).collect { state = it } } + BoxWithConstraints( modifier = modifier.imageSemantics(imageOptions), propagateMinConstraints = true, @@ -85,7 +85,7 @@ public fun ImageLoad( } } -private suspend fun executeImageLoading( +private fun executeImageLoading( executeImageRequest: suspend () -> Flow, ) = flow { // execute imager loading