2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/24069 - Use the correct design tokens for Powered by Pocket text

This commit is contained in:
Gabriel Luong 2022-03-02 17:04:17 -05:00 committed by mergify[bot]
parent d6c7b9f7ef
commit b0750c2980
2 changed files with 19 additions and 24 deletions

View File

@ -5,7 +5,6 @@
package org.mozilla.fenix.compose
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.text.ClickableText
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.tooling.preview.Preview
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.
@ -45,12 +44,7 @@ fun ClickableSubstringLink(
)
addStyle(
SpanStyle(
color = when (isSystemInDarkTheme()) {
true -> PhotonColors.Violet40
false -> PhotonColors.Violet70
}
),
SpanStyle(color = FirefoxTheme.colors.textAccent),
start = clickableStartIndex,
end = clickableEndIndex
)
@ -91,12 +85,15 @@ fun ClickableSubstringLink(
@Preview
private fun ClickableSubstringTextPreview() {
val text = "This text contains a link"
Box(modifier = Modifier.background(PhotonColors.White)) {
ClickableSubstringLink(
text,
PhotonColors.DarkGrey90,
text.indexOf("link"),
text.length
) { }
FirefoxTheme {
Box(modifier = Modifier.background(color = FirefoxTheme.colors.layer1)) {
ClickableSubstringLink(
text = text,
textColor = FirefoxTheme.colors.textPrimary,
clickableStartIndex = text.indexOf("link"),
clickableEndIndex = text.length
) { }
}
}
}

View File

@ -8,7 +8,6 @@ package org.mozilla.fenix.home.pocket
import android.net.Uri
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
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.sp
import mozilla.components.service.pocket.PocketRecommendedStory
import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.ClickableSubstringLink
import org.mozilla.fenix.compose.EagerFlingBehavior
@ -194,11 +192,6 @@ fun PoweredByPocketHeader(
onLearnMoreClicked: (String) -> Unit,
modifier: Modifier = Modifier
) {
val color = when (isSystemInDarkTheme()) {
true -> PhotonColors.LightGrey30
false -> PhotonColors.DarkGrey90
}
val link = stringResource(R.string.pocket_stories_feature_learn_more)
val text = stringResource(R.string.pocket_stories_feature_caption, link)
val linkStartIndex = text.indexOf(link)
@ -226,12 +219,17 @@ fun PoweredByPocketHeader(
Column {
Text(
text = stringResource(R.string.pocket_stories_feature_title),
color = color,
color = FirefoxTheme.colors.textPrimary,
fontSize = 12.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")
}
}