For #26444: Adapt HomeSectionHeader text colors to wallpaper.

This commit is contained in:
mcarare 2022-08-30 21:14:52 +03:00 committed by mergify[bot]
parent 02be7600e8
commit 186dee7e77
2 changed files with 11 additions and 3 deletions

View File

@ -7,6 +7,7 @@ package org.mozilla.fenix.compose
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import org.mozilla.fenix.theme.FirefoxTheme
@ -16,16 +17,18 @@ import org.mozilla.fenix.theme.FirefoxTheme
*
* @param text [String] to be styled as header and displayed.
* @param modifier [Modifier] to be applied to the [Text].
* @param textColor [Color] to be applied to the [Text].
*/
@Composable
fun SectionHeader(
text: String,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
textColor: Color = FirefoxTheme.colors.textPrimary,
) {
Text(
text = text,
modifier = modifier,
color = FirefoxTheme.colors.textPrimary,
color = textColor,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
style = FirefoxTheme.typography.headline7

View File

@ -53,16 +53,19 @@ fun HomeSectionHeader(
val wallpaperState = components.appStore
.observeAsComposableState { state -> state.wallpaperState }.value
val wallpaperAdaptedTextColor = wallpaperState?.currentWallpaper?.textColor?.let { Color(it) }
val isWallpaperDefault =
(wallpaperState?.currentWallpaper ?: Wallpaper.Default) == Wallpaper.Default
HomeSectionHeaderContent(
headerText = headerText,
textColor = wallpaperAdaptedTextColor ?: FirefoxTheme.colors.textPrimary,
description = description,
showAllTextColor = if (isWallpaperDefault) {
FirefoxTheme.colors.textAccent
} else {
FirefoxTheme.colors.textPrimary
wallpaperAdaptedTextColor ?: FirefoxTheme.colors.textAccent
},
onShowAllClick = onShowAllClick,
)
@ -80,6 +83,7 @@ fun HomeSectionHeader(
@Composable
private fun HomeSectionHeaderContent(
headerText: String,
textColor: Color = FirefoxTheme.colors.textPrimary,
description: String = "",
showAllTextColor: Color = FirefoxTheme.colors.textAccent,
onShowAllClick: (() -> Unit)? = null,
@ -89,6 +93,7 @@ private fun HomeSectionHeaderContent(
) {
SectionHeader(
text = headerText,
textColor = textColor,
modifier = Modifier
.weight(1f)
.wrapContentHeight(align = Alignment.Top)