|
@@ -1,5 +1,6 @@
|
|
|
package io.nexilis.alpha.ui.main
|
|
|
|
|
|
+import android.text.format.DateUtils
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
@@ -10,13 +11,17 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.automirrored.filled.Send
|
|
|
import androidx.compose.material.icons.filled.Add
|
|
|
+import androidx.compose.material.icons.filled.DoneAll
|
|
|
import androidx.compose.material3.*
|
|
|
import androidx.compose.runtime.*
|
|
|
import androidx.compose.runtime.livedata.observeAsState
|
|
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.graphics.Shape
|
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.text.TextRange
|
|
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
|
|
import androidx.compose.ui.text.input.TextFieldValue
|
|
@@ -66,10 +71,7 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
) {
|
|
|
if (message?.f_pin == me?.f_pin) {
|
|
|
Spacer(modifier = Modifier.weight(0.2f))
|
|
|
- Text(
|
|
|
- text = list?.get(it)?.message_text ?: "",
|
|
|
- color = MaterialTheme.colorScheme.onPrimary,
|
|
|
- style = MaterialTheme.typography.bodyMedium,
|
|
|
+ Row(
|
|
|
modifier = Modifier
|
|
|
.graphicsLayer {
|
|
|
shadowElevation = 2.dp.toPx()
|
|
@@ -77,14 +79,44 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
clip = true
|
|
|
}
|
|
|
.weight(weight = 0.8f, fill = false)
|
|
|
- .background(color = MaterialTheme.colorScheme.primary)
|
|
|
+ .background(color = MaterialTheme.colorScheme.primaryContainer)
|
|
|
.padding(8.dp)
|
|
|
- )
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ modifier = Modifier.padding(
|
|
|
+ PaddingValues(
|
|
|
+ start = 6.dp,
|
|
|
+ top = 6.dp,
|
|
|
+ end = 12.dp,
|
|
|
+ bottom = 6.dp
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ text = list?.get(it)?.message_text ?: "",
|
|
|
+ color = MaterialTheme.colorScheme.onPrimaryContainer,
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ modifier = Modifier.align(Alignment.Bottom),
|
|
|
+ text = DateUtils.formatDateTime(
|
|
|
+ LocalContext.current,
|
|
|
+ list?.get(it)?.server_date ?: 0,
|
|
|
+ DateUtils.FORMAT_SHOW_TIME
|
|
|
+ ),
|
|
|
+ color = MaterialTheme.colorScheme.onPrimaryContainer,
|
|
|
+ style = MaterialTheme.typography.bodySmall,
|
|
|
+ )
|
|
|
+ Spacer(modifier = Modifier.width(6.dp))
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Default.DoneAll,
|
|
|
+ contentDescription = "",
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.Bottom)
|
|
|
+ .size(16.dp),
|
|
|
+ tint = Color(0xFF0075F1)
|
|
|
+ )
|
|
|
+ }
|
|
|
} else {
|
|
|
- Text(
|
|
|
- text = list?.get(it)?.message_text ?: "",
|
|
|
- color = MaterialTheme.colorScheme.onSurface,
|
|
|
- style = MaterialTheme.typography.bodyMedium,
|
|
|
+ Row(
|
|
|
modifier = Modifier
|
|
|
.graphicsLayer {
|
|
|
shadowElevation = 2.dp.toPx()
|
|
@@ -94,7 +126,31 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
.weight(weight = 0.8f, fill = false)
|
|
|
.background(color = MaterialTheme.colorScheme.surface)
|
|
|
.padding(8.dp)
|
|
|
- )
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ modifier = Modifier.padding(
|
|
|
+ PaddingValues(
|
|
|
+ start = 6.dp,
|
|
|
+ top = 6.dp,
|
|
|
+ end = 12.dp,
|
|
|
+ bottom = 6.dp
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ text = list?.get(it)?.message_text ?: "",
|
|
|
+ color = MaterialTheme.colorScheme.onSurface,
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ modifier = Modifier.align(Alignment.Bottom),
|
|
|
+ text = DateUtils.formatDateTime(
|
|
|
+ LocalContext.current,
|
|
|
+ list?.get(it)?.server_date ?: 0,
|
|
|
+ DateUtils.FORMAT_SHOW_TIME
|
|
|
+ ),
|
|
|
+ color = MaterialTheme.colorScheme.onSurface,
|
|
|
+ style = MaterialTheme.typography.bodySmall,
|
|
|
+ )
|
|
|
+ }
|
|
|
Spacer(modifier = Modifier.weight(0.2f))
|
|
|
}
|
|
|
}
|