DRY pass #2, batch 8, F20: drawer titles and tag colour names come from strings.xml (#5372)

Destination carried its English title as a field, and NoteTint its colour
name; every other word on screen is a string resource. Destination.title()
now reads nav_notes/reminders/archive/trash (a tag's destination keeps its
name), and NoteTint.label is a @StringRes. Error fallbacks raised in view
models and the install receiver stay as constants: they are made outside
composition, with no Context to read a resource from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:10:15 -04:00
co-authored by Claude Opus 5.5
parent cba428461c
commit 0d82e26eea
5 changed files with 44 additions and 28 deletions
@@ -470,6 +470,16 @@ private fun NavigationDrawer(
} }
} }
@Composable
private fun Destination.title(): String =
when (this) {
Destination.Notes -> stringResource(R.string.nav_notes)
Destination.Reminders -> stringResource(R.string.nav_reminders)
Destination.Archive -> stringResource(R.string.nav_archive)
Destination.Trash -> stringResource(R.string.nav_trash)
is Destination.WithLabel -> name
}
@Composable @Composable
private fun DrawerRow( private fun DrawerRow(
destination: Destination, destination: Destination,
@@ -477,7 +487,7 @@ private fun DrawerRow(
onOpen: (Destination) -> Unit, onOpen: (Destination) -> Unit,
) { ) {
NavigationDrawerItem( NavigationDrawerItem(
label = { Text(destination.title) }, label = { Text(destination.title()) },
selected = destination == current, selected = destination == current,
onClick = { onOpen(destination) }, onClick = { onOpen(destination) },
modifier = Modifier.padding(horizontal = 12.dp), modifier = Modifier.padding(horizontal = 12.dp),
@@ -30,27 +30,17 @@ import kotlinx.coroutines.withContext
* empty board. * empty board.
*/ */
sealed interface Destination { sealed interface Destination {
val title: String data object Notes : Destination
data object Notes : Destination { data object Reminders : Destination
override val title = "Notes"
}
data object Reminders : Destination { data object Archive : Destination
override val title = "Reminders"
}
data object Archive : Destination { data object Trash : Destination
override val title = "Archive"
}
data object Trash : Destination {
override val title = "Trash"
}
data class WithLabel( data class WithLabel(
val id: String, val id: String,
override val title: String, val name: String,
) : Destination ) : Destination
} }
@@ -1,8 +1,10 @@
package com.fabledsword.inkwell.ui package com.fabledsword.inkwell.ui
import androidx.annotation.StringRes
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import com.fabledsword.inkwell.R
/** /**
* The colour palette, matching `frontend/src/notes/colors.ts` VALUE FOR VALUE. * The colour palette, matching `frontend/src/notes/colors.ts` VALUE FOR VALUE.
@@ -27,7 +29,7 @@ import androidx.compose.ui.graphics.Color
* acid against the neutral surfaces. * acid against the neutral surfaces.
*/ */
data class NoteTint( data class NoteTint(
val label: String, @StringRes val label: Int,
val lightBackground: Color, val lightBackground: Color,
val lightBorder: Color, val lightBorder: Color,
val darkBackground: Color, val darkBackground: Color,
@@ -121,7 +123,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
mapOf( mapOf(
"default" to "default" to
NoteTint( NoteTint(
label = "Default", label = R.string.tint_default,
lightBackground = Color(0xFFFFFFFF), lightBackground = Color(0xFFFFFFFF),
lightBorder = Color(0xFFE5E5E5), lightBorder = Color(0xFFE5E5E5),
darkBackground = Color(0xFF171717), darkBackground = Color(0xFF171717),
@@ -135,7 +137,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"red" to "red" to
NoteTint( NoteTint(
label = "Red", label = R.string.tint_red,
lightBackground = Color(0xFFFEF2F2), lightBackground = Color(0xFFFEF2F2),
lightBorder = Color(0xFFFECACA), lightBorder = Color(0xFFFECACA),
darkBackground = Color(0x66450A0A), darkBackground = Color(0x66450A0A),
@@ -149,7 +151,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"orange" to "orange" to
NoteTint( NoteTint(
label = "Orange", label = R.string.tint_orange,
lightBackground = Color(0xFFFFF7ED), lightBackground = Color(0xFFFFF7ED),
lightBorder = Color(0xFFFED7AA), lightBorder = Color(0xFFFED7AA),
darkBackground = Color(0x66431407), darkBackground = Color(0x66431407),
@@ -163,7 +165,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"yellow" to "yellow" to
NoteTint( NoteTint(
label = "Yellow", label = R.string.tint_yellow,
lightBackground = Color(0xFFFFFBEB), lightBackground = Color(0xFFFFFBEB),
lightBorder = Color(0xFFFDE68A), lightBorder = Color(0xFFFDE68A),
darkBackground = Color(0x66451A03), darkBackground = Color(0x66451A03),
@@ -177,7 +179,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"green" to "green" to
NoteTint( NoteTint(
label = "Green", label = R.string.tint_green,
lightBackground = Color(0xFFF0FDF4), lightBackground = Color(0xFFF0FDF4),
lightBorder = Color(0xFFBBF7D0), lightBorder = Color(0xFFBBF7D0),
darkBackground = Color(0x66052E16), darkBackground = Color(0x66052E16),
@@ -191,7 +193,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"teal" to "teal" to
NoteTint( NoteTint(
label = "Teal", label = R.string.tint_teal,
lightBackground = Color(0xFFF0FDFA), lightBackground = Color(0xFFF0FDFA),
lightBorder = Color(0xFF99F6E4), lightBorder = Color(0xFF99F6E4),
darkBackground = Color(0x66042F2E), darkBackground = Color(0x66042F2E),
@@ -205,7 +207,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"blue" to "blue" to
NoteTint( NoteTint(
label = "Blue", label = R.string.tint_blue,
lightBackground = Color(0xFFEFF6FF), lightBackground = Color(0xFFEFF6FF),
lightBorder = Color(0xFFBFDBFE), lightBorder = Color(0xFFBFDBFE),
darkBackground = Color(0x66172554), darkBackground = Color(0x66172554),
@@ -219,7 +221,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"purple" to "purple" to
NoteTint( NoteTint(
label = "Purple", label = R.string.tint_purple,
lightBackground = Color(0xFFFAF5FF), lightBackground = Color(0xFFFAF5FF),
lightBorder = Color(0xFFE9D5FF), lightBorder = Color(0xFFE9D5FF),
darkBackground = Color(0x663B0764), darkBackground = Color(0x663B0764),
@@ -233,7 +235,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"pink" to "pink" to
NoteTint( NoteTint(
label = "Pink", label = R.string.tint_pink,
lightBackground = Color(0xFFFDF2F8), lightBackground = Color(0xFFFDF2F8),
lightBorder = Color(0xFFFBCFE8), lightBorder = Color(0xFFFBCFE8),
darkBackground = Color(0x66500724), darkBackground = Color(0x66500724),
@@ -247,7 +249,7 @@ val NOTE_TINTS: Map<String, NoteTint> =
), ),
"gray" to "gray" to
NoteTint( NoteTint(
label = "Gray", label = R.string.tint_gray,
lightBackground = Color(0xFFF5F5F5), lightBackground = Color(0xFFF5F5F5),
lightBorder = Color(0xFFD4D4D4), lightBorder = Color(0xFFD4D4D4),
darkBackground = Color(0xFF262626), darkBackground = Color(0xFF262626),
@@ -524,7 +524,7 @@ private fun ColourDialog(
) { ) {
Swatch(tint, dark) Swatch(tint, dark)
Text( Text(
text = tint.label, text = stringResource(tint.label),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = color =
if (key == tag.color) { if (key == tag.color) {
@@ -7,6 +7,20 @@
<string name="search_clear">Clear search</string> <string name="search_clear">Clear search</string>
<string name="nav_open">Open navigation</string> <string name="nav_open">Open navigation</string>
<string name="nav_labels">Tags</string> <string name="nav_labels">Tags</string>
<string name="nav_notes">Notes</string>
<string name="nav_reminders">Reminders</string>
<string name="nav_archive">Archive</string>
<string name="nav_trash">Trash</string>
<string name="tint_default">Default</string>
<string name="tint_red">Red</string>
<string name="tint_orange">Orange</string>
<string name="tint_yellow">Yellow</string>
<string name="tint_green">Green</string>
<string name="tint_teal">Teal</string>
<string name="tint_blue">Blue</string>
<string name="tint_purple">Purple</string>
<string name="tint_pink">Pink</string>
<string name="tint_gray">Gray</string>
<!-- Compose sheet --> <!-- Compose sheet -->
<string name="compose_open">New note</string> <string name="compose_open">New note</string>