For #26444: Adapt Pocket 'powered by' text to wallpaper.

This commit is contained in:
mcarare 2022-08-30 21:35:17 +03:00 committed by mergify[bot]
parent 186dee7e77
commit 7cbe730b8a
2 changed files with 14 additions and 4 deletions

View File

@ -13,12 +13,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.R
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.ComposeViewHolder
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme
@ -42,12 +45,17 @@ class PocketRecommendationsHeaderViewHolder(
composeView.resources.getDimensionPixelSize(R.dimen.home_item_horizontal_margin)
composeView.setPadding(horizontalPadding, 0, horizontalPadding, 0)
val wallpaperState = components.appStore
.observeAsComposableState { state -> state.wallpaperState }.value
val wallpaperAdaptedTextColor = wallpaperState?.currentWallpaper?.textColor?.let { Color(it) }
Column {
Spacer(Modifier.height(24.dp))
PoweredByPocketHeader(
onLearnMoreClicked = interactor::onLearnMoreClicked,
modifier = Modifier.fillMaxWidth()
modifier = Modifier.fillMaxWidth(),
textColor = wallpaperAdaptedTextColor ?: FirefoxTheme.colors.textPrimary
)
}
}

View File

@ -378,11 +378,13 @@ fun PocketStoriesCategories(
* @param onLearnMoreClicked Callback invoked when the user clicks the "Learn more" link.
* Contains the full URL for where the user should be navigated to.
* @param modifier [Modifier] to be applied to the layout.
* @param textColor [Color] to be applied to the text.
*/
@Composable
fun PoweredByPocketHeader(
onLearnMoreClicked: (String) -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
textColor: Color = FirefoxTheme.colors.textPrimary,
) {
val link = stringResource(R.string.pocket_stories_feature_learn_more)
val text = stringResource(R.string.pocket_stories_feature_caption, link)
@ -411,14 +413,14 @@ fun PoweredByPocketHeader(
Column {
Text(
text = stringResource(R.string.pocket_stories_feature_title),
color = FirefoxTheme.colors.textPrimary,
color = textColor,
fontSize = 12.sp,
lineHeight = 16.sp
)
ClickableSubstringLink(
text = text,
textColor = FirefoxTheme.colors.textPrimary,
textColor = textColor,
clickableStartIndex = linkStartIndex,
clickableEndIndex = linkEndIndex
) {