mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3223 Space-level chat | Fix | Attachment number (#1987)
This commit is contained in:
parent
210b7e70a3
commit
e0675d5d1d
2 changed files with 80 additions and 68 deletions
|
@ -87,4 +87,8 @@ sealed interface DiscussionView {
|
|||
data class Image(val hash: Hash): Avatar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object ChatConfig {
|
||||
const val MAX_ATTACHMENT_COUNT = 10
|
||||
}
|
|
@ -143,6 +143,7 @@ import com.anytypeio.anytype.core_utils.const.DateConst.TIME_H24
|
|||
import com.anytypeio.anytype.core_utils.ext.formatTimeInMillis
|
||||
import com.anytypeio.anytype.core_utils.ext.parseImagePath
|
||||
import com.anytypeio.anytype.feature_discussions.R
|
||||
import com.anytypeio.anytype.feature_discussions.presentation.ChatConfig
|
||||
import com.anytypeio.anytype.feature_discussions.presentation.DiscussionView
|
||||
import com.anytypeio.anytype.feature_discussions.presentation.DiscussionViewModel
|
||||
import com.anytypeio.anytype.feature_discussions.presentation.DiscussionViewModel.ChatBoxMode
|
||||
|
@ -522,12 +523,17 @@ private fun ChatBox(
|
|||
onChatBoxMediaPicked: (List<Uri>) -> Unit,
|
||||
onChatBoxFilePicked: (List<Uri>) -> Unit,
|
||||
) {
|
||||
val uploadMediaLauncher = rememberLauncherForActivityResult(ActivityResultContracts.PickMultipleVisualMedia()) {
|
||||
|
||||
val uploadMediaLauncher = rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.PickMultipleVisualMedia(maxItems = ChatConfig.MAX_ATTACHMENT_COUNT)
|
||||
) {
|
||||
onChatBoxMediaPicked(it)
|
||||
}
|
||||
|
||||
val uploadFileLauncher = rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) {
|
||||
onChatBoxFilePicked(it)
|
||||
val uploadFileLauncher = rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.OpenMultipleDocuments()
|
||||
) { uris ->
|
||||
onChatBoxFilePicked(uris.take(ChatConfig.MAX_ATTACHMENT_COUNT))
|
||||
}
|
||||
|
||||
var showDropdownMenu by remember { mutableStateOf(false) }
|
||||
|
@ -763,76 +769,78 @@ 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
|
||||
if (attachments.size < ChatConfig.MAX_ATTACHMENT_COUNT) {
|
||||
MaterialTheme(
|
||||
shapes = MaterialTheme.shapes.copy(
|
||||
medium = RoundedCornerShape(
|
||||
12.dp
|
||||
)
|
||||
),
|
||||
colors = MaterialTheme.colors.copy(
|
||||
surface = colorResource(id = R.color.background_secondary)
|
||||
)
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = stringResource(R.string.chat_attachment_object),
|
||||
color = colorResource(id = R.color.text_primary)
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
DropdownMenu(
|
||||
offset = DpOffset(8.dp, 40.dp),
|
||||
expanded = showDropdownMenu,
|
||||
onDismissRequest = {
|
||||
showDropdownMenu = false
|
||||
onAttachObjectClicked()
|
||||
}
|
||||
)
|
||||
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
|
||||
uploadMediaLauncher.launch(
|
||||
PickVisualMediaRequest(mediaType = ActivityResultContracts.PickVisualMedia.ImageOnly)
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.defaultMinSize(
|
||||
minWidth = 252.dp
|
||||
)
|
||||
}
|
||||
)
|
||||
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
|
||||
uploadFileLauncher.launch(
|
||||
arrayOf("*/*")
|
||||
)
|
||||
}
|
||||
)
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = stringResource(R.string.chat_attachment_object),
|
||||
color = colorResource(id = R.color.text_primary)
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
showDropdownMenu = false
|
||||
onAttachObjectClicked()
|
||||
}
|
||||
)
|
||||
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
|
||||
uploadMediaLauncher.launch(
|
||||
PickVisualMediaRequest(mediaType = ActivityResultContracts.PickVisualMedia.ImageOnly)
|
||||
)
|
||||
}
|
||||
)
|
||||
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
|
||||
uploadFileLauncher.launch(
|
||||
arrayOf("*/*")
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue