From 05df6af0b43a0d25416935d22c497b5ff2f0b53d Mon Sep 17 00:00:00 2001 From: mcarare Date: Tue, 30 Aug 2022 21:35:17 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/26444: Adapt Pocket 'powered by' text to wallpaper. --- .../pocket/PocketRecommendationsHeaderViewHolder.kt | 10 +++++++++- .../fenix/home/pocket/PocketStoriesComposables.kt | 8 +++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/pocket/PocketRecommendationsHeaderViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/pocket/PocketRecommendationsHeaderViewHolder.kt index 6a165e686a..66d896ca76 100644 --- a/app/src/main/java/org/mozilla/fenix/home/pocket/PocketRecommendationsHeaderViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/pocket/PocketRecommendationsHeaderViewHolder.kt @@ -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 ) } } diff --git a/app/src/main/java/org/mozilla/fenix/home/pocket/PocketStoriesComposables.kt b/app/src/main/java/org/mozilla/fenix/home/pocket/PocketStoriesComposables.kt index 96e06d2e8a..11007ff988 100644 --- a/app/src/main/java/org/mozilla/fenix/home/pocket/PocketStoriesComposables.kt +++ b/app/src/main/java/org/mozilla/fenix/home/pocket/PocketStoriesComposables.kt @@ -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 ) {