package com.peachpasswords.ui.pairing import android.content.Intent import android.net.Uri import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.semantics.heading import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp import com.peachpasswords.ui.theme.LocalPeachAccent import com.peachpasswords.ui.theme.PeachSpacing import com.peachpasswords.ui.theme.PeachType import com.peachpasswords.ui.theme.peachColors internal const val PEACH_PRO_PURCHASE_URL = "https://buy.polar.sh/polar_cl_IXSFIPojx67rcOTksn8LkH5mnU3osPHtYqBIl1eyuIz" private val pairingProFeatures = listOf( "01" to ("Peach Sync" to "Encrypted sync across every paired device"), "02" to ("One-time purchase" to "$39 once · yours forever"), "03" to ("One shared key" to "Pro transfers during authenticated pairing"), ) /** * Terminal pairing fallback derived from Settings' Peach Pro card. A tonal * Surface provides the MD3 container while Peach typography and spacing keep * it visually native to the rest of the app. */ @Composable internal fun PairingProRequired( onRetry: () -> Unit, onOpenPro: (() -> Unit)? = null, ) { val context = LocalContext.current val accent = LocalPeachAccent.current Surface( modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(24.dp), color = peachColors.SurfaceElevated, tonalElevation = 3.dp, ) { Column(Modifier.padding(PeachSpacing.lg)) { Text( "PEACH PRO · SYNC", color = accent, fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.18.em, ) Spacer(Modifier.height(PeachSpacing.sm)) Text( "Pair freely. Sync with Pro.", color = peachColors.T0, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 28.sp, modifier = Modifier.semantics { heading() }, ) Spacer(Modifier.height(PeachSpacing.sm)) Text( "Pairing can start from any device, but at least one of these two " + "devices needs a valid Peach Pro license before pairing can finish. " + "No vault or device record was added.", color = peachColors.T1, fontFamily = PeachType.Body, fontSize = 13.sp, lineHeight = 19.sp, ) Spacer(Modifier.height(PeachSpacing.md)) pairingProFeatures.forEach { (number, feature) -> HorizontalDivider(color = peachColors.T3.copy(alpha = 0.55f)) Row( Modifier .fillMaxWidth() .padding(vertical = PeachSpacing.sm), ) { Text( number, color = accent, fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(end = PeachSpacing.md), ) Column { Text( feature.first, color = peachColors.T0, fontFamily = PeachType.Body, fontSize = 14.sp, ) Text( feature.second, color = peachColors.T2, fontFamily = PeachType.Body, fontSize = 11.sp, ) } } } Spacer(Modifier.height(PeachSpacing.md)) PillButton( if (onOpenPro == null) "Get Peach Pro" else "Open Peach Pro", accent, filled = true, ) { if (onOpenPro != null) { onOpenPro() } else { runCatching { context.startActivity( Intent(Intent.ACTION_VIEW, Uri.parse(PEACH_PRO_PURCHASE_URL)), ) } } } Spacer(Modifier.height(PeachSpacing.xs)) PillButton("Try another device", peachColors.T2, filled = false, onClick = onRetry) } } }