Improvements to the layout of the kinds

This commit is contained in:
Vitor Pamplona
2026-03-27 11:21:46 -04:00
parent cf28e799b7
commit 0862be2761
3 changed files with 16 additions and 6 deletions
@@ -528,7 +528,7 @@ fun RelayInformationBody(
// Active subscriptions + outbox display
// ---------------------------------------------------------------------------
private fun kindDisplayName(kind: Int): Int =
fun kindDisplayName(kind: Int): Int =
when (kind) {
AdvertisedRelayListEvent.KIND -> R.string.kind_outbox_relays
AppDefinitionEvent.KIND -> R.string.kind_apps
@@ -85,6 +85,7 @@ import com.vitorpamplona.amethyst.ui.note.ObserveAndRenderNIP05VerifiedSymbol
import com.vitorpamplona.amethyst.ui.note.UsernameDisplay
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.qrcode.BackButton
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.kindDisplayName
import com.vitorpamplona.amethyst.ui.theme.Font14SP
import com.vitorpamplona.amethyst.ui.theme.NIP05IconSize
import com.vitorpamplona.amethyst.ui.theme.Size55dp
@@ -94,6 +95,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl
import com.vitorpamplona.quartz.nip86RelayManagement.rpc.Nip86Method
import kotlinx.collections.immutable.ImmutableList
@Composable
fun RelayManagementScreen(
@@ -219,7 +221,7 @@ fun RelayManagementScreen(
private fun RelayManagementContent(
pad: PaddingValues,
viewModel: RelayManagementViewModel,
supportedMethods: List<String>,
supportedMethods: ImmutableList<String>,
error: String?,
accountViewModel: AccountViewModel,
) {
@@ -881,8 +883,11 @@ private fun KindEntryCard(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
val nameResId = kindDisplayName(kind)
val name = if (nameResId != -1) stringResource(nameResId) else ""
Text(
"Kind $kind",
"Kind $kind: $name",
style = MaterialTheme.typography.bodyMedium,
fontFamily = FontFamily.Monospace,
)
@@ -20,6 +20,7 @@
*/
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.nip86
import androidx.compose.runtime.Stable
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.vitorpamplona.amethyst.model.LocalCache
@@ -34,6 +35,9 @@ import com.vitorpamplona.quartz.nip86RelayManagement.rpc.BannedPubkey
import com.vitorpamplona.quartz.nip86RelayManagement.rpc.BlockedIp
import com.vitorpamplona.quartz.nip86RelayManagement.rpc.EventNeedingModeration
import com.vitorpamplona.quartz.nip86RelayManagement.rpc.Nip86Request
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -45,6 +49,7 @@ class PubkeyUser(
val reason: String?,
)
@Stable
class RelayManagementViewModel(
relayUrl: NormalizedRelayUrl,
signer: NostrSigner,
@@ -52,8 +57,8 @@ class RelayManagementViewModel(
) : ViewModel() {
val client = Nip86Client(relayUrl, signer)
private val _supportedMethods = MutableStateFlow<List<String>>(emptyList())
val supportedMethods: StateFlow<List<String>> = _supportedMethods
private val _supportedMethods = MutableStateFlow<ImmutableList<String>>(persistentListOf())
val supportedMethods: StateFlow<ImmutableList<String>> = _supportedMethods
private val _bannedPubkeys = MutableStateFlow<List<BannedPubkey>>(emptyList())
val bannedPubkeys: StateFlow<List<BannedPubkey>> = _bannedPubkeys
@@ -101,7 +106,7 @@ class RelayManagementViewModel(
if (response.error != null) {
_error.value = response.error
} else {
_supportedMethods.value = client.parseSupportedMethods(response) ?: emptyList()
_supportedMethods.value = client.parseSupportedMethods(response)?.toImmutableList() ?: persistentListOf()
}
_isLoading.value = false
}