From 938622ffcb29be8c653d941dfe94b38fc56d0cc6 Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Fri, 22 Nov 2024 18:18:17 +0100 Subject: [PATCH] DROID-3098 added menu for attachments --- .../ui/DiscussionScreen.kt | 88 ++++++++++++++++++- localization/src/main/res/values/strings.xml | 5 ++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/feature-discussions/src/main/java/com/anytypeio/anytype/feature_discussions/ui/DiscussionScreen.kt b/feature-discussions/src/main/java/com/anytypeio/anytype/feature_discussions/ui/DiscussionScreen.kt index 4140051309..0d2497f148 100644 --- a/feature-discussions/src/main/java/com/anytypeio/anytype/feature_discussions/ui/DiscussionScreen.kt +++ b/feature-discussions/src/main/java/com/anytypeio/anytype/feature_discussions/ui/DiscussionScreen.kt @@ -335,7 +335,9 @@ fun DiscussionScreen( } ChatBox( - modifier = Modifier.imePadding().navigationBarsPadding(), + modifier = Modifier + .imePadding() + .navigationBarsPadding(), chatBoxFocusRequester = chatBoxFocusRequester, textState = textState, onMessageSent = onMessageSent, @@ -499,6 +501,8 @@ private fun ChatBox( updateValue: (TextFieldValue) -> Unit ) { + var showDropdownMenu by remember { mutableStateOf(false) } + val scope = rememberCoroutineScope() val focus = LocalFocusManager.current @@ -560,7 +564,7 @@ private fun ChatBox( .clickable { scope.launch { focus.clearFocus(force = true) - onAttachClicked() + showDropdownMenu = true } } ) { @@ -571,6 +575,86 @@ private fun ChatBox( .align(Alignment.Center) .padding(horizontal = 4.dp, vertical = 4.dp) ) + MaterialTheme( + shapes = MaterialTheme.shapes.copy( + medium = RoundedCornerShape( + 12.dp + ) + ), + colors = MaterialTheme.colors.copy( + surface = colorResource(id = R.color.background_secondary) + ) + ) { + DropdownMenu( + offset = DpOffset(8.dp, 40.dp), + expanded = showDropdownMenu, + onDismissRequest = { + showDropdownMenu = false + }, + modifier = Modifier + .align(Alignment.BottomEnd) + .defaultMinSize( + minWidth = 252.dp + ) + ) { + DropdownMenuItem( + text = { + Text( + text = stringResource(R.string.chat_attachment_object), + color = colorResource(id = R.color.text_primary) + ) + }, + onClick = { + showDropdownMenu = false + } + ) + Divider( + paddingStart = 0.dp, + paddingEnd = 0.dp + ) + DropdownMenuItem( + text = { + Text( + text = stringResource(R.string.chat_attachment_media), + color = colorResource(id = R.color.text_primary) + ) + }, + onClick = { + showDropdownMenu = false + } + ) + Divider( + paddingStart = 0.dp, + paddingEnd = 0.dp + ) + DropdownMenuItem( + text = { + Text( + text = stringResource(R.string.chat_attachment_file), + color = colorResource(id = R.color.text_primary) + ) + }, + onClick = { + showDropdownMenu = false + } + ) + Divider( + paddingStart = 0.dp, + paddingEnd = 0.dp + ) + DropdownMenuItem( + text = { + Text( + text = stringResource(R.string.chat_attachment_upload), + color = colorResource(id = R.color.text_primary) + ) + }, + onClick = { + showDropdownMenu = false + } + ) + } + } } } } diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml index f8588da1e8..3327ca3d81 100644 --- a/localization/src/main/res/values/strings.xml +++ b/localization/src/main/res/values/strings.xml @@ -1823,4 +1823,9 @@ Please provide specific details of your needs here. There is no messages yet.\nBe the first to start a discussion. Write a message... + Object + File + Media + Upload + \ No newline at end of file