|
|
@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.Spacer
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
import androidx.compose.material.Icon
|
|
|
|
import androidx.compose.material.Icon
|
|
|
|
import androidx.compose.material.Text
|
|
|
|
import androidx.compose.material.Text
|
|
|
@ -59,10 +60,12 @@ import org.mozilla.fenix.theme.FirefoxTheme
|
|
|
|
* @param modifier The modifier to be applied to the Composable.
|
|
|
|
* @param modifier The modifier to be applied to the Composable.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
@Suppress("LongParameterList")
|
|
|
|
fun ProductAnalysis(
|
|
|
|
fun ProductAnalysis(
|
|
|
|
productRecommendationsEnabled: Boolean,
|
|
|
|
productRecommendationsEnabled: Boolean,
|
|
|
|
productAnalysis: AnalysisPresent,
|
|
|
|
productAnalysis: AnalysisPresent,
|
|
|
|
onOptOutClick: () -> Unit,
|
|
|
|
onOptOutClick: () -> Unit,
|
|
|
|
|
|
|
|
onReanalyzeClick: () -> Unit,
|
|
|
|
onProductRecommendationsEnabledStateChange: (Boolean) -> Unit,
|
|
|
|
onProductRecommendationsEnabledStateChange: (Boolean) -> Unit,
|
|
|
|
onReviewGradeLearnMoreClick: (String) -> Unit,
|
|
|
|
onReviewGradeLearnMoreClick: (String) -> Unit,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
@ -71,6 +74,12 @@ fun ProductAnalysis(
|
|
|
|
modifier = modifier,
|
|
|
|
modifier = modifier,
|
|
|
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
|
|
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (productAnalysis.needsAnalysis) {
|
|
|
|
|
|
|
|
ReanalyzeCard(
|
|
|
|
|
|
|
|
onReanalyzeClick = onReanalyzeClick,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (productAnalysis.reviewGrade != null) {
|
|
|
|
if (productAnalysis.reviewGrade != null) {
|
|
|
|
ReviewGradeCard(
|
|
|
|
ReviewGradeCard(
|
|
|
|
reviewGrade = productAnalysis.reviewGrade,
|
|
|
|
reviewGrade = productAnalysis.reviewGrade,
|
|
|
@ -111,6 +120,27 @@ fun ProductAnalysis(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
private fun ReanalyzeCard(
|
|
|
|
|
|
|
|
onReanalyzeClick: () -> Unit,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
ReviewQualityCheckInfoCard(
|
|
|
|
|
|
|
|
title = stringResource(R.string.review_quality_check_outdated_analysis_warning_title),
|
|
|
|
|
|
|
|
type = ReviewQualityCheckInfoType.AnalysisUpdate,
|
|
|
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
|
|
|
buttonText = stringResource(R.string.review_quality_check_outdated_analysis_warning_action),
|
|
|
|
|
|
|
|
onButtonClick = onReanalyzeClick,
|
|
|
|
|
|
|
|
icon = {
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
painter = painterResource(id = R.drawable.mozac_ic_information_fill_24),
|
|
|
|
|
|
|
|
contentDescription = null,
|
|
|
|
|
|
|
|
modifier = Modifier.size(24.dp),
|
|
|
|
|
|
|
|
tint = FirefoxTheme.colors.iconPrimary,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
private fun ReviewGradeCard(
|
|
|
|
private fun ReviewGradeCard(
|
|
|
|
reviewGrade: ReviewQualityCheckState.Grade,
|
|
|
|
reviewGrade: ReviewQualityCheckState.Grade,
|
|
|
@ -504,6 +534,7 @@ private fun ProductAnalysisPreview() {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onOptOutClick = {},
|
|
|
|
onOptOutClick = {},
|
|
|
|
|
|
|
|
onReanalyzeClick = {},
|
|
|
|
onProductRecommendationsEnabledStateChange = {
|
|
|
|
onProductRecommendationsEnabledStateChange = {
|
|
|
|
productRecommendationsEnabled.value = it
|
|
|
|
productRecommendationsEnabled.value = it
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -530,3 +561,20 @@ private fun ReviewQualityInfoPreview() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
@LightDarkPreview
|
|
|
|
|
|
|
|
private fun ReanalyzeCardPreview() {
|
|
|
|
|
|
|
|
FirefoxTheme {
|
|
|
|
|
|
|
|
Box(
|
|
|
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
|
|
|
.background(color = FirefoxTheme.colors.layer1)
|
|
|
|
|
|
|
|
.padding(all = 16.dp),
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
ReanalyzeCard(
|
|
|
|
|
|
|
|
onReanalyzeClick = {},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|