package com.mhss.app.mybrain.presentation.tgbot.dialogs import androidx.compose.foundation.layout.Arrangement 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.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.mhss.app.mybrain.presentation.tgbot.WelcomeModuleConfig import com.mhss.app.ui.theme.PrimaryColor @Composable fun WelcomeConfigDialog( initialConfig: WelcomeModuleConfig, onDismiss: () -> Unit, onSave: (WelcomeModuleConfig) -> Unit ) { var messageText by remember { mutableStateOf(initialConfig.messageText) } var btn1Text by remember { mutableStateOf(initialConfig.button1Text) } var btn1Url by remember { mutableStateOf(initialConfig.button1Url) } var btn2Text by remember { mutableStateOf(initialConfig.button2Text) } var btn2Url by remember { mutableStateOf(initialConfig.button2Url) } AlertDialog( onDismissRequest = onDismiss, title = { Text( text = "Configure Welcome Module", style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold) ) }, text = { Column( modifier = Modifier .fillMaxWidth() .verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(10.dp) ) { Text( text = "Welcome Greeting Text (/start response):", style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant ) OutlinedTextField( value = messageText, onValueChange = { messageText = it }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(12.dp), minLines = 3, maxLines = 6 ) Spacer(Modifier.height(4.dp)) Text( text = "Inline Button 1 (Channel Link):", style = MaterialTheme.typography.labelSmall, color = PrimaryColor, fontWeight = FontWeight.SemiBold ) OutlinedTextField( value = btn1Text, onValueChange = { btn1Text = it }, label = { Text("Button Text") }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(10.dp), singleLine = true ) OutlinedTextField( value = btn1Url, onValueChange = { btn1Url = it }, label = { Text("Button URL") }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(10.dp), singleLine = true ) Spacer(Modifier.height(4.dp)) Text( text = "Inline Button 2 (Support Link):", style = MaterialTheme.typography.labelSmall, color = PrimaryColor, fontWeight = FontWeight.SemiBold ) OutlinedTextField( value = btn2Text, onValueChange = { btn2Text = it }, label = { Text("Button Text") }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(10.dp), singleLine = true ) OutlinedTextField( value = btn2Url, onValueChange = { btn2Url = it }, label = { Text("Button URL") }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(10.dp), singleLine = true ) } }, confirmButton = { Button( onClick = { onSave( initialConfig.copy( messageText = messageText, button1Text = btn1Text, button1Url = btn1Url, button2Text = btn2Text, button2Url = btn2Url ) ) onDismiss() }, shape = RoundedCornerShape(10.dp), colors = ButtonDefaults.buttonColors(containerColor = PrimaryColor) ) { Text("Save Changes") } }, dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } } ) }