Repository: Automattic/pocket-casts-android
File: modules/features/account/src/main/java/au/com/shiftyjelly/pocketcasts/account/onboarding/upgrade/OnboardingUpgradeScreen.kt (Kotlin)

Code before:
    pages: List<ContentPage>,
    modifier: Modifier = Modifier,
) {
    Column(modifier = modifier) {
        val pagerState = rememberPagerState(initialPage = 0) { pages.size }
        val coroutineScope = rememberCoroutineScope()
        VerticalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { page ->
            when (val currentPage = pages[page]) {
                is ContentPage.Features -> FeaturesContent(
                    features = currentPage,
                    onCtaClicked = { coroutineScope.launch { pagerState.animateScrollToPage(pages.size - page - 1) } },
                )

                is ContentPage.TrialSchedule -> ScheduleContent(
                    trialSchedule = currentPage,
                    onCtaClicked = { coroutineScope.launch { pagerState.animateScrollToPage(pages.size - page - 1) } },
                )
            }
        }
    }
}

@Composable
private fun FeaturesContent(
    features: ContentPage.Features,
    onCtaClicked: () -> Unit,
) {
    LazyColumn {
        items(features.features.size) {
            UpgradeFeatureItem(
                item = features.features[it],
                iconColor = MaterialTheme.theme.colors.primaryText01,
                textColor = MaterialTheme.theme.colors.secondaryText02,
            )
        }
        if (features.showCta) {
            item {
                Spacer(modifier = Modifier.height(24.dp))
                TextP40(
                    text = stringResource(LR.string.onboarding_upgrade_features_trial_schedule),
                    modifier = Modifier.clickable { onCtaClicked() },
                    color = MaterialTheme.theme.colors.primaryInteractive01,
                )
            }
        }
    }
}

@Composable
private fun ScheduleContent(
    trialSchedule: ContentPage.TrialSchedule,

Review comment (suggestion):
```suggestion
                    onCtaClicked = { coroutineScope.launch { pagerState.animateScrollToPage(pagerState.currentPage + 1) } },
```

Code after:
        }
    }
}

private sealed interface UpgradePagerContent {
    val showCta: Boolean

    data class Features(val features: List<UpgradeFeatureItem>, override val showCta: Boolean) : UpgradePagerContent
    data class TrialSchedule(val timelineItems: List<UpgradeTrialItem>, override val showCta: Boolean) : UpgradePagerContent
}

@Composable
private fun UpgradeContent(
    pages: List<UpgradePagerContent>,
    modifier: Modifier = Modifier,
) {
    Column(modifier = modifier) {
        val pagerState = rememberPagerState(initialPage = 0) { pages.size }
        val coroutineScope = rememberCoroutineScope()
        VerticalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { page ->
            when (val currentPage = pages[page]) {
                is UpgradePagerContent.Features -> FeaturesContent(
                    features = currentPage,
                    onCtaClick = { coroutineScope.launch { pagerState.animateScrollToPage(pages.size - page) } },
                )

                is UpgradePagerContent.TrialSchedule -> ScheduleContent(
                    trialSchedule = currentPage,
                    onCtaClick = { coroutineScope.launch { pagerState.animateScrollToPage(pages.size - page) } },
                )
            }
        }
    }
}

@Composable
private fun FeaturesContent(
    features: UpgradePagerContent.Features,
    onCtaClick: () -> Unit,
) {
    FadedLazyColumn {
        items(features.features.size) {
            UpgradeFeatureItem(
                item = features.features[it],
                iconColor = MaterialTheme.theme.colors.primaryText01,
                textColor = MaterialTheme.theme.colors.secondaryText02,
            )
        }
        if (features.showCta) {
            item {
                TextP40(