SettingsScreen.kt
package dev.stave.ui.settings
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import dev.stave.ui.components.staveFocusable
import dev.stave.ui.theme.AccentAmber
import dev.stave.ui.theme.OnMuted
import dev.stave.ui.theme.OnPrimary
import dev.stave.ui.theme.OnQuiet
import dev.stave.ui.theme.SurfaceRaised
import dev.stave.ui.theme.adaptiveScreenPaddingHorizontal
import dev.stave.ui.theme.adaptiveScreenPaddingVertical
import dev.stave.ui.theme.withInterDigits
@Composable
fun SettingsScreen(
onBack: () -> Unit,
onOpenAbout: () -> Unit,
onOpenGuide: () -> Unit,
onChooseServer: () -> Unit,
onOpenPlayback: () -> Unit,
onExit: () -> Unit,
) {
BackHandler(onBack = onBack)
Column(
Modifier
.fillMaxSize()
.padding(horizontal = adaptiveScreenPaddingHorizontal(), vertical = adaptiveScreenPaddingVertical())
) {
// Brand header
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
coil3.compose.AsyncImage(
model = dev.stave.R.drawable.earhorn_gramophone_glow,
contentDescription = null,
modifier = Modifier.size(48.dp),
)
Column {
Text("Settings", style = MaterialTheme.typography.displaySmall, color = OnPrimary)
Text("Earhorn Music Player", style = MaterialTheme.typography.bodySmall, color = OnMuted)
}
}
Spacer(Modifier.height(32.dp))
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
item {
NavCard(
title = "Settings",
subtitle = "Mesh networking, output device, sound, lyrics, privacy, metadata, and display",
onClick = onOpenPlayback,
)
}
item {
NavCard(
title = "Server",
subtitle = "Rescan the network and pick a different UPnP/DLNA library",
onClick = onChooseServer,
)
}
item {
NavCard(
title = "User guide",
subtitle = "How clicks, long-presses, and the queue work",
onClick = onOpenGuide,
)
}
item {
NavCard(
title = "About",
subtitle = "Version, credits, and licenses",
onClick = onOpenAbout,
)
}
item { Spacer(Modifier.height(16.dp)) }
item {
NavCard(
title = "Exit Earhorn",
subtitle = "Close the app completely",
onClick = onExit,
accent = false,
)
}
}
}
}
@Composable
private fun NavCard(
title: String,
subtitle: String,
onClick: () -> Unit,
accent: Boolean = true,
) {
val interaction = remember { MutableInteractionSource() }
Box(
Modifier
.fillMaxWidth()
.background(SurfaceRaised)
.staveFocusable(interaction)
.clickable(interaction, indication = null) { onClick() }
.padding(horizontal = 24.dp, vertical = 18.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Column(Modifier.weight(1f)) {
Text(
withInterDigits(title),
style = MaterialTheme.typography.titleMedium,
color = if (accent) OnPrimary else OnMuted,
)
Spacer(Modifier.height(4.dp))
Text(
withInterDigits(subtitle),
style = MaterialTheme.typography.bodySmall,
color = OnMuted,
)
}
Text(
"\u25b8",
style = MaterialTheme.typography.titleLarge,
color = if (accent) AccentAmber else OnQuiet,
)
}
}
}