mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-27 11:53:03 +00:00
Section / Theme: extract sectionCardColor() helper
Three SectionView overloads were each computing the same cardColor inline: if (CurrentColors.value.base == DefaultTheme.LIGHT) Color.White else MaterialTheme.colors.background.mixWith(...). DRY violation paired with the canvasColorForCurrentTheme() helper that already covers the canvas side of the same theme split. Add a sectionCardColor() function in Theme.kt and collapse the 3 inline formulas to one call.
This commit is contained in:
@@ -613,6 +613,15 @@ fun canvasColorForCurrentTheme(): Color {
|
||||
}
|
||||
}
|
||||
|
||||
// Card background color for SectionView. LIGHT: pure white (raised above the
|
||||
// off-white canvas). DARK/BLACK/SIMPLEX: founder's mixWith formula (lifts cards
|
||||
// above palette bg using onBackground tint).
|
||||
fun sectionCardColor(): Color {
|
||||
val theme = CurrentColors.value
|
||||
return if (theme.base == DefaultTheme.LIGHT) Color.White
|
||||
else theme.colors.background.mixWith(theme.colors.onBackground, 0.95f)
|
||||
}
|
||||
|
||||
fun Modifier.themedBackground(baseTheme: DefaultTheme = CurrentColors.value.base, bgLayerSize: MutableState<IntSize>?, bgLayer: GraphicsLayer?/*, shape: Shape = RectangleShape*/): Modifier {
|
||||
return drawBehind {
|
||||
copyBackgroundToAppBar(bgLayerSize, bgLayer) {
|
||||
|
||||
+3
-6
@@ -46,8 +46,7 @@ private fun Modifier.sectionItemDivider(): Modifier {
|
||||
|
||||
@Composable
|
||||
fun SectionView(title: String? = null, contentPadding: PaddingValues = PaddingValues(), headerBottomPadding: Dp = 8.dp, content: (@Composable ColumnScope.() -> Unit)) {
|
||||
val cardColor = if (CurrentColors.value.base == DefaultTheme.LIGHT) Color.White
|
||||
else MaterialTheme.colors.background.mixWith(MaterialTheme.colors.onBackground, 0.95f)
|
||||
val cardColor = sectionCardColor()
|
||||
Column {
|
||||
if (title != null) {
|
||||
Text(
|
||||
@@ -77,8 +76,7 @@ fun SectionView(
|
||||
padding: PaddingValues = PaddingValues(),
|
||||
content: (@Composable ColumnScope.() -> Unit)
|
||||
) {
|
||||
val cardColor = if (CurrentColors.value.base == DefaultTheme.LIGHT) Color.White
|
||||
else MaterialTheme.colors.background.mixWith(MaterialTheme.colors.onBackground, 0.95f)
|
||||
val cardColor = sectionCardColor()
|
||||
Column {
|
||||
val iconSize = with(LocalDensity.current) { 21.sp.toDp() }
|
||||
Row(Modifier.padding(start = DEFAULT_PADDING + DEFAULT_PADDING_HALF, bottom = 5.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
@@ -101,8 +99,7 @@ fun SectionView(
|
||||
|
||||
@Composable
|
||||
fun SectionViewWithButton(title: String? = null, titleButton: (@Composable () -> Unit)?, contentPadding: PaddingValues = PaddingValues(), headerBottomPadding: Dp = 8.dp, content: (@Composable ColumnScope.() -> Unit)) {
|
||||
val cardColor = if (CurrentColors.value.base == DefaultTheme.LIGHT) Color.White
|
||||
else MaterialTheme.colors.background.mixWith(MaterialTheme.colors.onBackground, 0.95f)
|
||||
val cardColor = sectionCardColor()
|
||||
Column {
|
||||
if (title != null || titleButton != null) {
|
||||
Row(modifier = Modifier.padding(start = DEFAULT_PADDING + DEFAULT_PADDING_HALF, end = DEFAULT_PADDING + DEFAULT_PADDING_HALF, bottom = headerBottomPadding).fillMaxWidth()) {
|
||||
|
||||
Reference in New Issue
Block a user