Repository: Automattic/pocket-casts-android
File: modules/features/endofyear/src/main/java/au/com/shiftyjelly/pocketcasts/endofyear/ui/StoriesPage.kt (Kotlin)

Code before:
    onFailedToLoad: () -> Unit,
) {
    val size = LocalContext.current.sizeLimit?.let(Modifier::size) ?: Modifier.fillMaxSize()
    BoxWithConstraints(
        modifier = Modifier.then(size),
    ) {
        val density = LocalDensity.current
        val widthPx = density.run { maxWidth.toPx() }

        var isTextSizeComputed by remember { mutableStateOf(false) }
        var coverFontSize by remember { mutableStateOf(24.sp) }
        var coverTextHeight by remember { mutableStateOf(0.dp) }
        val measurements = remember(maxWidth, maxHeight, insets, coverFontSize, coverTextHeight) {
            EndOfYearMeasurements(
                width = maxWidth,
                height = maxHeight,
                statusBarInsets = insets,
                coverFontSize = coverFontSize,
                coverTextHeight = coverTextHeight,
                closeButtonBottomEdge = density.run { insets.getTop(density).toDp() } + 36.dp,
            )
        }

        if (state is UiState.Failure) {
            onFailedToLoad()
        } else if (!isTextSizeComputed) {
            // oopsie
        } else if (state is UiState.Syncing) {
            Stories(
                stories = state.stories,
                measurements = measurements,
                controller = controller,
                pagerState = pagerState,
                onChangeStory = onChangeStory,
                onShareStory = onShareStory,
                onHoldStory = onHoldStory,
                onReleaseStory = onReleaseStory,
                onLearnAboutRatings = onLearnAboutRatings,
                onClickUpsell = onClickUpsell,
                onRestartPlayback = onRestartPlayback,
                blockGestures = true,
            )
        } else if (state is UiState.Synced) {
            Stories(
                stories = state.stories,
                measurements = measurements,
                controller = controller,
                pagerState = pagerState,
                onChangeStory = onChangeStory,
                onShareStory = onShareStory,
                onHoldStory = onHoldStory,

Review comment (suggestion):
❓ From my understanding this variable no longer has any use. Last year it was needed to compute the correct size to fit the text. I think we can remove it now and all the calculations associated with it.

Code after:
    val size = LocalContext.current.sizeLimit?.let(Modifier::size) ?: Modifier.fillMaxSize()
    BoxWithConstraints(
        modifier = Modifier.then(size),
    ) {
        val density = LocalDensity.current

        var coverFontSize by remember { mutableStateOf(24.sp) }
        var coverTextHeight by remember { mutableStateOf(0.dp) }
        val measurements = remember(maxWidth, maxHeight, insets, coverFontSize, coverTextHeight) {
            EndOfYearMeasurements(
                width = maxWidth,
                height = maxHeight,
                statusBarInsets = insets,
                coverFontSize = coverFontSize,
                coverTextHeight = coverTextHeight,
                closeButtonBottomEdge = density.run { insets.getTop(density).toDp() } + 36.dp,
            )
        }

        if (state is UiState.Failure) {
            onFailedToLoad()
        } else if (state is UiState.Syncing) {
            Stories(
                stories = state.stories,
                measurements = measurements,
                controller = controller,
                pagerState = pagerState,
                onChangeStory = onChangeStory,
                onShareStory = onShareStory,
                onHoldStory = onHoldStory,
                onReleaseStory = onReleaseStory,
                onLearnAboutRatings = onLearnAboutRatings,
                onClickUpsell = onClickUpsell,
                onRestartPlayback = onRestartPlayback,
                blockGestures = true,
            )
        } else if (state is UiState.Synced) {
            Stories(
                stories = state.stories,
                measurements = measurements,
                controller = controller,
                pagerState = pagerState,
                onChangeStory = onChangeStory,
                onShareStory = onShareStory,
                onHoldStory = onHoldStory,
                onReleaseStory = onReleaseStory,
                onLearnAboutRatings = onLearnAboutRatings,
                onClickUpsell = onClickUpsell,
                onRestartPlayback = onRestartPlayback,
            )
        }