feat: highlight if mention, fix avatar padding

Signed-off-by: Infi <wingit@geist.ga>
This commit is contained in:
Infi 2023-06-06 00:48:44 +02:00
parent f778a0502c
commit 8d143dffd1
1 changed files with 150 additions and 134 deletions

View File

@ -12,6 +12,7 @@ import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -145,6 +146,17 @@ fun Message(
Spacer(modifier = Modifier.height(10.dp)) Spacer(modifier = Modifier.height(10.dp))
} }
Column(
modifier = Modifier.then(
if (message.mentions?.contains(RevoltAPI.selfId) == true) {
Modifier.background(
MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
} else {
Modifier
}
)
) {
message.replies?.forEach { reply -> message.replies?.forEach { reply ->
val replyMessage = RevoltAPI.messageCache[reply] val replyMessage = RevoltAPI.messageCache[reply]
@ -179,12 +191,15 @@ fun Message(
.fillMaxWidth() .fillMaxWidth()
) { ) {
if (message.tail == false) { if (message.tail == false) {
Column {
Spacer(modifier = Modifier.height(4.dp))
UserAvatar( UserAvatar(
username = author.username ?: "", username = author.username ?: "",
userId = author.id ?: message.id ?: ULID.makeSpecial(0), userId = author.id ?: message.id ?: ULID.makeSpecial(0),
avatar = author.avatar, avatar = author.avatar,
rawUrl = message.masquerade?.avatar?.let { asJanuaryProxyUrl(it) } rawUrl = message.masquerade?.avatar?.let { asJanuaryProxyUrl(it) }
) )
}
} else { } else {
UserAvatarWidthPlaceholder() UserAvatarWidthPlaceholder()
} }
@ -306,3 +321,4 @@ fun Message(
} }
} }
} }
}