From 963bf54e3f4552af9a1b31b20933f9c20f17b5f1 Mon Sep 17 00:00:00 2001 From: DongChyeon Date: Mon, 12 Feb 2024 23:17:04 +0900 Subject: [PATCH] =?UTF-8?q?#47=20Feat=20:=20Glide=20->=20Coil=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/java/Dependency.kt | 1 - buildSrc/src/main/java/Versions.kt | 1 - core/design/build.gradle.kts | 8 ++-- .../imagepicker/ImagePickerScreen.kt | 31 +++++++++++---- feature/map/build.gradle.kts | 2 +- .../map/components/MapBottomSheetContent.kt | 3 -- .../teamwiney/map/components/WineShopItem.kt | 24 ++++++------ .../teamwiney/map/components/WineShopList.kt | 39 ------------------- feature/mypage/build.gradle.kts | 2 +- .../mypage/badge/MyPageBadgeScreen.kt | 14 ++++--- feature/note/build.gradle.kts | 2 +- .../notedetail/component/WineMemo.kt | 16 ++++---- .../notewrite/NoteWineInfoMemoScreen.kt | 13 +++---- 13 files changed, 66 insertions(+), 90 deletions(-) diff --git a/buildSrc/src/main/java/Dependency.kt b/buildSrc/src/main/java/Dependency.kt index 89ac0f81..fa364614 100644 --- a/buildSrc/src/main/java/Dependency.kt +++ b/buildSrc/src/main/java/Dependency.kt @@ -61,6 +61,5 @@ object Dependency { const val TEST_ESPRESSO_CORE = "androidx.test.espresso:espresso-core:${Versions.TEST_ESPRESSO_CORE}" const val JUNIT = "junit:junit:4.13.2" - const val COMPOSE_GLIDE = "com.github.bumptech.glide:compose:${Versions.COMPOSE_GLIDE}" const val COMPOSE_UI_UTIL = "androidx.compose.ui:ui-util:$${Versions.COMPOSE}" } \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 01f3e6bb..5400797e 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -26,7 +26,6 @@ object Versions { const val TEST_EXT_JUNIT = "1.1.5" const val TEST_ESPRESSO_CORE = "3.5.1" const val JUNIT = "4.13.2" - const val COMPOSE_GLIDE = "1.0.0-beta01" const val GOOGLE_SERVICES = "4.4.0" const val PLAY_SERVICES_AUTH = "20.7.0" const val PLAY_SERVICES_LOCATION = "21.1.0" diff --git a/core/design/build.gradle.kts b/core/design/build.gradle.kts index 011a01df..b3beb2a1 100644 --- a/core/design/build.gradle.kts +++ b/core/design/build.gradle.kts @@ -44,18 +44,16 @@ android { dependencies { with(Dependency) { - implementation(COMPOSE_GLIDE) implementation(ANDROID_CORE_KTX) implementation(ACTIVITY_COMPOSE) implementation(LIFECYCLE_RUNTIME_VIEWMODEL_COMPOSE) + implementation(COMPOSE_COIL) implementation(COMPOSE_MATERIAL3) implementation(COMPOSE_MATERIAL) implementation(COMPOSE_UI) implementation(COMPOSE_UI_TOOLING) + implementation(COMPOSE_UI_TEST_MANIFEST) implementation(COMPOSE_UI_PREVIEW) + implementation(platform(KOTLIN_BOM)) } - - implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) - debugImplementation("androidx.compose.ui:ui-tooling") - debugImplementation("androidx.compose.ui:ui-test-manifest") } \ No newline at end of file diff --git a/core/design/src/main/java/com/teamwiney/ui/components/imagepicker/ImagePickerScreen.kt b/core/design/src/main/java/com/teamwiney/ui/components/imagepicker/ImagePickerScreen.kt index 64ec728b..b5e13994 100644 --- a/core/design/src/main/java/com/teamwiney/ui/components/imagepicker/ImagePickerScreen.kt +++ b/core/design/src/main/java/com/teamwiney/ui/components/imagepicker/ImagePickerScreen.kt @@ -10,7 +10,17 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items @@ -18,10 +28,12 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Icon import androidx.compose.material.Surface import androidx.compose.material.Text -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -29,8 +41,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.core.content.ContextCompat import androidx.lifecycle.viewmodel.compose.viewModel -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.core.design.R import com.teamwiney.ui.components.TopBar import com.teamwiney.ui.components.WButton @@ -180,7 +192,6 @@ internal fun PickerContent( } } -@OptIn(ExperimentalGlideComposeApi::class) @Composable internal fun ImageItem( image: ImageInfo, @@ -189,6 +200,8 @@ internal fun ImageItem( removeImage: (ImageInfo) -> Unit, maxImgCount: Int ) { + val context = LocalContext.current + val selected = selectedImages.any { it.id == image.id } Box( @@ -207,9 +220,12 @@ internal fun ImageItem( ), contentAlignment = Alignment.TopEnd ) { - GlideImage( - model = image.contentUri, + AsyncImage( + model = ImageRequest.Builder(context) + .data(image.contentUri) + .build(), contentDescription = "IMG_URL", + filterQuality = FilterQuality.Low, contentScale = ContentScale.Crop, modifier = Modifier .aspectRatio(1.0F) @@ -225,7 +241,6 @@ internal fun ImageItem( } } - @Composable internal fun ImageIndicator( imgCount: Int diff --git a/feature/map/build.gradle.kts b/feature/map/build.gradle.kts index 0e60be47..752f090c 100644 --- a/feature/map/build.gradle.kts +++ b/feature/map/build.gradle.kts @@ -56,8 +56,8 @@ dependencies { implementation(PLAY_SERVICES_MAPS) implementation(NAVER_MAP_COMPOSE) implementation(NAVER_MAP_LOCATION) - implementation(COMPOSE_GLIDE) implementation(ANDROID_CORE_KTX) + implementation(COMPOSE_COIL) implementation(COMPOSE_MATERIAL) implementation(COMPOSE_MATERIAL3) implementation(COMPOSE_UI) diff --git a/feature/map/src/main/java/com/teamwiney/map/components/MapBottomSheetContent.kt b/feature/map/src/main/java/com/teamwiney/map/components/MapBottomSheetContent.kt index 648e6d75..3bde0986 100644 --- a/feature/map/src/main/java/com/teamwiney/map/components/MapBottomSheetContent.kt +++ b/feature/map/src/main/java/com/teamwiney/map/components/MapBottomSheetContent.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalGlideComposeApi::class) - package com.teamwiney.map.components import androidx.compose.foundation.background @@ -18,7 +16,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi import com.naver.maps.geometry.LatLng import com.teamwiney.data.network.model.response.WineShop import com.teamwiney.map.model.ShopCategory diff --git a/feature/map/src/main/java/com/teamwiney/map/components/WineShopItem.kt b/feature/map/src/main/java/com/teamwiney/map/components/WineShopItem.kt index 2e83ac01..4691260c 100644 --- a/feature/map/src/main/java/com/teamwiney/map/components/WineShopItem.kt +++ b/feature/map/src/main/java/com/teamwiney/map/components/WineShopItem.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalGlideComposeApi::class, ExperimentalFoundationApi::class) - package com.teamwiney.map.components import androidx.compose.foundation.BorderStroke @@ -29,23 +27,26 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.core.design.R import com.teamwiney.data.network.model.response.WineShop import com.teamwiney.ui.components.HeightSpacer import com.teamwiney.ui.components.HeightSpacerWithLine import com.teamwiney.ui.theme.WineyTheme - +@OptIn(ExperimentalFoundationApi::class) @Composable fun LazyItemScope.WineShopItem( wineShop: WineShop, postBookmark: (WineShop) -> Unit, setSelectedMarker: (WineShop) -> Unit ) { + val context = LocalContext.current + Row( modifier = Modifier .padding(24.dp) @@ -56,17 +57,18 @@ fun LazyItemScope.WineShopItem( } .animateItemPlacement() ) { - GlideImage( - model = wineShop.imgUrl, + AsyncImage( + model = ImageRequest.Builder(context) + .placeholder(R.drawable.img_dummy_wine) + .error(R.drawable.img_dummy_wine) + .data(wineShop.imgUrl) + .build(), contentDescription = "IMG_WINE", modifier = Modifier .clip(RoundedCornerShape(10.dp)) .size(110.dp, 100.dp) .background(WineyTheme.colors.gray_900), - contentScale = ContentScale.Crop, - requestBuilderTransform = { requestBuilder -> - requestBuilder.apply(options) - }, + contentScale = ContentScale.Crop ) Spacer(modifier = Modifier.width(17.dp)) Column( diff --git a/feature/map/src/main/java/com/teamwiney/map/components/WineShopList.kt b/feature/map/src/main/java/com/teamwiney/map/components/WineShopList.kt index f0bd82f1..3c389065 100644 --- a/feature/map/src/main/java/com/teamwiney/map/components/WineShopList.kt +++ b/feature/map/src/main/java/com/teamwiney/map/components/WineShopList.kt @@ -1,51 +1,12 @@ -@file:OptIn(ExperimentalGlideComposeApi::class) - package com.teamwiney.map.components -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.horizontalScroll -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.IntrinsicSize -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Icon -import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage -import com.bumptech.glide.load.engine.DiskCacheStrategy -import com.bumptech.glide.request.RequestOptions -import com.teamwiney.core.design.R import com.teamwiney.data.network.model.response.WineShop -import com.teamwiney.ui.components.HeightSpacer -import com.teamwiney.ui.components.HeightSpacerWithLine -import com.teamwiney.ui.theme.WineyTheme - -val options = RequestOptions() - .centerCrop() - .error(R.drawable.img_dummy_wine) - .diskCacheStrategy(DiskCacheStrategy.ALL) @Composable fun ColumnScope.WineShopList( diff --git a/feature/mypage/build.gradle.kts b/feature/mypage/build.gradle.kts index 7146ea55..97f4ed09 100644 --- a/feature/mypage/build.gradle.kts +++ b/feature/mypage/build.gradle.kts @@ -49,8 +49,8 @@ dependencies { with(Dependency) { kapt(HILT_ANDROID_COMPILER) implementation(BROWSER) - implementation(COMPOSE_GLIDE) implementation(ANDROID_CORE_KTX) + implementation(COMPOSE_COIL) implementation(COMPOSE_MATERIAL3) implementation(COMPOSE_MATERIAL) implementation(COMPOSE_UI) diff --git a/feature/mypage/src/main/java/com/teamwiney/mypage/badge/MyPageBadgeScreen.kt b/feature/mypage/src/main/java/com/teamwiney/mypage/badge/MyPageBadgeScreen.kt index 23f50264..62af0425 100644 --- a/feature/mypage/src/main/java/com/teamwiney/mypage/badge/MyPageBadgeScreen.kt +++ b/feature/mypage/src/main/java/com/teamwiney/mypage/badge/MyPageBadgeScreen.kt @@ -39,14 +39,15 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.core.common.WineyAppState import com.teamwiney.core.common.WineyBottomSheetState import com.teamwiney.data.network.model.response.WineBadge @@ -250,12 +251,13 @@ private fun MyPageActivityBadge( } } -@OptIn(ExperimentalGlideComposeApi::class) @Composable private fun WineBadgeItem( modifier: Modifier = Modifier, wineBadge: WineBadge ) { + val context = LocalContext.current + Column( modifier = modifier.height(IntrinsicSize.Max) ) { @@ -290,8 +292,10 @@ private fun WineBadgeItem( shape = RoundedCornerShape(5.dp) ) ) { - GlideImage( - model = wineBadge.badgeImage, + AsyncImage( + model = ImageRequest.Builder(context) + .data(wineBadge.badgeImage) + .build(), contentDescription = "BADGE_IMAGE", modifier = Modifier .fillMaxWidth() diff --git a/feature/note/build.gradle.kts b/feature/note/build.gradle.kts index 22924ad2..b5d06bf1 100644 --- a/feature/note/build.gradle.kts +++ b/feature/note/build.gradle.kts @@ -48,8 +48,8 @@ dependencies { with(Dependency) { kapt(HILT_ANDROID_COMPILER) implementation(ACCOMPANIST_SYSTEMUI) - implementation(COMPOSE_GLIDE) implementation(ANDROID_CORE_KTX) + implementation(COMPOSE_COIL) implementation(COMPOSE_MATERIAL3) implementation(COMPOSE_MATERIAL) implementation(COMPOSE_UI) diff --git a/feature/note/src/main/java/com/teamwiney/notedetail/component/WineMemo.kt b/feature/note/src/main/java/com/teamwiney/notedetail/component/WineMemo.kt index a31b52e4..57ce5e35 100644 --- a/feature/note/src/main/java/com/teamwiney/notedetail/component/WineMemo.kt +++ b/feature/note/src/main/java/com/teamwiney/notedetail/component/WineMemo.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalGlideComposeApi::class) - package com.teamwiney.notedetail.component import androidx.compose.foundation.BorderStroke @@ -22,17 +20,19 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.data.network.model.response.TastingNoteDetail import com.teamwiney.ui.components.HeightSpacer import com.teamwiney.ui.theme.WineyTheme - @Composable fun WineMemo(noteDetail: TastingNoteDetail) { + val context = LocalContext.current + Column { Text( text = "Feature", @@ -53,8 +53,10 @@ fun WineMemo(noteDetail: TastingNoteDetail) { Spacer(modifier = Modifier.width(14.dp)) } items(noteDetail.tastingNoteImage.map { it.imgUrl }) { - GlideImage( - model = it, + AsyncImage( + model = ImageRequest.Builder(context) + .data(it) + .build(), contentDescription = "IMG_URL", modifier = Modifier .size(120.dp) diff --git a/feature/note/src/main/java/com/teamwiney/notewrite/NoteWineInfoMemoScreen.kt b/feature/note/src/main/java/com/teamwiney/notewrite/NoteWineInfoMemoScreen.kt index b5a7a755..0e0371fd 100644 --- a/feature/note/src/main/java/com/teamwiney/notewrite/NoteWineInfoMemoScreen.kt +++ b/feature/note/src/main/java/com/teamwiney/notewrite/NoteWineInfoMemoScreen.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalGlideComposeApi::class, ExperimentalGlideComposeApi::class) - package com.teamwiney.notewrite import android.Manifest @@ -54,8 +52,8 @@ import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat.startActivity import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.navOptions -import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi -import com.bumptech.glide.integration.compose.GlideImage +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.core.common.WineyAppState import com.teamwiney.core.common.navigation.NoteDestinations import com.teamwiney.core.design.R @@ -67,7 +65,6 @@ import com.teamwiney.ui.components.imagepicker.ImagePickerContract import com.teamwiney.ui.theme.WineyTheme import kotlinx.coroutines.flow.collectLatest -@OptIn(ExperimentalGlideComposeApi::class) @Composable fun NoteWineInfoMemoScreen( appState: WineyAppState, @@ -199,8 +196,10 @@ fun NoteWineInfoMemoScreen( ) { uiState.wineNote.imgs.map { Box { - GlideImage( - model = it, + AsyncImage( + model = ImageRequest.Builder(context) + .data(it) + .build(), contentDescription = "IMG_URL", modifier = Modifier .size(100.dp)