android: filled buttons and sections name their role
FilledButton takes a required ButtonRole: Primary fills with accent_fill (white on it 5.17:1, where stock Button's accent was 3.47:1), Destructive with color_error. The document detail screen's sections are Section, flat on the ground under their heading rule like the desktop's, instead of stock Cards in the groove color; clippings, podcast search results and Human interactions are RecordCard, bg_card with a hairline. RecordCard names its content color: errorContainer and surface are both bg_card, and contentColorFor() matches errorContainer first, so an unnamed one drew its text red. Noted at the mapping in Theme.kt. The first components of ADR 0055 §4; the detekt bans wait for the remaining call sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
862868b325
commit
e2d4e57ed3
13 files changed
+186
-47
No files matched your search
+5
-5
@@ -20,7 +20,6 @@ import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -48,6 +47,7 @@ import com.gregshuflin.synchronicity.OnStoreChange
|
||||
import com.gregshuflin.synchronicity.documents.ui.formatDate
|
||||
import com.gregshuflin.synchronicity.ui.ChangedElsewhereStrip
|
||||
import com.gregshuflin.synchronicity.ui.IncomingBodyStrip
|
||||
import com.gregshuflin.synchronicity.ui.RecordCard
|
||||
import com.gregshuflin.synchronicity.ui.SectionTabs
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
@@ -652,7 +652,7 @@ private fun ScrapbookNameForm(
|
||||
val labels = SharedCopy.actions
|
||||
val pending = naming.buffer.incoming != null
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth().padding(SCREEN_PADDING)) {
|
||||
RecordCard(modifier = Modifier.fillMaxWidth().padding(SCREEN_PADDING)) {
|
||||
Column(
|
||||
modifier = Modifier.padding(CARD_PADDING),
|
||||
verticalArrangement = Arrangement.spacedBy(GAP),
|
||||
@@ -777,7 +777,7 @@ private fun Composer(
|
||||
var sourceUrl by remember { mutableStateOf("") }
|
||||
val labels = SharedCopy.actions
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth().padding(SCREEN_PADDING)) {
|
||||
RecordCard(modifier = Modifier.fillMaxWidth().padding(SCREEN_PADDING)) {
|
||||
Column(
|
||||
modifier = Modifier.padding(CARD_PADDING),
|
||||
verticalArrangement = Arrangement.spacedBy(GAP),
|
||||
@@ -832,7 +832,7 @@ private fun ClippingEditor(
|
||||
val labels = SharedCopy.actions
|
||||
val pending = session.incoming != null
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
RecordCard(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(CARD_PADDING),
|
||||
verticalArrangement = Arrangement.spacedBy(GAP),
|
||||
@@ -891,7 +891,7 @@ private fun ClippingCard(
|
||||
val labels = SharedCopy.actions
|
||||
val body = clipping.text
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
RecordCard(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(CARD_PADDING),
|
||||
verticalArrangement = Arrangement.spacedBy(GAP),
|
||||
|
||||
+19
-25
@@ -24,17 +24,19 @@ import com.gregshuflin.synchronicity.jobs.JobActivity
|
||||
import com.gregshuflin.synchronicity.jobs.JobControl
|
||||
import com.gregshuflin.synchronicity.jobs.rememberJobControl
|
||||
import com.gregshuflin.synchronicity.rememberReloadKey
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.CenteredLoading
|
||||
import com.gregshuflin.synchronicity.ui.CenteredMessage
|
||||
import com.gregshuflin.synchronicity.ui.ConfirmDialog
|
||||
import com.gregshuflin.synchronicity.ui.EvictionConfirmDialog
|
||||
import com.gregshuflin.synchronicity.ui.EvictionFlowState
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.HashChip
|
||||
import com.gregshuflin.synchronicity.ui.InlineSpinner
|
||||
import com.gregshuflin.synchronicity.ui.LabeledValue
|
||||
import com.gregshuflin.synchronicity.ui.PresenceDot
|
||||
import com.gregshuflin.synchronicity.ui.PresenceLook
|
||||
import com.gregshuflin.synchronicity.ui.SectionHeading
|
||||
import com.gregshuflin.synchronicity.ui.Section
|
||||
import com.gregshuflin.synchronicity.ui.SectionTabs
|
||||
import com.gregshuflin.synchronicity.ui.SegmentedChoice
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
@@ -540,7 +542,7 @@ private fun MetadataCard(
|
||||
nodeStatuses: List<DocumentNodeStatusItem> = emptyList(),
|
||||
) {
|
||||
val fields = SharedCopy.documentFields
|
||||
DetailCard("Document Info") {
|
||||
DetailSection("Document Info") {
|
||||
LabeledValue(label = fields.docType, value = document.displayName)
|
||||
LabeledValue(label = fields.created, value = formatDate(document.createdAt, timezone))
|
||||
LabeledValue(label = fields.size, value = formatBytes(totalBytes))
|
||||
@@ -617,14 +619,14 @@ private fun PlacementCard(
|
||||
onRowAction: (DocumentPlacementRow) -> Unit,
|
||||
onOverrideChange: (DocumentPlacementRow, DocumentSyncOverride?) -> Unit,
|
||||
) {
|
||||
DetailCard(SharedCopy.placement.heading) {
|
||||
DetailSection(SharedCopy.placement.heading) {
|
||||
if (placement == null) {
|
||||
Text(
|
||||
text = SharedCopy.progress.loading,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
return@DetailCard
|
||||
return@DetailSection
|
||||
}
|
||||
Text(
|
||||
text = placement.summaryLine,
|
||||
@@ -753,7 +755,11 @@ private fun PlacementNodeRow(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
val copy = SharedCopy.placement
|
||||
Button(onClick = onRowAction, enabled = !control.busy) {
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = onRowAction,
|
||||
enabled = !control.busy,
|
||||
) {
|
||||
Text(if (row.isThisNode) copy.download else copy.pushNow)
|
||||
}
|
||||
JobActivity(
|
||||
@@ -867,20 +873,16 @@ private fun DangerZoneCard(
|
||||
val evicting =
|
||||
rememberJobControl(JobKind.EVICTION, JobSubject.Document(documentId = documentId))
|
||||
val copy = SharedCopy.documents
|
||||
DetailCard(copy.dangerZone) {
|
||||
DetailSection(copy.dangerZone) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Button(
|
||||
FilledButton(
|
||||
role = ButtonRole.Destructive,
|
||||
onClick = onPurgeClick,
|
||||
enabled = !purging,
|
||||
colors =
|
||||
ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.error,
|
||||
contentColor = MaterialTheme.colorScheme.onError,
|
||||
),
|
||||
) {
|
||||
if (purging) {
|
||||
InlineSpinner(size = 16.dp, color = MaterialTheme.colorScheme.onError)
|
||||
@@ -955,7 +957,7 @@ private fun PurgeConfirmDialog(
|
||||
|
||||
@Composable
|
||||
private fun PropertiesCard(properties: List<DocumentPropertyItem>) {
|
||||
DetailCard(SharedCopy.documentFields.properties, trailing = "${properties.size}") {
|
||||
DetailSection(SharedCopy.documentFields.properties, trailing = "${properties.size}") {
|
||||
if (properties.isEmpty()) {
|
||||
Text(
|
||||
text = SharedCopy.documentFields.noProperties,
|
||||
@@ -1049,7 +1051,7 @@ private fun ArtifactsCard(
|
||||
syncStates: Map<String, AssetSyncState>,
|
||||
onSync: (ContentKey) -> Unit,
|
||||
) {
|
||||
DetailCard(
|
||||
DetailSection(
|
||||
SharedCopy.documentFields.artifacts,
|
||||
trailing = "${artifacts.size + blobRefs.size}",
|
||||
) {
|
||||
@@ -1272,20 +1274,12 @@ private fun NodeStatusRow(status: DocumentNodeStatusItem) {
|
||||
}
|
||||
}
|
||||
|
||||
/** One titled section of the detail screen: a card holding a [SectionHeading] and its rows. */
|
||||
/** One titled section of the detail screen, flat on the ground like the desktop's. */
|
||||
@Composable
|
||||
private fun DetailCard(
|
||||
private fun DetailSection(
|
||||
title: String,
|
||||
trailing: String? = null,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
SectionHeading(title, trailing = trailing)
|
||||
content()
|
||||
}
|
||||
}
|
||||
Section(title, trailing = trailing, content = content)
|
||||
}
|
||||
+4
-1
@@ -25,8 +25,10 @@ import com.gregshuflin.synchronicity.importPickedFile
|
||||
import com.gregshuflin.synchronicity.jobs.ActiveJobs
|
||||
import com.gregshuflin.synchronicity.jobs.JobActivity
|
||||
import com.gregshuflin.synchronicity.jobs.JobControl
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.CenteredLoading
|
||||
import com.gregshuflin.synchronicity.ui.ChangedElsewhereStrip
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.IMPORT_ICON
|
||||
import com.gregshuflin.synchronicity.ui.LabeledSwitch
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
@@ -512,7 +514,8 @@ private fun ImportDocumentDialog(
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
Button(
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = { if (urlText.isNotBlank()) onUrl(urlText.trim()) },
|
||||
enabled = urlText.isNotBlank(),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
||||
+17
-8
@@ -24,8 +24,11 @@ import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.OnStoreChange
|
||||
import com.gregshuflin.synchronicity.ffiCatching
|
||||
import com.gregshuflin.synchronicity.result
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.ConfirmDialog
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.LabeledValue
|
||||
import com.gregshuflin.synchronicity.ui.RecordCard
|
||||
import com.gregshuflin.synchronicity.ui.SectionHeading
|
||||
import com.gregshuflin.synchronicity.ui.SectionTabs
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
@@ -455,7 +458,8 @@ fun HumanDetailScreen(humanId: String, onBack: () -> Unit, modifier: Modifier =
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
if (editing) {
|
||||
Button(
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = {
|
||||
error = null
|
||||
// A filled-in entry row is part of the form, so Save
|
||||
@@ -468,7 +472,7 @@ fun HumanDetailScreen(humanId: String, onBack: () -> Unit, modifier: Modifier =
|
||||
contactMethods = stagedContacts
|
||||
contactEntry = nextContact
|
||||
if (nextFact.error != null || nextContact.error != null) {
|
||||
return@Button
|
||||
return@FilledButton
|
||||
}
|
||||
// Check the one parsed field on its own first: update()
|
||||
// rejects the whole record with an error that names no
|
||||
@@ -479,7 +483,7 @@ fun HumanDetailScreen(humanId: String, onBack: () -> Unit, modifier: Modifier =
|
||||
.exceptionOrNull()
|
||||
if (badDate != null) {
|
||||
birthDateError = badDate.userMessage
|
||||
return@Button
|
||||
return@FilledButton
|
||||
}
|
||||
birthDateError = null
|
||||
saveProfile(
|
||||
@@ -522,7 +526,11 @@ fun HumanDetailScreen(humanId: String, onBack: () -> Unit, modifier: Modifier =
|
||||
Text(SharedCopy.actions.cancel)
|
||||
}
|
||||
} else {
|
||||
Button(onClick = { editing = true }, modifier = Modifier.fillMaxWidth()) {
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = { editing = true },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(SharedCopy.actions.edit)
|
||||
}
|
||||
}
|
||||
@@ -969,16 +977,17 @@ private fun HistoryTab(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = {
|
||||
val what = title.trim()
|
||||
if (what.isEmpty()) return@Button
|
||||
if (what.isEmpty()) return@FilledButton
|
||||
val badDate =
|
||||
ffiCatching { validatePartialDate(occurredOn.trim(), required = true) }
|
||||
.exceptionOrNull()
|
||||
if (badDate != null) {
|
||||
occurredOnError = badDate.userMessage
|
||||
return@Button
|
||||
return@FilledButton
|
||||
}
|
||||
occurredOnError = null
|
||||
val editing = editingId
|
||||
@@ -1090,7 +1099,7 @@ private fun InteractionCard(
|
||||
) {
|
||||
val others = item.attendees.filter { it.id != humanId }.map { it.name }
|
||||
|
||||
OutlinedCard(modifier = Modifier.fillMaxWidth()) {
|
||||
RecordCard(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
|
||||
@@ -16,6 +16,8 @@ import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.rememberReloadKey
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.InputDialog
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
@@ -156,7 +158,7 @@ private fun EmptyHumansPlaceholder(onAdd: () -> Unit) {
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(text = SharedCopy.humans.empty, style = MaterialTheme.typography.titleMedium)
|
||||
Spacer(Modifier.height(24.dp))
|
||||
Button(onClick = onAdd) {
|
||||
FilledButton(role = ButtonRole.Primary, onClick = onAdd) {
|
||||
Icon(Icons.Default.Add, contentDescription = null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(SharedCopy.humans.addPerson)
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.podcast.Podcast
|
||||
import com.gregshuflin.synchronicity.ui.CenteredLoading
|
||||
import com.gregshuflin.synchronicity.ui.CenteredMessage
|
||||
import com.gregshuflin.synchronicity.ui.RecordCard
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import com.gregshuflin.synchronicity.userMessage
|
||||
@@ -48,7 +49,7 @@ private fun SearchResults(
|
||||
) {
|
||||
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
items(searchResults) { result ->
|
||||
Card(
|
||||
RecordCard(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().clickable {
|
||||
onPodcastSelect(
|
||||
|
||||
+5
-2
@@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
@@ -26,6 +25,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
import com.gregshuflin.synchronicity.ui.theme.SynTheme
|
||||
@@ -162,7 +163,9 @@ private fun Controls(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
val copy = SharedCopy.pomodoro
|
||||
Button(onClick = onToggle) { Text(if (timer.running) copy.pause else copy.start) }
|
||||
FilledButton(role = ButtonRole.Primary, onClick = onToggle) {
|
||||
Text(if (timer.running) copy.pause else copy.start)
|
||||
}
|
||||
OutlinedButton(onClick = onReset, enabled = started) { Text(copy.reset) }
|
||||
OutlinedButton(onClick = onSkip) { Text(copy.skip) }
|
||||
}
|
||||
|
||||
+4
-2
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
@@ -27,6 +26,8 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.NativeLib
|
||||
import com.gregshuflin.synchronicity.ui.ButtonRole
|
||||
import com.gregshuflin.synchronicity.ui.FilledButton
|
||||
import com.gregshuflin.synchronicity.ui.SectionHeading
|
||||
import com.gregshuflin.synchronicity.ui.SharedCopy
|
||||
import com.gregshuflin.synchronicity.ui.SubAppScreen
|
||||
@@ -187,7 +188,8 @@ private fun ServiceBlock(
|
||||
}
|
||||
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(GAP)) {
|
||||
Button(
|
||||
FilledButton(
|
||||
role = ButtonRole.Primary,
|
||||
onClick = {
|
||||
onSave(filled.toMap())
|
||||
entries.clear()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gregshuflin.synchronicity.ui
|
||||
|
||||
/** What a filled button is for, which is what decides its color. */
|
||||
enum class ButtonRole {
|
||||
/** The one thing the screen is for: the selection block's `accentFill`. */
|
||||
Primary,
|
||||
/** An action that destroys something: `colorError`, with the ground's text on it. */
|
||||
Destructive,
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.gregshuflin.synchronicity.ui
|
||||
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonColors
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.gregshuflin.synchronicity.ui.theme.SynTheme
|
||||
|
||||
/**
|
||||
* A filled button, colored by its [role] rather than by Material's `primary` slot.
|
||||
*
|
||||
* Stock `Button` fills itself with `primary`, which is the accent stroke color (`#4585ff` on
|
||||
* Charcoal) — white on it is 3.47:1, below AA for a label. The accent *surface* that carries text
|
||||
* is `accentFill` (5.17:1), and this is how a screen reaches it. ADR 0032, "Secondary and tertiary
|
||||
* containers are quiet"; ADR 0055 §4.
|
||||
*/
|
||||
@Composable
|
||||
fun FilledButton(
|
||||
onClick: () -> Unit,
|
||||
role: ButtonRole,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
content: @Composable RowScope.() -> Unit,
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
colors = role.colors(),
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ButtonRole.colors(): ButtonColors {
|
||||
val palette = SynTheme.palette
|
||||
return when (this) {
|
||||
ButtonRole.Primary ->
|
||||
ButtonDefaults.buttonColors(
|
||||
containerColor = palette.accentFill,
|
||||
contentColor = palette.textOnAccent,
|
||||
)
|
||||
ButtonRole.Destructive ->
|
||||
ButtonDefaults.buttonColors(
|
||||
containerColor = palette.colorError,
|
||||
contentColor = palette.textOnError,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.gregshuflin.synchronicity.ui
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.gregshuflin.synchronicity.ui.theme.SynShapes
|
||||
import com.gregshuflin.synchronicity.ui.theme.SynTheme
|
||||
|
||||
/** Between a section's heading and its rows, and between the rows. */
|
||||
private val SECTION_GAP = 8.dp
|
||||
|
||||
/**
|
||||
* One titled division of a screen, flat on the ground: a [SectionHeading] and its content, with no
|
||||
* panel behind them. The heading's rule is what divides the screen, which is ADR 0032 §5's
|
||||
* "hairlines and gutters, never tinted panels" — and what the desktop's `components::section`
|
||||
* already does. A stock `Card` here came out in `bgRaised`, the groove color, and made every
|
||||
* section a heavy raised block where the desktop is flat.
|
||||
*/
|
||||
@Composable
|
||||
fun Section(
|
||||
title: String,
|
||||
modifier: Modifier = Modifier,
|
||||
trailing: String? = null,
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(SECTION_GAP),
|
||||
) {
|
||||
SectionHeading(title, trailing = trailing)
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A record of its own shown in a list — a clipping, a search result — as a `bgCard` surface with a
|
||||
* hairline. Unlike a [Section], which divides one record's screen, this marks off one record from
|
||||
* its neighbors, so it is the one place a container earns a fill.
|
||||
*/
|
||||
@Composable
|
||||
fun RecordCard(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) {
|
||||
Surface(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = SynShapes.Card,
|
||||
color = SynTheme.palette.bgCard,
|
||||
// Named, not left to contentColorFor(): that matches errorContainer before surface, and
|
||||
// both are bgCard, so the default text color here would be colorError (see Theme.kt).
|
||||
contentColor = SynTheme.palette.textPrimary,
|
||||
border = BorderStroke(Dp.Hairline, SynTheme.palette.borderDefault),
|
||||
) {
|
||||
Column(content = content)
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,9 @@ private fun scheme(p: SynPalette, dark: Boolean): ColorScheme =
|
||||
inverseOnSurface = p.textPrimary,
|
||||
error = p.colorError,
|
||||
onError = p.textOnError,
|
||||
// The same value as `surface`, by design (a plain card, not a red wash). One consequence:
|
||||
// `contentColorFor()` checks `errorContainer` before `surface`, so a `Surface` filled with
|
||||
// bgCard that does not name its `contentColor` gets `onErrorContainer` — red text.
|
||||
errorContainer = p.bgCard,
|
||||
onErrorContainer = p.colorError,
|
||||
outline = p.borderCard,
|
||||
|
||||
@@ -76,8 +76,10 @@ thing anyone sees.
|
||||
`Theme.kt` maps `primary` to `accent` (`#4585ff`), and every stock filled
|
||||
`Button` draws its container in `primary`. White on `#4585ff` is **3.47:1** —
|
||||
below AA for text. On screen: "Download" and "Push now"
|
||||
(`detail-sync-charcoal.png`), "Edit" (`human-detail-charcoal.png`), the play
|
||||
button's glyph.
|
||||
(`detail-sync-charcoal.png`), "Edit" (`human-detail-charcoal.png`). The play
|
||||
button is the same white on `accent`, but it is a glyph rather than a label,
|
||||
and a non-text component needs only 3:1 — it passes, and cobalt there means
|
||||
"playing", which §4 allows.
|
||||
|
||||
This is the exact failure ADR 0032's Context predicted — "one accent value
|
||||
cannot serve both roles against a near-black ground" — and the ADR's answer,
|
||||
|
||||
Reference in new issue
Block a user