diff --git a/domain/src/main/java/com/terning/domain/entity/search/SearchBanner.kt b/domain/src/main/java/com/terning/domain/entity/search/SearchBanner.kt new file mode 100644 index 00000000..23ab0870 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/entity/search/SearchBanner.kt @@ -0,0 +1,6 @@ +package com.terning.domain.entity.search + +data class SearchBanner( + val imageRes: Int, + val url: String +) diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index d95786be..27d081b1 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -31,6 +31,7 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.noRippleClickable import com.terning.core.state.UiState +import com.terning.domain.entity.search.SearchBanner import com.terning.domain.entity.search.SearchPopularAnnouncement import com.terning.feature.R import com.terning.feature.search.search.component.ImageSlider @@ -38,9 +39,6 @@ import com.terning.feature.search.search.component.InternListType import com.terning.feature.search.search.component.SearchInternList import okhttp3.internal.toImmutableList -const val ADVERTISEMENT_URL = - "https://www.instagram.com/terning_official?igsh=NnNma245bnUzbWNm&utm_source=qr" - @Composable fun SearchRoute( modifier: Modifier, @@ -84,6 +82,7 @@ fun SearchRoute( SearchScreen( modifier = modifier, + bannerList = SearchViewModel.bannerList, searchViewsList = searchViewsList, searchScrapsList = searchScrapsList, navigateToSearchProcess = { @@ -94,8 +93,8 @@ fun SearchRoute( navigateToSearchProcess() }, navigateToIntern = navigateToIntern, - onAdvertisementClick = { - CustomTabsIntent.Builder().build().launchUrl(context, ADVERTISEMENT_URL.toUri()) + onAdvertisementClick = { pageIndex -> + CustomTabsIntent.Builder().build().launchUrl(context, SearchViewModel.bannerList[pageIndex].url.toUri()) } ) } @@ -103,19 +102,13 @@ fun SearchRoute( @Composable fun SearchScreen( modifier: Modifier = Modifier, + bannerList: List, searchViewsList: List, searchScrapsList: List, navigateToSearchProcess: () -> Unit, navigateToIntern: (Long) -> Unit, - onAdvertisementClick: () -> Unit, + onAdvertisementClick: (Int) -> Unit, ) { - - val images = listOf( - R.drawable.img_ad_1, - R.drawable.img_ad_2, - R.drawable.img_ad_3, - ) - Column( modifier = modifier .fillMaxSize() @@ -150,7 +143,7 @@ fun SearchScreen( LazyColumn { item { ImageSlider( - images = images, + images = bannerList, onAdvertisementClick = onAdvertisementClick, ) diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index 981ddf58..37c67778 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -3,6 +3,7 @@ package com.terning.feature.search.search import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState +import com.terning.domain.entity.search.SearchBanner import com.terning.domain.repository.SearchRepository import com.terning.feature.R import com.terning.feature.search.search.model.SearchScrapsListState @@ -61,4 +62,21 @@ class SearchViewModel @Inject constructor( } } } + + companion object { + val bannerList: List = listOf( + SearchBanner( + imageRes = R.drawable.img_ad_1, + url = "https://www.instagram.com/p/DBWCO97TRds/?igsh=bDhjMGxlMGliNDc2" + ), + SearchBanner( + imageRes = R.drawable.img_ad_2, + url = "https://www.instagram.com/terning_official/" + ), + SearchBanner( + imageRes = R.drawable.img_ad_3, + url = "https://forms.gle/4btEwEbUQ3JSjTKP7" + ) + ) + } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt index cd08de88..fb004d3b 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt @@ -19,13 +19,14 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Grey200 import com.terning.core.extension.noRippleClickable +import com.terning.domain.entity.search.SearchBanner import kotlinx.coroutines.delay @Composable fun ImageSlider( modifier: Modifier = Modifier, - images: List, - onAdvertisementClick: () -> Unit, + images: List, + onAdvertisementClick: (Int) -> Unit, ) { val pagerState = rememberPagerState( initialPage = 0, @@ -36,7 +37,7 @@ fun ImageSlider( LaunchedEffect(autoScroll.value) { if (autoScroll.value) { while (true) { - delay(3000) + delay(2500) if (!pagerState.isScrollInProgress) { val nextPage = pagerState.currentPage + 1 pagerState.animateScrollToPage(nextPage) @@ -62,12 +63,12 @@ fun ImageSlider( ) { currentPage -> val pageIndex = currentPage % images.size Image( - painter = painterResource(id = images[pageIndex]), + painter = painterResource(id = images[pageIndex].imageRes), contentDescription = null, modifier = modifier .fillMaxWidth() .height(112.dp) - .noRippleClickable(onAdvertisementClick), + .noRippleClickable { onAdvertisementClick(pageIndex) }, contentScale = ContentScale.Crop, ) } diff --git a/feature/src/main/res/drawable/img_ad_1.png b/feature/src/main/res/drawable/img_ad_1.png index 9d1a44b0..c2045411 100644 Binary files a/feature/src/main/res/drawable/img_ad_1.png and b/feature/src/main/res/drawable/img_ad_1.png differ diff --git a/feature/src/main/res/drawable/img_ad_2.png b/feature/src/main/res/drawable/img_ad_2.png index 05e12477..643ce85a 100644 Binary files a/feature/src/main/res/drawable/img_ad_2.png and b/feature/src/main/res/drawable/img_ad_2.png differ diff --git a/feature/src/main/res/drawable/img_ad_3.png b/feature/src/main/res/drawable/img_ad_3.png index f263ac52..7dd64d6f 100644 Binary files a/feature/src/main/res/drawable/img_ad_3.png and b/feature/src/main/res/drawable/img_ad_3.png differ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a93f332b..45ae80bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ compileSdk = "34" minSdk = "28" targetSdk = "34" -versionName = "1.1.6" -versionCode = "10106" +versionName = "1.1.7" +versionCode = "10107" kotlinCompilerExtensionVersion = "1.5.0" jvmTarget = "1.8"