From b470815ab36a408a18ff2ef8a4408794eb413134 Mon Sep 17 00:00:00 2001 From: WooJin Kong Date: Sat, 30 Mar 2024 15:01:26 +0900 Subject: [PATCH] refactor: Switch to coil from glide --- app/build.gradle.kts | 1 + .../kongjak/koreatechboard/ui/article/Article.kt | 14 +++++++++++--- gradle/libs.versions.toml | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a87f0b47..19dfd0cc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -73,6 +73,7 @@ dependencies { implementation(libs.androidx.paging.runtime) implementation(libs.coil) + implementation(libs.coil.compose) implementation(libs.okhttp) implementation(libs.okhttp.logging.interceptor) implementation(libs.retrofit) diff --git a/app/src/main/java/com/kongjak/koreatechboard/ui/article/Article.kt b/app/src/main/java/com/kongjak/koreatechboard/ui/article/Article.kt index b43710dc..68231368 100644 --- a/app/src/main/java/com/kongjak/koreatechboard/ui/article/Article.kt +++ b/app/src/main/java/com/kongjak/koreatechboard/ui/article/Article.kt @@ -23,7 +23,11 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.kongjak.koreatechboard.ui.components.FileText import com.kongjak.koreatechboard.ui.components.HtmlView import com.kongjak.koreatechboard.ui.theme.articleSubText @@ -106,12 +110,16 @@ fun ArticleScreen( html = data?.content!!, themeViewModel.isDarkTheme.value ?: isSystemInDarkTheme(), image = { url, description -> - GlideImage( + AsyncImage( modifier = Modifier .padding(horizontal = 16.dp) .fillMaxSize(), - model = url, - contentDescription = description + model = ImageRequest.Builder(LocalContext.current) + .data(url) + .crossfade(true) + .build(), + contentDescription = description, + contentScale = ContentScale.FillWidth ) } ) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4b4f5ff6..6854e6f2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -62,6 +62,7 @@ androidx-paging-compose = { module = "androidx.paging:paging-compose", version.r androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "androidx-paging" } coil = { module = "io.coil-kt:coil", version.ref = "coil" } +coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }