Skip to content

Commit

Permalink
DROID-2893 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uburoiubu committed Feb 13, 2025
1 parent 98d94b1 commit 2466684
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.core_models.Hash
import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.core_models.ObjectWrapper
import com.anytypeio.anytype.presentation.confgs.ChatConfig
import com.anytypeio.anytype.presentation.objects.ObjectIcon
import com.anytypeio.anytype.presentation.search.GlobalSearchItemView

Expand All @@ -28,6 +29,9 @@ sealed interface ChatView {
val reply: Reply? = null
) : ChatView {

val isMaxUserReactionCountReached: Boolean =
reactions.count { it.isSelected } >= ChatConfig.MAX_REACTION_COUNT

data class Content(val msg: String, val parts: List<Part>) {
data class Part(
val part: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fun Bubble(
attachments: List<ChatView.Message.Attachment> = emptyList(),
isUserAuthor: Boolean = false,
isEdited: Boolean = false,
isMaxUserReactionCountReached: Boolean = false,
reactions: List<ChatView.Message.Reaction> = emptyList(),
onReacted: (String) -> Unit,
onDeleteMessage: () -> Unit,
Expand Down Expand Up @@ -304,7 +305,8 @@ fun Bubble(
reactions = reactions,
onReacted = onReacted,
onViewReaction = onViewChatReaction,
onAddNewReaction = onAddReactionClicked
onAddNewReaction = onAddReactionClicked,
isMaxReactionCountReached = isMaxUserReactionCountReached
)
}
MaterialTheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ fun Messages(
timestamp = msg.timestamp,
attachments = msg.attachments,
isUserAuthor = msg.isUserAuthor,
isMaxUserReactionCountReached = msg.isMaxUserReactionCountReached,
isEdited = msg.isEdited,
onReacted = { emoji ->
onReacted(msg.id, emoji)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.anytypeio.anytype.feature_chats.ui

import android.content.res.Configuration
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand All @@ -24,7 +23,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.anytypeio.anytype.core_ui.common.DefaultPreviews
import com.anytypeio.anytype.core_ui.views.BodyCalloutMedium
Expand All @@ -38,7 +36,8 @@ fun ReactionList(
reactions: List<ChatView.Message.Reaction>,
onReacted: (String) -> Unit,
onViewReaction: (String) -> Unit,
onAddNewReaction: () -> Unit
onAddNewReaction: () -> Unit,
isMaxReactionCountReached: Boolean = false,
) {
FlowRow(
modifier = Modifier.padding(start = 12.dp, end = 12.dp, bottom = 12.dp, top = 4.dp),
Expand Down Expand Up @@ -102,20 +101,22 @@ fun ReactionList(
)
}
}
Box(
modifier = Modifier
.padding(end = 8.dp)
.size(28.dp)
.clip(CircleShape)
.clickable {
onAddNewReaction()
}
) {
Image(
painter = painterResource(R.drawable.ic_add_reaction),
contentDescription = null,
modifier = Modifier.align(Alignment.Center)
)
if (!isMaxReactionCountReached) {
Box(
modifier = Modifier
.padding(end = 8.dp)
.size(28.dp)
.clip(CircleShape)
.clickable {
onAddNewReaction()
}
) {
Image(
painter = painterResource(R.drawable.ic_add_reaction),
contentDescription = null,
modifier = Modifier.align(Alignment.Center)
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.presentation.BuildConfig

object ChatConfig {

const val MAX_ATTACHMENT_COUNT = 10
const val MAX_REACTION_COUNT = 3

/**
* Spaces for beta-testing space-level chats
Expand Down

0 comments on commit 2466684

Please sign in to comment.