Bug 1852994 - Add review quality check byline

fenix/119.0
Noah Bond 9 months ago committed by mergify[bot]
parent 830a754a60
commit d79ace91ce

@ -52,6 +52,7 @@ import org.mozilla.fenix.theme.FirefoxTheme
* @param onProductRecommendationsEnabledStateChange Invoked when the user changes the product
* recommendations toggle state.
* @param onReviewGradeLearnMoreClick Invoked when the user clicks to learn more about review grades.
* @param onBylineLinkClick Invoked when the user clicks on the byline link.
* @param modifier The modifier to be applied to the Composable.
*/
@Composable
@ -63,6 +64,7 @@ fun ProductAnalysis(
onReanalyzeClick: () -> Unit,
onProductRecommendationsEnabledStateChange: (Boolean) -> Unit,
onReviewGradeLearnMoreClick: (String) -> Unit,
onBylineLinkClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
Column(
@ -107,6 +109,10 @@ fun ProductAnalysis(
onTurnOffReviewQualityCheckClick = onOptOutClick,
modifier = Modifier.fillMaxWidth(),
)
ReviewQualityCheckFooter(
onLinkClick = onBylineLinkClick,
)
}
}
@ -392,6 +398,7 @@ private fun ProductAnalysisPreview() {
productRecommendationsEnabled.value = it
},
onReviewGradeLearnMoreClick = {},
onBylineLinkClick = {},
)
}
}

@ -24,6 +24,7 @@ import org.mozilla.fenix.theme.FirefoxTheme
* @param onOptOutClick Invoked when the user opts out of the review quality check feature.
* @param onProductRecommendationsEnabledStateChange Invoked when the user changes the product
* recommendations toggle state.
* @param onBylineLinkClick Invoked when the user clicks on the byline link.
* @param modifier Modifier to apply to the layout.
*/
@Composable
@ -32,6 +33,7 @@ fun ProductAnalysisError(
onReviewGradeLearnMoreClick: (String) -> Unit,
onOptOutClick: () -> Unit,
onProductRecommendationsEnabledStateChange: (Boolean) -> Unit,
onBylineLinkClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
Column(
@ -50,6 +52,10 @@ fun ProductAnalysisError(
onTurnOffReviewQualityCheckClick = onOptOutClick,
modifier = Modifier.fillMaxWidth(),
)
ReviewQualityCheckFooter(
onLinkClick = onBylineLinkClick,
)
}
}
@ -68,6 +74,7 @@ private fun ProductAnalysisErrorPreview() {
onReviewGradeLearnMoreClick = {},
onOptOutClick = {},
onProductRecommendationsEnabledStateChange = {},
onBylineLinkClick = {},
modifier = Modifier.fillMaxWidth(),
)
}

@ -67,6 +67,13 @@ fun ReviewQualityCheckBottomSheet(
),
)
},
onBylineLinkClick = { url ->
store.dispatch(
ReviewQualityCheckAction.OpenLink(
ReviewQualityCheckState.LinkType.ExternalLink(url),
),
)
},
)
}
@ -82,12 +89,14 @@ fun ReviewQualityCheckBottomSheet(
}
@Composable
@Suppress("LongParameterList")
private fun ProductReview(
state: ReviewQualityCheckState.OptedIn,
onOptOutClick: () -> Unit,
onReanalyzeClick: () -> Unit,
onProductRecommendationsEnabledStateChange: (Boolean) -> Unit,
onReviewGradeLearnMoreClick: (String) -> Unit,
onBylineLinkClick: (String) -> Unit,
) {
Crossfade(
targetState = state.productReviewState,
@ -102,6 +111,7 @@ private fun ProductReview(
onReanalyzeClick = onReanalyzeClick,
onProductRecommendationsEnabledStateChange = onProductRecommendationsEnabledStateChange,
onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick,
onBylineLinkClick = onBylineLinkClick,
)
}
@ -111,6 +121,7 @@ private fun ProductReview(
onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick,
onOptOutClick = onOptOutClick,
onProductRecommendationsEnabledStateChange = onProductRecommendationsEnabledStateChange,
onBylineLinkClick = onBylineLinkClick,
modifier = Modifier.fillMaxWidth(),
)
}

@ -0,0 +1,69 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.shopping.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.LinkText
import org.mozilla.fenix.compose.LinkTextState
import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.theme.FirefoxTheme
private const val FOOTER_LINK = "http://fakespot.com/"
/**
* Review Quality Check footer with an embedded link to navigate to Fakespot.com.
*
* @param onLinkClick Invoked when the user clicks on the embedded link.
*/
@Composable
fun ReviewQualityCheckFooter(
onLinkClick: (String) -> Unit,
) {
val poweredByLinkText = stringResource(
id = R.string.review_quality_check_powered_by_link,
stringResource(id = R.string.shopping_product_name),
)
LinkText(
text = stringResource(
id = R.string.review_quality_check_powered_by,
poweredByLinkText,
),
linkTextState = LinkTextState(
text = poweredByLinkText,
url = FOOTER_LINK,
onClick = onLinkClick,
),
style = FirefoxTheme.typography.body2.copy(
color = FirefoxTheme.colors.textPrimary,
),
linkTextColor = FirefoxTheme.colors.textAccent,
)
}
@LightDarkPreview
@Composable
private fun ReviewQualityCheckFooterPreview() {
FirefoxTheme {
Box(
modifier = Modifier
.fillMaxWidth()
.background(color = FirefoxTheme.colors.layer1)
.padding(all = 16.dp),
) {
ReviewQualityCheckFooter(
onLinkClick = {},
)
}
}
}

@ -2153,7 +2153,7 @@
<!-- Caption for recommended product section indicating this is an ad by Fakespot. First parameter is the Fakespot product name. -->
<string name="review_quality_check_ad_caption" tools:ignore="UnusedResources">Ad by %s</string>
<!-- Caption for review quality check panel. First parameter is for clickable text defined in review_quality_check_powered_by_link. -->
<string name="review_quality_check_powered_by" tools:ignore="UnusedResources">Review checker is powered by %s.</string>
<string name="review_quality_check_powered_by">Review checker is powered by %s</string>
<!-- Clickable text that links to Fakespot.com. First parameter is the Fakespot product name. In the phrase "Fakespot by Mozilla", "by" can be localized. Does not need to stay by. -->
<string name="review_quality_check_powered_by_link" tools:ignore="UnusedResources">%s by Mozilla</string>
<!-- Text for title of warning card informing the user that the current analysis is outdated. -->

Loading…
Cancel
Save