package com.peachpasswords.ui.updates import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel import com.peachpasswords.ui.theme.PeachSpacing import com.peachpasswords.ui.theme.PeachType import com.peachpasswords.ui.theme.ShellBackground import com.peachpasswords.ui.theme.peachColors /** * Shown once, after an update, for the version now running. The gate is a stored * "last seen changelog version" compared against this build — so it appears on the * first launch of a new version and never again, and never at all on a fresh * install (there is nothing to catch up on). */ @Composable fun WhatsNewScreen( onDone: () -> Unit, vm: UpdateViewModel = hiltViewModel(), ) { // Snapshotted, not collected: dismissing clears the flow, and a live read would // blank the text out from under the exit animation. val notes = remember { vm.whatsNew.value.orEmpty() } fun finish() { vm.dismissWhatsNew() onDone() } BackHandler { finish() } ShellBackground { Column( Modifier .fillMaxSize() .systemBarsPadding() .padding(horizontal = PeachSpacing.lg, vertical = PeachSpacing.xl), ) { Text("what's new", color = peachColors.T0, style = PeachType.createHeadline) Spacer(Modifier.height(PeachSpacing.xs)) Text("v${vm.currentVersion}", color = peachColors.T1, style = PeachType.labelMono) Spacer(Modifier.height(PeachSpacing.xl)) Column(Modifier.weight(1f).verticalScroll(rememberScrollState())) { ReleaseNotes(notes) } Spacer(Modifier.height(PeachSpacing.lg)) PrimaryButton("Continue") { finish() } } } }