package com.suno.android.common_ui.components.billing import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.suno.android.common_ui.R import com.suno.android.common_ui.theme.ExtendedTheme import com.suno.android.common_ui.theme.SunoTheme import com.suno.android.common_res.R as CommonResR @Composable fun BillingSubscriptionOptionCard( modifier: Modifier = Modifier, planTitle: String, planPeriod: String, priceText: String, displayPeriod: String, // perksText: String, perksList: List, isExternalStoreMode: Boolean, isActivePlan: Boolean = false, onPlanClick: () -> Unit = {}, cardLoading: Boolean = false, prediscountPrice: String? = null, ) { Column( modifier = Modifier .background( shape = RoundedCornerShape(24.dp), color = Color(0xFFE8E1DC), ) .height(400.dp) .fillMaxWidth(), ) { Column( modifier = Modifier.padding( start = 18.dp, end = 18.dp, top = 24.dp, ), ) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { Text( modifier = Modifier .background( color = Color.White, shape = RoundedCornerShape(8.dp), ) .padding(8.dp), text = planTitle, style = ExtendedTheme.typography.body, ) Text( modifier = Modifier.alpha(0.5f), text = planPeriod, style = ExtendedTheme.typography.body, ) } if (prediscountPrice != null) { Text( modifier = Modifier.padding(top = 16.dp, start = 4.dp), text = prediscountPrice, textDecoration = TextDecoration.LineThrough, style = ExtendedTheme.typography.categoryHeadline, color = ExtendedTheme.colors.textTertiary, ) } Row( verticalAlignment = Alignment.Bottom, modifier = Modifier.padding( bottom = 16.dp, top = if (prediscountPrice == null) 16.dp else 0.dp, ), ) { Text( text = priceText, style = ExtendedTheme.typography.largeHeadline, ) Text( modifier = Modifier.padding(start = 4.dp, bottom = 4.dp), text = if (displayPeriod == "monthly") { stringResource(CommonResR.string.per_month) } else if (displayPeriod == "annually") { stringResource(CommonResR.string.per_year) } else { "" }, style = ExtendedTheme.typography.categoryHeadline, ) } } HorizontalDivider( thickness = 1.dp, color = Color(0xFFD5CFCA), ) Column( modifier = Modifier .padding(horizontal = 18.dp, vertical = 16.dp) .weight(1f), verticalArrangement = Arrangement.SpaceBetween, ) { LazyColumn( modifier = Modifier .weight(1f) .padding(bottom = 16.dp), ) { items(perksList) { perksText -> Text( modifier = Modifier .fillMaxWidth() .padding(vertical = 8.dp), text = perksText, style = ExtendedTheme.typography.smallBody, overflow = TextOverflow.Visible, maxLines = 2, lineHeight = 16.sp, ) } } Row( modifier = Modifier .clip(RoundedCornerShape(8.dp)) .clickable(enabled = !isActivePlan || !cardLoading) { onPlanClick.invoke() } .fillMaxWidth() .height(64.dp) .background( color = if (isActivePlan || cardLoading) Color.Gray else Color.Black, ), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center, ) { if (cardLoading) { CircularProgressIndicator( modifier = Modifier .padding(horizontal = 8.dp) .size(24.dp), color = Color.White, ) } Text( text = if (cardLoading) { "Loading..." } else if (isActivePlan) { "Active Plan" } else { "+ Select Plan" }, style = ExtendedTheme.typography.body, color = Color.White, ) if (isExternalStoreMode && !cardLoading) { Icon( modifier = Modifier.padding(horizontal = 4.dp), imageVector = ImageVector.vectorResource( R.drawable.external_link, ), contentDescription = null, tint = Color.White, ) } } } } } @Preview(showSystemUi = true) @Composable private fun BillingSubscriptionOptionCard_Preview() { SunoTheme { BillingSubscriptionOptionCard( planTitle = "Free plan", priceText = "$0", prediscountPrice = "$10", perksList = listOf( "50 daily credits (10 songs)", "Non-commercial terms", "No credit top ups", ), isActivePlan = true, planPeriod = "Billed annually (20% off)", isExternalStoreMode = true, cardLoading = false, displayPeriod = "annually", ) } }