Repository: android/compose-samples
File: Jetcaster/wear/src/main/java/com/example/jetcaster/ui/library/PodcastsScreen.kt (Kotlin)

Code before:
    podcastViewModel: PodcastViewModel = hiltViewModel(),
    onPodcastsItemClick: (PodcastInfo) -> Unit,
    onErrorDialogCancelClick: () -> Unit,
) {
    val uiState by podcastViewModel.uiState.collectAsStateWithLifecycle()

    val modifiedState = when (uiState) {
        is PodcastsScreenState.Loaded -> {
            val modifiedPodcast = (uiState as PodcastsScreenState.Loaded).podcastList.map {
                it.takeIf { it.title.isNotEmpty() }
                    ?: it.copy(title = stringResource(id = R.string.no_title))
            }

            PodcastsScreenState.Loaded(modifiedPodcast)
        }

        PodcastsScreenState.Failed,
        PodcastsScreenState.Loading,
        -> uiState
    }

    PodcastsScreen(
        podcastsScreenState = modifiedState,
        onPodcastItemClick = {
            onPodcastsItemClick(it)
        },
    )

    if (modifiedState == PodcastsScreenState.Failed) {
        Dialog(
            showDialog = true,
            onDismissRequest = onErrorDialogCancelClick,
            scrollState = rememberScalingLazyListState(),
        ) {
            Alert(
                title = {
                    Text(
                        text = stringResource(R.string.podcasts_no_podcasts),
                        color = MaterialTheme.colors.onBackground,
                        textAlign = TextAlign.Center,
                        style = MaterialTheme.typography.title3,
                    )
                },
            ) {
                item {
                    Row(
                        verticalAlignment = Alignment.CenterVertically,
                    ) {
                        Button(
                            onClick = onErrorDialogCancelClick,
                            colors = ButtonDefaults.secondaryButtonColors(),

Review comment (suggestion):
```suggestion
        onPodcastItemClick = onPodcastsItemClick,
```

Code after:
    onPodcastsItemClick: (PodcastInfo) -> Unit,
    onErrorDialogCancelClick: () -> Unit,
) {
    val uiState by podcastsViewModel.uiState.collectAsStateWithLifecycle()

    val modifiedState = when (uiState) {
        is PodcastsScreenState.Loaded -> {
            val modifiedPodcast = (uiState as PodcastsScreenState.Loaded).podcastList.map {
                it.takeIf { it.title.isNotEmpty() }
                    ?: it.copy(title = stringResource(id = R.string.no_title))
            }

            PodcastsScreenState.Loaded(modifiedPodcast)
        }

        PodcastsScreenState.Empty,
        PodcastsScreenState.Loading,
        -> uiState
    }

    PodcastsScreen(
        podcastsScreenState = modifiedState,
        onPodcastsItemClick = onPodcastsItemClick
    )

    Dialog(
        showDialog = modifiedState == PodcastsScreenState.Empty,
        onDismissRequest = onErrorDialogCancelClick,
        scrollState = rememberScalingLazyListState(),
    ) {
        Alert(
            title = {
                Text(
                    text = stringResource(R.string.podcasts_no_podcasts),
                    color = MaterialTheme.colors.onBackground,
                    textAlign = TextAlign.Center,
                    style = MaterialTheme.typography.title3,
                )
            },
        ) {
            item {
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                ) {

                    Button(
                        imageVector = Icons.Default.Close,
                        contentDescription = stringResource(
                            id = R.string
                                .podcasts_failed_dialog_cancel_button_content_description,
                        ),