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