Theme: document why canvasColorForCurrentTheme reads CurrentColors.value directly

Reviewer asked why this helper uses CurrentColors.value.base instead of the
Compose MaterialTheme/CompositionLocal route. Reason is that the helper is
intentionally callable from both @Composable bodies and DrawScope (inside
sectionItemDivider's drawWithContent), and DrawScope can't invoke @Composable
getters. Add a paragraph to the doc-comment so future readers don't try to
'fix' it back to MaterialTheme.colors and break the divider draw path.
This commit is contained in:
another-simple-pixel
2026-05-18 04:13:14 -07:00
parent 5c4a24f15e
commit c924c13297
@@ -603,6 +603,13 @@ data class ThemeModeOverride (
// cards above. DARK/BLACK: palette bg (cards already raised via founder's
// formula in Section.kt). SIMPLEX: gradient bottom stop (darker), since the
// canvas itself is a gradient drawn by themedBackgroundBrush.
//
// Reads CurrentColors.value directly rather than via MaterialTheme/CompositionLocal
// because this helper is called from two scopes: @Composable bodies (SectionView,
// SectionDivider) and DrawScope (sectionItemDivider's drawWithContent). DrawScope
// can't call @Composable getters, so a snapshot read keeps one helper usable in
// both places. State invalidation still works — CurrentColors is a MutableStateFlow,
// reads are tracked by Compose snapshot system.
fun canvasColorForCurrentTheme(): Color {
val theme = CurrentColors.value
val c = theme.colors