Adds scores to the notification cards

This commit is contained in:
Vitor Pamplona
2025-12-02 18:07:29 -05:00
parent 742fa14286
commit aa1aaeea38
2 changed files with 55 additions and 5 deletions
@@ -67,6 +67,7 @@ import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.NoteState import com.vitorpamplona.amethyst.model.NoteState
import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.User
import com.vitorpamplona.amethyst.service.CachedRichTextParser import com.vitorpamplona.amethyst.service.CachedRichTextParser
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsScore
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserPicture import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserPicture
import com.vitorpamplona.amethyst.ui.components.AnimatedBorderTextCornerRadius import com.vitorpamplona.amethyst.ui.components.AnimatedBorderTextCornerRadius
import com.vitorpamplona.amethyst.ui.components.CoreSecretMessage import com.vitorpamplona.amethyst.ui.components.CoreSecretMessage
@@ -626,6 +627,22 @@ fun WatchUserMetadataAndFollowsAndRenderUserProfilePicture(
} }
} }
} }
ObserveAndRenderBoxedUserCards(author, accountViewModel)
}
@Composable
fun ObserveAndRenderBoxedUserCards(
user: User,
accountViewModel: AccountViewModel,
) {
val score by observeUserContactCardsScore(user, accountViewModel)
score?.let {
Box(modifier = Size35Modifier, contentAlignment = Alignment.BottomCenter) {
ScoreTagSmall(it, Modifier)
}
}
} }
@Composable @Composable
@@ -58,7 +58,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.LoadUser
import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel
import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.Font10SP import com.vitorpamplona.amethyst.ui.theme.Font10SP
import com.vitorpamplona.amethyst.ui.theme.Font6SP import com.vitorpamplona.amethyst.ui.theme.Font8SP
import com.vitorpamplona.amethyst.ui.theme.SmallBorder import com.vitorpamplona.amethyst.ui.theme.SmallBorder
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.HexKey
@@ -507,20 +507,53 @@ fun ScoreTag(
score: Int, score: Int,
size: Dp, size: Dp,
modifier: Modifier, modifier: Modifier,
) {
if (size > 34.dp) {
ScoreTagRegular(score, modifier)
} else {
ScoreTagSmall(score, modifier)
}
}
@Composable
fun ScoreTagRegular(
score: Int,
modifier: Modifier,
) { ) {
Text( Text(
text = score.toString(), text = score.toString(),
color = Color.White, color = Color.White,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
fontSize = if (size > 34.dp) Font10SP else Font6SP, fontSize = Font10SP,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Clip, overflow = TextOverflow.Clip,
lineHeight = if (size > 34.dp) Font10SP else Font6SP, lineHeight = Font10SP,
modifier = modifier =
modifier modifier
.clip(SmallBorder) .clip(SmallBorder)
.background(Color.Black) .background(Color.Black)
.padding(horizontal = if (size > 34.dp) 4.dp else 3.dp, vertical = 0.dp), .padding(horizontal = 4.dp, vertical = 0.dp),
)
}
@Composable
fun ScoreTagSmall(
score: Int,
modifier: Modifier,
) {
Text(
text = score.toString(),
color = Color.White,
fontWeight = FontWeight.Bold,
fontSize = Font8SP,
maxLines = 1,
overflow = TextOverflow.Clip,
lineHeight = Font8SP,
modifier =
modifier
.clip(SmallBorder)
.background(Color.Black)
.padding(horizontal = 3.dp, vertical = 0.dp),
) )
} }
@@ -602,7 +635,7 @@ fun WatchUserFollows(
fun ObserveAndRenderUserCards( fun ObserveAndRenderUserCards(
user: User, user: User,
size: Dp, size: Dp,
modifier: Modifier, modifier: Modifier = Modifier,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
) { ) {
val score by observeUserContactCardsScore(user, accountViewModel) val score by observeUserContactCardsScore(user, accountViewModel)