|
|
|
@ -20,7 +20,9 @@ import android.content.Intent
|
|
|
|
|
import android.net.Uri
|
|
|
|
|
import androidx.compose.foundation.lazy.LazyListScope
|
|
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.toArgb
|
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
|
|
|
|
@ -47,8 +49,8 @@ fun <T> LazyListScope.newsResourceCardItems(
|
|
|
|
|
key = { newsResourceMapper(it).id },
|
|
|
|
|
itemContent = { item ->
|
|
|
|
|
val newsResource = newsResourceMapper(item)
|
|
|
|
|
val launchResourceIntent =
|
|
|
|
|
Intent(Intent.ACTION_VIEW, Uri.parse(newsResource.url))
|
|
|
|
|
val resourceUrl = Uri.parse(newsResource.url)
|
|
|
|
|
val backgroundColor = MaterialTheme.colorScheme.background.toArgb()
|
|
|
|
|
val context = LocalContext.current
|
|
|
|
|
|
|
|
|
|
NewsResourceCardExpanded(
|
|
|
|
@ -57,7 +59,7 @@ fun <T> LazyListScope.newsResourceCardItems(
|
|
|
|
|
onToggleBookmark = { onToggleBookmark(item) },
|
|
|
|
|
onClick = {
|
|
|
|
|
when (onItemClick) {
|
|
|
|
|
null -> ContextCompat.startActivity(context, launchResourceIntent, null)
|
|
|
|
|
null -> launchCustomChromeTab(context, resourceUrl, backgroundColor)
|
|
|
|
|
else -> onItemClick(item)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|