WhatsNewScreen.kt

2.3 KB · raw

1package com.peachpasswords.ui.updates23import androidx.activity.compose.BackHandler4import androidx.compose.foundation.layout.Column5import androidx.compose.foundation.layout.Spacer6import androidx.compose.foundation.layout.fillMaxSize7import androidx.compose.foundation.layout.height8import androidx.compose.foundation.layout.padding9import androidx.compose.foundation.layout.systemBarsPadding10import androidx.compose.foundation.rememberScrollState11import androidx.compose.foundation.verticalScroll12import androidx.compose.material3.Text13import androidx.compose.runtime.Composable14import androidx.compose.runtime.remember15import androidx.compose.ui.Modifier16import androidx.hilt.navigation.compose.hiltViewModel17import com.peachpasswords.ui.theme.PeachSpacing18import com.peachpasswords.ui.theme.PeachType19import com.peachpasswords.ui.theme.ShellBackground20import com.peachpasswords.ui.theme.peachColors2122/**23 * Shown once, after an update, for the version now running. The gate is a stored24 * "last seen changelog version" compared against this build — so it appears on the25 * first launch of a new version and never again, and never at all on a fresh26 * install (there is nothing to catch up on).27 */28@Composable29fun WhatsNewScreen(30    onDone: () -> Unit,31    vm: UpdateViewModel = hiltViewModel(),32) {33    // Snapshotted, not collected: dismissing clears the flow, and a live read would34    // blank the text out from under the exit animation.35    val notes = remember { vm.whatsNew.value.orEmpty() }3637    fun finish() {38        vm.dismissWhatsNew()39        onDone()40    }41    BackHandler { finish() }4243    ShellBackground {44        Column(45            Modifier46                .fillMaxSize()47                .systemBarsPadding()48                .padding(horizontal = PeachSpacing.lg, vertical = PeachSpacing.xl),49        ) {50            Text("what's new", color = peachColors.T0, style = PeachType.createHeadline)51            Spacer(Modifier.height(PeachSpacing.xs))52            Text("v${vm.currentVersion}", color = peachColors.T1, style = PeachType.labelMono)53            Spacer(Modifier.height(PeachSpacing.xl))5455            Column(Modifier.weight(1f).verticalScroll(rememberScrollState())) {56                ReleaseNotes(notes)57            }5859            Spacer(Modifier.height(PeachSpacing.lg))60            PrimaryButton("Continue") { finish() }61        }62    }63}