mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 16:47:40 +01:00
enhancement: highlight inbox unread items (#185)
This commit is contained in:
parent
e5f45222bb
commit
9938b80b6e
@ -23,6 +23,7 @@ object CornerSize {
|
||||
}
|
||||
|
||||
object IconSize {
|
||||
val xs = 10.dp
|
||||
val s = 20.dp
|
||||
val m = 26.dp
|
||||
val l = 30.dp
|
||||
|
@ -1,14 +1,21 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.components
|
||||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.FiberManualRecord
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PersonMentionModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||
@ -43,10 +50,24 @@ fun InboxCardHeader(
|
||||
append(mention.post.title)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(vertical = Spacing.xs, horizontal = Spacing.xs),
|
||||
text = header,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(end = Spacing.s),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(vertical = Spacing.xs, horizontal = Spacing.xs),
|
||||
text = header,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
if (!mention.read) {
|
||||
Icon(
|
||||
modifier = Modifier.size(IconSize.xs),
|
||||
imageVector = Icons.Filled.FiberManualRecord,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,18 @@ class InboxMentionsViewModel(
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
mentions = currentState.mentions.map { m ->
|
||||
if (m.id == mention.id) {
|
||||
m.copy(read = read)
|
||||
} else {
|
||||
m
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
updateUnreadItems()
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.FiberManualRecord
|
||||
import androidx.compose.material.icons.filled.MoreHoriz
|
||||
import androidx.compose.material.icons.filled.Schedule
|
||||
import androidx.compose.material3.Icon
|
||||
@ -49,6 +50,7 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
|
||||
internal fun ChatCard(
|
||||
user: UserModel?,
|
||||
autoLoadImages: Boolean = true,
|
||||
read: Boolean = true,
|
||||
lastMessage: String,
|
||||
lastMessageDate: String? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
@ -75,8 +77,6 @@ internal fun ChatCard(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(Spacing.m),
|
||||
) {
|
||||
|
||||
|
||||
if (creatorAvatar.isNotEmpty()) {
|
||||
CustomImage(
|
||||
modifier = Modifier
|
||||
@ -111,19 +111,33 @@ internal fun ChatCard(
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(Spacing.xxs)
|
||||
) {
|
||||
// user name
|
||||
Text(
|
||||
text = buildString {
|
||||
append(creatorName)
|
||||
if (creatorHost.isNotEmpty()) {
|
||||
append("@$creatorHost")
|
||||
}
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(end = Spacing.m),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// user name
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = buildString {
|
||||
append(creatorName)
|
||||
if (creatorHost.isNotEmpty()) {
|
||||
append("@$creatorHost")
|
||||
}
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
if (!read) {
|
||||
Icon(
|
||||
modifier = Modifier.size(IconSize.xs),
|
||||
imageVector = Icons.Filled.FiberManualRecord,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
ScaledContent {
|
||||
// last message text
|
||||
PostCardTitle(
|
||||
|
@ -114,13 +114,14 @@ class InboxMessagesScreen : Tab {
|
||||
items(
|
||||
items = uiState.chats,
|
||||
key = {
|
||||
it.id.toString() + it.updateDate + uiState.unreadOnly
|
||||
it.id.toString() + it.updateDate + it.read + uiState.unreadOnly
|
||||
},
|
||||
) { chat ->
|
||||
ChatCard(
|
||||
user = chat.otherUser(uiState.currentUserId),
|
||||
autoLoadImages = uiState.autoLoadImages,
|
||||
lastMessage = chat.content.orEmpty(),
|
||||
read = chat.read,
|
||||
lastMessageDate = chat.publishDate,
|
||||
onOpenUser = rememberCallbackArgs { user ->
|
||||
navigationCoordinator.pushScreen(
|
||||
|
@ -188,6 +188,18 @@ class InboxRepliesViewModel(
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
mvi.updateState {
|
||||
it.copy(
|
||||
replies = currentState.replies.map { r ->
|
||||
if (r.id == mention.id) {
|
||||
r.copy(read = read)
|
||||
} else {
|
||||
r
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
updateUnreadItems()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user