add send button
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:autoMirrored="true">
|
||||||
|
<path
|
||||||
|
android:fillColor="#fff"
|
||||||
|
android:pathData="M120,800L120,160L880,480L120,800ZM200,680L674,480L200,280L200,420L440,480L200,540L200,680ZM200,680L200,480L200,280L200,420L200,420L200,540L200,540L200,680Z"/>
|
||||||
|
</vector>
|
||||||
+15
-1
@@ -5,10 +5,12 @@ import androiddev.feature.chat.chat_client.generated.resources.chat_input_placeh
|
|||||||
import androiddev.feature.chat.chat_client.generated.resources.chat_load_error
|
import androiddev.feature.chat.chat_client.generated.resources.chat_load_error
|
||||||
import androiddev.feature.chat.chat_client.generated.resources.chat_ok
|
import androiddev.feature.chat.chat_client.generated.resources.chat_ok
|
||||||
import androiddev.feature.chat.chat_client.generated.resources.chat_retry_button
|
import androiddev.feature.chat.chat_client.generated.resources.chat_retry_button
|
||||||
|
import androiddev.feature.chat.chat_client.generated.resources.send
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.calculateEndPadding
|
import androidx.compose.foundation.layout.calculateEndPadding
|
||||||
import androidx.compose.foundation.layout.calculateStartPadding
|
import androidx.compose.foundation.layout.calculateStartPadding
|
||||||
@@ -26,6 +28,8 @@ import androidx.compose.foundation.text.selection.SelectionContainer
|
|||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.LinearProgressIndicator
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
@@ -56,6 +60,7 @@ import androidx.compose.ui.text.style.TextDecoration
|
|||||||
import androidx.compose.ui.text.withLink
|
import androidx.compose.ui.text.withLink
|
||||||
import androidx.compose.ui.unit.LayoutDirection
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import org.jetbrains.compose.resources.painterResource
|
||||||
import org.jetbrains.compose.resources.stringResource
|
import org.jetbrains.compose.resources.stringResource
|
||||||
import ru.shadowsparky.chat.domain.ChatRoles
|
import ru.shadowsparky.chat.domain.ChatRoles
|
||||||
import ru.shadowsparky.chat.domain.Message
|
import ru.shadowsparky.chat.domain.Message
|
||||||
@@ -172,10 +177,12 @@ private fun ChatContent(
|
|||||||
if (state.isSending) {
|
if (state.isSending) {
|
||||||
LinearProgressIndicator(Modifier.fillMaxWidth())
|
LinearProgressIndicator(Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
|
Spacer(Modifier.height(4.dp))
|
||||||
|
Row {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = textInput,
|
value = textInput,
|
||||||
onValueChange = { textInput = it },
|
onValueChange = { textInput = it },
|
||||||
modifier = Modifier.focusRequester(textFieldFocusRequester).resetFocusOnUpEvent(listFocusRequester).fillMaxWidth(),
|
modifier = Modifier.focusRequester(textFieldFocusRequester).resetFocusOnUpEvent(listFocusRequester).weight(1f),
|
||||||
shape = RoundedCornerShape(24.dp),
|
shape = RoundedCornerShape(24.dp),
|
||||||
placeholder = { Text(stringResource(Res.string.chat_input_placeholder)) },
|
placeholder = { Text(stringResource(Res.string.chat_input_placeholder)) },
|
||||||
enabled = !state.isSending,
|
enabled = !state.isSending,
|
||||||
@@ -186,6 +193,13 @@ private fun ChatContent(
|
|||||||
),
|
),
|
||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done)
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done)
|
||||||
)
|
)
|
||||||
|
IconButton(
|
||||||
|
onClick = { onSendMessage(textInput) },
|
||||||
|
enabled = !state.isSending
|
||||||
|
) {
|
||||||
|
Icon(painterResource(Res.drawable.send), contentDescription = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LaunchedEffect(null) {
|
LaunchedEffect(null) {
|
||||||
withFrameNanos {}
|
withFrameNanos {}
|
||||||
|
|||||||
Reference in New Issue
Block a user