@ -33,6 +33,8 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.annotation.LightDarkPreview
@ -43,6 +45,7 @@ import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductR
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent.AnalysisStatus
import org.mozilla.fenix.shopping.store.forCompactMode
import org.mozilla.fenix.theme.FirefoxTheme
import java.util.SortedMap
/ * *
* UI for review quality check content displaying product analysis .
@ -78,7 +81,7 @@ fun ProductAnalysis(
}
AnalysisStatus . REANALYZING -> {
// TBD
ReanalysisInProgressCard ( )
}
AnalysisStatus . COMPLETED -> {
@ -152,6 +155,20 @@ private fun ReanalyzeCard(
)
}
@Composable
private fun ReanalysisInProgressCard ( ) {
ReviewQualityCheckInfoCard (
title = stringResource ( R . string . review _quality _check _reanalysis _in _progress _warning _title ) ,
type = ReviewQualityCheckInfoType . AnalysisUpdate ,
modifier = Modifier . fillMaxWidth ( ) ,
icon = {
IndeterminateProgressIndicator (
modifier = Modifier . size ( 24. dp ) ,
)
} ,
)
}
@Composable
private fun ReviewGradeCard (
reviewGrade : ReviewQualityCheckState . Grade ,
@ -366,55 +383,106 @@ private enum class Highlight(
) ,
}
private class ProductAnalysisPreviewModel (
val productRecommendationsEnabled : Boolean ? ,
val productAnalysis : AnalysisPresent ,
) {
constructor (
productRecommendationsEnabled : Boolean ? = false ,
productId : String = " 123 " ,
reviewGrade : ReviewQualityCheckState . Grade ? = ReviewQualityCheckState . Grade . B ,
analysisStatus : AnalysisStatus = AnalysisStatus . UP _TO _DATE ,
adjustedRating : Float ? = 3.6f ,
productUrl : String = " " ,
highlights : SortedMap < HighlightType , List < String > > ? = sortedMapOf (
HighlightType . QUALITY to listOf (
" High quality " ,
" Excellent craftsmanship " ,
" Superior materials " ,
) ,
HighlightType . PRICE to listOf (
" Affordable prices " ,
" Great value for money " ,
" Discounted offers " ,
) ,
HighlightType . SHIPPING to listOf (
" Fast and reliable shipping " ,
" Free shipping options " ,
" Express delivery " ,
) ,
HighlightType . PACKAGING _AND _APPEARANCE to listOf (
" Elegant packaging " ,
" Attractive appearance " ,
" Beautiful design " ,
) ,
HighlightType . COMPETITIVENESS to listOf (
" Competitive pricing " ,
" Strong market presence " ,
" Unbeatable deals " ,
) ,
) ,
recommendedProductState : ReviewQualityCheckState . RecommendedProductState =
ReviewQualityCheckState . RecommendedProductState . Initial ,
) : this (
productRecommendationsEnabled = productRecommendationsEnabled ,
productAnalysis = AnalysisPresent (
productId = productId ,
reviewGrade = reviewGrade ,
analysisStatus = analysisStatus ,
adjustedRating = adjustedRating ,
productUrl = productUrl ,
highlights = highlights ,
recommendedProductState = recommendedProductState ,
) ,
)
}
private class ProductAnalysisPreviewModelParameterProvider :
PreviewParameterProvider < ProductAnalysisPreviewModel > {
override val values : Sequence < ProductAnalysisPreviewModel >
get ( ) = sequenceOf (
ProductAnalysisPreviewModel ( ) ,
ProductAnalysisPreviewModel (
analysisStatus = AnalysisStatus . NEEDS _ANALYSIS ,
) ,
ProductAnalysisPreviewModel (
analysisStatus = AnalysisStatus . REANALYZING ,
) ,
ProductAnalysisPreviewModel (
analysisStatus = AnalysisStatus . COMPLETED ,
) ,
ProductAnalysisPreviewModel (
reviewGrade = null ,
) ,
ProductAnalysisPreviewModel (
highlights = sortedMapOf (
HighlightType . QUALITY to listOf (
" High quality " ,
" Excellent craftsmanship " ,
) ,
) ,
) ,
)
}
@Composable
@LightDarkPreview
private fun ProductAnalysisPreview ( ) {
private fun ProductAnalysisPreview (
@PreviewParameter ( ProductAnalysisPreviewModelParameterProvider :: class ) model : ProductAnalysisPreviewModel ,
) {
FirefoxTheme {
ReviewQualityCheckScaffold (
onRequestDismiss = { } ,
) {
val productRecommendationsEnabled = remember { mutableStateOf ( false ) }
va r productRecommendationsEnabled by remember { mutableStateOf ( model . productRecommendationsEnabled ) }
ProductAnalysis (
productRecommendationsEnabled = productRecommendationsEnabled . value ,
productAnalysis = AnalysisPresent (
productId = " 123 " ,
reviewGrade = ReviewQualityCheckState . Grade . B ,
analysisStatus = AnalysisStatus . UP _TO _DATE ,
adjustedRating = 3.6f ,
productUrl = " 123 " ,
highlights = sortedMapOf (
HighlightType . QUALITY to listOf (
" High quality " ,
" Excellent craftsmanship " ,
" Superior materials " ,
) ,
HighlightType . PRICE to listOf (
" Affordable prices " ,
" Great value for money " ,
" Discounted offers " ,
) ,
HighlightType . SHIPPING to listOf (
" Fast and reliable shipping " ,
" Free shipping options " ,
" Express delivery " ,
) ,
HighlightType . PACKAGING _AND _APPEARANCE to listOf (
" Elegant packaging " ,
" Attractive appearance " ,
" Beautiful design " ,
) ,
HighlightType . COMPETITIVENESS to listOf (
" Competitive pricing " ,
" Strong market presence " ,
" Unbeatable deals " ,
) ,
) ,
) ,
productRecommendationsEnabled = productRecommendationsEnabled ,
productAnalysis = model . productAnalysis ,
onOptOutClick = { } ,
onReanalyzeClick = { } ,
onProductRecommendationsEnabledStateChange = {
productRecommendationsEnabled . value = it
productRecommendationsEnabled = it
} ,
onReviewGradeLearnMoreClick = { } ,
onFooterLinkClick = { } ,
@ -422,20 +490,3 @@ private fun ProductAnalysisPreview() {
}
}
}
@Composable
@LightDarkPreview
private fun ReanalyzeCardPreview ( ) {
FirefoxTheme {
Box (
modifier = Modifier
. fillMaxWidth ( )
. background ( color = FirefoxTheme . colors . layer1 )
. padding ( all = 16. dp ) ,
) {
ReanalyzeCard (
onReanalyzeClick = { } ,
)
}
}
}