diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ffc1b0d7..56545aaa 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,7 +9,7 @@ on: jobs: lint: name: Spotless check - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v4.1.1 @@ -23,7 +23,7 @@ jobs: api_check: name: API check - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v4.1.1 @@ -37,7 +37,7 @@ jobs: build: name: Build and Tests - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index ae794441..550a5ba0 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -9,7 +9,7 @@ permissions: jobs: deploy: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 8ea64975..de26c894 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -9,7 +9,7 @@ on: jobs: publish: name: Snapshot build and publish - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 41d9c6b5..1d0d2e55 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,7 @@ on: jobs: publish: name: Release build and publish - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v4.1.1 diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index f90e6170..a9ca7f4f 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -1,33 +1,37 @@ plugins { - `kotlin-dsl` + `kotlin-dsl` } group = "com.skydoves.landscapist.buildlogic" java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } dependencies { - compileOnly(libs.android.gradlePlugin) - compileOnly(libs.kotlin.gradlePlugin) - compileOnly(libs.spotless.gradlePlugin) + compileOnly(libs.android.gradlePlugin) + compileOnly(libs.kotlin.gradlePlugin) + compileOnly(libs.spotless.gradlePlugin) } gradlePlugin { - plugins { - register("androidApplicationCompose") { - id = "landscapist.application.compose" - implementationClass = "AndroidApplicationComposeConventionPlugin" - } - register("androidLibraryCompose") { - id = "landscapist.library.compose" - implementationClass = "AndroidLibraryComposeConventionPlugin" - } - register("spotless") { - id = "landscapist.spotless" - implementationClass = "SpotlessConventionPlugin" - } + plugins { + register("androidApplicationCompose") { + id = "landscapist.application.compose" + implementationClass = "AndroidApplicationComposeConventionPlugin" } + register("androidLibraryCompose") { + id = "landscapist.library.compose" + implementationClass = "AndroidLibraryComposeConventionPlugin" + } + register("composeMultiplatformLibrary") { + id = "landscapist.library.compose.multiplatform" + implementationClass = "ComposeMultiplatformLibraryConventionPlugin" + } + register("spotless") { + id = "landscapist.spotless" + implementationClass = "SpotlessConventionPlugin" + } + } } diff --git a/build-logic/convention/src/main/kotlin/ComposeMultiplatformLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/ComposeMultiplatformLibraryConventionPlugin.kt new file mode 100644 index 00000000..ff70fdb1 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/ComposeMultiplatformLibraryConventionPlugin.kt @@ -0,0 +1,58 @@ +/* + * Designed and developed by 2020-2022 skydoves (Jaewoong Eum) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.android.build.gradle.LibraryExtension +import com.skydoves.landscapist.configureAndroidCompose +import com.skydoves.landscapist.configureComposeMultiplatform +import com.skydoves.landscapist.configureKotlinAndroid +import com.skydoves.landscapist.kotlinOptions +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension + +class ComposeMultiplatformLibraryConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + pluginManager.apply("com.android.library") + pluginManager.apply("org.jetbrains.kotlin.multiplatform") + pluginManager.apply("org.jetbrains.compose") + pluginManager.apply("com.vanniktech.maven.publish") + pluginManager.apply("binary-compatibility-validator") + pluginManager.apply("androidx.baselineprofile") + + extensions.configure libraryExtension@{ + extensions.configure kmpExtension@{ + configureComposeMultiplatform(this@libraryExtension, this@kmpExtension) + } + } + + val libs = extensions.getByType().named("libs") + tasks.withType(JavaCompile::class.java).configureEach { + this.targetCompatibility = libs.findVersion("jvmTarget").get().toString() + this.sourceCompatibility = libs.findVersion("jvmTarget").get().toString() + } + + dependencies { + add("baselineProfile", project(":benchmark-landscapist")) + } + } + } +} diff --git a/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/ComposeMultiplatform.kt b/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/ComposeMultiplatform.kt new file mode 100644 index 00000000..c05f34fe --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/skydoves/landscapist/ComposeMultiplatform.kt @@ -0,0 +1,117 @@ +/* + * Designed and developed by 2020-2022 skydoves (Jaewoong Eum) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:Suppress("UnstableApiUsage") + +package com.skydoves.landscapist + +import com.android.build.api.dsl.CommonExtension +import java.io.File +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension + +/** + * Configure Compose-Multiplatform-specific options + */ +internal fun Project.configureComposeMultiplatform( + commonExtension: CommonExtension<*, *, *, *, *>, + kotlinMultiplatformExtension: KotlinMultiplatformExtension, +) { + val libs = extensions.getByType().named("libs") + + kotlinMultiplatformExtension.apply { + androidTarget { publishLibraryVariants("release") } + jvm("desktop") + iosX64() + iosArm64() + iosSimulatorArm64() + macosX64() + macosArm64() + + @Suppress("OPT_IN_USAGE") + applyHierarchyTemplate { + common { + group("jvm") { + withAndroidTarget() + withJvm() + } + group("skia") { + withJvm() + group("darwin") { + group("apple") { + group("ios") { + withIosX64() + withIosArm64() + withIosSimulatorArm64() + } + group("macos") { + withMacosX64() + withMacosArm64() + } + } + withJs() + } + } + } + } + + explicitApi() + } + + commonExtension.apply { + buildFeatures { + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = + libs.findVersion("androidxComposeCompiler").get().toString() + } + + packaging { + resources { + excludes.add("/META-INF/{AL2.0,LGPL2.1}") + } + } + } +} + +private fun Project.buildComposeMetricsParameters(): List { + val metricParameters = mutableListOf() + val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics") + val enableMetrics = (enableMetricsProvider.orNull == "true") + if (enableMetrics) { + val metricsFolder = File(project.buildDir, "compose-metrics") + metricParameters.add("-P") + metricParameters.add( + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${metricsFolder.absolutePath}/compose_metrics" + ) + } + + val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports") + val enableReports = (enableReportsProvider.orNull == "true") + if (enableReports) { + val reportsFolder = File(project.buildDir, "compose-reports") + metricParameters.add("-P") + metricParameters.add( + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${reportsFolder.absolutePath}/compose_metrics" + ) + } + return metricParameters.toList() +} diff --git a/build.gradle.kts b/build.gradle.kts index 5990fbdb..5d87d68f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,8 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.multiplatform) apply false + alias(libs.plugins.jetbrains.compose) apply false alias(libs.plugins.kotlin.binary.compatibility) apply false alias(libs.plugins.baseline.profile) apply false alias(libs.plugins.hilt) apply false diff --git a/gradle.properties b/gradle.properties index c15ddc57..16a2cf00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,6 +41,19 @@ android.nonTransitiveRClass=true enableComposeCompilerMetrics=true enableComposeCompilerReports=true +# MPP +kotlin.mpp.enableCInteropCommonization=true +kotlin.mpp.stability.nowarn=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +kotlin.native.binary.memoryModel=experimental +kotlin.native.cacheKind=none + +# Compose +org.jetbrains.compose.experimental.uikit.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.jscanvas.enabled=true +compose.kotlin.native.manageCacheKind=false + # Required to publish to Nexus (see https://github.com/gradle/gradle/issues/11308) systemProp.org.gradle.internal.publish.checksums.insecure=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bbed7da1..ebe76dbf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,6 +18,7 @@ androidxJunit = "1.1.5" androidxMacroBenchmark = "1.2.2" androidxProfileinstaller = "1.3.1" androidxUiAutomator = "2.3.0-beta01" +jetbrains-compose = "1.5.11" glide = "4.16.0" fresco = "3.1.3" coil = "2.5.0" @@ -73,7 +74,8 @@ android-application = { id = "com.android.application", version.ref = "androidGr android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "jetbrains-compose" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" } kotlin-binary-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinBinaryCompatibility" } diff --git a/landscapist/api/android/landscapist.api b/landscapist/api/android/landscapist.api new file mode 100644 index 00000000..07a2018d --- /dev/null +++ b/landscapist/api/android/landscapist.api @@ -0,0 +1,191 @@ +public final class com/skydoves/landscapist/DataSource : java/lang/Enum { + public static final field DISK Lcom/skydoves/landscapist/DataSource; + public static final field MEMORY Lcom/skydoves/landscapist/DataSource; + public static final field NETWORK Lcom/skydoves/landscapist/DataSource; + public static final field UNKNOWN Lcom/skydoves/landscapist/DataSource; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/skydoves/landscapist/DataSource; + public static fun values ()[Lcom/skydoves/landscapist/DataSource; +} + +public final class com/skydoves/landscapist/DrawablePainterKt { + public static final fun rememberDrawablePainter (Landroid/graphics/drawable/Drawable;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public final class com/skydoves/landscapist/ImageBySourceKt { + public static final fun ImageBySource (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Ljava/lang/String;Landroidx/compose/ui/graphics/ColorFilter;FLandroidx/compose/runtime/Composer;II)V +} + +public final class com/skydoves/landscapist/ImageLoadKt { + public static final fun ImageLoad (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lcom/skydoves/landscapist/constraints/Constrainable;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V + public static final fun getZeroConstraints ()J +} + +public abstract class com/skydoves/landscapist/ImageLoadState { + public static final field $stable I +} + +public final class com/skydoves/landscapist/ImageLoadState$Failure : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public fun (Ljava/lang/Object;Ljava/lang/Throwable;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Ljava/lang/Throwable; + public final fun copy (Ljava/lang/Object;Ljava/lang/Throwable;)Lcom/skydoves/landscapist/ImageLoadState$Failure; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/ImageLoadState$Failure;Ljava/lang/Object;Ljava/lang/Throwable;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageLoadState$Failure; + public fun equals (Ljava/lang/Object;)Z + public final fun getData ()Ljava/lang/Object; + public final fun getReason ()Ljava/lang/Throwable; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$Loading : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$Loading; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$None : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$None; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$Success : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public fun (Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Lcom/skydoves/landscapist/DataSource; + public final fun copy (Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;)Lcom/skydoves/landscapist/ImageLoadState$Success; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/ImageLoadState$Success;Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageLoadState$Success; + public fun equals (Ljava/lang/Object;)Z + public final fun getData ()Ljava/lang/Object; + public final fun getDataSource ()Lcom/skydoves/landscapist/DataSource; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageOptions { + public static final field $stable I + public static final field DEFAULT_IMAGE_SIZE I + public synthetic fun (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Landroidx/compose/ui/Alignment; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Landroidx/compose/ui/layout/ContentScale; + public final fun component4 ()Landroidx/compose/ui/graphics/ColorFilter; + public final fun component5 ()F + public final fun component6-YbymL2g ()J + public final fun component7 ()Ljava/lang/String; + public final fun copy-WCgVKUs (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;)Lcom/skydoves/landscapist/ImageOptions; + public static synthetic fun copy-WCgVKUs$default (Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageOptions; + public fun equals (Ljava/lang/Object;)Z + public final fun getAlignment ()Landroidx/compose/ui/Alignment; + public final fun getAlpha ()F + public final fun getColorFilter ()Landroidx/compose/ui/graphics/ColorFilter; + public final fun getContentDescription ()Ljava/lang/String; + public final fun getContentScale ()Landroidx/compose/ui/layout/ContentScale; + public final fun getRequestSize-YbymL2g ()J + public final fun getTestTag ()Ljava/lang/String; + public fun hashCode ()I + public final fun isValidSize ()Z + public fun toString ()Ljava/lang/String; +} + +public abstract interface class com/skydoves/landscapist/ImageState { +} + +public abstract interface annotation class com/skydoves/landscapist/InternalLandscapistApi : java/lang/annotation/Annotation { +} + +public final class com/skydoves/landscapist/LandscapistImageKt { + public static final fun LandscapistImage (Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/runtime/Composer;I)V +} + +public final class com/skydoves/landscapist/RememberDrawablePainterKt { + public static final fun rememberDrawablePainter (Landroid/graphics/drawable/Drawable;Ljava/util/List;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public final class com/skydoves/landscapist/RememberPainterPluginsKt { + public static final fun rememberBitmapPainter (Ljava/util/List;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public final class com/skydoves/landscapist/StableHolder { + public static final field $stable I + public fun (Ljava/lang/Object;)V + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Lcom/skydoves/landscapist/StableHolder; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/StableHolder;Ljava/lang/Object;ILjava/lang/Object;)Lcom/skydoves/landscapist/StableHolder; + public fun equals (Ljava/lang/Object;)Z + public final fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class com/skydoves/landscapist/components/ImageComponent { +} + +public final class com/skydoves/landscapist/components/ImageComponentExtensionsKt { + public static final fun ComposeFailureStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Ljava/lang/Throwable;Landroidx/compose/runtime/Composer;I)V + public static final fun ComposeLoadingStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)V + public static final fun ComposeSuccessStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Ljava/lang/Object;Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)V + public static final fun getImagePlugins (Lcom/skydoves/landscapist/components/ImageComponent;)Ljava/util/List; +} + +public final class com/skydoves/landscapist/components/ImagePluginComponent : com/skydoves/landscapist/components/ImageComponent { + public static final field $stable I + public fun ()V + public fun (Ljava/util/List;)V + public synthetic fun (Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun add (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun addPlugins (Ljava/util/List;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun compose (Lkotlin/jvm/functions/Function1;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun getMutablePlugins ()Ljava/util/List; + public final fun getPlugins ()Ljava/util/List; + public final fun remove (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun unaryPlus (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public final class com/skydoves/landscapist/components/ImagePluginComponentKt { + public static final fun imageComponent (Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public final class com/skydoves/landscapist/components/LocalImageComponentKt { + public static final fun getLocalImageComponent ()Landroidx/compose/runtime/ProvidableCompositionLocal; +} + +public final class com/skydoves/landscapist/components/RememberImageComponentKt { + public static final fun rememberImageComponent (Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public abstract interface class com/skydoves/landscapist/constraints/Constrainable { + public abstract fun setConstraints-BRTryo0 (J)V +} + +public final class com/skydoves/landscapist/constraints/ConstraintsExtensionsKt { + public static final fun constraint (Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/BoxWithConstraintsScope;)Landroidx/compose/ui/Modifier; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin { +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$FailureStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Ljava/lang/Throwable;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$PainterPlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$SuccessStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Ljava/lang/Object;Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + diff --git a/landscapist/api/desktop/landscapist.api b/landscapist/api/desktop/landscapist.api new file mode 100644 index 00000000..c5ea6526 --- /dev/null +++ b/landscapist/api/desktop/landscapist.api @@ -0,0 +1,183 @@ +public final class com/skydoves/landscapist/DataSource : java/lang/Enum { + public static final field DISK Lcom/skydoves/landscapist/DataSource; + public static final field MEMORY Lcom/skydoves/landscapist/DataSource; + public static final field NETWORK Lcom/skydoves/landscapist/DataSource; + public static final field UNKNOWN Lcom/skydoves/landscapist/DataSource; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/skydoves/landscapist/DataSource; + public static fun values ()[Lcom/skydoves/landscapist/DataSource; +} + +public final class com/skydoves/landscapist/ImageBySourceKt { + public static final fun ImageBySource (Ljava/lang/Object;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;Ljava/lang/String;Landroidx/compose/ui/graphics/ColorFilter;FLandroidx/compose/runtime/Composer;II)V +} + +public final class com/skydoves/landscapist/ImageLoadKt { + public static final fun ImageLoad (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lcom/skydoves/landscapist/constraints/Constrainable;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V + public static final fun getZeroConstraints ()J +} + +public abstract class com/skydoves/landscapist/ImageLoadState { + public static final field $stable I +} + +public final class com/skydoves/landscapist/ImageLoadState$Failure : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public fun (Ljava/lang/Object;Ljava/lang/Throwable;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Ljava/lang/Throwable; + public final fun copy (Ljava/lang/Object;Ljava/lang/Throwable;)Lcom/skydoves/landscapist/ImageLoadState$Failure; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/ImageLoadState$Failure;Ljava/lang/Object;Ljava/lang/Throwable;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageLoadState$Failure; + public fun equals (Ljava/lang/Object;)Z + public final fun getData ()Ljava/lang/Object; + public final fun getReason ()Ljava/lang/Throwable; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$Loading : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$Loading; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$None : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public static final field INSTANCE Lcom/skydoves/landscapist/ImageLoadState$None; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageLoadState$Success : com/skydoves/landscapist/ImageLoadState { + public static final field $stable I + public fun (Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Lcom/skydoves/landscapist/DataSource; + public final fun copy (Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;)Lcom/skydoves/landscapist/ImageLoadState$Success; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/ImageLoadState$Success;Ljava/lang/Object;Lcom/skydoves/landscapist/DataSource;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageLoadState$Success; + public fun equals (Ljava/lang/Object;)Z + public final fun getData ()Ljava/lang/Object; + public final fun getDataSource ()Lcom/skydoves/landscapist/DataSource; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class com/skydoves/landscapist/ImageOptions { + public static final field $stable I + public static final field DEFAULT_IMAGE_SIZE I + public synthetic fun (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Landroidx/compose/ui/Alignment; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Landroidx/compose/ui/layout/ContentScale; + public final fun component4 ()Landroidx/compose/ui/graphics/ColorFilter; + public final fun component5 ()F + public final fun component6-YbymL2g ()J + public final fun component7 ()Ljava/lang/String; + public final fun copy-WCgVKUs (Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;)Lcom/skydoves/landscapist/ImageOptions; + public static synthetic fun copy-WCgVKUs$default (Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/Alignment;Ljava/lang/String;Landroidx/compose/ui/layout/ContentScale;Landroidx/compose/ui/graphics/ColorFilter;FJLjava/lang/String;ILjava/lang/Object;)Lcom/skydoves/landscapist/ImageOptions; + public fun equals (Ljava/lang/Object;)Z + public final fun getAlignment ()Landroidx/compose/ui/Alignment; + public final fun getAlpha ()F + public final fun getColorFilter ()Landroidx/compose/ui/graphics/ColorFilter; + public final fun getContentDescription ()Ljava/lang/String; + public final fun getContentScale ()Landroidx/compose/ui/layout/ContentScale; + public final fun getRequestSize-YbymL2g ()J + public final fun getTestTag ()Ljava/lang/String; + public fun hashCode ()I + public final fun isValidSize ()Z + public fun toString ()Ljava/lang/String; +} + +public abstract interface class com/skydoves/landscapist/ImageState { +} + +public abstract interface annotation class com/skydoves/landscapist/InternalLandscapistApi : java/lang/annotation/Annotation { +} + +public final class com/skydoves/landscapist/LandscapistImageKt { + public static final fun LandscapistImage (Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/runtime/Composer;I)V +} + +public final class com/skydoves/landscapist/RememberPainterPluginsKt { + public static final fun rememberBitmapPainter (Ljava/util/List;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public final class com/skydoves/landscapist/StableHolder { + public static final field $stable I + public fun (Ljava/lang/Object;)V + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Lcom/skydoves/landscapist/StableHolder; + public static synthetic fun copy$default (Lcom/skydoves/landscapist/StableHolder;Ljava/lang/Object;ILjava/lang/Object;)Lcom/skydoves/landscapist/StableHolder; + public fun equals (Ljava/lang/Object;)Z + public final fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class com/skydoves/landscapist/components/ImageComponent { +} + +public final class com/skydoves/landscapist/components/ImageComponentExtensionsKt { + public static final fun ComposeFailureStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Ljava/lang/Throwable;Landroidx/compose/runtime/Composer;I)V + public static final fun ComposeLoadingStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)V + public static final fun ComposeSuccessStatePlugins (Lcom/skydoves/landscapist/components/ImageComponent;Landroidx/compose/ui/Modifier;Ljava/lang/Object;Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)V + public static final fun getImagePlugins (Lcom/skydoves/landscapist/components/ImageComponent;)Ljava/util/List; +} + +public final class com/skydoves/landscapist/components/ImagePluginComponent : com/skydoves/landscapist/components/ImageComponent { + public static final field $stable I + public fun ()V + public fun (Ljava/util/List;)V + public synthetic fun (Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun add (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun addPlugins (Ljava/util/List;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun compose (Lkotlin/jvm/functions/Function1;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun getMutablePlugins ()Ljava/util/List; + public final fun getPlugins ()Ljava/util/List; + public final fun remove (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; + public final fun unaryPlus (Lcom/skydoves/landscapist/plugins/ImagePlugin;)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public final class com/skydoves/landscapist/components/ImagePluginComponentKt { + public static final fun imageComponent (Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public final class com/skydoves/landscapist/components/LocalImageComponentKt { + public static final fun getLocalImageComponent ()Landroidx/compose/runtime/ProvidableCompositionLocal; +} + +public final class com/skydoves/landscapist/components/RememberImageComponentKt { + public static final fun rememberImageComponent (Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/components/ImagePluginComponent; +} + +public abstract interface class com/skydoves/landscapist/constraints/Constrainable { + public abstract fun setConstraints-BRTryo0 (J)V +} + +public final class com/skydoves/landscapist/constraints/ConstraintsExtensionsKt { + public static final fun constraint (Landroidx/compose/ui/Modifier;Landroidx/compose/foundation/layout/BoxWithConstraintsScope;)Landroidx/compose/ui/Modifier; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin { +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$FailureStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Ljava/lang/Throwable;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$LoadingStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$PainterPlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/painter/Painter; +} + +public abstract interface class com/skydoves/landscapist/plugins/ImagePlugin$SuccessStatePlugin : com/skydoves/landscapist/plugins/ImagePlugin { + public abstract fun compose (Landroidx/compose/ui/Modifier;Ljava/lang/Object;Lcom/skydoves/landscapist/ImageOptions;Landroidx/compose/ui/graphics/ImageBitmap;Landroidx/compose/runtime/Composer;I)Lcom/skydoves/landscapist/plugins/ImagePlugin; +} + diff --git a/landscapist/build.gradle.kts b/landscapist/build.gradle.kts index a266f65d..6cadcf04 100644 --- a/landscapist/build.gradle.kts +++ b/landscapist/build.gradle.kts @@ -17,7 +17,7 @@ import com.github.skydoves.landscapist.Configuration plugins { - id("landscapist.library.compose") + id("landscapist.library.compose.multiplatform") id("landscapist.spotless") } @@ -36,6 +36,30 @@ mavenPublishing { } } +kotlin { + sourceSets { + all { + languageSettings.optIn("kotlin.RequiresOptIn") + languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + languageSettings.optIn("com.skydoves.landscapist.InternalLandscapistApi") + } + val commonMain by getting { + dependencies { + implementation(compose.ui) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(libs.kotlinx.coroutines.core) + } + } + + val androidMain by getting { + dependencies { + implementation(libs.androidx.core.ktx) + } + } + } +} + android { namespace = "com.skydoves.landscapist" compileSdk = Configuration.compileSdk @@ -59,10 +83,14 @@ baselineProfile { } } -dependencies { - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.compose.ui) - implementation(libs.androidx.compose.runtime) - implementation(libs.androidx.compose.foundation) - implementation(libs.kotlinx.coroutines.core) +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", + ) + } } diff --git a/landscapist/src/main/AndroidManifest.xml b/landscapist/src/androidMain/AndroidManifest.xml similarity index 100% rename from landscapist/src/main/AndroidManifest.xml rename to landscapist/src/androidMain/AndroidManifest.xml diff --git a/landscapist/src/main/baseline-prof.txt b/landscapist/src/androidMain/baseline-prof.txt similarity index 100% rename from landscapist/src/main/baseline-prof.txt rename to landscapist/src/androidMain/baseline-prof.txt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/DrawablePainter.kt b/landscapist/src/androidMain/kotlin/com/skydoves/landscapist/DrawablePainter.kt similarity index 99% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/DrawablePainter.kt rename to landscapist/src/androidMain/kotlin/com/skydoves/landscapist/DrawablePainter.kt index cc8b1c97..abc63a3a 100644 --- a/landscapist/src/main/kotlin/com/skydoves/landscapist/DrawablePainter.kt +++ b/landscapist/src/androidMain/kotlin/com/skydoves/landscapist/DrawablePainter.kt @@ -151,6 +151,7 @@ private val Drawable.intrinsicSize: Size intrinsicWidth >= 0 && intrinsicHeight >= 0 -> { Size(width = intrinsicWidth.toFloat(), height = intrinsicHeight.toFloat()) } + else -> Size.Unspecified } diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt b/landscapist/src/androidMain/kotlin/com/skydoves/landscapist/RememberDrawablePainter.kt similarity index 80% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt rename to landscapist/src/androidMain/kotlin/com/skydoves/landscapist/RememberDrawablePainter.kt index ee518804..c6b8ef0f 100644 --- a/landscapist/src/main/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt +++ b/landscapist/src/androidMain/kotlin/com/skydoves/landscapist/RememberDrawablePainter.kt @@ -21,7 +21,6 @@ import android.graphics.drawable.Drawable import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.graphics.painter.ColorPainter @@ -60,18 +59,3 @@ public fun rememberDrawablePainter( imagePlugins = imagePlugins, imageBitmap = drawable.toBitmap().asImageBitmap(), ) - -/** - * Remembers [ImageBitmap] wrapped up as a [Painter] with a given the list of [ImagePlugin]. - * - * @param imageBitmap An [ImageBitmap] to be drawn. - * @param imagePlugins A list of [ImagePlugin] that will be applied to the drawable painter. - */ -@Composable -@InternalLandscapistApi -public fun rememberBitmapPainter( - imagePlugins: List, - imageBitmap: ImageBitmap, -): Painter = remember(imageBitmap, imagePlugins) { - BitmapPainter(imageBitmap) -}.composePainterPlugins(imagePlugins = imagePlugins, imageBitmap = imageBitmap) diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/DataSource.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/DataSource.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/DataSource.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/DataSource.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageBySource.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageBySource.kt similarity index 98% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageBySource.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageBySource.kt index 4d101ac5..8202147d 100644 --- a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageBySource.kt +++ b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageBySource.kt @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:JvmName("ImageWithSource") -@file:JvmMultifileClass - package com.skydoves.landscapist import androidx.compose.foundation.Image @@ -62,6 +59,7 @@ public fun ImageBySource( alpha = alpha, ) } + is ImageVector -> { Image( imageVector = source, @@ -73,6 +71,7 @@ public fun ImageBySource( alpha = alpha, ) } + is Painter -> { Image( painter = source, @@ -84,6 +83,7 @@ public fun ImageBySource( alpha = alpha, ) } + else -> { throw IllegalArgumentException( "Wrong source was used: $source, " + diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageLoad.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt similarity index 98% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageLoad.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt index d3bf55e7..6622f57b 100644 --- a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageLoad.kt +++ b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoad.kt @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:JvmName("ImageLoad") -@file:JvmMultifileClass - package com.skydoves.landscapist import androidx.compose.foundation.layout.BoxWithConstraints @@ -30,6 +27,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Constraints import com.skydoves.landscapist.constraints.Constrainable import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageLoadState.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoadState.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageLoadState.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageLoadState.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageOptions.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageOptions.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageOptions.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageOptions.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageSemantics.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageSemantics.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageSemantics.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageSemantics.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/ImageState.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageState.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/ImageState.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/ImageState.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/InternalLandscapistApi.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/InternalLandscapistApi.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/InternalLandscapistApi.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/InternalLandscapistApi.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/LandscapistImage.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/LandscapistImage.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/LandscapistImage.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/LandscapistImage.kt diff --git a/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt new file mode 100644 index 00000000..d5ddeed4 --- /dev/null +++ b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/RememberPainterPlugins.kt @@ -0,0 +1,39 @@ +/* + * Designed and developed by 2020-2023 skydoves (Jaewoong Eum) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.skydoves.landscapist + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.painter.BitmapPainter +import androidx.compose.ui.graphics.painter.Painter +import com.skydoves.landscapist.plugins.ImagePlugin +import com.skydoves.landscapist.plugins.composePainterPlugins + +/** + * Remembers [ImageBitmap] wrapped up as a [Painter] with a given the list of [ImagePlugin]. + * + * @param imageBitmap An [ImageBitmap] to be drawn. + * @param imagePlugins A list of [ImagePlugin] that will be applied to the drawable painter. + */ +@Composable +@InternalLandscapistApi +public fun rememberBitmapPainter( + imagePlugins: List, + imageBitmap: ImageBitmap, +): Painter = remember(imageBitmap, imagePlugins) { + BitmapPainter(imageBitmap) +}.composePainterPlugins(imagePlugins = imagePlugins, imageBitmap = imageBitmap) diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/StableHolder.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/StableHolder.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/StableHolder.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/StableHolder.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImageComponent.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImageComponent.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImageComponent.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImageComponent.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImageComponentExtensions.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImageComponentExtensions.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImageComponentExtensions.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImageComponentExtensions.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImagePluginComponent.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImagePluginComponent.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/components/ImagePluginComponent.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/ImagePluginComponent.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/components/LocalImageComponent.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/LocalImageComponent.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/components/LocalImageComponent.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/LocalImageComponent.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/components/RememberImageComponent.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/RememberImageComponent.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/components/RememberImageComponent.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/components/RememberImageComponent.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/constraints/Constrainable.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/constraints/Constrainable.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/constraints/Constrainable.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/constraints/Constrainable.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/constraints/ConstraintsExtensions.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/constraints/ConstraintsExtensions.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/constraints/ConstraintsExtensions.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/constraints/ConstraintsExtensions.kt diff --git a/landscapist/src/main/kotlin/com/skydoves/landscapist/plugins/ImagePlugin.kt b/landscapist/src/commonMain/kotlin/com/skydoves/landscapist/plugins/ImagePlugin.kt similarity index 100% rename from landscapist/src/main/kotlin/com/skydoves/landscapist/plugins/ImagePlugin.kt rename to landscapist/src/commonMain/kotlin/com/skydoves/landscapist/plugins/ImagePlugin.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index d23da95a..0915f791 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,14 +7,16 @@ pluginManagement { gradlePluginPortal() mavenCentral() maven(url = "https://plugins.gradle.org/m2/") + maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") } } dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositoriesMode.set(RepositoriesMode.PREFER_PROJECT) repositories { google() mavenCentral() maven(url = "https://plugins.gradle.org/m2/") + maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") } }