Skip to content

Commit

Permalink
Review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
adriendev committed Dec 12, 2024
1 parent 36a8f08 commit fab901a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class _ProductRawDataCategoryTile extends StatelessWidget {
: Colors.white;

final Color dividerColor =
lightTheme ? const Color.fromRGBO(228, 228, 228, 1.0) : Colors.white;
lightTheme ? const Color(0xFFF9F9F9) : Colors.white;

return Container(
color: const Color.fromRGBO(249, 249, 249, 1.0),
color: const Color(0xFFFEFEFE),
child: Column(
children: <Widget>[
Container(
Expand All @@ -61,18 +61,20 @@ class _ProductRawDataCategoryTile extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
//Element icon + label
Row(children: <Widget>[
const SizedBox(width: 31.0),
IconTheme(
data: IconThemeData(
color: contentColor,
size: 18.0,
Row(
children: <Widget>[
const SizedBox(width: 31.0),
IconTheme(
data: IconThemeData(
color: contentColor,
size: 18.0,
),
child: icon,
),
child: icon,
),
const SizedBox(width: MEDIUM_SPACE),
Text(label),
]),
const SizedBox(width: MEDIUM_SPACE),
Text(label),
],
),
//Edit button
const Row(
children: <Widget>[
Expand All @@ -83,7 +85,7 @@ class _ProductRawDataCategoryTile extends StatelessWidget {
),
child: icons.Edit(),
),
SizedBox(width: 28),
SizedBox(width: 28.0),
],
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,75 @@ extension RawDataExt on Product {

final OpenFoodFactsLanguage language = _getLanguage();

_addRawDataInList(toReturn, ProductRawDataCategories.labels,
labelsTagsInLanguages?[language]);
_addRawDataInList(
toReturn,
ProductRawDataCategories.labels,
labelsTagsInLanguages?[language],
);

_addRawDataInList(toReturn, ProductRawDataCategories.category,
categoriesTagsInLanguages?[language]);
_addRawDataInList(
toReturn,
ProductRawDataCategories.category,
categoriesTagsInLanguages?[language],
);

_addRawDataInList(toReturn, ProductRawDataCategories.ingredients,
_splitString(ingredientsTextInLanguages?[language]));
_addRawDataInList(
toReturn,
ProductRawDataCategories.ingredients,
_splitString(ingredientsTextInLanguages?[language]),
);

// TODO(micheldr): Change presentation into two Textfields instead of concatenation.
_addRawDataDoubleTextInList(toReturn, ProductRawDataCategories.nutriment,
AttributeFirstRowNutritionHelper(product: this).getAllTerms());
_addRawDataDoubleTextInList(
toReturn,
ProductRawDataCategories.nutriment,
AttributeFirstRowNutritionHelper(product: this).getAllTerms(),
);

_addRawDataInList(
toReturn, ProductRawDataCategories.packaging, _splitString(packaging));
toReturn,
ProductRawDataCategories.packaging,
_splitString(packaging),
);

_addRawDataInList(
toReturn, ProductRawDataCategories.stores, _splitString(stores));
toReturn,
ProductRawDataCategories.stores,
_splitString(stores),
);

_addRawDataInList(toReturn, ProductRawDataCategories.countries,
countriesTagsInLanguages?[language]);
_addRawDataInList(
toReturn,
ProductRawDataCategories.countries,
countriesTagsInLanguages?[language],
);

return toReturn;
}

void _addRawDataInList(List<ProductRawDataCategory> toBeFilled,
ProductRawDataCategories label, List<String>? toAdd) {
void _addRawDataInList(
List<ProductRawDataCategory> toBeFilled,
ProductRawDataCategories label,
List<String>? toAdd,
) {
if (toAdd != null) {
toBeFilled.add(ProductRawDataCategory(label, _toRawData(toAdd)));
toBeFilled.add(ProductRawDataCategory(
label,
_toRawData(toAdd),
));
}
}

void _addRawDataDoubleTextInList(List<ProductRawDataCategory> toBeFilled,
ProductRawDataCategories label, List<StringPair>? toAdd) {
void _addRawDataDoubleTextInList(
List<ProductRawDataCategory> toBeFilled,
ProductRawDataCategories label,
List<StringPair>? toAdd,
) {
if (toAdd != null) {
toBeFilled
.add(ProductRawDataCategory(label, _toRawDataDoubleText(toAdd)));
toBeFilled.add(ProductRawDataCategory(
label,
_toRawDataDoubleText(toAdd),
));
}
}

Expand All @@ -58,7 +90,9 @@ extension RawDataExt on Product {
List<StringPair> list) =>
list
.map((StringPair element) => ProductRawDataElementDoubleText(
element.first, element.second ?? ''))
element.first,
element.second ?? '',
))
.toList();

List<String>? _splitString(String? input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class _ProductRawDataPageState extends State<ProductRawDataPage> {
Widget build(BuildContext context) {
final List<ProductRawDataCategory> productRawDatas =
widget.product.toRawDatas();
final Color dividerColor = context.lightTheme()
? const Color.fromRGBO(228, 228, 228, 1.0)
: Colors.white;
final Color dividerColor =
context.lightTheme() ? const Color(0xFFF9F9F9) : Colors.white;

return Scaffold(
body: ListView.separated(
Expand Down

0 comments on commit fab901a

Please sign in to comment.