package com.mhss.app.mybrain.presentation.plans import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer 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.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavHostController import com.mhss.app.mybrain.presentation.tgbot.BotCatalogData import com.mhss.app.mybrain.presentation.tgbot.SubscriptionPlan import com.mhss.app.ui.Res import com.mhss.app.ui.components.common.MyBrainAppBar import com.mhss.app.ui.ic_bolt import com.mhss.app.ui.ic_check import com.mhss.app.ui.theme.Green import com.mhss.app.ui.theme.PrimaryColor import com.mhss.app.ui.theme.SecondaryColor import org.jetbrains.compose.resources.painterResource @Composable fun PlansScreen( navController: NavHostController, onPlanSelected: (String) -> Unit = {} ) { Scaffold( topBar = { MyBrainAppBar( title = "Subscription Plans", actions = { androidx.compose.material3.TextButton( onClick = { navController.popBackStack() } ) { Text("Close", color = PrimaryColor, fontWeight = FontWeight.Bold) } } ) } ) { paddingValues -> LazyColumn( modifier = Modifier .fillMaxSize() .padding(paddingValues), contentPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp), verticalArrangement = Arrangement.spacedBy(16.dp) ) { item { Column( modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp), horizontalAlignment = Alignment.CenterHorizontally ) { Text( text = "Choose the Right Plan for Your Bot", style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold), textAlign = TextAlign.Center ) Spacer(Modifier.height(4.dp)) Text( text = "Scale your Telegram audience with 24/7 dedicated cloud engine and automated modules.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center ) } } items(BotCatalogData.subscriptionPlans) { plan -> SubscriptionPlanCard( plan = plan, onSelect = { onPlanSelected(plan.id) } ) } item { Spacer(Modifier.height(40.dp)) } } } } @Composable fun SubscriptionPlanCard( plan: SubscriptionPlan, onSelect: () -> Unit ) { val isPopular = plan.isPopular val borderModifier = if (isPopular) { Modifier.border( width = 2.dp, brush = Brush.linearGradient(listOf(PrimaryColor, SecondaryColor)), shape = RoundedCornerShape(20.dp) ) } else { Modifier.border( width = 1.dp, color = MaterialTheme.colorScheme.outline.copy(alpha = 0.2f), shape = RoundedCornerShape(20.dp) ) } Card( modifier = Modifier .fillMaxWidth() .then(borderModifier), shape = RoundedCornerShape(20.dp), colors = CardDefaults.cardColors( containerColor = if (isPopular) { MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.45f) } else { MaterialTheme.colorScheme.surface } ), elevation = CardDefaults.cardElevation(defaultElevation = if (isPopular) 4.dp else 1.dp) ) { Column(modifier = Modifier.padding(20.dp)) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { Column { Text( text = plan.name, style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Bold) ) Text( text = "${plan.botLimitText} • ${plan.userLimitText}", style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant ) } if (isPopular) { Surface( shape = RoundedCornerShape(8.dp), color = PrimaryColor ) { Text( text = "MOST POPULAR", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall.copy( fontWeight = FontWeight.Bold, color = Color.White ) ) } } else if (plan.isCurrent) { Surface( shape = RoundedCornerShape(8.dp), color = Green.copy(alpha = 0.15f) ) { Text( text = "CURRENT PLAN", modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), style = MaterialTheme.typography.labelSmall.copy( fontWeight = FontWeight.Bold, color = Green ) ) } } } Spacer(Modifier.height(14.dp)) Row(verticalAlignment = Alignment.Bottom) { Text( text = plan.priceFormatted, style = MaterialTheme.typography.headlineMedium.copy(fontWeight = FontWeight.Bold), color = MaterialTheme.colorScheme.onSurface ) Spacer(Modifier.width(6.dp)) Text( text = "/ ${plan.period}", style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(bottom = 4.dp) ) } Spacer(Modifier.height(16.dp)) Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { plan.features.forEach { feature -> Row(verticalAlignment = Alignment.CenterVertically) { Icon( painter = painterResource(Res.drawable.ic_check), contentDescription = null, tint = if (isPopular) PrimaryColor else Green, modifier = Modifier.size(16.dp) ) Spacer(Modifier.width(10.dp)) Text( text = feature, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurface ) } } } Spacer(Modifier.height(20.dp)) if (plan.isCurrent) { OutlinedButton( onClick = {}, enabled = false, modifier = Modifier.fillMaxWidth().height(46.dp), shape = RoundedCornerShape(12.dp) ) { Text("Current Active Plan") } } else { Button( onClick = onSelect, modifier = Modifier.fillMaxWidth().height(46.dp), shape = RoundedCornerShape(12.dp), colors = ButtonDefaults.buttonColors( containerColor = if (isPopular) PrimaryColor else MaterialTheme.colorScheme.secondary ) ) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( painter = painterResource(Res.drawable.ic_bolt), contentDescription = null, tint = Color.White, modifier = Modifier.size(16.dp) ) Spacer(Modifier.width(6.dp)) Text( text = "Choose ${plan.name}", fontWeight = FontWeight.Bold, color = Color.White ) } } } } } }