Improving the looks of namecoin settings

This commit is contained in:
Vitor Pamplona
2026-03-11 12:33:52 -04:00
parent 3bd2f4251b
commit 1bd96707e5
3 changed files with 51 additions and 70 deletions
@@ -20,6 +20,7 @@
*/ */
package com.vitorpamplona.amethyst.service.namecoin package com.vitorpamplona.amethyst.service.namecoin
import androidx.compose.runtime.Stable
import com.vitorpamplona.quartz.nip05DnsIdentifiers.namecoin.ElectrumxServer import com.vitorpamplona.quartz.nip05DnsIdentifiers.namecoin.ElectrumxServer
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@@ -31,6 +32,7 @@ import kotlinx.serialization.Serializable
* control over which ElectrumX servers observe their name lookups. * control over which ElectrumX servers observe their name lookups.
*/ */
@Serializable @Serializable
@Stable
data class NamecoinSettings( data class NamecoinSettings(
/** Whether Namecoin resolution is enabled at all. */ /** Whether Namecoin resolution is enabled at all. */
val enabled: Boolean = true, val enabled: Boolean = true,
@@ -21,9 +21,7 @@
package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -63,8 +61,6 @@ fun NamecoinSettingsScreen(
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
.padding(horizontal = 10.dp), .padding(horizontal = 10.dp),
) { ) {
Spacer(Modifier.height(16.dp))
NamecoinSettingsSection( NamecoinSettingsSection(
settings = namecoinSettings, settings = namecoinSettings,
onToggleEnabled = { enabled -> onToggleEnabled = { enabled ->
@@ -80,8 +76,6 @@ fun NamecoinSettingsScreen(
scope.launch { namecoinPrefs.reset() } scope.launch { namecoinPrefs.reset() }
}, },
) )
Spacer(Modifier.height(16.dp))
} }
} }
} }
@@ -41,8 +41,6 @@ import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Lock import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
@@ -91,77 +89,64 @@ fun NamecoinSettingsSection(
onReset: () -> Unit, onReset: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
Card( Column(modifier = modifier.padding(16.dp)) {
modifier = // ── Section header ─────────────────────────────────────────
modifier SectionHeader(enabled = settings.enabled, onToggle = onToggleEnabled)
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
shape = RoundedCornerShape(12.dp),
elevation = CardDefaults.cardElevation(defaultElevation = 1.dp),
colors =
CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f),
),
) {
Column(modifier = Modifier.padding(16.dp)) {
// ── Section header ─────────────────────────────────────────
SectionHeader(enabled = settings.enabled, onToggle = onToggleEnabled)
AnimatedVisibility( AnimatedVisibility(
visible = settings.enabled, visible = settings.enabled,
enter = expandVertically(), enter = expandVertically(),
exit = shrinkVertically(), exit = shrinkVertically(),
) { ) {
Column { Column {
Spacer(Modifier.height(12.dp)) Spacer(Modifier.height(12.dp))
// ── Explanation ───────────────────────────────────── // ── Explanation ─────────────────────────────────────
Text( Text(
"Namecoin names (.bit, d/, id/) are resolved via ElectrumX servers. " + "Namecoin names (.bit, d/, id/) are resolved via ElectrumX servers. " +
"By default, public community servers are used. " + "By default, public community servers are used. " +
"For maximum privacy, add your own server below — when custom " + "For maximum privacy, add your own server below — when custom " +
"servers are set, the defaults are completely ignored.", "servers are set, the defaults are completely ignored.",
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))
// ── Active servers display ───────────────────────── // ── Active servers display ─────────────────────────
ActiveServersDisplay(settings = settings) ActiveServersDisplay(settings = settings)
Spacer(Modifier.height(12.dp)) Spacer(Modifier.height(12.dp))
HorizontalDivider( HorizontalDivider(
color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f), color = MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f),
) )
Spacer(Modifier.height(12.dp)) Spacer(Modifier.height(12.dp))
// ── Custom servers list ──────────────────────────── // ── Custom servers list ────────────────────────────
CustomServersList( CustomServersList(
servers = settings.customServers, servers = settings.customServers,
onRemove = onRemoveServer, onRemove = onRemoveServer,
) )
// ── Add server input ─────────────────────────────── // ── Add server input ───────────────────────────────
AddServerInput(onAdd = onAddServer) AddServerInput(onAdd = onAddServer)
Spacer(Modifier.height(8.dp)) Spacer(Modifier.height(8.dp))
// ── Reset button ─────────────────────────────────── // ── Reset button ───────────────────────────────────
if (settings.hasCustomServers) { if (settings.hasCustomServers) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End, horizontalArrangement = Arrangement.End,
) { ) {
TextButton(onClick = onReset) { TextButton(onClick = onReset) {
Icon( Icon(
Icons.Default.Refresh, Icons.Default.Refresh,
contentDescription = null, contentDescription = null,
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp),
) )
Spacer(Modifier.width(4.dp)) Spacer(Modifier.width(4.dp))
Text("Reset to defaults") Text("Reset to defaults")
}
} }
} }
} }