This commit is contained in:
Alex Yong 2025-09-30 10:57:15 -04:00 committed by GitHub
commit 5c0c4e26e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 52 additions and 5 deletions

View File

@ -64,10 +64,20 @@ fun ChannelHeader(
}
channel.channelType?.let {
ChannelIcon(
channelType = it,
modifier = Modifier.alpha(0.6f)
)
when (it) {
ChannelType.TextChannel, ChannelType.VoiceChannel -> {
ChannelIcon(
channel = channel,
modifier = Modifier.alpha(0.6f)
)
}
else -> {
ChannelIcon(
channelType = it,
modifier = Modifier.alpha(0.6f)
)
}
}
}
Spacer(modifier = Modifier.width(8.dp))

View File

@ -1,15 +1,21 @@
package chat.revolt.composables.screens.chat
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import chat.revolt.R
import chat.revolt.api.REVOLT_FILES
import chat.revolt.api.schemas.Channel
import chat.revolt.api.schemas.ChannelType
import chat.revolt.composables.generic.RemoteImage
@Composable
fun ChannelIcon(channelType: ChannelType, modifier: Modifier = Modifier) {
@ -56,6 +62,29 @@ fun ChannelIcon(channelType: ChannelType, modifier: Modifier = Modifier) {
}
}
@Composable
fun ChannelIcon(
channel: Channel,
modifier: Modifier = Modifier,
size: androidx.compose.ui.unit.Dp = 24.dp
) {
val channelType = channel.channelType ?: ChannelType.TextChannel
if (channel.icon?.id != null) {
RemoteImage(
url = "$REVOLT_FILES/icons/${channel.icon.id}",
description = channel.name ?: stringResource(R.string.unknown),
contentScale = ContentScale.Crop,
height = size.value.toInt(),
width = size.value.toInt(),
allowAnimation = false,
modifier = modifier.size(size)
)
} else {
ChannelIcon(channelType = channelType, modifier = modifier)
}
}
class ChannelTypeProvider : PreviewParameterProvider<ChannelType> {
override val values: Sequence<ChannelType>
get() = sequenceOf(

View File

@ -924,7 +924,7 @@ fun ChannelItem(
)
}
else -> ChannelIcon(iconType.type)
else -> ChannelIcon(channel = channel, size = 24.dp)
}
}

View File

@ -551,6 +551,14 @@ fun ChannelScreen(
)
}
ChannelType.TextChannel, ChannelType.VoiceChannel -> {
ChannelIcon(
channel = it,
size = 24.dp,
modifier = Modifier.alpha(0.8f)
)
}
else -> {
ChannelIcon(
channelType = it.channelType ?: ChannelType.TextChannel,