Skip to content

Commit

Permalink
fix: The photo sections should not move after photo upload (openfoodf…
Browse files Browse the repository at this point in the history
…acts#2297)

* fix: Don't reorder uploaded images

* Update add_new_product_page.dart
  • Loading branch information
M123-dev authored Jun 19, 2022
1 parent d57f2e5 commit 183ef7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
25 changes: 14 additions & 11 deletions packages/smooth_app/lib/pages/product/add_new_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,23 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
// "other photos" uploaded by the user.
if (imageType == ImageField.OTHER) {
rows.add(_buildAddImageButton(context, imageType));
continue;
}
// Everything else can only be uploaded once, skip building the
// "Add Image button" if an image for this type is already uploaded.
if (!_isImageUploadedForType(imageType)) {
rows.add(_buildAddImageButton(context, imageType));
}
}
// Now build rows for images that are already uploaded.
for (final ImageField imageType in ImageField.values) {
if (_isImageUploadedForType(imageType)) {
for (final File image in _uploadedImages[imageType]!) {
rows.add(_buildImageUploadedRow(context, imageType, image));
}
continue;
}

// Everything else can only be uploaded once
if (_isImageUploadedForType(imageType)) {
rows.add(
_buildImageUploadedRow(
context,
imageType,
_uploadedImages[imageType]![0],
),
);
} else {
rows.add(_buildAddImageButton(context, imageType));
}
}
return rows;
Expand Down
12 changes: 6 additions & 6 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ packages:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.1.0"
google_mlkit_barcode_scanning:
dependency: "direct main"
description:
Expand Down Expand Up @@ -584,7 +584,7 @@ packages:
name: image_picker_android
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5"
version: "0.8.5+1"
image_picker_for_web:
dependency: transitive
description:
Expand Down Expand Up @@ -759,7 +759,7 @@ packages:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.1.0"
package_info_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -836,14 +836,14 @@ packages:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.14"
version: "2.0.15"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
path_provider_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -1289,7 +1289,7 @@ packages:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.12"
url_launcher_windows:
dependency: transitive
description:
Expand Down

0 comments on commit 183ef7b

Please sign in to comment.