diff --git a/data/search/src/main/java/com/terning/data/search/mapper/SearchBannersMapper.kt b/data/search/src/main/java/com/terning/data/search/mapper/SearchBannersMapper.kt index ee8506d2..82a4583e 100644 --- a/data/search/src/main/java/com/terning/data/search/mapper/SearchBannersMapper.kt +++ b/data/search/src/main/java/com/terning/data/search/mapper/SearchBannersMapper.kt @@ -6,7 +6,7 @@ import com.terning.domain.search.entity.SearchBanner fun SearchBannersResponseDto.toSearchBannerList(): List { return banners.map { SearchBanner( - imageRes = it.imageUrl, + imageUrl = it.imageUrl, url = it.link, ) } diff --git a/domain/search/src/main/java/com/terning/domain/search/entity/SearchBanner.kt b/domain/search/src/main/java/com/terning/domain/search/entity/SearchBanner.kt index 4da5bfdf..94c5b778 100644 --- a/domain/search/src/main/java/com/terning/domain/search/entity/SearchBanner.kt +++ b/domain/search/src/main/java/com/terning/domain/search/entity/SearchBanner.kt @@ -1,6 +1,6 @@ package com.terning.domain.search.entity data class SearchBanner( - val imageRes: String, + val imageUrl: String, val url: String, ) diff --git a/feature/search/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/search/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 6f8483bd..c7ce931b 100644 --- a/feature/search/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/search/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -152,7 +152,7 @@ fun SearchScreen( LazyColumn { item { ImageSlider( - images = bannerList, + searchBanners = bannerList, onAdvertisementClick = onAdvertisementClick, ) diff --git a/feature/search/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt b/feature/search/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt index 6a5c675f..fc3a5e6f 100644 --- a/feature/search/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt +++ b/feature/search/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt @@ -14,21 +14,25 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage +import coil3.request.ImageRequest +import coil3.request.crossfade import com.terning.core.designsystem.extension.noRippleClickable import com.terning.core.designsystem.theme.Grey200 +import com.terning.domain.search.entity.SearchBanner import kotlinx.coroutines.delay @Composable fun ImageSlider( modifier: Modifier = Modifier, - images: List, + searchBanners: List, onAdvertisementClick: (Int) -> Unit, ) { val pagerState = rememberPagerState( initialPage = 0, - pageCount = { if (images.isEmpty()) 0 else Int.MAX_VALUE } + pageCount = { Int.MAX_VALUE } ) val autoScroll = remember { mutableStateOf(true) } @@ -36,8 +40,8 @@ fun ImageSlider( if (autoScroll.value) { while (true) { delay(2500) - if (!pagerState.isScrollInProgress && images.isNotEmpty()) { - val nextPage = (pagerState.currentPage + 1) % images.size + if (!pagerState.isScrollInProgress) { + val nextPage = pagerState.currentPage + 1 pagerState.animateScrollToPage(nextPage) } } @@ -50,7 +54,7 @@ fun ImageSlider( .background(Grey200), horizontalAlignment = Alignment.CenterHorizontally ) { - if (images.isNotEmpty()) { + if (searchBanners.isNotEmpty()) { Box( modifier = modifier, contentAlignment = Alignment.BottomCenter @@ -60,20 +64,23 @@ fun ImageSlider( modifier = modifier, beyondViewportPageCount = 1 ) { currentPage -> - val pageIndex = currentPage % images.size + val pageIndex = currentPage % searchBanners.size AsyncImage( - model = images[pageIndex].url, + model = ImageRequest.Builder(LocalContext.current) + .data(searchBanners[pageIndex].imageUrl) + .crossfade(true) + .build(), contentDescription = null, modifier = modifier .fillMaxWidth() .height(112.dp) .noRippleClickable { onAdvertisementClick(pageIndex) }, - contentScale = ContentScale.Crop + contentScale = ContentScale.Crop, ) } DotsIndicator( - pageCount = images.size, - currentPage = pagerState.currentPage % images.size + pageCount = searchBanners.size, + currentPage = pagerState.currentPage % searchBanners.size ) } }