feat: show bot owner in profile
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
fd45864974
commit
8b276aade3
|
|
@ -3,10 +3,12 @@ package chat.revolt.sheets
|
|||
import android.text.format.DateUtils
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
|
||||
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
|
||||
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
|
||||
|
|
@ -23,6 +25,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.res.painterResource
|
||||
|
|
@ -41,6 +44,7 @@ import chat.revolt.components.chat.RoleListEntry
|
|||
import chat.revolt.components.chat.UserBadgeList
|
||||
import chat.revolt.components.chat.UserBadgeRow
|
||||
import chat.revolt.components.generic.NonIdealState
|
||||
import chat.revolt.components.generic.UserAvatar
|
||||
import chat.revolt.components.markdown.RichMarkdown
|
||||
import chat.revolt.components.screens.settings.RawUserOverview
|
||||
import chat.revolt.components.screens.settings.UserButtons
|
||||
|
|
@ -241,6 +245,72 @@ fun UserInfoSheet(
|
|||
}
|
||||
}
|
||||
|
||||
if (user.bot != null) {
|
||||
val resolvedOwner = user.bot.owner?.let { RevoltAPI.userCache[it] }
|
||||
|
||||
item(key = "bot-owner") {
|
||||
SheetTile(
|
||||
header = {
|
||||
Text(stringResource(R.string.user_info_sheet_category_owner))
|
||||
},
|
||||
contentPreview = {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
resolvedOwner?.let {
|
||||
UserAvatar(
|
||||
username = it.displayName ?: it.username
|
||||
?: stringResource(R.string.unknown),
|
||||
avatar = it.avatar,
|
||||
userId = it.id!!,
|
||||
size = 32.dp
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = it.displayName ?: it.username
|
||||
?: stringResource(R.string.unknown),
|
||||
fontSize = 14.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
} ?: run {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_alert_decagram_24dp),
|
||||
contentDescription = null
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.unknown),
|
||||
fontSize = 14.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
resolvedOwner?.let {
|
||||
RawUserOverview(it, null, internalPadding = false)
|
||||
} ?: run {
|
||||
NonIdealState(
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_alert_decagram_24dp),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.user_info_sheet_owner_not_found)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile?.content.isNullOrBlank().not()) {
|
||||
item(key = "bio", span = StaggeredGridItemSpan.FullLine) {
|
||||
SheetTile(
|
||||
|
|
|
|||
|
|
@ -313,7 +313,8 @@
|
|||
<string name="user_info_sheet_category_joined">Joined</string>
|
||||
<string name="user_info_sheet_category_joined_revolt" translatable="false">Revolt</string>
|
||||
<string name="user_info_sheet_category_badges">Badges</string>
|
||||
<string name="user_info_sheet_category_bot">Bot</string>
|
||||
<string name="user_info_sheet_category_owner">Owner</string>
|
||||
<string name="user_info_sheet_owner_not_found">Could not fetch owner information</string>
|
||||
<string name="user_info_sheet_add_friend">Add Friend</string>
|
||||
<string name="user_info_sheet_send_message">Send Message</string>
|
||||
<string name="user_info_sheet_remove_friend">Remove Friend</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue