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.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.ForceJoinModuleConfig import com.mhss.app.ui.theme.Orange @Composable fun ForceJoinConfigDialog( initialConfig: ForceJoinModuleConfig, onDismiss: () -> Unit, onSave: (ForceJoinModuleConfig) -> Unit ) { var channelUsername by remember { mutableStateOf(initialConfig.channelUsername) } var channelTitle by remember { mutableStateOf(initialConfig.channelTitle) } var promptMessage by remember { mutableStateOf(initialConfig.promptMessage) } AlertDialog( onDismissRequest = onDismiss, title = { Text( text = "Force Join (FSub) Settings", style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold) ) }, text = { Column( modifier = Modifier .fillMaxWidth() .verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(10.dp) ) { Text( text = "Forces users to join your Telegram channel/group before unlocking bot commands.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f) ) Spacer(Modifier.height(4.dp)) OutlinedTextField( value = channelUsername, onValueChange = { channelUsername = it }, label = { Text("Channel Username") }, placeholder = { Text("e.g. @MyChannel") }, singleLine = true, shape = RoundedCornerShape(12.dp), modifier = Modifier.fillMaxWidth() ) OutlinedTextField( value = channelTitle, onValueChange = { channelTitle = it }, label = { Text("Channel Display Name") }, placeholder = { Text("e.g. Official Updates Channel") }, singleLine = true, shape = RoundedCornerShape(12.dp), modifier = Modifier.fillMaxWidth() ) OutlinedTextField( value = promptMessage, onValueChange = { promptMessage = it }, label = { Text("Join Warning Prompt") }, minLines = 3, maxLines = 5, shape = RoundedCornerShape(12.dp), modifier = Modifier.fillMaxWidth() ) Text( text = "Tip: Make sure your bot is added as an Administrator in this channel so it can verify memberships with getChatMember API.", style = MaterialTheme.typography.labelSmall, color = Orange ) } }, confirmButton = { Button( onClick = { onSave( initialConfig.copy( channelUsername = channelUsername, channelTitle = channelTitle, promptMessage = promptMessage, isEnabled = true ) ) onDismiss() }, shape = RoundedCornerShape(10.dp), colors = ButtonDefaults.buttonColors(containerColor = Orange) ) { Text("Save FSub Settings") } }, dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } } ) }