android, desktop: chat tags (#5396)

* types and api

* remaining api

* icons for tags (named label due to name conflict)

* icon fix

* wup

* desktop handlers to open list

* updates

* filtering

* progress

* wip dump

* icons

* preset updates

* unread

* + button in tags view

* drag n drop helpers

* chats reorder

* tag chat after list creation (when chat provided)

* updates on unread tags

* initial emoji picker

* fixes and tweaks

* reoder color

* clickable shapes

* paddings

* reachable form

* one hand for tags

* ui tweaks

* input for emojis desktop

* wrap chat tags in desktop

* handling longer texts

* fixed a couple of issues in updates of unread tags

* reset search text on active filter change

* fix multi row alignment

* fix modal paddings

* fix single emoji picker for skin colors

* dependency corrected

* icon, refactor, back action to exit edit mode

* different icon params to make it larger

* refactor

* refactor

* rename

* rename

* refactor

* refactor

* padding

* unread counter size

---------

Co-authored-by: Avently <7953703+avently@users.noreply.github.com>
Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Diogo
2024-12-25 11:35:48 +00:00
committed by GitHub
parent 32773c1d6e
commit 84a45cedbe
19 changed files with 1501 additions and 32 deletions
@@ -0,0 +1,81 @@
package chat.simplex.common.views.chatlist
import SectionItemView
import android.view.ViewGroup
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.emoji2.emojipicker.EmojiPickerView
import chat.simplex.common.model.ChatController.appPrefs
import chat.simplex.common.ui.theme.DEFAULT_PADDING_HALF
import chat.simplex.common.views.chat.topPaddingToContent
import chat.simplex.common.views.helpers.*
import chat.simplex.res.MR
import dev.icerock.moko.resources.compose.painterResource
@Composable
actual fun ChatTagInput(name: MutableState<String>, showError: State<Boolean>, emoji: MutableState<String?>) {
SectionItemView(padding = PaddingValues(horizontal = DEFAULT_PADDING_HALF)) {
Box(Modifier
.clip(shape = CircleShape)
.clickable {
ModalManager.start.showModalCloseable { close ->
EmojiPicker(close = {
close()
emoji.value = it
})
}
}
.padding(4.dp)
) {
val emojiValue = emoji.value
if (emojiValue != null) {
Text(emojiValue)
} else {
Icon(
painter = painterResource(MR.images.ic_add_reaction),
contentDescription = null,
tint = MaterialTheme.colors.secondary
)
}
}
Spacer(Modifier.width(8.dp))
TagListNameTextField(name, showError = showError)
}
}
@Composable
private fun EmojiPicker(close: (String?) -> Unit) {
val oneHandUI = remember { appPrefs.oneHandUI.state }
val topPaddingToContent = topPaddingToContent(false)
Column (
modifier = Modifier.fillMaxSize().navigationBarsPadding().padding(
start = DEFAULT_PADDING_HALF,
end = DEFAULT_PADDING_HALF,
top = if (oneHandUI.value) WindowInsets.statusBars.asPaddingValues().calculateTopPadding() else topPaddingToContent,
bottom = if (oneHandUI.value) WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + AppBarHeight * fontSizeSqrtMultiplier else 0.dp
),
) {
AndroidView(
factory = { context ->
EmojiPickerView(context).apply {
emojiGridColumns = 10
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
setOnEmojiPickedListener { pickedEmoji ->
close(pickedEmoji.emoji)
}
}
}
)
}
}