From c924c13297dfa93b29a0bae0ec2019a44e933ced Mon Sep 17 00:00:00 2001 From: another-simple-pixel Date: Mon, 18 May 2026 04:13:14 -0700 Subject: [PATCH] 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. --- .../kotlin/chat/simplex/common/ui/theme/Theme.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/Theme.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/Theme.kt index b70746db86..cfa7576f56 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/Theme.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/ui/theme/Theme.kt @@ -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