|
@@ -1,9 +1,9 @@
|
|
|
package io.nexilis.alpha.ui.main
|
|
|
|
|
|
+import Attachments
|
|
|
import android.text.format.DateUtils
|
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
import androidx.compose.foundation.background
|
|
|
-import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.combinedClickable
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
@@ -14,39 +14,27 @@ 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.AccessTime
|
|
|
-import androidx.compose.material.icons.filled.Add
|
|
|
-import androidx.compose.material.icons.filled.AttachFile
|
|
|
-import androidx.compose.material.icons.filled.Camera
|
|
|
import androidx.compose.material.icons.filled.Done
|
|
|
import androidx.compose.material.icons.filled.DoneAll
|
|
|
-import androidx.compose.material.icons.filled.Headset
|
|
|
-import androidx.compose.material.icons.filled.Image
|
|
|
-import androidx.compose.material.icons.filled.LocationOn
|
|
|
-import androidx.compose.material.icons.filled.Person
|
|
|
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.focus.FocusRequester
|
|
|
-import androidx.compose.ui.focus.focusRequester
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
|
import androidx.compose.ui.layout.onSizeChanged
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
-import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
import androidx.compose.ui.text.TextRange
|
|
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
|
|
import androidx.compose.ui.text.input.TextFieldValue
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
-import androidx.compose.ui.window.Popup
|
|
|
import androidx.hilt.navigation.compose.hiltViewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import io.nexilis.alpha.ui.viewmodel.MainViewModel
|
|
|
-import io.nexilis.service.core.DarkLimeGreen
|
|
|
-import io.nexilis.service.core.Orange
|
|
|
-import io.nexilis.service.core.Purple
|
|
|
+import io.nexilis.service.core.BlueSky
|
|
|
+import io.nexilis.service.core.WhiteTransparent
|
|
|
import io.nexilis.service.data.entities.Message
|
|
|
import io.nexilis.service.data.viewmodels.BuddyViewModel
|
|
|
import io.nexilis.service.data.viewmodels.MessageStatusViewModel
|
|
@@ -55,7 +43,6 @@ import io.nexilis.service.data.viewmodels.MessageViewModel
|
|
|
@OptIn(ExperimentalFoundationApi::class)
|
|
|
@Composable
|
|
|
fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewModel) {
|
|
|
- val focusRequester = remember { FocusRequester() }
|
|
|
var textInput by rememberSaveable(stateSaver = TextFieldValue.Saver) {
|
|
|
mutableStateOf(TextFieldValue("", TextRange(0, 7)))
|
|
|
}
|
|
@@ -144,7 +131,7 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
modifier = Modifier
|
|
|
.align(Alignment.Bottom)
|
|
|
.size(16.dp),
|
|
|
- tint = if (messageStatus?.status == 4) Color(0xFF0075F1) else Color.Gray
|
|
|
+ tint = if (messageStatus?.status == 4) Color.BlueSky else Color.Gray
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -199,7 +186,6 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
shape = CircleShape
|
|
|
clip = true
|
|
|
}
|
|
|
- .focusRequester(focusRequester)
|
|
|
.imePadding(),
|
|
|
value = textInput,
|
|
|
onValueChange = { textInput = it },
|
|
@@ -217,8 +203,7 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
clip = true
|
|
|
}
|
|
|
- .background(Color(0xEFFFFFFF)),
|
|
|
- focusRequester = focusRequester
|
|
|
+ .background(Color.WhiteTransparent)
|
|
|
)
|
|
|
},
|
|
|
trailingIcon = {
|
|
@@ -272,127 +257,3 @@ fun Chat(navController: NavHostController, pin: String, mainViewModel: MainViewM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-@OptIn(ExperimentalMaterial3Api::class)
|
|
|
-@Composable
|
|
|
-fun Attachments(modifier: Modifier, focusRequester: FocusRequester) {
|
|
|
- val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
- val positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider()
|
|
|
- var isOpenMenu by remember {
|
|
|
- mutableStateOf(false)
|
|
|
- }
|
|
|
- IconButton(onClick = {
|
|
|
- focusRequester.requestFocus()
|
|
|
- keyboardController?.hide()
|
|
|
- isOpenMenu = !isOpenMenu
|
|
|
- }
|
|
|
- ) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Add,
|
|
|
- contentDescription = "",
|
|
|
- tint = MaterialTheme.colorScheme.primary
|
|
|
- )
|
|
|
- }
|
|
|
- if (isOpenMenu) {
|
|
|
- Popup(popupPositionProvider = positionProvider, onDismissRequest = { isOpenMenu = false }) {
|
|
|
- Box(modifier = modifier) {
|
|
|
- Row(Modifier.align(Alignment.Center)) {
|
|
|
- Column {
|
|
|
- AttachmentButton(
|
|
|
- color = MaterialTheme.colorScheme.primary,
|
|
|
- onClick = {},
|
|
|
- text = {
|
|
|
- Text(text = "File", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.AttachFile,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(32.dp))
|
|
|
- AttachmentButton(color = Color.Orange, onClick = {}, text = {
|
|
|
- Text(text = "Audio", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Headset,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(16.dp))
|
|
|
- Column {
|
|
|
- AttachmentButton(color = Color.Red, onClick = {}, text = {
|
|
|
- Text(text = "Camera", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Camera,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(32.dp))
|
|
|
- AttachmentButton(color = Color.DarkLimeGreen, onClick = {}, text = {
|
|
|
- Text(text = "Location", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.LocationOn,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(16.dp))
|
|
|
- Column {
|
|
|
- AttachmentButton(color = Color.Purple, onClick = {}, text = {
|
|
|
- Text(text = "Gallery", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Image,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(32.dp))
|
|
|
- AttachmentButton(color = Color.Blue, onClick = {}, text = {
|
|
|
- Text(text = "Contact", style = MaterialTheme.typography.bodySmall)
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Person,
|
|
|
- contentDescription = "",
|
|
|
- tint = Color.White
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-@Composable
|
|
|
-fun AttachmentButton(
|
|
|
- color: Color = MaterialTheme.colorScheme.primary,
|
|
|
- onClick: () -> Unit,
|
|
|
- text: @Composable () -> Unit,
|
|
|
- content: @Composable () -> Unit
|
|
|
-) {
|
|
|
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .then(Modifier.size(72.dp))
|
|
|
- .graphicsLayer {
|
|
|
- shape = CircleShape
|
|
|
- clip = true
|
|
|
- }
|
|
|
- .clickable(onClick = onClick)
|
|
|
- .padding(0.dp)
|
|
|
- .background(color),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
- ) {
|
|
|
- content()
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.size(6.dp))
|
|
|
- text()
|
|
|
- }
|
|
|
-}
|