Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement coil3 module and support KMP #401

Merged
merged 21 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation(project(":landscapist-palette"))

implementation(project(":glide"))
implementation(project(":coil"))
implementation(project(":coil3"))
implementation(project(":fresco"))
implementation(project(":fresco-websupport"))

Expand Down
14 changes: 13 additions & 1 deletion app/src/main/kotlin/com/github/skydoves/landscapistdemo/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@

package com.github.skydoves.landscapistdemo

import android.content.Context
import androidx.multidex.MultiDexApplication
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.fetch.NetworkFetcher
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory
import dagger.hilt.android.HiltAndroidApp
import okhttp3.OkHttpClient

@HiltAndroidApp
class App : MultiDexApplication() {
class App : MultiDexApplication(), SingletonImageLoader.Factory {

override fun onCreate() {
super.onCreate()
Expand All @@ -40,4 +44,12 @@ class App : MultiDexApplication() {

Fresco.initialize(this, pipelineConfig)
}

override fun newImageLoader(context: Context): ImageLoader {
return ImageLoader.Builder(context)
.components {
add(NetworkFetcher.Factory())
}
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -59,6 +60,7 @@ import com.github.skydoves.landscapistdemo.theme.background
import com.skydoves.landscapist.ImageOptions
import com.skydoves.landscapist.animation.circular.CircularRevealPlugin
import com.skydoves.landscapist.animation.crossfade.CrossfadePlugin
import com.skydoves.landscapist.coil3.CoilImage
import com.skydoves.landscapist.components.rememberImageComponent
import com.skydoves.landscapist.fresco.FrescoImage
import com.skydoves.landscapist.glide.GlideImage
Expand Down Expand Up @@ -132,7 +134,7 @@ private fun SelectedPoster(
) {
var palette by rememberPaletteState(null)

GlideImage(
CoilImage(
imageModel = { poster.image },
modifier = Modifier.aspectRatio(0.8f),
component = rememberImageComponent {
Expand All @@ -149,7 +151,7 @@ private fun SelectedPoster(
+CircularRevealPlugin()
+PalettePlugin { palette = it }
},
previewPlaceholder = R.drawable.poster,
previewPlaceholder = painterResource(id = R.drawable.poster),
)

ColorPalettes(palette)
Expand Down
1 change: 1 addition & 0 deletions benchmark-landscapist-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {

implementation(project(":glide"))
implementation(project(":coil"))
implementation(project(":coil3"))
implementation(project(":fresco"))
implementation(project(":fresco-websupport"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
package com.skydoves.benchmark.landscapist.app

import android.app.Application
import android.content.Context
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.fetch.NetworkFetcher
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory
import okhttp3.OkHttpClient

class App : Application() {
class App : Application(), SingletonImageLoader.Factory {

override fun onCreate() {
super.onCreate()
Expand All @@ -38,4 +42,12 @@ class App : Application() {

Fresco.initialize(this, pipelineConfig)
}

override fun newImageLoader(context: Context): ImageLoader {
return ImageLoader.Builder(context)
.components {
add(NetworkFetcher.Factory())
}
.build()
}
}
Original file line number Diff line number Diff line change
@@ -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.benchmark.landscapist.app

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.skydoves.landscapist.ImageOptions
import com.skydoves.landscapist.coil3.CoilImage
import com.skydoves.landscapist.components.LocalImageComponent

@Composable
fun Coil3ImageProfiles() {
CoilImage(
modifier = Modifier.size(120.dp),
imageModel = {
"https://user-images.githubusercontent.com/" +
"24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg"
},
previewPlaceholder = painterResource(id = R.drawable.poster),
component = LocalImageComponent.current,
imageOptions = ImageOptions(tag = "CoilImage"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ fun CoilImageProfiles() {
},
previewPlaceholder = R.drawable.poster,
component = LocalImageComponent.current,
imageOptions = ImageOptions(testTag = "CoilImage"),
imageOptions = ImageOptions(tag = "CoilImage"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ fun FrescoImageProfiles() {
"24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg",
previewPlaceholder = R.drawable.poster,
component = LocalImageComponent.current,
imageOptions = ImageOptions(testTag = "FrescoImage"),
imageOptions = ImageOptions(tag = "FrescoImage"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ fun GlideImageProfiles() {
},
previewPlaceholder = R.drawable.poster,
component = LocalImageComponent.current,
imageOptions = ImageOptions(testTag = "GlideImage"),
imageOptions = ImageOptions(tag = "GlideImage"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MainActivity : ComponentActivity() {
},
) {
CoilImageProfiles()
Coil3ImageProfiles()
GlideImageProfiles()
FrescoImageProfiles()
FrescoWebSupportProfiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public fun CoilImage(
imageOptions.LandscapistImage(
modifier = Modifier
.constraint(this)
.testTag(imageOptions.testTag),
.testTag(imageOptions.tag),
painter = painter,
)
}
Expand Down
1 change: 1 addition & 0 deletions coil3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions coil3/api/android/coil3.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
public final class com/skydoves/landscapist/coil3/CoilImageKt {
public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V
}

public abstract class com/skydoves/landscapist/coil3/CoilImageState : com/skydoves/landscapist/ImageState {
public static final field $stable I
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Failure : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public fun <init> (Lcoil3/Image;Ljava/lang/Throwable;)V
public final fun component1 ()Lcoil3/Image;
public final fun component2 ()Ljava/lang/Throwable;
public final fun copy (Lcoil3/Image;Ljava/lang/Throwable;)Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;Lcoil3/Image;Ljava/lang/Throwable;ILjava/lang/Object;)Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;
public fun equals (Ljava/lang/Object;)Z
public final fun getErrorImage ()Lcoil3/Image;
public final fun getReason ()Ljava/lang/Throwable;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Loading : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/CoilImageState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$None : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/CoilImageState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Success : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public fun <init> (Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;)V
public final fun component1 ()Lcoil3/Image;
public final fun component2 ()Lcom/skydoves/landscapist/DataSource;
public final fun copy (Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;)Lcom/skydoves/landscapist/coil3/CoilImageState$Success;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/coil3/CoilImageState$Success;Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;ILjava/lang/Object;)Lcom/skydoves/landscapist/coil3/CoilImageState$Success;
public fun equals (Ljava/lang/Object;)Z
public final fun getDataSource ()Lcom/skydoves/landscapist/DataSource;
public final fun getImage ()Lcoil3/Image;
public final fun getImageBitmap (Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/ImageBitmap;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageStateKt {
public static final fun toCoilImageState (Lcom/skydoves/landscapist/ImageLoadState;)Lcom/skydoves/landscapist/coil3/CoilImageState;
}

public final class com/skydoves/landscapist/coil3/ComposableSingletons$CoilImageKt {
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/ComposableSingletons$CoilImageKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$coil3_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$coil3_release ()Lkotlin/jvm/functions/Function3;
}

public final class com/skydoves/landscapist/coil3/LocalCoilProviderKt {
public static final fun getLocalCoilImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal;
}

public final class com/skydoves/landscapist/coil3/RememberCoilImageStateKt {
public static final fun rememberCoilImageState (Lcom/skydoves/landscapist/coil3/CoilImageState;Ljava/lang/Object;Landroidx/compose/runtime/Composer;II)Landroidx/compose/runtime/MutableState;
}

75 changes: 75 additions & 0 deletions coil3/api/desktop/coil3.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
public final class com/skydoves/landscapist/coil3/CoilImageKt {
public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V
public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V
}

public abstract class com/skydoves/landscapist/coil3/CoilImageState : com/skydoves/landscapist/ImageState {
public static final field $stable I
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Failure : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public fun <init> (Lcoil3/Image;Ljava/lang/Throwable;)V
public final fun component1 ()Lcoil3/Image;
public final fun component2 ()Ljava/lang/Throwable;
public final fun copy (Lcoil3/Image;Ljava/lang/Throwable;)Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;Lcoil3/Image;Ljava/lang/Throwable;ILjava/lang/Object;)Lcom/skydoves/landscapist/coil3/CoilImageState$Failure;
public fun equals (Ljava/lang/Object;)Z
public final fun getErrorImage ()Lcoil3/Image;
public final fun getReason ()Ljava/lang/Throwable;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Loading : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/CoilImageState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$None : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/CoilImageState$None;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageState$Success : com/skydoves/landscapist/coil3/CoilImageState {
public static final field $stable I
public fun <init> (Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;)V
public final fun component1 ()Lcoil3/Image;
public final fun component2 ()Lcom/skydoves/landscapist/DataSource;
public final fun copy (Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;)Lcom/skydoves/landscapist/coil3/CoilImageState$Success;
public static synthetic fun copy$default (Lcom/skydoves/landscapist/coil3/CoilImageState$Success;Lcoil3/Image;Lcom/skydoves/landscapist/DataSource;ILjava/lang/Object;)Lcom/skydoves/landscapist/coil3/CoilImageState$Success;
public fun equals (Ljava/lang/Object;)Z
public final fun getDataSource ()Lcom/skydoves/landscapist/DataSource;
public final fun getImage ()Lcoil3/Image;
public final fun getImageBitmap (Landroidx/compose/runtime/Composer;I)Landroidx/compose/ui/graphics/ImageBitmap;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/skydoves/landscapist/coil3/CoilImageStateKt {
public static final fun toCoilImageState (Lcom/skydoves/landscapist/ImageLoadState;)Lcom/skydoves/landscapist/coil3/CoilImageState;
}

public final class com/skydoves/landscapist/coil3/ComposableSingletons$CoilImageKt {
public static final field INSTANCE Lcom/skydoves/landscapist/coil3/ComposableSingletons$CoilImageKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$coil3 ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$coil3 ()Lkotlin/jvm/functions/Function3;
}

public final class com/skydoves/landscapist/coil3/LocalCoilProviderKt {
public static final fun getLocalCoilImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal;
}

public final class com/skydoves/landscapist/coil3/RememberCoilImageStateKt {
public static final fun rememberCoilImageState (Lcom/skydoves/landscapist/coil3/CoilImageState;Ljava/lang/Object;Landroidx/compose/runtime/Composer;II)Landroidx/compose/runtime/MutableState;
}

Loading