Improves display of the drop down when adding relays.

This commit is contained in:
Vitor Pamplona
2026-03-08 13:47:11 -04:00
parent 7fa9fdff9e
commit af4404c86e
19 changed files with 204 additions and 81 deletions
@@ -46,6 +46,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel import com.vitorpamplona.amethyst.commons.model.nip28PublicChats.PublicChatChannel
import com.vitorpamplona.amethyst.ui.actions.uploads.SelectSingleFromGallery import com.vitorpamplona.amethyst.ui.actions.uploads.SelectSingleFromGallery
@@ -222,8 +223,9 @@ private fun ChannelMetadataScaffold(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteHomeRelay(item) }, onDelete = { postViewModel.deleteHomeRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderBlockedItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -70,7 +71,8 @@ fun LazyListScope.renderBroadcastItems(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nip11CachedRetriever = Amethyst.instance.nip11Cache,
nav = nav,
) )
} }
@@ -37,6 +37,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever
import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.note.RenderRelayIcon import com.vitorpamplona.amethyst.ui.note.RenderRelayIcon
@@ -61,6 +62,7 @@ fun BasicRelaySetupInfoClickableRow(
loadRobohash: Boolean, loadRobohash: Boolean,
onDelete: ((BasicRelaySetupInfo) -> Unit)?, onDelete: ((BasicRelaySetupInfo) -> Unit)?,
onClick: () -> Unit, onClick: () -> Unit,
nip11CachedRetriever: Nip11CachedRetriever,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
@@ -79,7 +81,7 @@ fun BasicRelaySetupInfoClickableRow(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
modifier = HalfVertPadding, modifier = HalfVertPadding,
) { ) {
val iconUrlFromRelayInfoDoc by loadRelayInfo(item.relay) val iconUrlFromRelayInfoDoc by loadRelayInfo(item.relay, nip11CachedRetriever)
RenderRelayIcon( RenderRelayIcon(
iconUrlFromRelayInfoDoc.id ?: item.relay.displayUrl(), iconUrlFromRelayInfoDoc.id ?: item.relay.displayUrl(),
@@ -21,6 +21,7 @@
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.navigation.routes.Route
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -28,6 +29,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@Composable @Composable
fun BasicRelaySetupInfoDialog( fun BasicRelaySetupInfoDialog(
item: BasicRelaySetupInfo, item: BasicRelaySetupInfo,
nip11CachedRetriever: Nip11CachedRetriever,
onDelete: ((BasicRelaySetupInfo) -> Unit)?, onDelete: ((BasicRelaySetupInfo) -> Unit)?,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
@@ -37,8 +39,9 @@ fun BasicRelaySetupInfoDialog(
loadProfilePicture = accountViewModel.settings.showProfilePictures(), loadProfilePicture = accountViewModel.settings.showProfilePictures(),
loadRobohash = accountViewModel.settings.isNotPerformanceMode(), loadRobohash = accountViewModel.settings.isNotPerformanceMode(),
onDelete = onDelete, onDelete = onDelete,
accountViewModel = accountViewModel,
onClick = { nav.nav(Route.RelayInfo(item.relay.url)) }, onClick = { nav.nav(Route.RelayInfo(item.relay.url)) },
nip11CachedRetriever = nip11CachedRetriever,
accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
} }
@@ -20,10 +20,12 @@
*/ */
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common
import android.R.id.input
import androidx.compose.runtime.Stable import androidx.compose.runtime.Stable
import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.LocalCache
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
@@ -31,11 +33,11 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
@Stable @Stable
class RelaySuggestionState { class RelaySuggestionState : IRelaySuggestionState {
val currentInput = MutableStateFlow("") val currentInput = MutableStateFlow("")
@OptIn(FlowPreview::class) @OptIn(FlowPreview::class)
val results = override val results =
currentInput currentInput
.debounce(300) .debounce(300)
.distinctUntilChanged() .distinctUntilChanged()
@@ -52,11 +54,20 @@ class RelaySuggestionState {
} }
}.flowOn(Dispatchers.IO) }.flowOn(Dispatchers.IO)
fun processInput(input: String) { override fun processInput(input: String) {
currentInput.tryEmit(input) currentInput.tryEmit(input)
} }
fun reset() { override fun reset() {
currentInput.tryEmit("") currentInput.tryEmit("")
} }
} }
@Stable
interface IRelaySuggestionState {
val results: Flow<List<BasicRelaySetupInfo>>
fun processInput(input: String)
fun reset()
}
@@ -20,13 +20,15 @@
*/ */
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults.cardElevation
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text import androidx.compose.material3.Text
@@ -35,33 +37,81 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever
import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel
import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.HalfHorzPadding
import com.vitorpamplona.amethyst.ui.theme.PopupUpEffect
import com.vitorpamplona.amethyst.ui.theme.StdEndPadding
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.quartz.nip01Core.relay.client.stats.RelayStat
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl 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.normalizeRelayUrl
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
@Preview @Preview
@Composable @Composable
fun RelayUrlEditFieldPreview() { fun RelayUrlEditFieldPreview() {
val suggestions =
listOf(
BasicRelaySetupInfo(
relay = "wss://nos.lol".normalizeRelayUrl(),
relayStat =
RelayStat(
receivedBytes = 1000,
sentBytes = 1000,
spamCounter = 12,
errorCounter = 0,
),
),
BasicRelaySetupInfo(
relay = "wss://nostr.mom".normalizeRelayUrl(),
relayStat =
RelayStat(
receivedBytes = 1000,
sentBytes = 1000,
spamCounter = 12,
errorCounter = 0,
),
),
)
val relaySuggestions =
remember {
object : IRelaySuggestionState {
override val results: Flow<List<BasicRelaySetupInfo>> =
MutableStateFlow(suggestions)
override fun processInput(input: String) {}
override fun reset() {}
}
}
val accountViewModel = mockAccountViewModel()
ThemeComparisonColumn { ThemeComparisonColumn {
RelayUrlEditField( RelayUrlEditField(
onNewRelay = {}, onNewRelay = {},
accountViewModel = mockAccountViewModel(), relaySuggestions = relaySuggestions,
nip11CachedRetriever = Nip11CachedRetriever { TODO() },
accountViewModel = accountViewModel,
nav = EmptyNav(), nav = EmptyNav(),
) )
} }
@@ -73,11 +123,29 @@ fun RelayUrlEditField(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
var url by remember { mutableStateOf("") }
val relaySuggestions = remember { RelaySuggestionState() } val relaySuggestions = remember { RelaySuggestionState() }
val nip11CachedRetriever = remember { Amethyst.instance.nip11Cache }
RelayUrlEditField(
onNewRelay = onNewRelay,
relaySuggestions = relaySuggestions,
nip11CachedRetriever = nip11CachedRetriever,
accountViewModel = accountViewModel,
nav = nav,
)
}
@Composable
fun RelayUrlEditField(
onNewRelay: (NormalizedRelayUrl) -> Unit,
relaySuggestions: IRelaySuggestionState,
nip11CachedRetriever: Nip11CachedRetriever,
accountViewModel: AccountViewModel,
nav: INav,
) {
var url by remember { mutableStateOf("") }
fun submitRelay() { fun submitRelay() {
if (url.isNotBlank() && url != "/") { if (url.isNotBlank()) {
val relay = RelayUrlNormalizer.normalizeOrNull(url) val relay = RelayUrlNormalizer.normalizeOrNull(url)
if (relay != null) { if (relay != null) {
onNewRelay(relay) onNewRelay(relay)
@@ -88,10 +156,9 @@ fun RelayUrlEditField(
} }
Column { Column {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(Size10dp)) {
OutlinedTextField( OutlinedTextField(
label = { Text(text = stringRes(R.string.add_a_relay)) }, label = { Text(text = stringRes(R.string.add_a_relay)) },
modifier = Modifier.weight(1f), modifier = Modifier.fillMaxWidth(),
value = url, value = url,
onValueChange = { onValueChange = {
url = it url = it
@@ -116,8 +183,7 @@ fun RelayUrlEditField(
KeyboardActions( KeyboardActions(
onGo = { submitRelay() }, onGo = { submitRelay() },
), ),
) trailingIcon = {
Button( Button(
onClick = { submitRelay() }, onClick = { submitRelay() },
shape = ButtonBorder, shape = ButtonBorder,
@@ -130,19 +196,29 @@ fun RelayUrlEditField(
MaterialTheme.colorScheme.placeholderText MaterialTheme.colorScheme.placeholderText
}, },
), ),
modifier = StdEndPadding,
) { ) {
Text(text = stringRes(id = R.string.add), color = Color.White) Text(text = stringRes(id = R.string.add), color = Color.White)
} }
} },
)
Card(
modifier = Modifier.padding(horizontal = 1.dp),
elevation = cardElevation(5.dp),
shape = PopupUpEffect,
) {
ShowRelaySuggestionList( ShowRelaySuggestionList(
relaySuggestions = relaySuggestions, relaySuggestions = relaySuggestions,
onSelect = { relay -> onSelect = { relay ->
url = relay.url url = relay.url
relaySuggestions.reset() relaySuggestions.reset()
}, },
modifier = HalfHorzPadding,
nip11CachedRetriever = nip11CachedRetriever,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
} }
} }
}
@@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.DividerThickness
@@ -34,9 +35,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Composable @Composable
fun ShowRelaySuggestionList( fun ShowRelaySuggestionList(
relaySuggestions: RelaySuggestionState, relaySuggestions: IRelaySuggestionState,
onSelect: (NormalizedRelayUrl) -> Unit, onSelect: (NormalizedRelayUrl) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
nip11CachedRetriever: Nip11CachedRetriever,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
@@ -51,6 +53,7 @@ fun ShowRelaySuggestionList(
loadRobohash = accountViewModel.settings.isNotPerformanceMode(), loadRobohash = accountViewModel.settings.isNotPerformanceMode(),
onClick = { onSelect(relayInfo.relay) }, onClick = { onSelect(relayInfo.relay) },
onDelete = null, onDelete = null,
nip11CachedRetriever = nip11CachedRetriever,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -28,6 +28,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -64,8 +65,9 @@ fun LazyListScope.renderConnectedItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = null, onDelete = null,
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -68,6 +69,7 @@ fun LazyListScope.renderDMItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderFavoriteItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderIndexerItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -68,8 +69,9 @@ fun LazyListScope.renderLocalItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -68,8 +69,9 @@ fun LazyListScope.renderPrivateOutboxItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -111,8 +112,9 @@ fun LazyListScope.renderNip65HomeItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteHomeRelay(item) }, onDelete = { postViewModel.deleteHomeRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -136,8 +138,9 @@ fun LazyListScope.renderNip65NotifItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteNotifRelay(item) }, onDelete = { postViewModel.deleteNotifRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderProxyItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderSearchItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -29,6 +29,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav import com.vitorpamplona.amethyst.ui.navigation.navs.rememberExtendedNav
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -69,8 +70,9 @@ fun LazyListScope.renderTrustedItems(
BasicRelaySetupInfoDialog( BasicRelaySetupInfoDialog(
item, item,
onDelete = { postViewModel.deleteRelay(item) }, onDelete = { postViewModel.deleteRelay(item) },
nip11CachedRetriever = Amethyst.instance.nip11Cache,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav, nav = nav,
) )
} }
@@ -125,6 +125,7 @@ val Size100dp = 100.dp
val Size110dp = 110.dp val Size110dp = 110.dp
val Size165dp = 165.dp val Size165dp = 165.dp
val StdEndPadding = Modifier.padding(end = 10.dp)
val HalfEndPadding = Modifier.padding(end = 5.dp) val HalfEndPadding = Modifier.padding(end = 5.dp)
val HalfStartPadding = Modifier.padding(start = 5.dp) val HalfStartPadding = Modifier.padding(start = 5.dp)
val StdStartPadding = Modifier.padding(start = 10.dp) val StdStartPadding = Modifier.padding(start = 10.dp)