For #26115 - Change homescreen Show all button color according to wallpaper
This commit is contained in:
parent
b33abbbec2
commit
c268161311
|
@ -4,14 +4,15 @@
|
|||
|
||||
package org.mozilla.fenix.compose.home
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
|
@ -20,10 +21,14 @@ import androidx.compose.ui.text.TextStyle
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import mozilla.components.lib.state.ext.observeAsComposableState
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.components
|
||||
import org.mozilla.fenix.compose.SectionHeader
|
||||
import org.mozilla.fenix.compose.inComposePreview
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
import org.mozilla.fenix.theme.Theme
|
||||
import org.mozilla.fenix.wallpapers.Wallpaper
|
||||
|
||||
/**
|
||||
* Homepage header.
|
||||
|
@ -37,6 +42,47 @@ fun HomeSectionHeader(
|
|||
headerText: String,
|
||||
description: String,
|
||||
onShowAllClick: () -> Unit
|
||||
) {
|
||||
if (inComposePreview) {
|
||||
HomeSectionHeaderContent(
|
||||
headerText = headerText,
|
||||
description = description,
|
||||
onShowAllClick = onShowAllClick
|
||||
)
|
||||
} else {
|
||||
val wallpaperState = components.appStore
|
||||
.observeAsComposableState { state -> state.wallpaperState }.value
|
||||
|
||||
val isWallpaperDefault =
|
||||
(wallpaperState?.currentWallpaper ?: Wallpaper.Default) == Wallpaper.Default
|
||||
|
||||
HomeSectionHeaderContent(
|
||||
headerText = headerText,
|
||||
description = description,
|
||||
showAllTextColor = if (isWallpaperDefault) {
|
||||
FirefoxTheme.colors.textAccent
|
||||
} else {
|
||||
FirefoxTheme.colors.textPrimary
|
||||
},
|
||||
onShowAllClick = onShowAllClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Homepage header content.
|
||||
*
|
||||
* @param headerText The header string.
|
||||
* @param description The description for click action
|
||||
* @param showAllTextColor [Color] for the "Show all" button.
|
||||
* @param onShowAllClick Invoked when "Show all" button is clicked.
|
||||
*/
|
||||
@Composable
|
||||
private fun HomeSectionHeaderContent(
|
||||
headerText: String,
|
||||
description: String,
|
||||
showAllTextColor: Color = FirefoxTheme.colors.textAccent,
|
||||
onShowAllClick: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
@ -55,7 +101,7 @@ fun HomeSectionHeader(
|
|||
contentDescription = description
|
||||
},
|
||||
style = TextStyle(
|
||||
color = FirefoxTheme.colors.textAccent,
|
||||
color = showAllTextColor,
|
||||
fontSize = 14.sp
|
||||
),
|
||||
onClick = { onShowAllClick() }
|
||||
|
|
Loading…
Reference in New Issue