Skip to content

Commit

Permalink
feat: openfoodfacts#2067 - new personalized page layout (no tabs, bac…
Browse files Browse the repository at this point in the history
…kgrounds) (openfoodfacts#2119)

* feat: openfoodfacts#2067 - new personalized page layout (no tabs, backgrounds)

Removed file:
* `smooth_it_model.dart`

Impacted files:
* `personalized_ranking_page.dart`: removed the tabs; added subtitles and background colors
* `product_compatibility_helper.dart`: refactored for more flexibility
* `smooth_product_card_found.dart`: minor refactoring
* `summary_card.dart`: minor refactoring

* feat: openfoodfacts#2067 - merge conflict fix

Impacted file:
* `summary_card.dart`: minor refactoring

* feat: openfoodfacts#2067 - tests with colored smooth cards

Impacted file:
* `personalized_ranking_page.dart`: colored smooth cards
  • Loading branch information
monsieurtanuki authored Jun 5, 2022
1 parent 8bd23be commit 9cedfb7
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SmoothProductCardFound extends StatelessWidget {
productPreferences,
);
final ProductCompatibilityHelper helper =
ProductCompatibilityHelper(matchedProduct);
ProductCompatibilityHelper.product(matchedProduct);
return GestureDetector(
onTap: onTap ??
() async {
Expand Down
54 changes: 0 additions & 54 deletions packages/smooth_app/lib/data_models/smooth_it_model.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import 'package:openfoodfacts/personalized_search/matched_product_v2.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';

class ProductCompatibilityHelper {
const ProductCompatibilityHelper(this.matchedProduct);
ProductCompatibilityHelper.product(final MatchedProductV2 product)
: status = product.status;

final MatchedProductV2 matchedProduct;
const ProductCompatibilityHelper.status(this.status);

final MatchedProductStatusV2 status;

Color getHeaderBackgroundColor(bool darkMode) {
if (darkMode) {
Expand All @@ -33,7 +36,7 @@ class ProductCompatibilityHelper {
// According to color contrast tool https://material.io/resources/color
// on all those background colors the best is to write in black.
Color _getDarkColors() {
switch (matchedProduct.status) {
switch (status) {
case MatchedProductStatusV2.VERY_GOOD_MATCH:
return DARK_GREEN_COLOR;
case MatchedProductStatusV2.GOOD_MATCH:
Expand All @@ -55,7 +58,7 @@ class ProductCompatibilityHelper {
}

String getHeaderText(final AppLocalizations appLocalizations) {
switch (matchedProduct.status) {
switch (status) {
case MatchedProductStatusV2.VERY_GOOD_MATCH:
return appLocalizations.match_very_good;
case MatchedProductStatusV2.GOOD_MATCH:
Expand All @@ -72,7 +75,7 @@ class ProductCompatibilityHelper {
}

String getSubtitle(final AppLocalizations appLocalizations) {
switch (matchedProduct.status) {
switch (status) {
case MatchedProductStatusV2.VERY_GOOD_MATCH:
return appLocalizations.match_short_very_good;
case MatchedProductStatusV2.GOOD_MATCH:
Expand Down
Loading

0 comments on commit 9cedfb7

Please sign in to comment.