Skip to content

Commit

Permalink
[FEAT/#260] 광고 배너 링크 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed Sep 23, 2024
1 parent 33b1524 commit b692302
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.terning.feature.search.search

import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -13,8 +14,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -33,6 +36,9 @@ 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,
Expand All @@ -41,6 +47,7 @@ fun SearchRoute(
viewModel: SearchViewModel = hiltViewModel(),
) {
val lifecycleOwner = LocalLifecycleOwner.current
val context = LocalContext.current

val viewState by viewModel.viewState.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner)
val scrapState by viewModel.scrapState.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner)
Expand Down Expand Up @@ -77,6 +84,9 @@ fun SearchRoute(
searchScrapsList = searchScrapsList,
navigateToSearchProcess = navigateToSearchProcess,
navigateToIntern = navigateToIntern,
onAdvertisementClick = {
CustomTabsIntent.Builder().build().launchUrl(context, ADVERTISEMENT_URL.toUri())
}
)
}

Expand All @@ -87,6 +97,7 @@ fun SearchScreen(
searchScrapsList: List<SearchPopularAnnouncement>,
navigateToSearchProcess: () -> Unit,
navigateToIntern: (Long) -> Unit,
onAdvertisementClick: () -> Unit,
) {

val images = listOf(
Expand Down Expand Up @@ -128,7 +139,10 @@ fun SearchScreen(

LazyColumn {
item {
ImageSlider(images = images)
ImageSlider(
images = images,
onAdvertisementClick = onAdvertisementClick,
)

Spacer(modifier = Modifier.padding(top = 20.dp))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import androidx.compose.ui.layout.ContentScale
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 kotlinx.coroutines.delay

@Composable
fun ImageSlider(
modifier: Modifier = Modifier,
images: List<Int>,
onAdvertisementClick: () -> Unit,
) {
val pagerState = rememberPagerState(pageCount = { images.size })
val autoScroll = remember { mutableStateOf(true) }
Expand Down Expand Up @@ -59,8 +61,9 @@ fun ImageSlider(
contentDescription = null,
modifier = modifier
.fillMaxWidth()
.height(112.dp),
contentScale = ContentScale.Crop
.height(112.dp)
.noRippleClickable(onAdvertisementClick),
contentScale = ContentScale.Crop,
)
}
DotsIndicator(
Expand Down

0 comments on commit b692302

Please sign in to comment.