package com.suno.android.common_ui.components.dialogs import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize 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.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.drawText import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.rememberTextMeasurer import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.suno.android.common_core_utils.environment.ThemeMode import com.suno.android.common_ui.theme.ExtendedTheme import com.suno.android.common_ui.theme.SunoPink import com.suno.android.common_ui.theme.SunoTheme import com.suno.android.common_res.R as CommonResR @Composable fun NoCreditsRemainingDialogScaffold( modifier: Modifier = Modifier, onCloseClick: () -> Unit, onUpgradeClick: () -> Unit, ) { val textMeasurer = rememberTextMeasurer() val firstTextStyle = ExtendedTheme.typography.largeHeadline.copy( color = ExtendedTheme.colors.textPrimary, ) val firstTextLayoutResult = textMeasurer.measure( text = "0", style = ExtendedTheme.typography.largeHeadline, ) Box( modifier = Modifier .width(310.dp) .height(410.dp) .clip(RoundedCornerShape(8.dp)), ) { Column( modifier = Modifier .fillMaxSize() .background(color = ExtendedTheme.colors.backgroundPrimary), ) { Column( modifier = Modifier .weight(1f) .fillMaxWidth() .padding(horizontal = 12.dp), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, ) { Canvas(modifier = modifier.size(80.dp)) { drawCircle( color = Color.White, radius = size.minDimension / 2f, style = Stroke(width = 2.dp.toPx()), ) drawArc( color = SunoPink.copy(alpha = 0.3f), startAngle = 0f, sweepAngle = 360f, useCenter = false, style = Stroke(width = 2.dp.toPx()), size = androidx.compose.ui.geometry.Size(size.width, size.height), topLeft = Offset(0f, 0f), ) // Calculate center position val centerX = size.width / 2 val centerY = size.height / 2 this.drawText( textMeasurer = textMeasurer, text = "0", style = firstTextStyle, topLeft = Offset( x = centerX - firstTextLayoutResult.size.width / 2, y = centerY - firstTextLayoutResult.size.height / 2 + 10, ), ) } Text( modifier = Modifier.padding(vertical = 18.dp), text = stringResource(CommonResR.string.credits_popup_title, 0), style = ExtendedTheme.typography.mediumHeadline, color = ExtendedTheme.colors.textPrimary, ) Text( modifier = Modifier.padding(bottom = 24.dp), style = ExtendedTheme.typography.body.copy( textAlign = TextAlign.Center, lineHeight = 24.sp, ), text = stringResource(CommonResR.string.credits_popup_message), color = ExtendedTheme.colors.textPrimary, ) } Row( modifier = Modifier .height(64.dp) .fillMaxWidth() .padding(horizontal = 16.dp), horizontalArrangement = Arrangement.SpaceBetween, ) { TextButton( onClick = { onCloseClick.invoke() }, ) { Text( text = stringResource(CommonResR.string.close), color = ExtendedTheme.colors.textPrimary, style = ExtendedTheme.typography.body.copy(fontWeight = FontWeight.Bold), ) } TextButton( onClick = { onUpgradeClick.invoke() }, ) { Text( text = stringResource(CommonResR.string.navigation_title_free), style = ExtendedTheme.typography.body.copy(fontWeight = FontWeight.Bold), color = ExtendedTheme.colors.sunoPink, ) } } } } } @Preview @Composable private fun NoCreditsRemainingDialog_Preview() { SunoTheme(themeMode = ThemeMode.DARK) { NoCreditsRemainingDialogScaffold( onCloseClick = {}, onUpgradeClick = {}, ) } }