Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions LESSONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,19 @@ rather than swallowing the event, so the card does not slide for no reason; and
the reveal panel's label is a per-card function of the action (Wake vs Snooze,
Restore vs Done, Turn off for a tag-alarm), not a property of the enum, which
keeps the enum free of UI and testable.

## 60. A colour axis is a seam that runs through the card *and* the sheets behind it

Settings › Colours was wired into `TaskCard` (#137) and the list looked right,
but tapping a task still opened `TaskOverviewSheet` and `EditTaskSheet` with
their own hardcoded chip and badge colours. The chore side had already passed
`badgeSwatch` / `iconSwatch` into `ChoreOverviewSheet` and `EditChoreSheet`; the
task sheets were simply never given the parameters, so the "fixed" screen was
only fixed until the first tap.

When a setting decides the colour of an element, the seam is every composable
that draws that element for the same item: the list card, the overview sheet,
the edit sheet, the search results, the Done section. Grep the screen's
`*Screen.kt` for every sheet it opens and check each takes the same swatch
parameters as its sibling on the other tab; the `*UiState.spineSwatchFor` /
`iconSwatchFor` helpers exist so every call site resolves the colour the same way.
15 changes: 11 additions & 4 deletions app/src/main/java/com/mapgie/dash/ui/components/EditTaskSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.mapgie.dash.data.model.DuePeriod
import com.mapgie.dash.data.model.Swatch
import com.mapgie.dash.data.model.TaskDraft
import com.mapgie.dash.data.model.TaskDto
import com.mapgie.dash.data.model.TaskDueType
Expand Down Expand Up @@ -63,6 +64,8 @@ import com.mapgie.dash.ui.components.sheet.enumStateSaver
import com.mapgie.dash.ui.components.sheet.jsonStateSaver
import com.mapgie.dash.ui.theme.LocalTypeAccents
import com.mapgie.dash.ui.theme.LucideIcons
import com.mapgie.dash.ui.theme.textColor
import com.mapgie.dash.ui.theme.tintColor
import com.mapgie.dash.util.CalendarShareUtils
import com.mapgie.dash.util.calendarEventForDate
import com.mapgie.dash.util.calendarEventForInstant
Expand Down Expand Up @@ -96,6 +99,10 @@ private const val DUE_PERIOD = TaskDueType.PERIOD
fun EditTaskSheet(
task: TaskDto?,
icon: ImageVector,
/** Category colour for the category value chip (Settings › Colours spine+badge axis), or null. */
badgeSwatch: Swatch?,
/** Category colour for the header icon chip (icon axis), or null for the task accent. */
iconSwatch: Swatch?,
owners: List<String>,
categories: List<String>,
onSave: (TaskInsert) -> Unit,
Expand Down Expand Up @@ -307,8 +314,8 @@ fun EditTaskSheet(
) {
SheetHeader(
icon = icon,
chipContainer = accents.taskContainer,
chipContent = accents.onTaskContainer,
chipContainer = iconSwatch?.tintColor() ?: accents.taskContainer,
chipContent = iconSwatch?.textColor() ?: accents.onTaskContainer,
eyebrow = if (isNew) "New task" else "Edit task",
) {
TitleField(
Expand All @@ -334,8 +341,8 @@ fun EditTaskSheet(
text = category.ifBlank { "None" },
onClick = { categoryMenuOpen = true },
contentDescription = "Category: ${category.ifBlank { "none" }}. Change category",
container = MaterialTheme.colorScheme.secondaryContainer,
content = MaterialTheme.colorScheme.onSecondaryContainer,
container = badgeSwatch?.tintColor() ?: MaterialTheme.colorScheme.secondaryContainer,
content = badgeSwatch?.textColor() ?: MaterialTheme.colorScheme.onSecondaryContainer,
)
CategoryMenu(
expanded = categoryMenuOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.mapgie.dash.data.model.ReminderDto
import com.mapgie.dash.data.model.Swatch
import com.mapgie.dash.data.model.TaskDto
import com.mapgie.dash.data.model.TaskPriority
import com.mapgie.dash.data.model.TaskUrgency
Expand All @@ -60,6 +61,7 @@ import com.mapgie.dash.ui.theme.StatusTone
import com.mapgie.dash.ui.theme.badgeContainerColor
import com.mapgie.dash.ui.theme.statusTone
import com.mapgie.dash.ui.theme.textColor
import com.mapgie.dash.ui.theme.tintColor
import com.mapgie.dash.util.CalendarShareUtils
import com.mapgie.dash.util.calendarEventForDate
import com.mapgie.dash.util.calendarEventForInstant
Expand All @@ -84,6 +86,10 @@ import java.time.temporal.ChronoUnit
fun TaskOverviewSheet(
task: TaskDto,
icon: ImageVector,
/** Category colour for the due badge (Settings › Colours spine+badge axis), or null to follow urgency. */
badgeSwatch: Swatch?,
/** Category colour for the icon chip (icon axis), or null to follow urgency. */
iconSwatch: Swatch?,
isPinned: Boolean,
sheetState: SheetState,
reminders: List<ReminderDto> = emptyList(),
Expand Down Expand Up @@ -117,9 +123,13 @@ fun TaskOverviewSheet(
sheetScope.launch { sheetState.hide() }.invokeOnCompletion { action() }
}

// Same resolution as TaskCard: the Settings › Colours icon axis wins, else
// the urgency tone, else the plain task accent.
val signalling = tone != StatusTone.NEUTRAL && tone != StatusTone.NONE
val chipContainer = if (signalling) tone.badgeContainerColor()!! else accents.taskContainer
val chipContent = if (signalling) tone.textColor() else accents.onTaskContainer
val chipContainer = iconSwatch?.tintColor()
?: if (signalling) tone.badgeContainerColor()!! else accents.taskContainer
val chipContent = iconSwatch?.textColor()
?: if (signalling) tone.textColor() else accents.onTaskContainer

ModalBottomSheet(
onDismissRequest = { hideAndDismiss() },
Expand Down Expand Up @@ -157,7 +167,17 @@ fun TaskOverviewSheet(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.padding(top = 8.dp),
) {
dueBadgeText(task)?.let { StatusBadge(text = it, tone = if (isDone) StatusTone.NEUTRAL else tone) }
dueBadgeText(task)?.let { text ->
// The badge follows the spine+badge axis like the card's; a done
// task's badge stays neutral so the sheet matches the muted card.
val swatch = badgeSwatch?.takeIf { !isDone }
StatusBadge(
text = text,
tone = if (isDone) StatusTone.NEUTRAL else tone,
containerOverride = swatch?.tintColor(),
textOverride = if (swatch != null) MaterialTheme.colorScheme.onSurfaceVariant else null,
)
}
Text(
text = metaText(task),
style = MaterialTheme.typography.labelSmall.copy(fontSize = 13.sp, fontWeight = FontWeight.Bold),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ fun TaskListScreen(
EditTaskSheet(
task = editingTask,
icon = editingTask?.let { iconFor(it) } ?: LucideIcons.CircleCheck,
badgeSwatch = editingTask?.let { uiState.spineSwatchFor(it) },
iconSwatch = editingTask?.let { uiState.iconSwatchFor(it) },
owners = uiState.owners,
categories = uiState.categories,
onSave = { insert -> viewModel.addTask(insert) },
Expand All @@ -530,6 +532,8 @@ fun TaskListScreen(
TaskOverviewSheet(
task = task,
icon = iconFor(task),
badgeSwatch = uiState.spineSwatchFor(task),
iconSwatch = uiState.iconSwatchFor(task),
isPinned = task.id == uiState.pinnedTaskId,
sheetState = overviewSheetState,
reminders = uiState.reminders
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/task-sheet-colour-axes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bump": "patch",
"fixed": [
"Opening or editing a task now colours the sheet's icon chip, due badge and category chip by the Settings > Colours axes, matching the task card and the chore sheets."
]
}
Loading