Repository: android/nowinandroid
File: core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt (Kotlin)

Code before:
        NewsFeedUiState.Loading -> Unit
        is NewsFeedUiState.Success -> {
            items(feedState.feed, key = { it.newsResource.id }) { saveableNewsResource ->
                val resourceUrl by remember {
                    mutableStateOf(Uri.parse(saveableNewsResource.newsResource.url))
                }
                val context = LocalContext.current
                val backgroundColor = MaterialTheme.colorScheme.background.toArgb()

                NewsResourceCardExpanded(
                    newsResource = saveableNewsResource.newsResource,
                    isBookmarked = saveableNewsResource.isSaved,
                    onClick = { launchCustomChromeTab(context, resourceUrl, backgroundColor) },
                    onToggleBookmark = {
                        onNewsResourcesCheckedChanged(
                            saveableNewsResource.newsResource.id,
                            !saveableNewsResource.isSaved
                        )
                    }
                )
            }
        }
    }
}

fun launchCustomChromeTab(context: Context, uri: Uri, toolbarColor: Int) {
    val customTabBarColor = CustomTabColorSchemeParams.Builder()
        .setToolbarColor(toolbarColor).build()
    val customTabsIntent = CustomTabsIntent.Builder()
        .setDefaultColorSchemeParams(customTabBarColor)
        .build()

    customTabsIntent.launchUrl(context, uri)
}

/**
 * A sealed hierarchy describing the state of the feed of news resources.
 */
sealed interface NewsFeedUiState {
    /**
     * The feed is still loading.
     */
    object Loading : NewsFeedUiState

    /**
     * The feed is loaded with the given list of news resources.
     */
    data class Success(
        /**
         * The list of news resources contained in this feed.
         */

Review comment (suggestion):
Nit: could we annotate this with `@ColorInt`?
```suggestion
fun launchCustomChromeTab(context: Context, uri: Uri, @ColorInt toolbarColor: Int) {
```

Code after:
    when (feedState) {
        NewsFeedUiState.Loading -> Unit
        is NewsFeedUiState.Success -> {
            items(feedState.feed, key = { it.newsResource.id }) { saveableNewsResource ->
                val resourceUrl by remember {
                    mutableStateOf(Uri.parse(saveableNewsResource.newsResource.url))
                }
                val context = LocalContext.current
                val backgroundColor = MaterialTheme.colorScheme.background.toArgb()

                NewsResourceCardExpanded(
                    newsResource = saveableNewsResource.newsResource,
                    isBookmarked = saveableNewsResource.isSaved,
                    onClick = { launchCustomChromeTab(context, resourceUrl, backgroundColor) },
                    onToggleBookmark = {
                        onNewsResourcesCheckedChanged(
                            saveableNewsResource.newsResource.id,
                            !saveableNewsResource.isSaved
                        )
                    }
                )
            }
        }
    }
}

fun launchCustomChromeTab(context: Context, uri: Uri, @ColorInt toolbarColor: Int) {
    val customTabBarColor = CustomTabColorSchemeParams.Builder()
        .setToolbarColor(toolbarColor).build()
    val customTabsIntent = CustomTabsIntent.Builder()
        .setDefaultColorSchemeParams(customTabBarColor)
        .build()

    customTabsIntent.launchUrl(context, uri)
}

/**
 * A sealed hierarchy describing the state of the feed of news resources.
 */
sealed interface NewsFeedUiState {
    /**
     * The feed is still loading.
     */
    object Loading : NewsFeedUiState

    /**
     * The feed is loaded with the given list of news resources.
     */
    data class Success(
        /**
         * The list of news resources contained in this feed.