|
@@ -4,13 +4,19 @@ import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.background
|
|
|
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.layout.size
|
|
|
+import androidx.compose.foundation.layout.width
|
|
|
+import androidx.compose.foundation.layout.widthIn
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
|
|
import androidx.compose.material.icons.filled.Headset
|
|
|
import androidx.compose.material3.Icon
|
|
|
+import androidx.compose.material3.LinearProgressIndicator
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
@@ -20,6 +26,7 @@ import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
+import androidx.compose.ui.text.style.TextOverflow
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.core.content.FileProvider
|
|
|
import coil.compose.rememberAsyncImagePainter
|
|
@@ -32,7 +39,7 @@ import io.nexilis.service.data.entities.Message
|
|
|
fun ContentChat(message: Message) {
|
|
|
val context = LocalContext.current
|
|
|
if (message.image_id.isNotEmpty()) {
|
|
|
- Column(modifier = Modifier.padding(3.dp)) {
|
|
|
+ Column(modifier = Modifier.padding(2.dp)) {
|
|
|
val file = context.getFileStreamPath(message.image_id)
|
|
|
val uri = FileProvider.getUriForFile(
|
|
|
context, BuildConfig.APPLICATION_ID + ".provider", file
|
|
@@ -57,7 +64,11 @@ fun ContentChat(message: Message) {
|
|
|
}
|
|
|
}
|
|
|
} else if (message.file_id.isNotEmpty()) {
|
|
|
- Column(modifier = Modifier.padding(3.dp)) {
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(2.dp)
|
|
|
+ .widthIn(max = 210.dp)
|
|
|
+ ) {
|
|
|
Row(modifier = Modifier
|
|
|
.graphicsLayer {
|
|
|
shape = RoundedCornerShape(12.dp)
|
|
@@ -66,8 +77,9 @@ fun ContentChat(message: Message) {
|
|
|
.background(MaterialTheme.colorScheme.surfaceContainerHigh)) {
|
|
|
Icon(
|
|
|
modifier = Modifier
|
|
|
- .size(40.dp)
|
|
|
- .padding(start = 8.dp, top = 8.dp),
|
|
|
+ .size(48.dp)
|
|
|
+ .padding(start = 8.dp)
|
|
|
+ .align(Alignment.CenterVertically),
|
|
|
imageVector = Icons.AutoMirrored.Filled.InsertDriveFile,
|
|
|
contentDescription = null,
|
|
|
tint = Color.DarkLimeGreen
|
|
@@ -90,30 +102,61 @@ fun ContentChat(message: Message) {
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
- val messageText = message.message_text
|
|
|
+ val messageText = message.message_text.split("|").last()
|
|
|
if (messageText.isNotEmpty()) {
|
|
|
Text(
|
|
|
modifier = Modifier.padding(8.dp),
|
|
|
- text = message.message_text.split("|").last(),
|
|
|
+ text = messageText,
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
} else if (message.audio_id.isNotEmpty()) {
|
|
|
- Column(modifier = Modifier.padding(3.dp)) {
|
|
|
- Icon(
|
|
|
- modifier = Modifier
|
|
|
- .size(56.dp)
|
|
|
- .padding(top = 5.dp)
|
|
|
- .align(Alignment.Start),
|
|
|
- imageVector = Icons.Default.Headset,
|
|
|
- contentDescription = null,
|
|
|
- tint = Color.Orange
|
|
|
- )
|
|
|
- if (message.message_text.isNotEmpty()) {
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(2.dp)
|
|
|
+ .widthIn(max = 210.dp)
|
|
|
+ ) {
|
|
|
+ Row(modifier = Modifier
|
|
|
+ .graphicsLayer {
|
|
|
+ shape = RoundedCornerShape(12.dp)
|
|
|
+ clip = true
|
|
|
+ }
|
|
|
+ .background(MaterialTheme.colorScheme.surfaceContainerHigh)) {
|
|
|
+ Icon(
|
|
|
+ modifier = Modifier
|
|
|
+ .size(48.dp)
|
|
|
+ .padding(start = 8.dp)
|
|
|
+ .align(Alignment.CenterVertically),
|
|
|
+ imageVector = Icons.Default.Headset,
|
|
|
+ contentDescription = null,
|
|
|
+ tint = Color.Orange
|
|
|
+ )
|
|
|
+ Column(
|
|
|
+ modifier = Modifier.padding(
|
|
|
+ start = 4.dp,
|
|
|
+ top = 8.dp,
|
|
|
+ end = 8.dp,
|
|
|
+ bottom = 8.dp
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ LinearProgressIndicator(
|
|
|
+ progress = { 50f },
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ text = message.message_text.split("|").first(),
|
|
|
+ style = MaterialTheme.typography.labelSmall,
|
|
|
+ maxLines = 1,
|
|
|
+ overflow = TextOverflow.Ellipsis
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val messageText = message.message_text.split("|").last()
|
|
|
+ if (messageText.isNotEmpty()) {
|
|
|
Text(
|
|
|
modifier = Modifier.padding(8.dp),
|
|
|
- text = message.message_text.split("|").first(),
|
|
|
+ text = messageText,
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
)
|
|
|
}
|