Roles we hadn't set fell back to Material's purple baseline, giving dark purple text on pale-blue buttons, near-invisible field borders and a now-playing panel that blended into the background. Both themes now define every role from the web UI palette, checked at >= 4.5:1 for text and >= 3:1 for field borders. The amber panel is theme-aware with an edge, and the "waiting to send" line no longer uses amber on the light page background. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e7e19c2f8d
commit
0be4ff9dce
5 files changed
+86
-46
No files matched your search
@@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.NavigationBarItemDefaults
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -47,13 +46,12 @@ fun ScrobbledApp(services: AppServices, serverUrl: String, username: String, onS
|
||||
val current by nav.currentBackStackEntryAsState()
|
||||
Scaffold(
|
||||
bottomBar = {
|
||||
NavigationBar(containerColor = MaterialTheme.colorScheme.surfaceVariant) {
|
||||
NavigationBar(containerColor = MaterialTheme.colorScheme.surfaceContainer) {
|
||||
Destination.entries.forEach { d ->
|
||||
NavigationBarItem(
|
||||
selected = current?.destination?.route == d.route,
|
||||
onClick = { nav.navigate(d.route) { launchSingleTop = true } },
|
||||
icon = {},
|
||||
colors = NavigationBarItemDefaults.colors(indicatorColor = MaterialTheme.colorScheme.outline),
|
||||
label = { Text(d.label) },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.FilterChipDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.PrimaryTabRow
|
||||
@@ -112,8 +111,7 @@ private fun ManualTab(s: AddState, vm: AddViewModel) {
|
||||
Row(Modifier.horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
WhenOption.entries.forEach { o ->
|
||||
FilterChip(
|
||||
selected = s.whenOption == o, onClick = { vm.onWhen(o) }, label = { Text(o.label) },
|
||||
colors = FilterChipDefaults.filterChipColors(selectedContainerColor = MaterialTheme.colorScheme.outline),
|
||||
selected = s.whenOption == o, onClick = { vm.onWhen(o) }, label = { Text(o.label) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.daubney.scrobbled.ui.home
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -26,9 +27,7 @@ import androidx.lifecycle.repeatOnLifecycle
|
||||
import dev.daubney.scrobbled.data.history.NowPlaying
|
||||
import dev.daubney.scrobbled.data.history.Summary
|
||||
import dev.daubney.scrobbled.ui.ScrobbleRow
|
||||
import dev.daubney.scrobbled.ui.theme.Glow
|
||||
import dev.daubney.scrobbled.ui.theme.Panel
|
||||
import dev.daubney.scrobbled.ui.theme.PanelText
|
||||
import dev.daubney.scrobbled.ui.theme.AppColors
|
||||
|
||||
private const val POLL_MS = 15_000L
|
||||
|
||||
@@ -63,7 +62,7 @@ fun HomeScreen(vm: HomeViewModel, onSettings: () -> Unit) {
|
||||
item {
|
||||
Text(
|
||||
if (state.pending == 1) "1 scrobble waiting to send" else "${state.pending} scrobbles waiting to send",
|
||||
color = Glow, style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary, style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -80,17 +79,19 @@ fun HomeScreen(vm: HomeViewModel, onSettings: () -> Unit) {
|
||||
/** The dark "hi-fi front panel" from the web UI, glowing amber while something plays. */
|
||||
@Composable
|
||||
private fun NowPlayingPanel(np: NowPlaying?) {
|
||||
val panel = AppColors.panel
|
||||
Column(
|
||||
Modifier.fillMaxWidth().background(Panel, RoundedCornerShape(14.dp)).padding(20.dp),
|
||||
Modifier.fillMaxWidth().background(panel.background, RoundedCornerShape(14.dp))
|
||||
.border(1.dp, panel.edge, RoundedCornerShape(14.dp)).padding(20.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(if (np != null) "NOW PLAYING" else "NOTHING PLAYING", style = MaterialTheme.typography.labelMedium, color = PanelText)
|
||||
Text(if (np != null) "NOW PLAYING" else "NOTHING PLAYING", style = MaterialTheme.typography.labelMedium, color = panel.text)
|
||||
if (np != null) {
|
||||
Text(np.track, style = MaterialTheme.typography.titleLarge, color = Glow)
|
||||
Text(np.artist, style = MaterialTheme.typography.bodyLarge, color = Glow)
|
||||
np.album?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = PanelText) }
|
||||
Text(np.track, style = MaterialTheme.typography.titleLarge, color = panel.glow)
|
||||
Text(np.artist, style = MaterialTheme.typography.bodyLarge, color = panel.glow)
|
||||
np.album?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = panel.text) }
|
||||
} else {
|
||||
Text("—", style = MaterialTheme.typography.titleLarge, color = PanelText)
|
||||
Text("—", style = MaterialTheme.typography.titleLarge, color = panel.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.pm.PackageManager
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -37,8 +38,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.ContextCompat
|
||||
import dev.daubney.scrobbled.ui.TrackFields
|
||||
import dev.daubney.scrobbled.ui.theme.Glow
|
||||
import dev.daubney.scrobbled.ui.theme.Panel
|
||||
import dev.daubney.scrobbled.ui.theme.AppColors
|
||||
|
||||
@Composable
|
||||
fun ListenScreen(vm: ListenViewModel, demoMode: Boolean) {
|
||||
@@ -59,10 +59,12 @@ fun ListenScreen(vm: ListenViewModel, demoMode: Boolean) {
|
||||
) {
|
||||
Text("Listen", style = MaterialTheme.typography.headlineSmall)
|
||||
if (demoMode) {
|
||||
val panel = AppColors.panel
|
||||
Text(
|
||||
"Demo mode: results are made up. Add your ACRCloud keys in Settings to identify real music.",
|
||||
style = MaterialTheme.typography.labelLarge, color = Glow,
|
||||
modifier = Modifier.fillMaxWidth().background(Panel, RoundedCornerShape(6.dp)).padding(12.dp),
|
||||
style = MaterialTheme.typography.labelLarge, color = panel.glow,
|
||||
modifier = Modifier.fillMaxWidth().background(panel.background, RoundedCornerShape(6.dp))
|
||||
.border(1.dp, panel.edge, RoundedCornerShape(6.dp)).padding(12.dp),
|
||||
)
|
||||
}
|
||||
when (s.phase) {
|
||||
@@ -89,12 +91,14 @@ private fun Idle(s: ListenState, onListen: () -> Unit) {
|
||||
/** A big round button in the web UI's amber-on-dark panel style. */
|
||||
@Composable
|
||||
private fun ListenButton(onClick: () -> Unit) {
|
||||
val panel = AppColors.panel
|
||||
Box(Modifier.fillMaxWidth().padding(vertical = 24.dp), contentAlignment = Alignment.Center) {
|
||||
Box(
|
||||
Modifier.size(168.dp).clip(CircleShape).background(Panel).clickable(onClick = onClick),
|
||||
Modifier.size(168.dp).clip(CircleShape).background(panel.background)
|
||||
.border(1.dp, panel.edge, CircleShape).clickable(onClick = onClick),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text("Listen", style = MaterialTheme.typography.titleLarge, color = Glow)
|
||||
Text("Listen", style = MaterialTheme.typography.titleLarge, color = panel.glow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,81 @@
|
||||
package dev.daubney.scrobbled.ui.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Shapes
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
// Mirrors the web UI's paper/ink palette (frontend/css/style.css in ScrobblingService).
|
||||
val Glow = Color(0xFFF2A541)
|
||||
val Panel = Color(0xFF1C2330)
|
||||
val PanelText = Color(0xFFB9C3D2)
|
||||
// Palette from the web UI (frontend/css/style.css in ScrobblingService). Every Material role is set
|
||||
// explicitly: any role left out falls back to Material's purple baseline, which clashes and (in dark
|
||||
// mode) gave low-contrast text. Text pairs are >= 4.5:1 and field borders >= 3:1 in both themes.
|
||||
|
||||
private val Light = lightColorScheme(
|
||||
primary = Color(0xFF2F5DA8),
|
||||
background = Color(0xFFE8ECF1),
|
||||
surface = Color(0xFFE8ECF1),
|
||||
surfaceVariant = Color(0xFFF4F6F9),
|
||||
onBackground = Color(0xFF18202C),
|
||||
onSurface = Color(0xFF18202C),
|
||||
onSurfaceVariant = Color(0xFF4A5566),
|
||||
outline = Color(0xFFC9D0DA),
|
||||
error = Color(0xFFB3412E),
|
||||
primary = Color(0xFF2F5DA8), onPrimary = Color(0xFFFFFFFF),
|
||||
primaryContainer = Color(0xFFD3E0F7), onPrimaryContainer = Color(0xFF0E2A57),
|
||||
secondary = Color(0xFF5B6B82), onSecondary = Color(0xFFFFFFFF),
|
||||
secondaryContainer = Color(0xFFCDD6E2), onSecondaryContainer = Color(0xFF18202C),
|
||||
tertiary = Color(0xFF5B6B82), onTertiary = Color(0xFFFFFFFF),
|
||||
tertiaryContainer = Color(0xFFCDD6E2), onTertiaryContainer = Color(0xFF18202C),
|
||||
background = Color(0xFFE8ECF1), onBackground = Color(0xFF18202C),
|
||||
surface = Color(0xFFE8ECF1), onSurface = Color(0xFF18202C),
|
||||
surfaceVariant = Color(0xFFDCE2EA), onSurfaceVariant = Color(0xFF434F60),
|
||||
surfaceTint = Color(0xFF2F5DA8),
|
||||
surfaceDim = Color(0xFFDDE2E9), surfaceBright = Color(0xFFF4F6F9),
|
||||
surfaceContainerLowest = Color(0xFFFFFFFF), surfaceContainerLow = Color(0xFFEFF2F6),
|
||||
surfaceContainer = Color(0xFFF4F6F9), surfaceContainerHigh = Color(0xFFFAFBFC),
|
||||
surfaceContainerHighest = Color(0xFFFFFFFF),
|
||||
outline = Color(0xFF6B7789), outlineVariant = Color(0xFFC9D0DA),
|
||||
error = Color(0xFFB3412E), onError = Color(0xFFFFFFFF),
|
||||
errorContainer = Color(0xFFF6D5CD), onErrorContainer = Color(0xFF4A1409),
|
||||
inverseSurface = Color(0xFF18202C), inverseOnSurface = Color(0xFFE8ECF1), inversePrimary = Color(0xFF8FB4F0),
|
||||
scrim = Color(0xFF000000),
|
||||
)
|
||||
|
||||
private val Dark = darkColorScheme(
|
||||
primary = Color(0xFF8FB4F0),
|
||||
background = Color(0xFF12171F),
|
||||
surface = Color(0xFF12171F),
|
||||
surfaceVariant = Color(0xFF19202B),
|
||||
onBackground = Color(0xFFE3E8EF),
|
||||
onSurface = Color(0xFFE3E8EF),
|
||||
onSurfaceVariant = Color(0xFFA7B1C0),
|
||||
outline = Color(0xFF2C3543),
|
||||
error = Color(0xFFE0806C),
|
||||
primary = Color(0xFF8FB4F0), onPrimary = Color(0xFF0A1D3D),
|
||||
primaryContainer = Color(0xFF26416D), onPrimaryContainer = Color(0xFFD9E5FB),
|
||||
secondary = Color(0xFF8795AA), onSecondary = Color(0xFF0F1622),
|
||||
secondaryContainer = Color(0xFF2D3A50), onSecondaryContainer = Color(0xFFE3E8EF),
|
||||
tertiary = Color(0xFF8795AA), onTertiary = Color(0xFF0F1622),
|
||||
tertiaryContainer = Color(0xFF2D3A50), onTertiaryContainer = Color(0xFFE3E8EF),
|
||||
background = Color(0xFF12171F), onBackground = Color(0xFFE3E8EF),
|
||||
surface = Color(0xFF12171F), onSurface = Color(0xFFE3E8EF),
|
||||
surfaceVariant = Color(0xFF273142), onSurfaceVariant = Color(0xFFB3BDCC),
|
||||
surfaceTint = Color(0xFF8FB4F0),
|
||||
surfaceDim = Color(0xFF0E131A), surfaceBright = Color(0xFF2A3342),
|
||||
surfaceContainerLowest = Color(0xFF0C1016), surfaceContainerLow = Color(0xFF151B25),
|
||||
surfaceContainer = Color(0xFF19202B), surfaceContainerHigh = Color(0xFF222B38),
|
||||
surfaceContainerHighest = Color(0xFF2A3442),
|
||||
outline = Color(0xFF7D8AA0), outlineVariant = Color(0xFF2C3543),
|
||||
error = Color(0xFFF0907C), onError = Color(0xFF3B0D05),
|
||||
errorContainer = Color(0xFF7A2A1B), onErrorContainer = Color(0xFFFFDAD2),
|
||||
inverseSurface = Color(0xFFE3E8EF), inverseOnSurface = Color(0xFF18202C), inversePrimary = Color(0xFF2F5DA8),
|
||||
scrim = Color(0xFF000000),
|
||||
)
|
||||
|
||||
/** The web UI's "hi-fi front panel": a dark card with amber text, used for now-playing and Listen. */
|
||||
@Immutable
|
||||
class PanelColors(val background: Color, val edge: Color, val text: Color, val glow: Color)
|
||||
|
||||
private val LightPanel = PanelColors(Color(0xFF1C2330), Color(0xFF2A3445), Color(0xFFB9C3D2), Color(0xFFF2A541))
|
||||
private val DarkPanel = PanelColors(Color(0xFF232D3E), Color(0xFF3A4860), Color(0xFFC5CEDB), Color(0xFFF2A541))
|
||||
|
||||
private val LocalPanelColors = staticCompositionLocalOf { LightPanel }
|
||||
|
||||
object AppColors {
|
||||
val panel: PanelColors
|
||||
@Composable @ReadOnlyComposable get() = LocalPanelColors.current
|
||||
}
|
||||
|
||||
private val AppShapes = Shapes(
|
||||
small = RoundedCornerShape(6.dp),
|
||||
medium = RoundedCornerShape(6.dp),
|
||||
@@ -47,5 +84,7 @@ private val AppShapes = Shapes(
|
||||
|
||||
@Composable
|
||||
fun ScrobbledTheme(dark: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||
MaterialTheme(colorScheme = if (dark) Dark else Light, shapes = AppShapes, content = content)
|
||||
CompositionLocalProvider(LocalPanelColors provides if (dark) DarkPanel else LightPanel) {
|
||||
MaterialTheme(colorScheme = if (dark) Dark else Light, shapes = AppShapes, content = content)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user