Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashsri3bi committed Oct 13, 2022
2 parents 774a4c2 + d49c2bc commit 916f43b
Show file tree
Hide file tree
Showing 135 changed files with 1,507 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
// we need to load the full resolution image

if (_imageFullProvider == null) {
final String imageFullUrl =
widget.productImageData.imageUrl!.replaceAll('.400.', '.full.');
_imageFullProvider = NetworkImage(imageFullUrl);
final String? imageFullUrl =
widget.productImageData.getImageUrl(ImageSize.ORIGINAL);
if (imageFullUrl != null) {
_imageFullProvider = NetworkImage(imageFullUrl);
}
}

// TODO(monsieurtanuki): careful, waiting for pop'ed value
Expand Down
39 changes: 38 additions & 1 deletion packages/smooth_app/lib/data_models/product_image_data.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:openfoodfacts/model/ProductImage.dart';
import 'package:openfoodfacts/openfoodfacts.dart';

class ProductImageData {
const ProductImageData({
Expand All @@ -8,8 +8,45 @@ class ProductImageData {
this.imageUrl,
});

factory ProductImageData.from(ProductImage image, String barcode) {
return ProductImageData(
imageField: image.field,
// TODO(VaiTon): i18n
title: image.imgid ?? '',
buttonText: image.imgid ?? '',
imageUrl: ImageHelper.buildUrl(barcode, image),
);
}

final ImageField imageField;
final String title;
final String buttonText;
final String? imageUrl;

/// Try to convert [imageUrl] to specified [size].
/// Note that url for specified [size] might not exist on API.
String? getImageUrl(ImageSize size) {
final String? imageUrl = this.imageUrl;
if (imageUrl == null) {
return null;
}

const String SEPARATOR = '.';

final int extensionIndex = imageUrl.lastIndexOf(SEPARATOR);
if (extensionIndex < 0) {
return null;
}

final int sizeIndex = imageUrl.lastIndexOf(SEPARATOR, extensionIndex - 1);
if (sizeIndex < 0) {
return null;
}

final String baseUrl = imageUrl.substring(0, sizeIndex + 1);
final String number = size.toNumber();
final String extension =
imageUrl.substring(extensionIndex, imageUrl.length);
return baseUrl + number + extension;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ class SmoothImagesSliverGrid extends SmoothImagesView {
final MapEntry<ProductImageData, ImageProvider<Object>?> entry =
imageList[index];
final ImageProvider? imageProvider = entry.value;
final String? imageUrl = entry.key.imageUrl;

return imageProvider == null
return imageProvider == null || imageUrl == null
? const PictureNotFound()
: Hero(
tag: entry.key.imageUrl!,
tag: imageUrl,
child: _ImageTile(
image: imageProvider,
onTap: onTap == null
Expand Down
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_aa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_af.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_ak.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_am.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_as.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_az.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_be.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_bg.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_bm.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_bn.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_bo.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_br.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_bs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_ca.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_ce.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_co.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
16 changes: 12 additions & 4 deletions packages/smooth_app/lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -938,11 +938,11 @@
"@camera_play_sound_subtitle": {
"description": "SubTitle for the Camera play sound toggle"
},
"camera_mode_title": "Scanner mode",
"camera_mode_title": "Režim skenování",
"@camera_mode_title": {
"description": "Title for the mode for the camera/scanner"
},
"camera_mode_subtitle": "Only change this value, if you have some issues with the scanner (unable to decode barcodes). Tap to switch between the two modes.\nThe current one is: {mode}",
"camera_mode_subtitle": "Tuto hodnotu změňte pouze v případě, že máte nějaké problémy se skenerem (nelze dekódovat čárové kódy). Klepnutím přepnete mezi oběma režimy.\nAktuální režim je: {mode}",
"@camera_mode_subtitle": {
"description": "SubTitle for the mode for the camera/scanner",
"placeholders": {
Expand All @@ -951,8 +951,8 @@
}
}
},
"camera_mode_file_based": "Safe mode (by default)",
"camera_mode_bytes_array_based": "Quick mode",
"camera_mode_file_based": "Bezpečný režim (výchozí)",
"camera_mode_bytes_array_based": "Rychlý režim",
"app_haptic_feedback_title": "Vibrace a haptika",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
Expand Down Expand Up @@ -1696,5 +1696,13 @@
"word_separator": ", ",
"@word_separator": {
"description": "Word separator string. In English, this is a comma followed by a space: ', '"
},
"image_download_error": "Failed to download image",
"@image_download_error": {
"description": "Error message, when image download fails"
},
"image_edit_url_error": "Failed to edit image, image url not set.",
"@image_edit_url_error": {
"description": "Error message, when editing image fails, due to missing url."
}
}
Loading

0 comments on commit 916f43b

Please sign in to comment.