From 7233405dee6d6f13431829a9a2fc202c8c8fd66b Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 17 Sep 2024 22:14:09 +0900 Subject: [PATCH] feat: imageLoader -> coil --- core/designsystem/build.gradle.kts | 3 ++- .../kotlin/club/nito/core/ui/ProfileImage.kt | 14 +++++--------- .../schedule/detail/ScheduleDetailScreen.kt | 15 +++++---------- gradle/libs.versions.toml | 6 ++++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 8435fcc7..ea072815 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -16,7 +16,8 @@ kotlin { dependencies { implementation(compose.components.resources) implementation(compose.materialIconsExtended) - api(libs.imageLoader) + api(libs.coil) + api(libs.coilNetwork) } } } diff --git a/core/ui/src/commonMain/kotlin/club/nito/core/ui/ProfileImage.kt b/core/ui/src/commonMain/kotlin/club/nito/core/ui/ProfileImage.kt index d1d2edbb..26a0830a 100644 --- a/core/ui/src/commonMain/kotlin/club/nito/core/ui/ProfileImage.kt +++ b/core/ui/src/commonMain/kotlin/club/nito/core/ui/ProfileImage.kt @@ -1,15 +1,13 @@ package club.nito.core.ui -import androidx.compose.foundation.Image import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale import club.nito.core.designsystem.icon.NitoIcons import club.nito.core.model.UserProfile -import com.seiko.imageloader.rememberImagePainter +import coil3.compose.AsyncImage @Composable public fun ProfileImage( @@ -17,17 +15,15 @@ public fun ProfileImage( modifier: Modifier = Modifier, ) { if (profile.avatarUrl.isNotBlank()) { - Image( - painter = rememberImagePainter( - url = profile.avatarUrl, - ), + AsyncImage( + model = profile.avatarUrl, contentDescription = profile.displayName, contentScale = ContentScale.Crop, modifier = modifier.clip(CircleShape), ) } else { - Icon( - imageVector = NitoIcons.AccountCircle, + AsyncImage( + model = NitoIcons.AccountCircle, contentDescription = profile.displayName, modifier = modifier, ) diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt index 500cd8cf..e122a32b 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt @@ -1,6 +1,5 @@ package club.nito.feature.schedule.detail -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable @@ -60,7 +59,7 @@ import club.nito.core.model.schedule.ScheduleWithPlace import club.nito.core.ui.ProfileImage import club.nito.core.ui.koinStateMachine import club.nito.core.ui.message.SnackbarMessageEffect -import com.seiko.imageloader.rememberImagePainter +import coil3.compose.AsyncImage import org.koin.core.parameter.parametersOf @Composable @@ -243,10 +242,8 @@ private fun VenueSection( .fillMaxWidth() .heightIn(max = 200.dp), ) { - Image( - painter = rememberImagePainter( - url = schedule.venue.imageUrl, - ), + AsyncImage( + model = schedule.venue.imageUrl, modifier = Modifier.fillMaxWidth(), contentScale = ContentScale.FillWidth, contentDescription = null, @@ -307,10 +304,8 @@ private fun MeetSection( .fillMaxWidth() .heightIn(max = 200.dp), ) { - Image( - painter = rememberImagePainter( - url = schedule.meet.imageUrl, - ), + AsyncImage( + model = schedule.meet.imageUrl, modifier = Modifier.fillMaxWidth(), contentScale = ContentScale.FillWidth, contentDescription = null, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e1ff310a..3a6d9998 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,7 +33,7 @@ logback = "1.5.8" graphqlKotlin = "7.1.5" kotest = "5.9.1" precompose = "1.6.2" -imageLoader = "1.8.3" +coil = "3.0.0-alpha10" [libraries] androidGradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } @@ -65,7 +65,9 @@ kotlinxCollectionsImmutable = { module = "org.jetbrains.kotlinx:kotlinx-collecti kotlinxDatetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version = "0.6.1" } kotlinxAtomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.25.0" } -imageLoader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "imageLoader" } +coil = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" } +coilNetwork = { module = "io.coil-kt.coil3:coil-network-ktor2", version.ref = "coil" } +coilTest = { module = "io.coil-kt.coil3:coil-test", version.ref = "coil" } androidxActivityActivityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivity" } androidxDatastoreDatastorePreferences = { module = "androidx.datastore:datastore-preferences-core", version = "1.1.1" }