For #24069 - Use the correct design tokens for Powered by Pocket text

upstream-sync
Gabriel Luong 3 years ago committed by mergify[bot]
parent 50ab3d451e
commit bd3f1a420e

@ -5,7 +5,6 @@
package org.mozilla.fenix.compose package org.mozilla.fenix.compose
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.Text import androidx.compose.material.Text
@ -16,7 +15,7 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import mozilla.components.ui.colors.PhotonColors import org.mozilla.fenix.theme.FirefoxTheme
/** /**
* [Text] containing a substring styled as an URL informing when this is clicked. * [Text] containing a substring styled as an URL informing when this is clicked.
@ -45,12 +44,7 @@ fun ClickableSubstringLink(
) )
addStyle( addStyle(
SpanStyle( SpanStyle(color = FirefoxTheme.colors.textAccent),
color = when (isSystemInDarkTheme()) {
true -> PhotonColors.Violet40
false -> PhotonColors.Violet70
}
),
start = clickableStartIndex, start = clickableStartIndex,
end = clickableEndIndex end = clickableEndIndex
) )
@ -91,12 +85,15 @@ fun ClickableSubstringLink(
@Preview @Preview
private fun ClickableSubstringTextPreview() { private fun ClickableSubstringTextPreview() {
val text = "This text contains a link" val text = "This text contains a link"
Box(modifier = Modifier.background(PhotonColors.White)) {
ClickableSubstringLink( FirefoxTheme {
text, Box(modifier = Modifier.background(color = FirefoxTheme.colors.layer1)) {
PhotonColors.DarkGrey90, ClickableSubstringLink(
text.indexOf("link"), text = text,
text.length textColor = FirefoxTheme.colors.textPrimary,
) { } clickableStartIndex = text.indexOf("link"),
clickableEndIndex = text.length
) { }
}
} }
} }

@ -8,7 +8,6 @@ package org.mozilla.fenix.home.pocket
import android.net.Uri import android.net.Uri
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -38,7 +37,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import mozilla.components.service.pocket.PocketRecommendedStory import mozilla.components.service.pocket.PocketRecommendedStory
import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.compose.ClickableSubstringLink import org.mozilla.fenix.compose.ClickableSubstringLink
import org.mozilla.fenix.compose.EagerFlingBehavior import org.mozilla.fenix.compose.EagerFlingBehavior
@ -194,11 +192,6 @@ fun PoweredByPocketHeader(
onLearnMoreClicked: (String) -> Unit, onLearnMoreClicked: (String) -> Unit,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
val color = when (isSystemInDarkTheme()) {
true -> PhotonColors.LightGrey30
false -> PhotonColors.DarkGrey90
}
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)
val linkStartIndex = text.indexOf(link) val linkStartIndex = text.indexOf(link)
@ -226,12 +219,17 @@ fun PoweredByPocketHeader(
Column { Column {
Text( Text(
text = stringResource(R.string.pocket_stories_feature_title), text = stringResource(R.string.pocket_stories_feature_title),
color = color, color = FirefoxTheme.colors.textPrimary,
fontSize = 12.sp, fontSize = 12.sp,
lineHeight = 16.sp lineHeight = 16.sp
) )
ClickableSubstringLink(text, color, linkStartIndex, linkEndIndex) { ClickableSubstringLink(
text = text,
textColor = FirefoxTheme.colors.textPrimary,
clickableStartIndex = linkStartIndex,
clickableEndIndex = linkEndIndex
) {
onLearnMoreClicked("https://www.mozilla.org/en-US/firefox/pocket/?$POCKET_FEATURE_UTM_KEY_VALUE") onLearnMoreClicked("https://www.mozilla.org/en-US/firefox/pocket/?$POCKET_FEATURE_UTM_KEY_VALUE")
} }
} }

Loading…
Cancel
Save