Skip to content

Commit

Permalink
For mozilla-mobile#26444: Adapt HomeSectionHeader text colors to wall…
Browse files Browse the repository at this point in the history
…paper.
  • Loading branch information
mcarare committed Aug 31, 2022
1 parent affe51f commit e5f9808
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/org/mozilla/fenix/compose/SectionHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
Expand All @@ -89,6 +93,7 @@ private fun HomeSectionHeaderContent(
) {
SectionHeader(
text = headerText,
textColor = textColor,
modifier = Modifier
.weight(1f)
.wrapContentHeight(align = Alignment.Top)
Expand Down

0 comments on commit e5f9808

Please sign in to comment.