yayan 1 year ago
parent
commit
8f47a07617

+ 24 - 43
app/src/main/java/io/nexilis/alpha/ui/components/ContentChat.kt

@@ -19,6 +19,9 @@ import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.material3.Icon
 import androidx.compose.material3.IconButton
 import androidx.compose.material3.LinearProgressIndicator
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.ListItemColors
+import androidx.compose.material3.ListItemDefaults
 import androidx.compose.material3.MaterialTheme
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
@@ -102,52 +105,30 @@ fun ContentChat(modifier: Modifier = Modifier, message: Message) {
             }
         }
     } else if (message.file_id.isNotEmpty()) {
-        Column(
-            modifier = Modifier
-                .padding(2.dp)
-                .fillMaxWidth(0.65f)
-        ) {
-            Row(modifier = Modifier
-                .graphicsLayer {
-                    shape = RoundedCornerShape(12.dp)
-                    clip = true
-                }
-                .align(Alignment.CenterHorizontally)
-                .background(MaterialTheme.colorScheme.surface)
-                .padding(8.dp)
-            ) {
-                FileType(
-                    message = message, modifier = Modifier
-                        .align(Alignment.CenterVertically)
-                )
-                Column(
-                    modifier = Modifier
-                        .weight(1f)
-                ) {
-                    Text(
-                        text = message.message_text.split("|").first(),
-                        color = MaterialTheme.colorScheme.onSurface,
-                        style = MaterialTheme.typography.bodyMedium,
-                        maxLines = 2,
-                        overflow = TextOverflow.Ellipsis
-                    )
-                    FileDesc(file = message.file_id)
-                }
-                FileProgress(
-                    message = message,
-                    modifier = Modifier.align(Alignment.CenterVertically)
-                )
-            }
-            val messageText = message.message_text.split("|").last()
-            if (messageText.isNotEmpty()) {
+        ListItem(
+            headlineContent = {
                 Text(
-                    text = messageText,
-                    modifier = Modifier.padding(8.dp),
+                    text = message.message_text.split("|").first(),
                     color = MaterialTheme.colorScheme.onSurface,
                     style = MaterialTheme.typography.bodyMedium,
+                    maxLines = 2,
+                    overflow = TextOverflow.Ellipsis
                 )
-            }
-        }
+            },
+            modifier = Modifier.fillMaxWidth(0.76f),
+            supportingContent = {
+                FileDesc(file = message.file_id)
+            },
+            leadingContent = {
+                FileType(message = message)
+            },
+            trailingContent = {
+                FileProgress(message = message)
+            },
+            colors = ListItemDefaults.colors(
+                containerColor = Color.Transparent
+            )
+        )
     } else if (message.audio_id.isNotEmpty()) {
         Column(
             modifier = Modifier
@@ -229,7 +210,7 @@ fun ContentChat(modifier: Modifier = Modifier, message: Message) {
 }
 
 @Composable
-fun FileType(message: Message, modifier: Modifier) {
+fun FileType(message: Message, modifier: Modifier = Modifier) {
     val imageVector = when (message.file_id.extension) {
         "apk", "aab" -> ImageVector.vectorResource(id = R.drawable.ic_apk)
         "aac", "mp3", "m4a", "ogg" -> ImageVector.vectorResource(id = R.drawable.ic_audio)

+ 31 - 32
app/src/main/java/io/nexilis/alpha/ui/main/Chat.kt

@@ -36,19 +36,15 @@ fun Chat(
     val lazyPagingItems = flow.collectAsLazyPagingItems()
     val listState = rememberLazyListState()
     val scope = rememberCoroutineScope()
-    ConstraintLayout(
+    Column(
         modifier = Modifier
             .fillMaxSize()
             .imePadding()
 //            .imeNestedScroll()
     ) {
-        val (lazyColumn, fab, input) = createRefs()
         LazyColumn(
             modifier = Modifier
-                .fillMaxSize()
-                .constrainAs(lazyColumn) {
-                    bottom.linkTo(input.top)
-                },
+                .weight(1f),
             state = listState,
             reverseLayout = true
         ) {
@@ -88,37 +84,40 @@ fun Chat(
                 }
             }
         }
-        val showButton by remember {
-            derivedStateOf {
-                listState.firstVisibleItemIndex > 0
-            }
-        }
-        if (showButton) {
-            Button(
-                onClick = {
-                    scope.launch { listState.scrollToItem(0) }
-                },
-                modifier = Modifier
-                    .constrainAs(fab) {
-                        end.linkTo(parent.end)
-                        bottom.linkTo(input.top)
-                    }
-                    .padding(end = 6.dp, bottom = 6.dp)
-                    .size(32.dp),
-                shape = CircleShape,
-                contentPadding = PaddingValues(0.dp)
-            ) {
-                Icon(imageVector = Icons.Default.KeyboardArrowDown, contentDescription = "")
-            }
-        }
+//        ConstraintLayout {
+//                    val (fab, input) = createRefs()
+//            val showButton by remember {
+//                derivedStateOf {
+//                    listState.firstVisibleItemIndex > 0
+//                }
+//            }
+//            if (showButton) {
+//                Button(
+//                    onClick = {
+//                        scope.launch { listState.scrollToItem(0) }
+//                    },
+//                    modifier = Modifier
+//                        .constrainAs(fab) {
+//                            end.linkTo(parent.end)
+//                            bottom.linkTo(input.top)
+//                        }
+//                        .padding(end = 6.dp, bottom = 6.dp)
+//                        .size(32.dp),
+//                    shape = CircleShape,
+//                    contentPadding = PaddingValues(0.dp)
+//                ) {
+//                    Icon(imageVector = Icons.Default.KeyboardArrowDown, contentDescription = "")
+//                }
+//            }
         InputChat(
-            modifier = Modifier.constrainAs(input) {
-                bottom.linkTo(parent.bottom)
-            },
+//                modifier = Modifier.constrainAs(input) {
+//                    bottom.linkTo(parent.bottom)
+//                },
             navController = navController,
             pin = pin,
             me = me
         )
+//        }
     }
 }
 

+ 2 - 2
app/src/main/res/drawable/ic_apk.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_audio.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_excel.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
     <path

+ 2 - 2
app/src/main/res/drawable/ic_file.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
     <path

+ 2 - 2
app/src/main/res/drawable/ic_image.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_pdf.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_placeholder.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="400dp"
-    android:height="400dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <path

+ 2 - 2
app/src/main/res/drawable/ic_ppt.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_txt.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_video.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path

+ 2 - 2
app/src/main/res/drawable/ic_word.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
     <path

+ 2 - 2
app/src/main/res/drawable/ic_zip.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="200dp"
-    android:height="200dp"
+    android:width="72dp"
+    android:height="72dp"
     android:viewportWidth="512"
     android:viewportHeight="512">
   <path