package com.suno.android.ui.screens.orpheus.components 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.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.IconButtonDefaults 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.SolidColor import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import com.suno.android.common_ui.theme.DarkTextPrimary import com.suno.android.common_ui.theme.ExtendedTheme import com.suno.android.common_ui.theme.HeaderLibraryOrange import com.suno.android.common_ui.theme.SunoTheme import com.suno.android.common_res.R as CommonResR import com.suno.android.common_ui.R as CommonUiR @Composable fun ChatInput( message: String, onInputChange: (String) -> Unit, onSendClick: () -> Unit, onPlusClick: () -> Unit, onCustomModeClick: () -> Unit, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues.Zero, ) { Column( modifier = modifier .fillMaxWidth() .padding(contentPadding), verticalArrangement = Arrangement.spacedBy(8.dp), ) { Row( modifier = Modifier .fillMaxWidth() .padding(vertical = 16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, ) { BasicTextField( value = message, onValueChange = onInputChange, modifier = Modifier .weight(1f) .fillMaxWidth(), textStyle = ExtendedTheme.typography.body.copy( color = ExtendedTheme.colors.textPrimary, ), keyboardOptions = KeyboardOptions( imeAction = ImeAction.Default, capitalization = KeyboardCapitalization.Sentences, ), cursorBrush = SolidColor(ExtendedTheme.colors.sunoPink), minLines = 1, maxLines = 4, decorationBox = { innerTextField -> Box(modifier = Modifier.fillMaxWidth()) { if (message.isEmpty()) { Text( text = stringResource(CommonResR.string.orpheus_input_placeholder), style = ExtendedTheme.typography.body, color = ExtendedTheme.colors.textSecondary, ) } innerTextField() } }, ) } Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, ) { OrpheusActionButton( onClick = onPlusClick, iconPainter = painterResource(id = CommonUiR.drawable.plus), contentDescription = stringResource(CommonResR.string.options), ) OrpheusActionButton( onClick = onCustomModeClick, iconPainter = painterResource(id = CommonUiR.drawable.sliders), contentDescription = stringResource(CommonResR.string.orpheus_switch_to_custom), ) Spacer(modifier = Modifier.weight(1f)) OrpheusActionButton( onClick = onSendClick, iconPainter = painterResource(id = CommonUiR.drawable.arrow_up), contentDescription = stringResource(CommonResR.string.orpheus_send_message), colors = IconButtonDefaults.filledIconButtonColors( containerColor = HeaderLibraryOrange, contentColor = DarkTextPrimary, ), enabled = message.isNotBlank(), ) } } } @PreviewLightDark @Composable private fun ChatInputEmptyPreview() { SunoTheme { ChatInput( message = "", onInputChange = {}, onSendClick = {}, onCustomModeClick = {}, onPlusClick = {}, ) } } @PreviewLightDark @Composable private fun ChatInputSingleLinePreview() { SunoTheme { ChatInput( message = "Write me a song about summer", onInputChange = {}, onSendClick = {}, onPlusClick = {}, onCustomModeClick = {}, ) } } @PreviewLightDark @Composable private fun ChatInputMultilinePreview() { SunoTheme { ChatInput( message = "Write me a song about summer\n" + "with upbeat melodies and happy vibes\n" + "that makes people want to dance\n" + "and feel good about life", onInputChange = {}, onSendClick = {}, onPlusClick = {}, onCustomModeClick = {}, ) } }