Skip to content

Commit

Permalink
feature_2/#191 - added eco-score and nutri-score categories (ProductI…
Browse files Browse the repository at this point in the history
…mprovement) (#288)

Impacted file:
* `Product.dart`
  • Loading branch information
monsieurtanuki committed Nov 12, 2021
1 parent a708407 commit 797339d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/model/Product.dart
Expand Up @@ -60,6 +60,30 @@ enum ProductImprovement {
OBSOLETE_NUTRITION_IMAGE,
}

/// Category: what would this [ProductImprovement] help compute?
enum ProductImprovementCategory {
/// Eco-Score category
ECO_SCORE,

/// Nutri-Score category
NUTRI_SCORE,
}

extension ProductImprovementExtension on ProductImprovement {
ProductImprovementCategory getCategory() {
switch (this) {
case ProductImprovement.ORIGINS_TO_BE_COMPLETED:
return ProductImprovementCategory.ECO_SCORE;
case ProductImprovement.CATEGORIES_BUT_NO_NUTRISCORE:
case ProductImprovement.ADD_NUTRITION_FACTS:
case ProductImprovement.ADD_CATEGORY:
case ProductImprovement.ADD_NUTRITION_FACTS_AND_CATEGORY:
case ProductImprovement.OBSOLETE_NUTRITION_IMAGE:
return ProductImprovementCategory.NUTRI_SCORE;
}
}
}

/// This class contains most of the data about a specific product.
///
/// Please read the language mechanics explanation if you intend to display
Expand Down

0 comments on commit 797339d

Please sign in to comment.