[fenix] For https://github.com/mozilla-mobile/fenix/issues/26444: Adapt Pocket 'powered by' text to wallpaper.

pull/600/head
mcarare 2 years ago committed by mergify[bot]
parent 49e8207a93
commit 05df6af0b4

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

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

Loading…
Cancel
Save