improvements
This commit is contained in:
-1
@@ -9,7 +9,6 @@ import android.util.Log
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.text.StringAnnotation
|
|
||||||
import androidx.compose.ui.text.TextRange
|
import androidx.compose.ui.text.TextRange
|
||||||
import androidx.compose.ui.text.buildAnnotatedString
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
|
|||||||
+2
-2
@@ -80,6 +80,8 @@ fun MessagesHistoryInputBar(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val theme = LocalThemeConfig.current
|
val theme = LocalThemeConfig.current
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -130,7 +132,6 @@ fun MessagesHistoryInputBar(
|
|||||||
Spacer(modifier = Modifier.width(6.dp))
|
Spacer(modifier = Modifier.width(6.dp))
|
||||||
|
|
||||||
if (showEmojiButton) {
|
if (showEmojiButton) {
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val rotation = remember { Animatable(0f) }
|
val rotation = remember { Animatable(0f) }
|
||||||
|
|
||||||
Column(verticalArrangement = Arrangement.Bottom) {
|
Column(verticalArrangement = Arrangement.Bottom) {
|
||||||
@@ -239,7 +240,6 @@ fun MessagesHistoryInputBar(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val attachmentRotation = remember { Animatable(0f) }
|
val attachmentRotation = remember { Animatable(0f) }
|
||||||
|
|
||||||
Column(verticalArrangement = Arrangement.Bottom) {
|
Column(verticalArrangement = Arrangement.Bottom) {
|
||||||
|
|||||||
+1
@@ -50,6 +50,7 @@ fun MessagesHistoryRoute(
|
|||||||
screenState = screenState,
|
screenState = screenState,
|
||||||
messages = messages.toImmutableList(),
|
messages = messages.toImmutableList(),
|
||||||
uiMessages = uiMessages.toImmutableList(),
|
uiMessages = uiMessages.toImmutableList(),
|
||||||
|
isSelectedAtLeastOne = selectedMessages.isNotEmpty(),
|
||||||
scrollIndex = scrollIndex,
|
scrollIndex = scrollIndex,
|
||||||
selectedMessages = selectedMessages.toImmutableList(),
|
selectedMessages = selectedMessages.toImmutableList(),
|
||||||
baseError = baseError,
|
baseError = baseError,
|
||||||
|
|||||||
+6
-1
@@ -26,6 +26,7 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.rememberUpdatedState
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -61,6 +62,7 @@ fun MessagesHistoryScreen(
|
|||||||
screenState: MessagesHistoryScreenState = MessagesHistoryScreenState.EMPTY,
|
screenState: MessagesHistoryScreenState = MessagesHistoryScreenState.EMPTY,
|
||||||
messages: ImmutableList<VkMessage> = emptyImmutableList(),
|
messages: ImmutableList<VkMessage> = emptyImmutableList(),
|
||||||
uiMessages: ImmutableList<UiItem> = emptyImmutableList(),
|
uiMessages: ImmutableList<UiItem> = emptyImmutableList(),
|
||||||
|
isSelectedAtLeastOne: Boolean = false,
|
||||||
scrollIndex: Int? = null,
|
scrollIndex: Int? = null,
|
||||||
selectedMessages: ImmutableList<VkMessage> = emptyImmutableList(),
|
selectedMessages: ImmutableList<VkMessage> = emptyImmutableList(),
|
||||||
baseError: BaseError? = null,
|
baseError: BaseError? = null,
|
||||||
@@ -95,6 +97,8 @@ fun MessagesHistoryScreen(
|
|||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
val hazeState = remember { HazeState(true) }
|
val hazeState = remember { HazeState(true) }
|
||||||
|
|
||||||
|
val currentOnMessageClicked by rememberUpdatedState(onMessageClicked)
|
||||||
|
|
||||||
LaunchedEffect(scrollIndex) {
|
LaunchedEffect(scrollIndex) {
|
||||||
if (scrollIndex != null) {
|
if (scrollIndex != null) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
@@ -206,6 +210,7 @@ fun MessagesHistoryScreen(
|
|||||||
listState = listState,
|
listState = listState,
|
||||||
hasPinnedMessage = pinnedMessage != null,
|
hasPinnedMessage = pinnedMessage != null,
|
||||||
uiMessages = uiMessages,
|
uiMessages = uiMessages,
|
||||||
|
isSelectedAtLeastOne = isSelectedAtLeastOne,
|
||||||
isPaginating = screenState.isPaginating,
|
isPaginating = screenState.isPaginating,
|
||||||
messageBarHeight = messageBarHeight,
|
messageBarHeight = messageBarHeight,
|
||||||
onRequestScrollToCmId = { cmId ->
|
onRequestScrollToCmId = { cmId ->
|
||||||
@@ -224,7 +229,7 @@ fun MessagesHistoryScreen(
|
|||||||
view.performHapticFeedback(HapticFeedbackConstantsCompat.CONTEXT_CLICK)
|
view.performHapticFeedback(HapticFeedbackConstantsCompat.CONTEXT_CLICK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMessageClicked(id)
|
currentOnMessageClicked.invoke(id)
|
||||||
},
|
},
|
||||||
onMessageLongClicked = onMessageLongClicked
|
onMessageLongClicked = onMessageLongClicked
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-10
@@ -1,7 +1,6 @@
|
|||||||
package dev.meloda.fast.messageshistory.presentation
|
package dev.meloda.fast.messageshistory.presentation
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
@@ -23,7 +22,6 @@ import androidx.compose.material3.CircularProgressIndicator
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@@ -33,17 +31,17 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.net.toUri
|
||||||
import dev.chrisbanes.haze.HazeState
|
import dev.chrisbanes.haze.HazeState
|
||||||
import dev.chrisbanes.haze.hazeSource
|
import dev.chrisbanes.haze.hazeSource
|
||||||
import dev.meloda.fast.datastore.AppSettings
|
import dev.meloda.fast.datastore.AppSettings
|
||||||
import dev.meloda.fast.messageshistory.model.UiItem
|
import dev.meloda.fast.messageshistory.model.UiItem
|
||||||
import dev.meloda.fast.model.api.domain.VkAttachment
|
import dev.meloda.fast.model.api.domain.VkAttachment
|
||||||
|
import dev.meloda.fast.model.api.domain.VkFileDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkLinkDomain
|
import dev.meloda.fast.model.api.domain.VkLinkDomain
|
||||||
import dev.meloda.fast.model.api.domain.VkPhotoDomain
|
import dev.meloda.fast.model.api.domain.VkPhotoDomain
|
||||||
import dev.meloda.fast.ui.theme.LocalThemeConfig
|
import dev.meloda.fast.ui.theme.LocalThemeConfig
|
||||||
import dev.meloda.fast.ui.util.ImmutableList
|
import dev.meloda.fast.ui.util.ImmutableList
|
||||||
import androidx.core.net.toUri
|
|
||||||
import dev.meloda.fast.model.api.domain.VkFileDomain
|
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -53,6 +51,7 @@ fun MessagesList(
|
|||||||
hazeState: HazeState,
|
hazeState: HazeState,
|
||||||
listState: LazyListState,
|
listState: LazyListState,
|
||||||
uiMessages: ImmutableList<UiItem>,
|
uiMessages: ImmutableList<UiItem>,
|
||||||
|
isSelectedAtLeastOne: Boolean,
|
||||||
isPaginating: Boolean,
|
isPaginating: Boolean,
|
||||||
messageBarHeight: Dp,
|
messageBarHeight: Dp,
|
||||||
onRequestScrollToCmId: (cmId: Long) -> Unit = {},
|
onRequestScrollToCmId: (cmId: Long) -> Unit = {},
|
||||||
@@ -63,12 +62,6 @@ fun MessagesList(
|
|||||||
val theme = LocalThemeConfig.current
|
val theme = LocalThemeConfig.current
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
|
|
||||||
val isSelectedAtLeastOne by remember(uiMessages) {
|
|
||||||
derivedStateOf {
|
|
||||||
uiMessages.values.any { (it as? UiItem.Message)?.isSelected == true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val onAttachmentClick = remember {
|
val onAttachmentClick = remember {
|
||||||
{ message: UiItem.Message, attachment: VkAttachment ->
|
{ message: UiItem.Message, attachment: VkAttachment ->
|
||||||
if (isSelectedAtLeastOne) {
|
if (isSelectedAtLeastOne) {
|
||||||
|
|||||||
Reference in New Issue
Block a user