package com.mhss.app.mybrain.presentation.localsync.components 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.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.Card 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.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import com.mhss.app.ui.Res import com.mhss.app.ui.cancel import com.mhss.app.ui.name import com.mhss.app.ui.rename_device import com.mhss.app.ui.save import org.jetbrains.compose.resources.stringResource @Composable fun RenameDeviceDialog( currentName: String, onDismiss: () -> Unit, onConfirm: (String) -> Unit ) { var name by remember(currentName) { mutableStateOf(currentName) } Dialog(onDismissRequest = onDismiss) { Card( modifier = Modifier .fillMaxWidth() .padding(16.dp), shape = RoundedCornerShape(24.dp) ) { Column( modifier = Modifier .fillMaxWidth() .padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp) ) { Text( text = stringResource(Res.string.rename_device), style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold ) OutlinedTextField( value = name, onValueChange = { name = it }, label = { Text(stringResource(Res.string.name)) }, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(12.dp), singleLine = true ) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically ) { TextButton(onClick = onDismiss) { Text(stringResource(Res.string.cancel)) } Spacer(modifier = Modifier.width(8.dp)) Button( onClick = { onConfirm(name) }, enabled = name.isNotBlank() ) { Text(stringResource(Res.string.save)) } } } } } }